private void WriteLog2DB() { //string basicInfo = ""; WcfCaller.WriteLog(ex => { if (ex == null) { paintBackgroundColor(statusType.PASS); WriteLog(lrtxtLog, m_sSerialNumber + " " + "烧录成功!", 0); common.rf_beep(ReaderInfo.icdev, 10); List <string> csvValueList = new List <string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Pass", m_sTagUIDstring, m_sBasicInfo }; WriteCSVLog.WriteCSV(csvValueList); ShowModuleInfo(true, const_parameters); Speech("烧录成功"); } else { paintBackgroundColor(statusType.FAIL); WriteLog(lrtxtLog, m_sSerialNumber + " " + "写记录到数据库失败!", 1); common.rf_beep(ReaderInfo.icdev, 20); List <string> csvValueList = new List <string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; WriteCSVLog.WriteCSV(csvValueList); Speech("烧录失败"); } SetSerialTxtFocus(); }, new string[] { m_sTagUIDstring, m_sSerialNumber, m_sBasicInfo }); }
private void tbx_SerialWrite_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (chkbox_burningTag.Checked && cbx_customer.SelectedValue == null) { MessageBox.Show("请选择客户!!!"); return; } string customer = cbx_customer.SelectedValue.ToString(); RFIDConstants const_parameters = null; if (dic_customer_RFID_constants.ContainsKey(customer)) { const_parameters = dic_customer_RFID_constants[customer]; //ms_cfg_mfg_name = const_parameters.mfg_name; //ms_cfg_mfg_country = const_parameters.mfg_country; //ms_iec_date = const_parameters.iec_date; //ms_iec_verfy = const_parameters.iec_verfy; //ms_iso = const_parameters.iso_desc; //ms_producttype = const_parameters.product_type; //ms_cell_mfg = const_parameters.cell_mfg; //ms_cellsource_country = const_parameters.cellsource_country; //ms_iso9000_date = const_parameters.iso_9000_date; //ms_iso9000_name = const_parameters.iso_9000_name; //ms_iso14000_date = const_parameters.iso_14000_date; //ms_iso14000_name = const_parameters.iso_14000_name; //ms_polarity_of_terminal = const_parameters.polarity_of_terminal; //ms_max_sys_vol = const_parameters.max_sys_vol; //ms_cell_mfg_date = const_parameters.cell_mfg_date; } CleanIVCurves(); ShowModuleInfo(false, null); string ser = tbx_SerialWrite.Text.Trim().ToUpper(); //tbx_SerialWrite.Text = ""; if (ser.Length > 0) { paintBackgroundColor(statusType.START); tbx_SerialWrite.Enabled = false; SetLabelStatus(statusType.START); m_sSerialNumber = ser; //add by xue lei on 2019-1-6 数据源配置 var datatype = new Jsonhelp().readjson("DataType", AppDomain.CurrentDomain.BaseDirectory + "config.json"); if (datatype == "") { MessageBox.Show("请先配置数据源"); return; } if (chkbox_burningTag.Checked) { if (!GetTagUID()) { WriteLog(lrtxtLog, "没有发现标签!", 1); common.rf_beep(ReaderInfo.icdev, 20); paintBackgroundColor(statusType.FAIL); List <string> csvValueList = new List <string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; WriteCSVLog.WriteCSV(csvValueList); SetSerialTxtFocus(); Speech("烧录失败"); } else { if (datatype == "csv") { WriteRfid(QueryCSVToOdbc(const_parameters, ser)); } else if (datatype == "Access") { WriteRfid(QueryAccess(const_parameters, ser)); } else { #region query data from database WcfCaller.querySerialInfo((o, ex) => { if (ex == null) { if (o == null) { DoFailStuff(m_sSerialNumber + " " + "未找到组件记录!"); return; } #region chech region state if (string.IsNullOrEmpty(o.ProductType)) { o.ProductType = const_parameters.product_type; //DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt01); //return; } if (string.IsNullOrEmpty(o.CellDate)) { o.CellDate = const_parameters.cell_mfg_date; //DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt02); //return; } if (string.IsNullOrEmpty(o.PackedDate)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt03); return; } if (string.IsNullOrEmpty(o.Pmax)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt04); return; } if (string.IsNullOrEmpty(o.Voc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt05); return; } if (string.IsNullOrEmpty(o.Vpm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt06); return; } if (string.IsNullOrEmpty(o.Ipm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt07); return; } if (string.IsNullOrEmpty(o.Isc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt08); return; } #endregion ShowIVCurves(double.Parse(o.Isc), double.Parse(o.Ipm), double.Parse(o.Vpm), double.Parse(o.Voc)); o.customer = cbx_customer.SelectedValue.ToString(); //SetRFIDConstants(o.customer); byte[] btData = TagDataFormat.CreateByteArray(o, const_parameters); oModuleInfo = o; m_sBasicInfo = o.ProductType + "|" + o.PackedDate.Replace("-", ".") + "|" + o.Pivf + "|" + o.Module_ID + "|" + o.CellDate.Replace("-", ".") + "|3"; if (WriteData(btData)) { //WriteLog2DB(); paintBackgroundColor(statusType.PASS); WriteLog(lrtxtLog, m_sSerialNumber + " " + "烧录成功!", 0); common.rf_beep(ReaderInfo.icdev, 10); List <string> csvValueList = new List <string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Pass", m_sTagUIDstring, m_sBasicInfo }; WriteCSVLog.WriteCSV(csvValueList); ShowModuleInfo(true, const_parameters); Speech("烧录成功"); } else { DoFailStuff(m_sSerialNumber + " " + "烧录失败!"); } } else { DoFailStuff("与服务器通讯发生异常" + ex.Message); } SetSerialTxtFocus(); }, new string[] { m_sSerialNumber, m_sTagUIDstring }); #endregion } } } else { if (datatype == "csv") { QueryCSVToOdbc(const_parameters, ser); } else if (datatype == "Access") { QueryAccess(const_parameters, ser); } else { #region query data from database WcfCaller.querySerialInfo((o, ex) => { if (ex == null) { if (o == null) { DoFailStuff(m_sSerialNumber + " " + "未找到组件记录!"); return; } #region chech region state if (string.IsNullOrEmpty(o.ProductType)) { o.ProductType = const_parameters.product_type; //DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt01); //return; } if (string.IsNullOrEmpty(o.CellDate)) { o.CellDate = const_parameters.cell_mfg_date; //DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt02); //return; } if (string.IsNullOrEmpty(o.PackedDate)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt03); return; } if (string.IsNullOrEmpty(o.Pmax)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt04); return; } if (string.IsNullOrEmpty(o.Voc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt05); return; } if (string.IsNullOrEmpty(o.Vpm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt06); return; } if (string.IsNullOrEmpty(o.Ipm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt07); return; } if (string.IsNullOrEmpty(o.Isc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt08); return; } #endregion ShowIVCurves(double.Parse(o.Isc), double.Parse(o.Ipm), double.Parse(o.Vpm), double.Parse(o.Voc)); o.customer = cbx_customer.SelectedValue.ToString(); //SetRFIDConstants(o.customer); oModuleInfo = o; paintBackgroundColor(statusType.PASS); ShowModuleInfo(true, const_parameters); WriteLog(lrtxtLog, m_sSerialNumber + " " + "获取功率信息成功!", 0); SetSerialTxtFocus(); } else { DoFailStuff("与服务器通讯发生异常" + ex.Message); //WriteLog(lrtxtLog, "与服务器通讯发生异常"+ex.Message, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //SetSerialTxtFocus(); //Speech("烧录失败"); } }, new string[] { m_sSerialNumber, m_sTagUIDstring }); #endregion } } } } } }
private void tbx_SerialWrite_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (chkbox_burningTag.Checked && cbx_customer.SelectedValue == null) { MessageBox.Show("请选择客户!!!"); return; } CleanIVCurves(); ShowModuleInfo(false); string ser = tbx_SerialWrite.Text.Trim().ToUpper(); if (ser.Length > 0) { paintBackgroundColor(statusType.START); tbx_SerialWrite.Enabled = false; SetLabelStatus(statusType.START); m_sSerialNumber = ser; if (chkbox_burningTag.Checked) { if (!GetTagUID()) { WriteLog(lrtxtLog, "没有发现标签!", 1); common.rf_beep(ReaderInfo.icdev, 20); paintBackgroundColor(statusType.FAIL); List <string> csvValueList = new List <string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; WriteCSVLog.WriteCSV(csvValueList); SetSerialTxtFocus(); Speech("烧录失败"); } else { #region query data from database WcfCaller.querySerialInfo((o, ex) => { if (ex == null) { if (o == null) { DoFailStuff(m_sSerialNumber + " " + "未找到组件记录!"); return; } #region chech region state if (string.IsNullOrEmpty(o.ProductType)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt01); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt01, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.CellDate)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt02); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt02, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.PackedDate)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt03); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt03, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Pmax)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt04); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt04, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Voc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt05); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt05, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Vpm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt06); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt06, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Ipm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt07); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt07, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Isc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt08); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt08, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } #endregion ShowIVCurves(double.Parse(o.Isc), double.Parse(o.Ipm), double.Parse(o.Vpm), double.Parse(o.Voc)); o.customer = cbx_customer.SelectedValue.ToString(); SetRFIDConstants(o.customer); byte[] btData = TagDataFormat.CreateByteArray(o); oModuleInfo = o; m_sBasicInfo = o.ProductType + "|" + o.PackedDate.Replace("-", ".") + "|" + o.Pivf + "|" + o.Module_ID + "|" + o.CellDate.Replace("-", ".") + "|3"; if (WriteData(btData)) { WriteLog2DB(); //paintBackgroundColor(statusType.PASS); //WriteLog(lrtxtLog, "烧录成功!", 0); //common.rf_beep(ReaderInfo.icdev, 10); } else { DoFailStuff(m_sSerialNumber + " " + "烧录失败!"); //paintBackgroundColor(statusType.FAIL); //WriteLog(lrtxtLog, m_sSerialNumber + " " + "烧录失败!", 1); //common.rf_beep(ReaderInfo.icdev, 20); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //SetSerialTxtFocus(); //Speech("烧录失败"); } } else { DoFailStuff("与服务器通讯发生异常" + ex.Message); //WriteLog(lrtxtLog, "与服务器通讯发生异常"+ex.Message, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //SetSerialTxtFocus(); //Speech("烧录失败"); } }, new string[] { m_sSerialNumber, m_sTagUIDstring }); #endregion } } else { #region query data from database WcfCaller.querySerialInfo((o, ex) => { if (ex == null) { if (o == null) { DoFailStuff(m_sSerialNumber + " " + "未找到组件记录!"); return; } #region chech region state if (string.IsNullOrEmpty(o.ProductType)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt01); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt01, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.CellDate)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt02); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt02, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.PackedDate)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt03); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt03, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Pmax)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt04); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt04, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Voc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt05); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt05, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Vpm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt06); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt06, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Ipm)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt07); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt07, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } if (string.IsNullOrEmpty(o.Isc)) { DoFailStuff(m_sSerialNumber + " " + Resources.strPrompt08); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //WriteLog(lrtxtLog, m_sSerialNumber + " " + Resources.strPrompt08, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); return; } #endregion ShowIVCurves(double.Parse(o.Isc), double.Parse(o.Ipm), double.Parse(o.Vpm), double.Parse(o.Voc)); o.customer = cbx_customer.SelectedValue.ToString(); SetRFIDConstants(o.customer); oModuleInfo = o; paintBackgroundColor(statusType.PASS); ShowModuleInfo(true); WriteLog(lrtxtLog, m_sSerialNumber + " " + "获取功率信息成功!", 0); SetSerialTxtFocus(); } else { DoFailStuff("与服务器通讯发生异常" + ex.Message); //WriteLog(lrtxtLog, "与服务器通讯发生异常"+ex.Message, 1); //common.rf_beep(ReaderInfo.icdev, 20); //paintBackgroundColor(statusType.FAIL); //List<string> csvValueList = new List<string> { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_sSerialNumber, "Fail", "" }; //WriteCSVLog.WriteCSV(csvValueList); //SetSerialTxtFocus(); //Speech("烧录失败"); } }, new string[] { m_sSerialNumber, m_sTagUIDstring }); #endregion } } } }