protected void btnSearch_Click(object sender, EventArgs e) { clsHistoricRPU oclsHistoricRPU = new clsHistoricRPU(); StringBuilder strHTMLElectric = new StringBuilder(); StringBuilder strHTMLCommunication = new StringBuilder(); string strLoadingCharge = string.Empty; try { msgErrNew.InnerText = ""; msgErrNew.Style.Add("display", "none"); string strGrupo = cmbGroup.Items[cmbGroup.SelectedIndex].Value; if (ddl.SelectedIndex != -1) { strLoadingCharge = ddl.Items[ddl.SelectedIndex].Value; } if (ddl.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal({title: 'Error',html: $('<div>').addClass('some-class').text('Debe seleccionar un punto de carga.'),animation: true,customClass:'animated tada'});", true); } else { DataTable dtHistoricRPU = new DataTable("HistoricRPU"); dtHistoricRPU = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge); if (dtHistoricRPU.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricRPU); DBDataPlaceHolderPuntosdeCarga.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } else { //ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','No hay datos para mostrar','error');", true); //msgErrNew.InnerText = ""; //msgErrNew.Style.Add("display", "inline"); //msgErrNew.InnerText = ""; } DataTable dtHistoricPreguntas = new DataTable("HistoricPreguntas"); dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "1"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder1.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "2"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder2.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "3"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder3.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "4"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder4.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "5"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder5.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "6"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder6.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "7"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder7.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "8"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder8.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntas = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge, "9"); if (dtHistoricPreguntas.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntas); PlaceHolder9.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } DataTable dtPregunta; clsCommunication oClsComPregunta = new clsCommunication(); string strPath = oClsComPregunta.GetPathUploadCommunication(); string strFullPath = Server.MapPath(strPath); DataTable dtGetRPUDataArchivos = null; dtGetRPUDataArchivos = oClsComPregunta.GetArchivosComunicacion(strLoadingCharge); if (dtGetRPUDataArchivos.Rows.Count > 0) { StringBuilder strHTMLCommunication1 = new StringBuilder(); strHTMLCommunication1 = oClsComPregunta.CreateTableHTMLArchivos(dtGetRPUDataArchivos, strFullPath); DBDataPlaceHolderArchivos.Controls.Add(new Literal { Text = strHTMLCommunication1.ToString() }); } DataTable dtHistoricPreguntasMed = new DataTable("HistoricPreguntasMed"); dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "1"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores10.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "2"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores11.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "3"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores12.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "4"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores13.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "5"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores14.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "6"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores15.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "7"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores16.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "8"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores17.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "9"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores18.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "10"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores19.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "11"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores20.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "12"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores21.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "13"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores22.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "14"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores23.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } dtHistoricPreguntasMed = oclsHistoricRPU.GetSPCommunicationHistoricPorRPUMed(strLoadingCharge, "15"); if (dtHistoricPreguntasMed.Rows.Count > 0) { strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricPreguntasMed); PlaceHolderrMedidores24.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); } DataTable dtHistoricRPUConvenios = new DataTable("HistoricConvenios"); Class.Business.clsElectricMeters oClsElectricMeters = new Class.Business.clsElectricMeters(); dtHistoricRPUConvenios = null; dtHistoricRPUConvenios = oClsElectricMeters.GetAgreement4RPUHistorico(strLoadingCharge, 1); if (dtHistoricRPUConvenios.Rows.Count > 0) { strHTMLCommunication = oClsElectricMeters.CreateTableHTML4Agreement(dtHistoricRPUConvenios); DBDataPlaceHolderConvenios.Controls.Add(new Literal { Text = strHTMLCommunication.ToString() }); } //dtHistoricRPU = oclsHistoricRPU.GetSPCommunicationHistoricPorRPU(strLoadingCharge); //if (dtHistoricRPU.Rows.Count > 0) //{ // strHTMLElectric = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricRPU); // DBDataPlaceHolderPuntosdeCarga.Controls.Add(new Literal { Text = strHTMLElectric.ToString() }); //} //else //{ // msgErrNew.InnerText = ""; // msgErrNew.Style.Add("display", "inline"); // msgErrNew.InnerText = "No hay datos para mostrar"; //} //Now we need to fill up the communication table //spBuscarComunicacionHistoricoRPU dtHistoricRPU = null; //dtHistoricRPU = oclsHistoricRPU.GetSPCommunicationHistoricRPU(strLoadingCharge, 1); //if (dtHistoricRPU.Rows.Count > 0) //{ // strHTMLCommunication = oclsHistoricRPU.CreateTableHTMLHistorico(dtHistoricRPU); // DBDataPlaceHolderCommunication.Controls.Add(new Literal { Text = strHTMLCommunication.ToString() }); //} //msgErrNew.InnerText = ""; //msgErrNew.Style.Add("display", "inline"); //msgErrNew.InnerText = "Seleccion a un grupo"; //if ((ddl.Items[ddl.SelectedIndex].Value != "--TODOS--" && ddl.Items[ddl.SelectedIndex].Value !="")) // { // //dtHistoricRPU = oclsHistoricRPU.GetHistoricRPU(strLoadingCharge, 1); // } // else if ((ddl.Items[ddl.SelectedIndex].Value == "")) // { // ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Seleccione un punto de carga','error');", true); // //msgErrNew.InnerText = ""; // //msgErrNew.Style.Add("display", "inline"); // //msgErrNew.InnerText = "Seleccion a un punto de carga"; // } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "btnSearch_Click"; clsError.LogWrite(); JavaScriptSerializer serializer = new JavaScriptSerializer(); string mensaje = serializer.Serialize(ex.Message); ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('Error Detalle: " + mensaje + "');", true); //msgErrNew.InnerText = ""; //msgErrNew.Style.Add("display", "inline"); //msgErrNew.InnerHtml = ex.ToString(); } }
/// <summary> /// 下载待检信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDownTestData_Click(object sender, EventArgs e) { btnDownTestData.Enabled = false; try { string statu = clsHpptPost.BeihaiCommunicateTest(Global.ServerAdd, Global.ServerName, Global.ServerPassword, 2, out err); int d = 0; int count = 0; if (statu.Length > 5) { for (int i = 0; i < statu.Length; i++)//分割字符串 { if (statu.Substring(i, 1) == ",") { d = i; break; } } string st = statu.Substring(1, d - 1); string sample = statu.Substring(d + 1, statu.Length - d - 2); if (st.Contains("status")) { clsCommunication stu = JsonHelper.JsonToEntity <clsCommunication>(st); if (stu.status == "2") { Beihaisamples bs = JsonHelper.JsonToEntity <Beihaisamples>(sample); if (bs.samplings.Count > 0) { TestSamples model = new TestSamples(); for (int i = 0; i < bs.samplings.Count; i++) { sb.Length = 0; sb.AppendFormat("productId='{0}' and ", bs.samplings[i].productId); sb.AppendFormat("goodsName='{0}' and ", bs.samplings[i].goodsName); sb.AppendFormat("operateId='{0}' and ", bs.samplings[i].operateId); sb.AppendFormat("operateName='{0}' and ", bs.samplings[i].operateName); sb.AppendFormat("marketId='{0}' and ", bs.samplings[i].marketId); sb.AppendFormat("marketName='{0}' and ", bs.samplings[i].marketName); sb.AppendFormat("samplingPerson='{0}' and ", bs.samplings[i].samplingPerson); sb.AppendFormat("samplingTime='{0}' and ", bs.samplings[i].samplingTime); sb.AppendFormat("positionAddress='{0}' and ", bs.samplings[i].positionAddress); sb.AppendFormat("goodsId='{0}'", bs.samplings[i].goodsId); dt = sql.GetTestData(sb.ToString(), "", 1, out err); if (dt != null && dt.Rows.Count > 0) { continue; } model.productId = bs.samplings[i].productId; model.goodsName = bs.samplings[i].goodsName; model.operateId = bs.samplings[i].operateId; model.operateName = bs.samplings[i].operateName; model.marketId = bs.samplings[i].marketId; model.marketName = bs.samplings[i].marketName; model.samplingPerson = bs.samplings[i].samplingPerson; model.samplingTime = bs.samplings[i].samplingTime; model.positionAddress = bs.samplings[i].positionAddress; model.goodsId = bs.samplings[i].goodsId; sql.InsertTestSample(model, out err); count = count + 1; } } } } } MessageBox.Show("共成功下载" + count.ToString() + "条数据!"); BSearchSample("", "IsTest='否'"); } catch (Exception ex) { MessageBox.Show(ex.Message); btnDownTestData.Enabled = true; } btnDownTestData.Enabled = true; }
// public System.Timers.Timer t = new System.Timers.Timer(1000); public bool Run(int nCommandIndex, string strParamater) { Debug.WriteLine("run section nCommandIndex: " + nCommandIndex.ToString() + " strParamater: " + strParamater); // if (ConnectionCompleted!=null) // ConnectionCompleted(); if ((strParamater == "")) { strParamater = "7000;192.168.123.34;com1;10000;70000"; } str = strParamater.Split(';'); int API_TimeOut_ms = Convert.ToInt32(str[4]) + 10000; // 0: port // 1: ip // 2: usb port // 3: price // 4: timeout (ms) int nCommandIndex_Provider = nCommandIndex / 100; int temp = nCommandIndex % 100; int nCommandIndex_TransMode = temp / 10; temp = temp % 10; int nCommandIndex_ConType = temp; if (PEP_Pos != null) { PEP_Pos.Dispose(); } // t.Elapsed += T_Elapsed; try { switch (nCommandIndex_Provider) { case 11: //pep switch (nCommandIndex_TransMode) { case 1: //async switch (nCommandIndex_ConType) { case 1: //lan (sync) PEP_Pos = new PcPosClassLibrary.PCPOS(Convert.ToInt32(str[0]), str[1]); PEP_Pos.SetLanReceiveTimeout(Convert.ToInt32(Convert.ToInt32(str[4]) / 1000)); if (Convert.ToInt32(POS_Count) > 1) { semSepehr.Release(); //release Sepehr semaphore } CallWithTimeout(() => PEP_RD = PEP_Pos.SyncSale(Convert.ToInt32(str[3])), API_TimeOut_ms); semRecieveMessage.WaitOne(); //every thread recieved data block others //CallWithTimeout(() => RD = pos.SyncSale(Convert.ToInt32(str[3])),Convert.ToInt32( str[4])); // causing incomplete session in sync operation RefNo = PEP_RD.ReferenceNumber; Err = PEP_RD.ErrorCode.ToString(); break; case 2: //usb PEP_Pos = new PcPosClassLibrary.PCPOS(str[2]); // t.AutoReset = true; // t.Enabled = true; PEP_Pos.DataRecieved += new PcPosClassLibrary.DataRecievedEventHandler(this.Pep_pos_DataReceived); if (Convert.ToInt32(POS_Count) > 1) { semSepehr.Release(); //release Sepehr semaphore } PEP_Pos.Sale(Convert.ToInt32(str[3])); a.WaitOne(); // t.Stop(); break; } break; case 2: //sync switch (nCommandIndex_ConType) { case 1: //lan Debug.WriteLine("pep : " + nCommandIndex.ToString() + " : " + strParamater); string str1 = ""; for (int i = 0; i < 5; i++) { str1 += str[i]; } Debug.WriteLine("pep : " + str1); PEP_Pos = new PcPosClassLibrary.PCPOS(Convert.ToInt32(str[0]), str[1]); PEP_Pos.SetLanReceiveTimeout(Convert.ToInt32(Convert.ToInt32(str[4]) / 1000)); if (Convert.ToInt32(POS_Count) > 1) { semSepehr.Release(); //release Sepehr semaphore } CallWithTimeout(() => PEP_RD = PEP_Pos.SyncSale(Convert.ToInt32(str[3])), API_TimeOut_ms); semRecieveMessage.WaitOne(); //every thread recieved data blocked others Debug.WriteLine("------------- semRecieveMessage waitOne "); //CallWithTimeout(() => RD = pos.SyncSale(Convert.ToInt32(str[3])),Convert.ToInt32( str[4])); // causing incomplete session in sync operation RefNo = PEP_RD.ReferenceNumber; Err = PEP_RD.ErrorCode.ToString(); break; case 2: //usb PEP_Pos = new PcPosClassLibrary.PCPOS(str[2]); PEP_Pos.SetLanReceiveTimeout(Convert.ToInt32(Convert.ToInt32(str[4]) / 1000)); semSepehr.Release(); //release Sepehr semaphore CallWithTimeout(() => PEP_RD = PEP_Pos.SyncSale(Convert.ToInt32(str[3])), API_TimeOut_ms); semRecieveMessage.WaitOne(); //every thread recieved data block others //CallWithTimeout(() => RD = pos.SyncSale(Convert.ToInt32(str[3])),Convert.ToInt32( str[4])); // causing incomplete session in sync operation RefNo = PEP_RD.ReferenceNumber; Err = PEP_RD.ErrorCode.ToString(); break; } break; } break; case 12: //sepehr switch (nCommandIndex_TransMode) { case 1: //async switch (nCommandIndex_ConType) { case 1: //lan (sync) return(false); case 2: //usb return(false); } break; case 2: //sync switch (nCommandIndex_ConType) { case 1: //lan Debug.WriteLine("sepehr : " + nCommandIndex.ToString() + " : " + strParamater); string str1 = ""; for (int i = 0; i < 5; i++) { str1 += str[i]; } Debug.WriteLine("sepehr : " + str1); clsCommunication clsCommunicationObj = new clsCommunication(); clsCommunicationObj.ConnType = (int)clsCommunication.connectionType.ETHERNET; clsCommunicationObj.IPAddress = str[1]; clsCommunicationObj.IPPort = Convert.ToInt32(str[0]); clsCommunicationObj.TimeOut = Convert.ToInt32(Convert.ToInt32(str[4]) / 1000); // force 20 sec Sepehr_transaction = new clsMessage(); Sepehr_req.msgTyp = clsMessage.msgType.Sale; Sepehr_req.terminalID = ""; Sepehr_req.amount = str[3]; Sepehr_transaction.request = Sepehr_req; if (Convert.ToInt32(POS_Count) > 1) { semSepehr.WaitOne(); // wait until others begin } int SendretCode = Sepehr_transaction.SendMessage(0); if (SendretCode != 0) { Err = (100).ToString(); semRecieveMessage.WaitOne(); Debug.WriteLine("------------- semRecieveMessage waitOne "); goto end; } // not send int RecieveretCode = 0; CallWithTimeout(() => RecieveretCode = Sepehr_transaction.ReceiveMessage(0), API_TimeOut_ms); semRecieveMessage.WaitOne(); //every thread recieved data block others Debug.WriteLine("------------- semRecieveMessage waitOne "); if (RecieveretCode != 0) { Err = (RecieveretCode + 110).ToString(); goto end; } //not recieved // 110-1 : 109 : not recived // 110-5:105 : timeout // else : Message MAC Error string POSErrCode = Sepehr_transaction.response.AppResponseCode; if (Sepehr_transaction.response.AppResponseCode != "00") { Err = (Convert.ToInt32(POSErrCode) + 200).ToString(); goto end; } //POS Err code: +200 RefNo = Sepehr_transaction.response.SystemTraceNumber == "000000000000" ? "0":Sepehr_transaction.response.SystemTraceNumber; // 000000000000 -> 0 break; case 2: //usb break; } break; } break; } end: Debug.WriteLine("Error:" + Err + "\n RefNo:" + RefNo); } catch (Exception ex) { if (ex.Message == "The operation has timed out.") //handle Exception (CallWithTimeout) { if (nCommandIndex_Provider == 11) //PEP { Err = "132"; } else if (nCommandIndex_Provider == 12) //Sepehr { Err = "105"; } } Debug.WriteLine("Run Api Func Exception:" + ex.ToString() + "\n API_TimeOut_ms: " + API_TimeOut_ms); if (PEP_Pos != null) { PEP_Pos.cancelTrans(); } return(false); } return(true); }