예제 #1
0
        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);
                    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 });
        }
예제 #2
0
        private void tbx_SerialWrite_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                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 (!_RFIDDevice.ReadTagID())//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 check 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.Module_ID);

                                    byte[] btData = TagDataFormat.CreateByteArray(o);

                                    oModuleInfo = o;

                                    m_sBasicInfo = o.ProductType + "|" + o.PackedDate.Replace("-", ".") + "|"
                                                   + o.Pivf + "|" + o.Module_ID + "|" + o.CellDate.Replace("-", ".") + "|3";

                                    if (_RFIDDevice.WriteTagBuff(btData))//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 check 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.Module_ID);

                                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
                    }
                }
            }
        }