|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using CnasSynchronousCommon;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Text;
-
- namespace CnasSynchronusDAL
- {
- public class ReadFileSecond: BaseReadFileMode
- {
- public static DataTable ReadTableStructure()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("入厂批次号");
- dt.Columns.Add("录入时间");
- dt.Columns.Add("录入人");
- dt.Columns.Add("车厢总数");
- dt.Columns.Add("车厢序号");
- dt.Columns.Add("车厢型号");
- dt.Columns.Add("车厢编码");
- dt.Columns.Add("毛重");
- dt.Columns.Add("皮重");
- dt.Columns.Add("标重");
- dt.Columns.Add("净重");
- dt.Columns.Add("车速");
- dt.Columns.Add("运损");
- return dt;
- }
-
- public static DataTable ReadTableData(string strFilePath)
- {
- DataTable dt = ReadTableStructure();
- try
- {
- List<string> arryList = new List<string>();
- if (File.Exists(strFilePath))
- {
- FileStream fileStream = new FileStream(strFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
- StreamReader _StreamReaderKey = new StreamReader(fileStream, GetType(strFilePath));
- string strLine = "";
- while (!string.IsNullOrEmpty((strLine = _StreamReaderKey.ReadLine())))
- {
- arryList.Add(strLine);
- }
-
- fileStream.Close();
- }
-
- if (arryList.Count > 0)
- {
- for (int i = 11; i < arryList.Count; i++)
- {
- string strData = arryList[i].Trim();
- string[] strRowDatas = strData.Split(',');
- if (strRowDatas.Length == 14)
- {
- DataRow dr = dt.NewRow();
- dr["入厂批次号"] = arryList[0].Trim();
- dr["录入时间"] = arryList[2].Trim();
- dr["录入人"] = arryList[4].Trim();
- dr["车厢总数"] = arryList[7].Trim();
- dr["车厢序号"] = strRowDatas[0];
- dr["车厢型号"] = strRowDatas[1];
- dr["车厢编码"] = strRowDatas[2];
- dr["毛重"] = strRowDatas[3];
- dr["皮重"] = strRowDatas[4];
- dr["标重"] = strRowDatas[5];
- dr["净重"] = strRowDatas[6];
- dr["车速"] = strRowDatas[7];
- dr["运损"] = strRowDatas[8];
- dt.Rows.Add(dr);
- }
- }
- }
- }
- catch (Exception ex)
- {
- AppLog.Error(ex.Message);
- }
- return dt;
- }
- }
- }
|