private void ReadRecordFromFile() { if (File.Exists("D:\\" + GetBanciDate() + GetBanci() + "\\" + GetBanciDate() + GetBanci() + ".csv")) { DataTable dt = new DataTable(); dt.Columns.Add("日期", typeof(string)); dt.Columns.Add("班次", typeof(string)); dt.Columns.Add("机台号", typeof(string)); dt.Columns.Add("机台穴号", typeof(string)); dt.Columns.Add("产品barcode", typeof(string)); DataTable dt1 = Csvfile.GetFromCsv("D:\\" + GetBanciDate() + GetBanci() + "\\" + GetBanciDate() + GetBanci() + ".csv", 1, dt); if (dt1.Rows.Count > 0) { foreach (DataRow item in dt1.Rows) { RecordItem ri = new RecordItem(); ri.日期 = item["日期"].ToString(); ri.班次 = item["班次"].ToString(); ri.机台号 = item["机台号"].ToString(); ri.机台穴号 = item["机台穴号"].ToString(); ri.产品barcode = item["产品barcode"].ToString(); lock (LockObject) { recordItemList.Add(ri); } } } } else { MsgText = AddMessage("本地记录不存在"); } }
private async void ReUpLoad() { DataTable dt = new DataTable(); DataTable dt1; dt.Columns.Add("BLDATE", typeof(string)); dt.Columns.Add("BLID", typeof(string)); dt.Columns.Add("BLNAME", typeof(string)); dt.Columns.Add("BLUID", typeof(string)); dt.Columns.Add("BLMID", typeof(string)); dt.Columns.Add("Bar", typeof(string)); string filename = @"D:\NotUpdate.csv"; UpdateCount = 0; if (File.Exists(filename)) { dt1 = Csvfile.GetFromCsv(filename, 1, dt); if (dt1.Rows.Count > 0) { File.Delete(filename); foreach (DataRow item in dt1.Rows) { DP6SQLROW dP6SQLROW = new DP6SQLROW(); dP6SQLROW.BLDATE = item[0].ToString(); dP6SQLROW.BLID = item[1].ToString(); dP6SQLROW.BLMID = item[4].ToString(); dP6SQLROW.BLNAME = item[2].ToString(); dP6SQLROW.BLUID = item[3].ToString(); dP6SQLROW.Bar = item[5].ToString(); bool r; using (var releaser = await m_lock.LockAsync()) { r = await Update_A_Row(dP6SQLROW); } if (r)//更具是否上传成功,写入不同的记录文档 { lock (DisEq) { _BarcodeRecord.Enqueue(dP6SQLROW); } WriteRecordtoExcel(dP6SQLROW, true); UpdateCount++; //上传成功 } else { WriteRecordtoExcel(dP6SQLROW, false); //上传失败 } } } } LastReUpdateStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Inifile.INIWriteValue(iniParameterPath, "ReUpLoad", "LastReUpdateStr", LastReUpdateStr); }
private void ReadBarcodeRecordfromCSV() { //"Date", "Barcode", "MachineID", "UserID", "ProductName", "MachineName", "FactoryArea", "FactorySeparation" string filepath = "D:\\生产记录\\条码" + GlobalVar.GetBanci() + ".csv"; DataTable dt = new DataTable(); DataTable dt1; dt.Columns.Add("Date", typeof(string)); dt.Columns.Add("Barcode", typeof(string)); dt.Columns.Add("MachineID", typeof(string)); dt.Columns.Add("UserID", typeof(string)); dt.Columns.Add("ProductName", typeof(string)); dt.Columns.Add("MachineName", typeof(string)); dt.Columns.Add("FactoryArea", typeof(string)); dt.Columns.Add("FactorySeparation", typeof(string)); dt.Columns.Add("ZhiJuClass", typeof(string)); dt.Columns.Add("Barcodeproofing", typeof(string)); dt.Columns.Add("scancodetype", typeof(string)); dt.Columns.Add("CCD", typeof(string)); dt.Columns.Add("NNNN", typeof(string)); try { if (File.Exists(filepath)) { dt1 = Csvfile.GetFromCsv(filepath, 1, dt); if (dt1.Rows.Count > 0) { foreach (DataRow item in dt1.Rows) { MESDataItem tr = new MESDataItem() { Date = item[0].ToString(), Index = item[1].ToString(), Barcode = item[2].ToString(), MachineID = item[3].ToString(), UserID = item[4].ToString(), ProductName = item[5].ToString(), MachineName = item[6].ToString(), FactoryArea = item[7].ToString(), FactorySeparation = item[8].ToString() }; lock (GlobalVar.obj1) { //GlobalVar.AlarmRecord.Add(tr); GlobalVar.MESDataRecordQueue.Enqueue(tr); } } GlobalVar.AddMessage("读取条码记录完成"); } } else { GlobalVar.AddMessage("条码记录不存在"); } } catch (Exception ex) { GlobalVar.AddMessage(ex.Message); } }
private void LoadBarCsvFromFile() { DataTable dt = new DataTable(); DataTable dt1; dt.Columns.Add("BLDATE", typeof(string)); dt.Columns.Add("BLID", typeof(string)); dt.Columns.Add("BLNAME", typeof(string)); dt.Columns.Add("BLUID", typeof(string)); dt.Columns.Add("BLMID", typeof(string)); dt.Columns.Add("Bar", typeof(string)); string bcstr = GetBanci(); string filename = @"D:\Record\" + bcstr + ".csv"; try { if (File.Exists(filename)) { dt1 = Csvfile.GetFromCsv(filename, 1, dt); if (dt1.Rows.Count > 0) { foreach (DataRow item in dt1.Rows) { DP6SQLROW dp6 = new DP6SQLROW(); dp6.BLDATE = item[0].ToString(); dp6.BLID = item[1].ToString(); dp6.BLNAME = item[2].ToString(); dp6.BLUID = item[3].ToString(); dp6.BLMID = item[4].ToString(); dp6.Bar = item[5].ToString(); lock (DisEq) { _BarcodeRecord.Enqueue(dp6); } } } } } catch (Exception ex) { MsgText = AddMessage(ex.Message); } }
private void ReadAlarmRecordfromCSV() { string filepath = "D:\\报警记录\\报警记录" + GlobalVar.GetBanci() + ".csv"; DataTable dt = new DataTable(); DataTable dt1; dt.Columns.Add("AlarmDate", typeof(string)); dt.Columns.Add("MachineID", typeof(string)); dt.Columns.Add("UserID", typeof(string)); dt.Columns.Add("AlarmMessage", typeof(string)); try { if (File.Exists(filepath)) { dt1 = Csvfile.GetFromCsv(filepath, 1, dt); if (dt1.Rows.Count > 0) { foreach (DataRow item in dt1.Rows) { AlarmTableItem tr = new AlarmTableItem() { AlarmDate = item[0].ToString(), MachineID = item[1].ToString(), UserID = item[2].ToString(), AlarmMessage = item[3].ToString() }; lock (GlobalVar.obj) { //GlobalVar.AlarmRecord.Add(tr); GlobalVar.AlarmRecordQueue.Enqueue(tr); } } GlobalVar.AddMessage("读取报警记录完成"); } } else { GlobalVar.AddMessage("报警记录不存在"); } } catch (Exception ex) { GlobalVar.AddMessage(ex.Message); } }