/// <summary> /// 借书 /// </summary> /// <param name="patronBarcode"></param> /// <param name="itemBarcode"></param> /// <param name="error"></param> /// <returns> /// 1 借书成功 /// 0 借书失败 /// -1 出错 /// -2 尚未登录,需要自动测试中断 /// </returns> public int Checkout(string patronBarcode, string itemBarcode, out CheckoutResponse_12 response12, out string responseText, out string error) { error = ""; int nRet = 0; responseText = ""; response12 = null; Checkout_11 request = new Checkout_11() { TransactionDate_18 = SIPUtility.NowDateTime, AA_PatronIdentifier_r = patronBarcode, AB_ItemIdentifier_r = itemBarcode, AO_InstitutionId_r = SIPConst.AO_Value, }; request.SetDefaultValue();//设置其它默认值 // 发送和接收消息 string requestText = request.ToText(); BaseMessage response = null; nRet = SendAndRecvMessage(requestText, out response, out responseText, out error); if (nRet == -1) { return(-1); } response12 = response as CheckoutResponse_12; if (response12 == null) { error = "返回的不是12消息"; return(-1); } //if (this.IsLogin == false) //{ // error = "尚未登录ASC系统"; // return -2; //} if (response12.Ok_1 == "0") { return(0); } return(1); }
private void button_checkOut_Click(object sender, EventArgs e) { Checkout_11 request = new Checkout_11() { SCRenewalPolicy_1 = "Y", NoBlock_1 = "N", TransactionDate_18 = this.TransactionDate, AO_InstitutionId_r = "dp2Library", AA_PatronIdentifier_r = this.textBox_checkout_readerBarcode.Text, AD_PatronPassword_o = this.textBox_checkout_readerPassword.Text, BO_FeeAcknowledged_1_o = "N", BI_Cancel_1_o = "N", NbDueDate_18 = " ", AC_TerminalPassword_r = "", }; Button button = sender as Button; string responseText = ""; string error = ""; string[] barcodes = this.textBox_barcodes.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int i = 0; foreach (string barcode in barcodes) { this.Update(); Application.DoEvents(); Thread.Sleep(100); request.AB_ItemIdentifier_r = barcode; string cmdText = request.ToText(); this.Print("send:" + cmdText); BaseMessage response = null; int nRet = SCHelper.Instance.SendAndRecvMessage(cmdText, out response, out responseText, out error); if (nRet == -1) { MessageBox.Show(error); this.Print("error:" + error); return; } this.Print("recv:" + responseText); button.Text = "借书(" + (i + 1).ToString() + ")"; i++; } }
// 借书 // return.Value // -1 出错 // 0 请求失败 // 1 请求成功 public async Task <CheckoutResult> CheckoutAsync(string patronBarcode, string itemBarcode) { Checkout_11 request = new Checkout_11() { TransactionDate_18 = SIPUtility.NowDateTime, AA_PatronIdentifier_r = patronBarcode, AB_ItemIdentifier_r = itemBarcode, AO_InstitutionId_r = SIPConst.AO_Value, }; request.SetDefaulValue();//设置其它默认值 // 发送和接收消息 string requestText = request.ToText(); var result = await SendAndRecvAsync(requestText); if (result.Value == -1) { return(new CheckoutResult { Value = -1, ErrorInfo = result.ErrorInfo, ErrorCode = result.ErrorCode }); } var response12 = result.Response as CheckoutResponse_12; if (response12 == null) { return(new CheckoutResult { Value = -1, ErrorInfo = "返回的不是12消息" }); } return(new CheckoutResult { Value = response12.Ok_1 == "0" ? 0 : 1, ErrorInfo = response12.AF_ScreenMessage_o, Result = response12 }); }
//统一用一个专门的LogManager //// public static ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //public static ILog Logger = log4net.LogManager.GetLogger("dp2SIPLogging"); //public static void WriteLog(string message) //{ // Logger.Info(message); //} /// <summary> /// 将消息字符串 解析 成对应的消息对象 /// </summary> /// <param name="cmdText">消息字符串</param> /// <param name="message">解析后的消息对象</param> /// <param name="error">氏族</param> /// <returns> /// true 成功 /// false 出错 /// </returns> public static int ParseMessage(string cmdText, out BaseMessage message, out string error) { message = new BaseMessage(); error = ""; if (cmdText.Length < 2) { error = "命令长度不够2位"; return(-1); } string cmdIdentifiers = cmdText.Substring(0, 2); //text = text.Substring(2); switch (cmdIdentifiers) { case "93": { message = new Login_93(); break; } case "94": { message = new LoginResponse_94(); break; } case "99": { message = new SCStatus_99(); break; } case "98": { message = new ACSStatus_98(); break; } case "11": { message = new Checkout_11(); break; } case "12": { message = new CheckoutResponse_12(); break; } case "09": { message = new Checkin_09(); break; } case "10": { message = new CheckinResponse_10(); break; } case "63": { message = new PatronInformation_63(); break; } case "64": { message = new PatronInformationResponse_64(); break; } case "35": { message = new EndPatronSession_35(); break; } case "36": { message = new EndSessionResponse_36(); break; } case "17": { message = new ItemInformation_17(); break; } case "18": { message = new ItemInformationResponse_18(); break; } case "29": { message = new Renew_29(); break; } case "30": { message = new RenewResponse_30(); break; } case "37": { message = new FeePaid_37(); break; } case "38": { message = new FeePaidResponse_38(); break; } default: error = "不支持的命令'" + cmdIdentifiers + "'"; return(-1); } return(message.parse(cmdText, out error)); }
private void toolStripLabel_sample_Click(object sender, EventArgs e) { this.txtMsg.Text = ""; string error = ""; int nRet = 0; //BaseRequest request = null; string text = ""; if (this.tabControl_main.SelectedTab == this.tabPage_Login93) { text = "93 CNsupervisor|CO1|CPC00|AY0AZFB58"; Login_93 request93 = new Login_93(); nRet = request93.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_Login93_UIDAlgorithm_1.Text = request93.UIDAlgorithm_1; //.GetFixedFieldValue(SIPConst.F_UIDAlgorithm); this.textBox_Login93_PWDAlgorithm_1.Text = request93.PWDAlgorithm_1; //.GetFixedFieldValue(SIPConst.F_PWDAlgorithm); this.textBox_Login93_loginUserId_CN_r.Text = request93.CN_LoginUserId_r; //.GetVariableFieldValue(SIPConst.F_CN_LoginUserId); this.textBox_Login93_loginPassword_CO_r.Text = request93.CO_LoginPassword_r; //.GetVariableFieldValue(SIPConst.F_CO_LoginPassword); this.textBox_Login93_locationCode_CP_o.Text = request93.CP_LocationCode_o; //.GetVariableFieldValue(SIPConst.F_CP_LocationCode); } else if (this.tabControl_main.SelectedTab == this.tabPage_SCStatus99) { text = "9900302.00"; SCStatus_99 request99 = new SCStatus_99(); nRet = request99.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_SCStatus99_statusCode_1.Text = request99.StatusCode_1; //.GetFixedFieldValue(SIPConst.F_StatusCode); this.textBox_SCStatus99_maxPrintWidth_3.Text = request99.MaxPrintWidth_3; //.GetFixedFieldValue(SIPConst.F_MaxPrintWidth); this.textBox_SCStatus99_protocolVersion_4.Text = request99.ProtocolVersion_4; //.GetFixedFieldValue(SIPConst.F_ProtocolVersion); } else if (this.tabControl_main.SelectedTab == this.tabPage_Checkout11) { //20170630 141135 text = "11YN" + SIPUtility.NowDateTime + " AOdp2Library|AA" + SamplePatron + "|AB" + SampleItem + "|AC|BON|BIN|"; Checkout_11 request11 = new Checkout_11(); nRet = request11.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_Checkout11_SCRenewalPolicy_1.Text = request11.SCRenewalPolicy_1; //.GetFixedFieldValue(SIPConst.F_SCRenewalPolicy);//.SCRenewalPolicy_1; this.textBox_Checkout11_noBlock_1.Text = request11.NoBlock_1; //.GetFixedFieldValue(SIPConst.F_NoBlock);//.NoBlock_1; this.textBox_Checkout11_transactionDate_18.Text = request11.TransactionDate_18; //.GetFixedFieldValue(SIPConst.F_TransactionDate);//.TransactionDate_18; this.textBox_Checkout11_nbDueDate_18.Text = request11.NbDueDate_18; //.GetFixedFieldValue(SIPConst.F_NbDueDate);//.NbDueDate_18; this.textBox_Checkout11_institutionId_AO_r.Text = request11.AO_InstitutionId_r; //.GetVariableFieldValue(SIPConst.F_AO_InstitutionId);//.InstitutionId_AO_r; this.textBox_Checkout11_patronIdentifier_AA_r.Text = request11.AA_PatronIdentifier_r; //.GetVariableFieldValue(SIPConst.F_AA_PatronIdentifier);//.PatronIdentifier_AA_r; this.textBox_Checkout11_itemIdentifier_AB_r.Text = request11.AB_ItemIdentifier_r; //.GetVariableFieldValue(SIPConst.F_AB_ItemIdentifier);//.ItemIdentifier_AB_r; this.textBox_Checkout11_terminalPassword_AC_r.Text = request11.AC_TerminalPassword_r; //.GetVariableFieldValue(SIPConst.F_AC_TerminalPassword);//.TerminalPassword_AC_r; this.textBox_Checkout11_itemProperties_CH_o.Text = request11.CH_ItemProperties_o; //.GetVariableFieldValue(SIPConst.F_CH_ItemProperties);//.ItemProperties_CH_o; this.textBox_Checkout11_patronPassword_AD_o.Text = request11.AD_PatronPassword_o; //.GetVariableFieldValue(SIPConst.F_AD_PatronPassword);//.PatronPassword_AD_o; this.textBox_Checkout11_feeAcknowledged_BO_1_o.Text = request11.BO_FeeAcknowledged_1_o; //.GetVariableFieldValue(SIPConst.F_BO_FeeAcknowledged);//.FeeAcknowledged_BO_1_o; this.textBox_Checkout11_cancel_BI_1_o.Text = request11.BI_Cancel_1_o; //.GetVariableFieldValue(SIPConst.F_BI_Cancel);//Cancel_BI_1_o; } else if (this.tabControl_main.SelectedTab == this.tabPage_Checkin09) { //20170630 141630 string transactionDate = SIPUtility.NowDateTime; string returnDate = SIPUtility.NowDateTime; text = "09N" + transactionDate + returnDate + "AP|AOdp2Library|AB" + SampleItem + "|AC|BIN|"; //text = "09N20170906 170441|AB378344|AOhuanshuji|AC|BIN|AP|AY1AZEFA4"; Checkin_09 request09 = new Checkin_09(); nRet = request09.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_Checkin09_noBlock_1.Text = request09.NoBlock_1; //.GetFixedFieldValue(SIPConst.F_NoBlock);//.F_no.NoBlock_1; this.textBox_Checkin09_transactionDate_18.Text = request09.TransactionDate_18; //.GetFixedFieldValue(SIPConst.F_TransactionDate);//_18; this.textBox_Checkin09_returnDate_18.Text = request09.ReturnDate_18; //.GetFixedFieldValue(SIPConst.F_ReturnDate); this.textBox_Checkin09_currentLocation_AP_r.Text = request09.AP_CurrentLocation_r; //.GetVariableFieldValue(SIPConst.F_AP_CurrentLocation);// _r; this.textBox_Checkin09_institutionId_AO_r.Text = request09.AO_InstitutionId_r; //.GetVariableFieldValue(SIPConst.F_AO_InstitutionId); this.textBox_Checkin09_itemIdentifier_AB_r.Text = request09.AB_ItemIdentifier_r; //.GetVariableFieldValue(SIPConst.F_AB_ItemIdentifier); this.textBox_Checkin09_terminalPassword_AC_r.Text = request09.AC_TerminalPassword_r; //.GetVariableFieldValue(SIPConst.F_AC_TerminalPassword); this.textBox_Checkin09_itemProperties_CH_o.Text = request09.CH_ItemProperties_o; //.GetVariableFieldValue(SIPConst.F_CH_ItemProperties); this.textBox_Checkin09_cancel_BI_1_o.Text = request09.BI_Cancel_1_o; //.GetVariableFieldValue(SIPConst.F_BI_Cancel); } else if (this.tabControl_main.SelectedTab == this.tabPage_PatronInformation63) { //6301920170630 090808 Y AOdp2Library|AAA005312| string transactionDate = SIPUtility.NowDateTime; text = "63019" + transactionDate + " Y AOdp2Library|AA" + SamplePatron + "|"; PatronInformation_63 request63 = new PatronInformation_63(); nRet = request63.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_PatronInformation63_language_3.Text = request63.Language_3; //.GetFixedFieldValue(SIPConst.F_Language); this.textBox_PatronInformation63_transactionDate_18.Text = request63.TransactionDate_18; //.GetFixedFieldValue(SIPConst.F_TransactionDate);//.TransactionDate_18; this.textBox_PatronInformation63_summary_10.Text = request63.Summary_10; //.GetFixedFieldValue(SIPConst.F_Summary);//.Summary_10; this.textBox_PatronInformation63_institutionId_AO_r.Text = request63.AO_InstitutionId_r; //.GetVariableFieldValue(SIPConst.F_AO_InstitutionId);//.InstitutionId_AO_r; this.textBox_PatronInformation63_patronIdentifier_AA_r.Text = request63.AA_PatronIdentifier_r; //.GetVariableFieldValue(SIPConst.F_AA_PatronIdentifier);//.PatronIdentifier_AA_r; this.textBox_PatronInformation63_terminalPassword_AC_o.Text = request63.AC_TerminalPassword_o; //.GetVariableFieldValue(SIPConst.F_AC_TerminalPassword);//.TerminalPassword_AC_o; this.textBox_PatronInformation63_patronPassword_AD_o.Text = request63.AD_PatronPassword_o; //.GetVariableFieldValue(SIPConst.F_AD_PatronPassword);//.PatronPassword_AD_o; this.textBox_PatronInformation63_startItem_BP_o.Text = request63.BP_StartItem_o; //.GetVariableFieldValue(SIPConst.F_BP_StartItem);//.StartItem_BP_o; this.textBox_PatronInformation63_endItem_BQ_o.Text = request63.BQ_EndItem_o; //.GetVariableFieldValue(SIPConst.F_BQ_EndItem);//.EndItem_BQ_o; } else if (this.tabControl_main.SelectedTab == this.tabPage_ItemInformation17) { //1720170623 151645AOdp2Library|AB700635| string transactionDate = SIPUtility.NowDateTime; text = "17" + transactionDate + "AOdp2Library|AB" + SampleItem + "|"; ItemInformation_17 request17 = new ItemInformation_17(); nRet = request17.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_ItemInformation17_transactionDate_18.Text = request17.TransactionDate_18; //.GetFixedFieldValue(SIPConst.F_TransactionDate);//.TransactionDate_18; this.textBox_ItemInformation17_institutionId_AO_r.Text = request17.AO_InstitutionId_r; //.GetVariableFieldValue(SIPConst.F_AO_InstitutionId);//.InstitutionId_AO_r; this.textBox_ItemInformation17_itemIdentifier_AB_r.Text = request17.AB_ItemIdentifier_r; //.GetVariableFieldValue(SIPConst.F_AB_ItemIdentifier);//.ItemIdentifier_AB_r; this.textBox_ItemInformation17_terminalPassword_AC_o.Text = request17.AC_TerminalPassword_o; //.GetVariableFieldValue(SIPConst.F_AC_TerminalPassword);//.TerminalPassword_AC_o; } else if (this.tabControl_main.SelectedTab == this.tabPage_Renew29) { //29NN20170630 144419 AOdp2Library|AAL905071|AB510105|BON| string transactionDate = SIPUtility.NowDateTime; text = "29NN" + transactionDate + " AOdp2Library|AA" + SamplePatron + "|AB" + SampleItem + "|BON|"; Renew_29 request29 = new Renew_29(); nRet = request29.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_Renew29_thirdPartyAllowed_1.Text = request29.ThirdPartyAllowed_1; //.GetFixedFieldValue(SIPConst.F_ThirdPartyAllowed);//.ThirdPartyAllowed_1; this.textBox_Renew29_noBlock_1.Text = request29.NoBlock_1; //.GetFixedFieldValue(SIPConst.F_NoBlock);//.NoBlock_1; this.textBox_Renew29_transactionDate_18.Text = request29.TransactionDate_18; //.GetFixedFieldValue(SIPConst.F_TransactionDate);//.TransactionDate_18; this.textBox_Renew29_nbDueDate_18.Text = request29.NbDueDate_18; //.GetFixedFieldValue(SIPConst.F_NbDueDate);//.NbDueDate_18; this.textBox_Renew29_institutionId_AO_r.Text = request29.AO_InstitutionId_r; //.GetVariableFieldValue(SIPConst.F_AO_InstitutionId);//.InstitutionId_AO_r; this.textBox_Renew29_patronIdentifier_AA_r.Text = request29.AA_PatronIdentifier_r; //.GetVariableFieldValue(SIPConst.F_AA_PatronIdentifier);//.PatronIdentifier_AA_r; //AD AB AJ this.textBox_Renew29_patronPassword_AD_o.Text = request29.AD_PatronPassword_o; //.GetVariableFieldValue(SIPConst.F_AD_PatronPassword);//.PatronPassword_AD_o; this.textBox_Renew29_itemIdentifier_AB_o.Text = request29.AB_ItemIdentifier_o; //.GetVariableFieldValue(SIPConst.F_AB_ItemIdentifier);//.ItemIdentifier_AB_o; this.textBox_Renew29_titleIdentifier_AJ_o.Text = request29.AJ_TitleIdentifier_o; //.GetVariableFieldValue(SIPConst.F_AJ_TitleIdentifier);//.TitleIdentifier_AJ_o; //AC CH BO this.textBox_Renew29_terminalPassword_AC_o.Text = request29.AC_TerminalPassword_o; //.GetVariableFieldValue(SIPConst.F_AC_TerminalPassword);//.TerminalPassword_AC_o; this.textBox_Renew29_itemProperties_CH_o.Text = request29.CH_ItemProperties_o; //.GetVariableFieldValue(SIPConst.F_CH_ItemProperties);//.ItemProperties_CH_o; this.textBox_Renew29_feeAcknowledged_BO_1_o.Text = request29.BO_FeeAcknowledged_1_o; //.GetVariableFieldValue(SIPConst.F_BO_FeeAcknowledged);//.FeeAcknowledged_BO_1_o; } else if (this.tabControl_main.SelectedTab == this.tabPage_FeePaid37) { //3720180118 1309170100USDBV0.1|AOj163-z1|AAL120100000000000002|AY3AZEFFC string transactionDate = SIPUtility.NowDateTime; text = "37" + transactionDate + "0100USDBV0.1|AOj163-z1|AA" + SamplePatron + "|AY3AZEFFC"; FeePaid_37 request37 = new FeePaid_37(); nRet = request37.parse(text, out error); if (nRet == -1) { goto ERROR1; } this.textBox_FeePaid37_transactionDate_18.Text = request37.TransactionDate_18; this.textBox_FeePaid37_feeType.Text = request37.FeeType_2; this.textBox_FeePaid37_paymentType.Text = request37.PaymentType_2; this.textBox_FeePaid37_currencyType.Text = request37.CurrencyType_3; this.textBox_FeePaid37_feeAmount.Text = request37.BV_FeeAmount_r; this.textBox_FeePaid37_institutionId_AO_r.Text = request37.AO_InstitutionId_r; this.textBox_FeePaid37_patronIdentifier_AA_r.Text = request37.AA_PatronIdentifier_r; this.textBox_FeePaid37_terminalPassword_AC_o.Text = request37.AC_TerminalPassword_o; this.textBox_FeePaid37_patronPassword_AD_o.Text = request37.AD_PatronPassword_o; this.textBox_FeePaid37_feeIdentifier_CG_o.Text = request37.CG_FeeIdentifier_o; this.textBox_FeePaid37_transactionId_BK_o.Text = request37.BK_TransactionId_o; } return; ERROR1: this.Print("error:" + error); }
//发送消息 private void toolStripLabel_send_Click(object sender, EventArgs e) { string cmdText = ""; try { if (this.tabControl_main.SelectedTab == this.tabPage_Login93) { Login_93 request93 = new Login_93() { UIDAlgorithm_1 = this.textBox_Login93_UIDAlgorithm_1.Text, PWDAlgorithm_1 = this.textBox_Login93_PWDAlgorithm_1.Text, CN_LoginUserId_r = getText(this.textBox_Login93_loginUserId_CN_r), //.Text == "null" ? null : this.textBox_Login93_loginUserId_CN_r.Text CO_LoginPassword_r = getText(this.textBox_Login93_loginPassword_CO_r), //.Text == "null" ? null : this.textBox_Login93_loginPassword_CO_r.Text, CP_LocationCode_o = getText(this.textBox_Login93_locationCode_CP_o), //.Text == "null" ? null : this.textBox_Login93_locationCode_CP_o.Text }; cmdText = request93.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_SCStatus99) { SCStatus_99 request = new SCStatus_99() { StatusCode_1 = this.textBox_SCStatus99_statusCode_1.Text, MaxPrintWidth_3 = this.textBox_SCStatus99_maxPrintWidth_3.Text, ProtocolVersion_4 = this.textBox_SCStatus99_protocolVersion_4.Text }; cmdText = request.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_Checkout11) { Checkout_11 request = new Checkout_11() { SCRenewalPolicy_1 = this.textBox_Checkout11_SCRenewalPolicy_1.Text, NoBlock_1 = this.textBox_Checkout11_noBlock_1.Text, TransactionDate_18 = this.textBox_Checkout11_transactionDate_18.Text, NbDueDate_18 = this.textBox_Checkout11_nbDueDate_18.Text, AO_InstitutionId_r = getText(this.textBox_Checkout11_institutionId_AO_r), //.Text == "null" ? null : this.textBox_Checkout11_institutionId_AO_r.Text, AA_PatronIdentifier_r = getText(this.textBox_Checkout11_patronIdentifier_AA_r), //.Text == "null" ? null : this.textBox_Checkout11_patronIdentifier_AA_r.Text, AB_ItemIdentifier_r = getText(this.textBox_Checkout11_itemIdentifier_AB_r), //.Text == "null" ? null : this.textBox_Checkout11_itemIdentifier_AB_r.Text, AC_TerminalPassword_r = getText(this.textBox_Checkout11_terminalPassword_AC_r), //.Text == "null" ? null : this.textBox_Checkout11_terminalPassword_AC_r.Text; CH_ItemProperties_o = getText(this.textBox_Checkout11_itemProperties_CH_o), AD_PatronPassword_o = getText(this.textBox_Checkout11_patronPassword_AD_o), BO_FeeAcknowledged_1_o = getText(this.textBox_Checkout11_feeAcknowledged_BO_1_o), BI_Cancel_1_o = getText(this.textBox_Checkout11_cancel_BI_1_o), }; cmdText = request.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_Checkin09) { Checkin_09 request = new Checkin_09() { NoBlock_1 = this.textBox_Checkin09_noBlock_1.Text, TransactionDate_18 = this.textBox_Checkin09_transactionDate_18.Text, ReturnDate_18 = this.textBox_Checkin09_returnDate_18.Text, AP_CurrentLocation_r = getText(this.textBox_Checkin09_currentLocation_AP_r), AO_InstitutionId_r = getText(this.textBox_Checkin09_institutionId_AO_r), AB_ItemIdentifier_r = getText(this.textBox_Checkin09_itemIdentifier_AB_r), AC_TerminalPassword_r = getText(this.textBox_Checkin09_terminalPassword_AC_r), CH_ItemProperties_o = getText(this.textBox_Checkin09_itemProperties_CH_o), BI_Cancel_1_o = getText(this.textBox_Checkin09_cancel_BI_1_o), }; cmdText = request.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_PatronInformation63) { PatronInformation_63 request = new PatronInformation_63() { Language_3 = this.textBox_PatronInformation63_language_3.Text, TransactionDate_18 = this.textBox_PatronInformation63_transactionDate_18.Text, Summary_10 = this.textBox_PatronInformation63_summary_10.Text, AO_InstitutionId_r = getText(this.textBox_PatronInformation63_institutionId_AO_r), AA_PatronIdentifier_r = getText(this.textBox_PatronInformation63_patronIdentifier_AA_r), AC_TerminalPassword_o = getText(this.textBox_PatronInformation63_terminalPassword_AC_o), AD_PatronPassword_o = getText(this.textBox_PatronInformation63_patronPassword_AD_o), BP_StartItem_o = getText(this.textBox_PatronInformation63_startItem_BP_o), BQ_EndItem_o = getText(this.textBox_PatronInformation63_endItem_BQ_o), }; cmdText = request.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_ItemInformation17) { ItemInformation_17 request = new ItemInformation_17() { TransactionDate_18 = this.textBox_ItemInformation17_transactionDate_18.Text, AO_InstitutionId_r = getText(this.textBox_ItemInformation17_institutionId_AO_r), AB_ItemIdentifier_r = getText(this.textBox_ItemInformation17_itemIdentifier_AB_r), AC_TerminalPassword_o = getText(this.textBox_ItemInformation17_terminalPassword_AC_o), }; cmdText = request.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_Renew29) { Renew_29 request = new Renew_29() { ThirdPartyAllowed_1 = this.textBox_Renew29_thirdPartyAllowed_1.Text, NoBlock_1 = this.textBox_Renew29_noBlock_1.Text, TransactionDate_18 = this.textBox_Renew29_transactionDate_18.Text, NbDueDate_18 = this.textBox_Renew29_nbDueDate_18.Text, AO_InstitutionId_r = getText(this.textBox_Renew29_institutionId_AO_r), AA_PatronIdentifier_r = getText(this.textBox_Renew29_patronIdentifier_AA_r), AD_PatronPassword_o = getText(this.textBox_Renew29_patronPassword_AD_o), AB_ItemIdentifier_o = getText(this.textBox_Renew29_itemIdentifier_AB_o), AJ_TitleIdentifier_o = getText(this.textBox_Renew29_titleIdentifier_AJ_o), AC_TerminalPassword_o = getText(this.textBox_Renew29_terminalPassword_AC_o), CH_ItemProperties_o = getText(this.textBox_Renew29_itemProperties_CH_o), BO_FeeAcknowledged_1_o = getText(this.textBox_Renew29_feeAcknowledged_BO_1_o), }; cmdText = request.ToText(); } else if (this.tabControl_main.SelectedTab == this.tabPage_FeePaid37) { FeePaid_37 request = new FeePaid_37() { TransactionDate_18 = getText(this.textBox_FeePaid37_transactionDate_18), FeeType_2 = getText(this.textBox_FeePaid37_feeType), PaymentType_2 = getText(this.textBox_FeePaid37_paymentType), CurrencyType_3 = getText(this.textBox_FeePaid37_currencyType), BV_FeeAmount_r = getText(this.textBox_FeePaid37_feeAmount), AO_InstitutionId_r = getText(this.textBox_FeePaid37_institutionId_AO_r), AA_PatronIdentifier_r = getText(this.textBox_FeePaid37_patronIdentifier_AA_r), AC_TerminalPassword_o = getText(this.textBox_FeePaid37_terminalPassword_AC_o), AD_PatronPassword_o = getText(this.textBox_FeePaid37_patronPassword_AD_o), CG_FeeIdentifier_o = getText(this.textBox_FeePaid37_feeIdentifier_CG_o), BK_TransactionId_o = getText(this.textBox_FeePaid37_transactionId_BK_o), }; cmdText = request.ToText(); } //发送命令 this.txtMsg.Text = cmdText; this.sendCmd(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
//统一用一个专门的LogManager //// public static ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //public static ILog Logger = log4net.LogManager.GetLogger("dp2SIPLogging"); //public static void WriteLog(string message) //{ // Logger.Info(message); //} /// <summary> /// 将消息字符串 解析 成对应的消息对象 /// </summary> /// <param name="cmdText">消息字符串</param> /// <param name="message">解析后的消息对象</param> /// <param name="error">氏族</param> /// <returns> /// true 成功 /// false 出错 /// </returns> public static int ParseMessage(string cmdText, out BaseMessage message, out string error) { message = new BaseMessage(); error = ""; if (cmdText.Length < 2) { error = "命令长度不够2位"; return(-1); } string cmdIdentifiers = cmdText.Substring(0, 2); //text = text.Substring(2); switch (cmdIdentifiers) { case "93": { message = new Login_93(); break; } case "94": { message = new LoginResponse_94(); break; } case "99": { message = new SCStatus_99(); break; } case "98": { message = new ACSStatus_98(); break; } case "11": { message = new Checkout_11(); break; } case "12": { message = new CheckoutResponse_12(); break; } case "09": { message = new Checkin_09(); break; } case "10": { message = new CheckinResponse_10(); break; } case "63": { message = new PatronInformation_63(); break; } case "64": { message = new PatronInformationResponse_64(); break; } case "35": { message = new EndPatronSession_35(); break; } case "36": { message = new EndSessionResponse_36(); break; } case "17": { message = new ItemInformation_17(); break; } case "18": { message = new ItemInformationResponse_18(); break; } case "29": { message = new Renew_29(); break; } case "30": { message = new RenewResponse_30(); break; } case "65": { message = new RenewAll_65(); break; } case "66": { message = new RenewAllResponse_66(); break; } case "37": { message = new FeePaid_37(); break; } case "38": { message = new FeePaidResponse_38(); break; } case "97": { message = new RequestACSResend_97(); break; } case "96": { message = new RequestSCResend_96(); break; } case "23": { message = new PatronStatusRequest_23(); break; } case "24": { message = new PatronStatusResponse_24(); break; } case "25": { message = new PatronEnable_25(); break; } case "26": { message = new PatronEnableResponse_26(); break; } case "01": { message = new BlockPatron_01(); break; } case "15": { message = new Hold_15(); break; } case "16": { message = new HoldResponse_16(); break; } case "19": { message = new ItemStatusUpdate_19(); break; } case "20": { message = new ItemStatusUpdateResponse_20(); break; } default: error = "不支持的命令'" + cmdIdentifiers + "'"; return(-1); } return(message.parse(cmdText, out error)); }