public static void Main(String[] args) { try { DefaultEfileParse parse = new DefaultEfileParse(); String file = "E:\\6.½Î÷ÏîÄ¿\\elanguage\\data\\ºá±íʽ.txt"; List <ETable> list = parse.ParseFile(file); elanguage.Util.Debug.Debugwrite(list); ETable et = new ETable(); et.SetColumnNames(new string[] { "˳Ðò", "×Ö¶Î1", "×Ö¶Î2", "×Ö¶Î3" }); object[] o1 = new object[] { "1", "111", "333", "222" }; object[] o2 = new object[] { "2", "411", "343", "222" }; object[] o3 = new object[] { "3", "141", "333", "242" }; List <object[]> listo = new List <object[]>(); listo.Add(o1); listo.Add(o2); listo.Add(o3); et.SetDatas(listo); et.SetTableName("Õï¶Ï½á¹û"); et.SetDate(DateTime.Now.ToString()); parse.CreateEFile(et, "@", "D:\\test.txt"); } catch (Exception e) { Console.Error.WriteLine(e.StackTrace); } }
private void saveFiles() { DirectoryInfo dirinfo = new DirectoryInfo(saveEpath); FileInfo[] allFiles = dirinfo.GetFiles(Ext); foreach (FileInfo FileNm in allFiles) { if (FileNm.Extension == Ext.Substring(Ext.IndexOf("."))) { DefaultEfileParse parse = new DefaultEfileParse(); String file = FileNm.FullName; List <ETable> list = parse.ParseFile(file, Convert.ToInt32(Coding)); List <object[]> datas; int success = 0; //Etalbe集合 for (int i = 0; i < list.Count; i++) { try { datas = list[i].GetDatas(); //D5000 //行 //@顺序 厂站名称 发生时间 短信内容 //#1 '华中.罗坊站' '2016-12-08 14:56:17' '2016-12-08 14:56:17 华中.罗坊站 华中.罗坊站/35kV.302开关 分闸' //积成电子 //@Num OccurTime RDFID status content //序号 发生时间 开关编号 变位动作(0表示合转分,1表示分转合) 事项内容 if (datas.Count > 0) { string str = ""; string breaker = ""; string rtime = ""; switch (EMode) { case "0": { //列 rtime = datas[0][2].ToString(); str = datas[0][3].ToString(); //华中.罗坊站/35kV.302开关 分闸(停电) //江西.昌东站/220kV.211开关 分闸(封锁) //江西.罗湾厂/6kV.610开关 分闸 string state = str.Substring(datas[0][3].ToString().LastIndexOf(" ") + 6); string statestr = state; if (state == "分闸" || state.Contains("合闸")) { breaker = str.Substring(datas[0][3].ToString().IndexOf(" ") + 6).Split(' ')[1]; string sql = "select * from Relations_yaoxin where breakername='" + breaker + "'"; SqlDataReader sdr = SqlHelper.ExecuteDataReader(Connstr, sql, null); if (sdr.HasRows) { //[groupid],[sub],[line],[yaoxinid],[info],[yaoxintype],[breakername] while (sdr.Read()) { if (state == "分闸") { state = "0"; } else if ((state.Contains("合闸"))) { if (state == "合闸") { state = "1"; } else if (state.Contains("相合闸")) { //如果同意时间(秒)中没有合成的线路合闸信号而有A/B/C相合闸,则解析为线路合闸 string sql0 = "select id from Datas_yaoxin where groupid=" + sdr["groupid"] + " and yaoxinid=" + sdr["yaoxinid"] + " and rtime='" + rtime + "' and state='1'"; if (SqlHelper.ExecuteScalar(Connstr, sql0, null) == null) { state = "1"; } } } if (state == "0" || state == "1") { string sql1 = "INSERT INTO [Datas_yaoxin]([groupid],[yaoxinid],[state],[yaoxintype],[rtime],[datatype])VALUES" + "(" + sdr["groupid"] + "," + sdr["yaoxinid"] + ",'" + state + "','开关','" + rtime + "','z')"; if (SqlHelper.ExecuteNonQuery(Connstr, sql1, null) > 0) { Common.WriteLog("CIME实时分析服务", sdr["sub"] + " " + sdr["line"] + "(" + breaker + ")" + statestr + ",接收时间 " + rtime, Common.Now()); Common.WriteLog("CIME实时分析服务[变位]", sdr["sub"] + " " + sdr["line"] + "(" + breaker + ")" + statestr + "(state=" + state + "),接收时间 " + rtime, Common.Now()); } } else { Common.WriteLog("CIME实时分析服务[变位]", sdr["sub"] + " " + sdr["line"] + "(" + breaker + ")" + statestr + ",接收时间 " + rtime, Common.Now()); } } sdr.Close(); } else { sdr.Close(); } } break; } case "1": { //列 for (int j = 0; j < datas.Count; j++) { try { rtime = datas[j][1].ToString().Replace("_", " "); str = datas[j][2].ToString(); string state = datas[j][3].ToString(); string sql = "select * from Relations_yaoxin where breakername like '%." + str + "'"; SqlDataReader sdr = SqlHelper.ExecuteDataReader(Connstr, sql, null); if (sdr.HasRows) { //[groupid],[sub],[line],[yaoxinid],[info],[yaoxintype],[breakername] while (sdr.Read()) { breaker = sdr["info"].ToString() + "@" + str; string sql1 = "INSERT INTO [Datas_yaoxin]([groupid],[yaoxinid],[state],[yaoxintype],[rtime],[datatype])VALUES" + "(" + sdr["groupid"] + "," + sdr["yaoxinid"] + ",'" + state + "','开关','" + rtime + "','z')"; if (SqlHelper.ExecuteNonQuery(Connstr, sql1, null) > 0) { Common.WriteLog("CIME实时分析服务", sdr["sub"] + " " + sdr["line"] + "(" + breaker + ")跳闸,接收时间 " + rtime, Common.Now()); Common.WriteLog("CIME实时分析服务[跳闸]", sdr["sub"] + " " + sdr["line"] + "(" + breaker + ")跳闸,接收时间 " + rtime, Common.Now()); } } sdr.Close(); } else { sdr.Close(); } } catch (System.Exception ex) { } } break; } } } string oldpath = oldDatapath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(oldpath)) { Directory.CreateDirectory(oldpath); } oldpath += "\\" + FileNm.Name; try { File.Copy(FileNm.FullName, oldpath, true); File.Delete(FileNm.FullName); Common.WriteLog("CIME实时分析服务", "将文件" + FileNm.FullName + "移动到" + oldpath + "。", Common.Now()); } catch (System.Exception ex) { Common.WriteLog("CIME实时分析服务", "将文件" + FileNm.FullName + "移动到" + oldpath + "。时出错" + ex.Message.ToString(), Common.Now()); } } catch (System.Exception ex) { Common.WriteLog("CIME实时分析服务", "CIME实时分析服务[读取开关信息]出错!" + ex.Message.ToString(), Common.Now()); } } } } }