日期:2014-05-17 浏览次数:21398 次
public void parse() { for (int i = 0;i < Commond.fileInfo.Length ;i++ ) { try { if ((Commond.fileInfo[i].Name).Split('.')[1] != "csv") //判断是否csv文件 { Console.WriteLine(Commond.fileInfo[i].Name + "此文件不是csv格式"); continue; } using (StreamReader sr = new StreamReader(Commond.JLZDHdataPath + Commond.fileInfo[i].Name)) { Console.WriteLine("开始解析" + Commond.fileInfo[i].Name); Commond.evenList = new List<csvEvent>();//初始化commond类中数据集合 string s = "";//接收文本流 string[] ss;//截取文本流返回的数组 int index = 0;//检查是否有多个FID while ((s = sr.ReadLine()) != null) { csvEvent ce = new csvEvent(); ss = s.Split(',');//截取文本流 ce.Id = ss[0].Split('$')[1]; ce.St = ss[2]; ce.State = ss[3]; ce.Gis_pb_id = equipment_Id(ce.Id);//查询equipmentid index = checkFid(ce.Id); if (index > 0) { ce.Fid = selectFid(ce.Id);//查询Fid bool a = Commond.evenList.Contains(ce);//判断evenList里面是否存在相同对象 问题是现在它一直等于false if (a) continue;//如果存在就continue Commond.evenList.Add(ce); } Console.WriteLine(s); } } fillData(); //填写日志-------------------- RunLog2(System.Reflection.MethodBase.GetCurrentMethod().Name, "正常", Commond.fileInfo[i].Name); Commond.fileInfo[i].MoveTo(Commond.JLZDHdatabakPath + Commond.fileInfo[i].Name);//移动文件到文件夹 } catch (Exception e) { Console.WriteLine(e); //错误日志-------------------- RunLog2(System.Reflection.MethodBase.GetCurrentMethod().Name, "错误", Commond.fileInfo[i].Name+e); Console.ReadKey(true); Environment.Exit(0); } } Console.WriteLine("解析完毕!5分钟后将再次读取路径文件"); }