CNAS取数仪器端升级
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

4 个月前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using CnasSynchronousCommon;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. namespace CnasSynchronusDAL
  9. {
  10. public class ReadFileSecond: BaseReadFileMode
  11. {
  12. public static DataTable ReadTableStructure()
  13. {
  14. DataTable dt = new DataTable();
  15. dt.Columns.Add("入厂批次号");
  16. dt.Columns.Add("录入时间");
  17. dt.Columns.Add("录入人");
  18. dt.Columns.Add("车厢总数");
  19. dt.Columns.Add("车厢序号");
  20. dt.Columns.Add("车厢型号");
  21. dt.Columns.Add("车厢编码");
  22. dt.Columns.Add("毛重");
  23. dt.Columns.Add("皮重");
  24. dt.Columns.Add("标重");
  25. dt.Columns.Add("净重");
  26. dt.Columns.Add("车速");
  27. dt.Columns.Add("运损");
  28. return dt;
  29. }
  30. public static DataTable ReadTableData(string strFilePath)
  31. {
  32. DataTable dt = ReadTableStructure();
  33. try
  34. {
  35. List<string> arryList = new List<string>();
  36. if (File.Exists(strFilePath))
  37. {
  38. FileStream fileStream = new FileStream(strFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
  39. StreamReader _StreamReaderKey = new StreamReader(fileStream, GetType(strFilePath));
  40. string strLine = "";
  41. while (!string.IsNullOrEmpty((strLine = _StreamReaderKey.ReadLine())))
  42. {
  43. arryList.Add(strLine);
  44. }
  45. fileStream.Close();
  46. }
  47. if (arryList.Count > 0)
  48. {
  49. for (int i = 11; i < arryList.Count; i++)
  50. {
  51. string strData = arryList[i].Trim();
  52. string[] strRowDatas = strData.Split(',');
  53. if (strRowDatas.Length == 14)
  54. {
  55. DataRow dr = dt.NewRow();
  56. dr["入厂批次号"] = arryList[0].Trim();
  57. dr["录入时间"] = arryList[2].Trim();
  58. dr["录入人"] = arryList[4].Trim();
  59. dr["车厢总数"] = arryList[7].Trim();
  60. dr["车厢序号"] = strRowDatas[0];
  61. dr["车厢型号"] = strRowDatas[1];
  62. dr["车厢编码"] = strRowDatas[2];
  63. dr["毛重"] = strRowDatas[3];
  64. dr["皮重"] = strRowDatas[4];
  65. dr["标重"] = strRowDatas[5];
  66. dr["净重"] = strRowDatas[6];
  67. dr["车速"] = strRowDatas[7];
  68. dr["运损"] = strRowDatas[8];
  69. dt.Rows.Add(dr);
  70. }
  71. }
  72. }
  73. }
  74. catch (Exception ex)
  75. {
  76. AppLog.Error(ex.Message);
  77. }
  78. return dt;
  79. }
  80. }
  81. }