diff --git a/DLLSample_HK_MTR.rar b/DLLSample_HK_MTR.rar
new file mode 100644
index 0000000..4ce6b90
Binary files /dev/null and b/DLLSample_HK_MTR.rar differ
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.config b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.config
new file mode 100644
index 0000000..74ade9d
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.xaml b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.xaml
new file mode 100644
index 0000000..c414142
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.xaml.cs b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.xaml.cs
new file mode 100644
index 0000000..64291ff
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace ECR_N5_DLL_TestUI
+{
+ ///
+ /// App.xaml 的交互逻辑
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj
new file mode 100644
index 0000000..8389570
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj
@@ -0,0 +1,132 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {DEF387D0-3F98-4720-874D-8A753399B206}
+ WinExe
+ ECR_N5_DLL_TestUI
+ ECR_N5_DLL_TestUI
+ v4.0
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+ false
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.6.1 %28x86 和 x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+ {1f0c1d84-fd97-41f1-bc8b-f2f22c1997a1}
+ n5coredll
+
+
+
+
\ No newline at end of file
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/MainWindow.xaml b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/MainWindow.xaml
new file mode 100644
index 0000000..494f191
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/MainWindow.xaml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/MainWindow.xaml.cs b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
new file mode 100644
index 0000000..d91dc69
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
@@ -0,0 +1,901 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Threading;
+using System.Security.Cryptography;
+using System.Windows.Threading;
+using n5coredll;
+
+namespace ECR_N5_DLL_TestUI
+{
+ public partial class MainWindow : Window
+ {
+ private string portName = "COM3";
+ private string baudRate = "9600";
+ private string dataBits = "8";
+ private string stopBits = "One";
+ private string parity = "None";
+ private string timeOut = "12000";
+
+ private string thisEvent;
+
+ public bool addLogFlag = true;
+
+ public string currEventName = null;
+ public string jsonResultByThead = null;
+ public string requestStrByThead = null;
+ public string showResultStr = null;
+ public string txnAmtTextBoxValue = null;
+ public string paymentAppIdComboBoxValue = null;
+ public string qrValueTextBoxValue = null;
+ public string ecrTxnIdTextBoxValue = null;
+ public string panTextBoxValue = null;
+ public string authCodeTextBoxValue = null;
+ public string batchIdTextBoxValue = null;
+ public string settleDateTextBoxValue = null;
+ public string expDateTextBoxValue = null;
+ public string oriTxnDateTextBoxValue = null;
+ public string hostRefNoTextBoxValue = null;
+ public string paymentTypeTextBoxValue = null;
+ private n5coredll.N5Core n5Core = null;
+ private bool n5CoreInitSuccess = false;
+
+ private string txnIdForSale = null;
+ private string txnIdForRefund = null;
+ private string txnIdForPreAuth = null;
+ private string txnIdForOffline = null;
+ private string txnIdForAdjust = null;
+ private string txnIdForCreateOrder = null;
+ private string enquiryPeriod = null;
+
+ private string saleRequestMsg = null;
+ private string preAuthRequestMsg = null;
+ private string offlineRequestMsg = null;
+ private string adjustRequestMsg = null;
+ private string createOrderRequestMsg = null;
+ private string refundRequestMsg = null;
+ private string retrievalRequestMsg = null;
+ private string voidRequestMsg = null;
+ private string settlementRequestMsg = null;
+ private string getInfoRequestMsg = null;
+ private string checkUpdateRequestMsg = null;
+ private string executeUpdateRequestMsg = null;
+ private string linkTestRequestMsg = null;
+ private string reprintRequestMsg = null;
+ private string terminaionRequestMsg = null;
+ private string scanRequestMsg = null;
+ private string readCardRequestMsg = null;
+ private string addPointRequestMsg = null;
+ private string batchEnquiryRequestMsg = null;
+ private string settleEnquiryRequestMsg = null;
+ private string summaryEnquiryRequestMsg = null;
+ private string checkHealthRequestMsg = null;
+
+ private Boolean isRepeatSubmit = false;
+ private string timeout = "300000";
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ private void requestSummaryEnquiryThead()
+ {
+
+ jsonResultByThead = n5Core.sendSummaryEnquiryRequest(enquiryPeriod, timeout);
+ this.requestStrByThead = this.summaryEnquiryRequestMsg;
+ showResult();
+ }
+ private void requestSaleThead()
+ {
+ jsonResultByThead = n5Core.requestSale(txnIdForSale, txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue, timeout);
+ this.requestStrByThead = this.saleRequestMsg;
+ showResult();
+ }
+
+ private void requestRefundThead()
+ {
+ jsonResultByThead = n5Core.requestRefund(txnIdForRefund, txnAmtTextBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue, oriTxnDateTextBoxValue, hostRefNoTextBoxValue , timeout);
+ this.requestStrByThead = this.refundRequestMsg;
+ showResult();
+ }
+ private void requestRetrievalThead()
+ {
+ jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, timeout);
+ this.requestStrByThead = this.retrievalRequestMsg;
+ showResult();
+ }
+ private void requestRepeatRetrievalThead()
+ {
+ while (isRepeatSubmit)
+ {
+ /*
+ String result = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 10000);
+ addRepeatLog("=============================count" + repeatCount + "=============================");
+ addRepeatLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
+
+ RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(result);*/
+ String result = n5Core.requestSale(getTxnId(), "10", "0", "CC", "", "30000");
+ addRepeatLog("=============================count" + repeatCount + "=============================");
+ addRepeatLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
+
+ SaleResult saleResult = SaleResult.toSaleResultFromJsonMsg(result);
+ addRepeatLog("Sale Result:" + saleResult.Status);
+
+ }
+
+
+ }
+ private void requestVoidThead()
+ {
+ jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue, timeout);
+ this.requestStrByThead = this.voidRequestMsg;
+ showResult();
+ }
+
+ private void requestSettlementThead()
+ {
+ jsonResultByThead = n5Core.sendSettlementtRequest(timeout);
+ this.requestStrByThead = this.settlementRequestMsg;
+ showResult();
+ }
+
+ private void requesGetInfoThead()
+ {
+ jsonResultByThead = n5Core.requestGetInfo(timeout);
+ this.requestStrByThead = this.getInfoRequestMsg;
+ showResult();
+ }
+
+ private void requesCheckUpdateThead()
+ {
+ jsonResultByThead = n5Core.checkUpdate(timeout);
+ this.requestStrByThead = this.checkUpdateRequestMsg;
+ showResult();
+ }
+
+ private void requesExecuteUpdateThead()
+ {
+ jsonResultByThead = n5Core.executeUpdate(timeout);
+ this.requestStrByThead = this.executeUpdateRequestMsg;
+ showResult();
+ }
+
+ private void requestLinkRequestThead()
+ {
+ jsonResultByThead = n5Core.sendLinkTestRequest(timeout);
+ this.requestStrByThead = this.linkTestRequestMsg;
+ showResult();
+ }
+
+ private void requestReprintThead()
+ {
+ jsonResultByThead = n5Core.sendReprintRequest(ecrTxnIdTextBoxValue, timeout);
+ this.requestStrByThead = this.reprintRequestMsg;
+ showResult();
+ }
+
+ private void requestTerminaionThead()
+ {
+ jsonResultByThead = n5Core.sendAbortRequest();
+ this.requestStrByThead = this.terminaionRequestMsg;
+ showResult();
+ }
+
+ private void requestBatchEnquiryThead()
+ {
+ jsonResultByThead = n5Core.sendBatchEnquiryRequest(settleDateTextBoxValue, timeout);
+ this.requestStrByThead = this.batchEnquiryRequestMsg;
+ showResult();
+ }
+
+ private void requestSettleEnquiryThead()
+ {
+ jsonResultByThead = n5Core.sendSettleEnquiryRequest(batchIdTextBoxValue, timeout);
+ this.requestStrByThead = this.settleEnquiryRequestMsg;
+ showResult();
+ }
+
+ private int repeatCount = 1;
+ public void sendRepeatSubmit()
+ {
+ if (n5Core == null || !n5CoreInitSuccess)
+ {
+ n5Core = n5coredll.N5Core.getInstance();
+ int initResult = n5Core.initN5Core(portName, baudRate, dataBits, stopBits, parity, timeOut);
+ if (initResult == 0)
+ {
+ n5CoreInitSuccess = true;
+ }
+ }
+ ecrTxnIdTextBoxValue = ecrTxnIdTextBox.Text;
+ Thread th = new Thread(requestRepeatRetrievalThead);
+ th.Start();
+
+ }
+
+ public void stopRepeatSubmit()
+ {
+ repeatCount = 1;
+ }
+
+ public void sendSubmit()
+ {
+ addLogFlag = true;
+ addLog("====>> sendSubmit start, thisEvent = " + this.thisEvent);
+ currEventName = this.thisEvent;
+ if (currEventName == null || "".Equals(currEventName.Trim())) {
+ MessageBox.Show("Please select test function.", "Message");
+ return;
+ }
+ portName = this.portNameComboBox.Text;
+ if (n5Core == null || !n5CoreInitSuccess)
+ {
+ n5Core = n5coredll.N5Core.getInstance();
+ int initResult = n5Core.initN5Core(portName, baudRate, dataBits, stopBits, parity, timeOut);
+ //if (initResult == 0)
+ //{
+ n5CoreInitSuccess = true;
+ //}
+ }
+ if (!n5CoreInitSuccess)
+ {
+ this.requestStrByThead = "n5coredll init fail.";
+ this.jsonResultByThead = string.Empty;
+ showResult();
+ return;
+ }
+ this.requestStrByThead = string.Empty;
+ this.jsonResultByThead = string.Empty;
+ int show = showResult();
+ if (show != 0)
+ {
+ return;
+ }
+
+ if ("Sale".Equals(this.thisEvent))
+ {
+ if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.txnAmtTextBox.Focus();
+ return;
+ }
+ else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.paymentAppIdComboBox.Focus();
+ return;
+ }
+ else
+ {
+ txnAmtTextBoxValue = this.txnAmtTextBox.Text;
+ paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
+ qrValueTextBoxValue = this.qrValueTextBox.Text;
+ panTextBoxValue = this.panTextBox.Text;
+ expDateTextBoxValue = this.expDateTextBox.Text;
+
+ txnIdForSale = this.getTxnId();
+ this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForSale + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
+ showResult();
+ addLog("txnId = " + txnIdForSale + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
+ this.saleRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestSaleThead);
+ th.Start();
+ }
+
+ }
+ else if ("Refund".Equals(this.thisEvent))
+ {
+ if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.txnAmtTextBox.Focus();
+ }
+ else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.paymentAppIdComboBox.Focus();
+ return;
+ }
+ else
+ {
+ txnAmtTextBoxValue = this.txnAmtTextBox.Text;
+ paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
+ qrValueTextBoxValue = this.qrValueTextBox.Text;
+ oriTxnDateTextBoxValue = this.oriTxnDateTextBox.Text;
+ hostRefNoTextBoxValue = this.hostRefNoTextBox.Text;
+
+ txnIdForRefund = this.getTxnId();
+ this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForRefund + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
+ showResult();
+ addLog("txnId = " + txnIdForRefund + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
+
+ //jsonResultByThead = n5Core.requestRefund(txnId, txnAmtTextBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue);
+ this.refundRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestRefundThead);
+ th.Start();
+ }
+ }
+ else if ("Retrieval".Equals(this.thisEvent))
+ {
+ if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.ecrTxnIdTextBox.Focus();
+ return;
+ }
+ else
+ {
+ ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
+ this.requestStrByThead = "Test Function : " + currEventName + "\n ecrTxnId = " + ecrTxnIdTextBoxValue;
+ showResult();
+ addLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
+
+ //jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
+ this.retrievalRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestRetrievalThead);
+ th.Start();
+ }
+ }
+ else if ("SummaryEnquiry".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ enquiryPeriod = periodTextBox.Text;
+ //jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
+ this.summaryEnquiryRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestSummaryEnquiryThead);
+ th.Start();
+ }
+ else if ("Void".Equals(this.thisEvent))
+ {
+ if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.ecrTxnIdTextBox.Focus();
+ return;
+ }
+ else
+ {
+ qrValueTextBoxValue = this.qrValueTextBox.Text;
+ ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
+
+ this.requestStrByThead = "Test Function : " + currEventName + "\n ecrTxnId = " + ecrTxnIdTextBoxValue + "\n qrValue = " + qrValueTextBoxValue;
+ showResult();
+ addLog("ecrTxnId = " + ecrTxnIdTextBoxValue + ", qrValue = " + qrValueTextBoxValue);
+ // jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue);
+ this.voidRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestVoidThead);
+ th.Start();
+ }
+ }
+ else if ("Settlement".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.settlementRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestSettlementThead);
+ th.Start();
+ }
+ else if ("GetInfo".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.getInfoRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requesGetInfoThead);
+ th.Start();
+ }
+ else if ("CheckUpdate".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.checkUpdateRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requesCheckUpdateThead);
+ th.Start();
+ }
+ else if ("ExecuteUpdate".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.executeUpdateRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requesExecuteUpdateThead);
+ th.Start();
+ }
+ else if ("Link Request".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ //jsonResultByThead = n5Core.sendLinkTestRequest();
+ this.linkTestRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestLinkRequestThead);
+ th.Start();
+ }
+ else if ("Reprint".Equals(this.thisEvent))
+ {
+ ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ //jsonResultByThead = n5Core.sendReprintRequest();
+ this.reprintRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestReprintThead);
+ th.Start();
+ }
+ else if ("Terminaion".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ //jsonResultByThead = n5Core.sendAbortRequest();
+ this.terminaionRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestTerminaionThead);
+ th.Start();
+ }
+ else if ("BatchEnquiry".Equals(this.thisEvent))
+ {
+ if (this.settleDateTextBox.Text == null || "".Equals(this.settleDateTextBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.settleDateTextBox.Focus();
+ return;
+ }
+ else
+ {
+ this.settleDateTextBoxValue = this.settleDateTextBox.Text;
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ this.batchEnquiryRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestBatchEnquiryThead);
+ th.Start();
+ }
+ }
+ else if ("SettleEnquiry".Equals(this.thisEvent))
+ {
+ if (this.batchIdTextBox.Text == null || "".Equals(this.batchIdTextBox.Text.Trim()))
+ {
+ this.requestStrByThead = "Please input parameter.";
+ this.jsonResultByThead = "Please input parameter.";
+ showResult();
+ this.batchIdTextBox.Focus();
+ return;
+ }
+ else
+ {
+ this.batchIdTextBoxValue = this.batchIdTextBox.Text;
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ this.settleEnquiryRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestSettleEnquiryThead);
+ th.Start();
+ }
+ }
+ else
+ {
+ addLog("thisEvent is error");
+ MessageBox.Show("Please select test function.", "Message");
+
+ return;
+ }
+ addLog("jsonResultByThead = " + jsonResultByThead);
+ showResult();
+
+ return;
+ }
+
+ private void RadioButton_Checked(object sender, RoutedEventArgs e)
+ {
+ RadioButton thisButton = (RadioButton)sender;
+ this.thisEvent = thisButton.Content.ToString();
+
+ this.requestTextBox.Text = string.Empty;
+ this.result1TextBox.Text = string.Empty;
+
+ if (this.logPathTextBox.Text == null || "".Equals(this.logPathTextBox.Text.Trim()))
+ {
+ this.logPathTextBox.Text = "Log Path : " + System.IO.Path.GetTempPath() + "\\myN5TestWin.log";
+ }
+
+ if ("Sale".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.qrValueTextBox.IsEnabled = true;
+ this.panTextBox.IsEnabled = true;
+ this.expDateTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("CreateOrder".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ this.paymentTypeTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.qrValueTextBox.IsEnabled = true;
+ this.panTextBox.IsEnabled = true;
+ this.expDateTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if("PreAuth".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.panTextBox.IsEnabled = true;
+ this.expDateTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Offline".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.panTextBox.IsEnabled = true;
+ this.authCodeTextBox.IsEnabled = true;
+ this.expDateTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Adjust".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Refund".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+
+ this.txnAmtTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.qrValueTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Retrieval".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = true;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Void".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = true;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Settlement".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Link Request".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Terminaion".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("Scan".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("ReadCard".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("AddPoint".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = true;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ else if ("BatchEnquiry".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.panTextBox.Text = "";
+ this.authCodeTextBox.Text = "";
+ this.expDateTextBox.Text = "";
+ this.batchIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.panTextBox.IsEnabled = false;
+ this.authCodeTextBox.IsEnabled = false;
+ this.expDateTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = true;
+ }
+ else if ("SettleEnquiry".Equals(this.thisEvent))
+ {
+ this.txnAmtTextBox.Text = "";
+ this.paymentAppIdComboBox.Text = "";
+ this.qrValueTextBox.Text = "";
+ this.ecrTxnIdTextBox.Text = "";
+ this.panTextBox.Text = "";
+ this.authCodeTextBox.Text = "";
+ this.expDateTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = false;
+ this.paymentAppIdComboBox.IsEnabled = false;
+ this.qrValueTextBox.IsEnabled = false;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.panTextBox.IsEnabled = false;
+ this.authCodeTextBox.IsEnabled = false;
+ this.expDateTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = true;
+ this.settleDateTextBox.IsEnabled = false;
+ }
+ }
+
+ private void Submit_1_Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.requestTextBox.Text = string.Empty;
+ this.result1TextBox.Text = string.Empty;
+ this.submit_1_Button.IsEnabled = false;
+ addLog("==========Submit start========== ");
+ this.sendSubmit();
+ addLog("==========Submit end========== ");
+ this.submit_1_Button.IsEnabled = true;
+ }
+
+ private void Reset_Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.requestTextBox.Text = string.Empty;
+ this.result1TextBox.Text = string.Empty;
+ }
+
+ public void addLog(string logInfo)
+ {
+ try
+ {
+ if (addLogFlag)
+ {
+ StreamWriter sw = File.AppendText(System.IO.Path.GetTempPath() + "\\myN5TestWin.log");
+ sw.WriteLine(DateTime.Now.ToString() + " [LOGGER] " + logInfo + Environment.NewLine);
+ sw.Flush();
+ sw.Close();
+ // Console.WriteLine(logInfo);
+ }
+ }
+ catch (Exception err)
+ {
+ Console.WriteLine("Exception = " + err);
+ addLogFlag = false;
+ }
+ }
+
+ public void addRepeatLog(string logInfo)
+ {
+ try
+ {
+ StreamWriter sw = File.AppendText(System.IO.Path.GetTempPath() + "\\myN5TestWin_repeat.log");
+ sw.WriteLine(DateTime.Now.ToString() + " [LOGGER] " + logInfo + Environment.NewLine);
+ sw.Flush();
+ sw.Close();
+ // Console.WriteLine(logInfo);
+
+ }
+ catch (Exception err)
+ {
+ Console.WriteLine("Exception = " + err);
+ }
+ }
+
+ private string getTxnId()
+ {
+ StringBuilder txnIdSb = new StringBuilder();
+ DateTime dt = DateTime.Now;
+ txnIdSb.Append(dt.ToString("yyyyMMddHHmmssfff"));
+
+ byte[] randomBytes = new byte[15];
+ RNGCryptoServiceProvider rngServiceProvider = new RNGCryptoServiceProvider();
+ rngServiceProvider.GetBytes(randomBytes);
+ Int32 resultInt32 = BitConverter.ToInt32(randomBytes, 0);
+ for (int i = 0; i < 15; i++)
+ {
+ txnIdSb.Append(randomBytes[i].ToString());
+ }
+ string txnIdResult = null;
+ if (txnIdSb.ToString().Length > 32)
+ {
+ txnIdResult = txnIdSb.ToString().Substring(0, 32);
+ }
+ else
+ {
+ txnIdResult = txnIdSb.ToString();
+ }
+ addLog("txnIdResult = " + txnIdResult);
+ return txnIdResult;
+ }
+
+ private int showResult()
+ {
+ //this.requestTextBox.Text = this.requestStrByThead;
+ requestTextBox.Dispatcher.Invoke(
+ DispatcherPriority.Normal, TimeSpan.FromSeconds(1), new Action(showRequestTxtBox));
+
+ showResultStr = this.jsonResultByThead.Replace("{", "").Replace("}", "").Replace(",", "\n");
+ //this.result1TextBox.Text = showResultStr;
+
+ result1TextBox.Dispatcher.Invoke(
+ DispatcherPriority.Normal, TimeSpan.FromSeconds(1), new Action(showResultTxtBox));
+ return 0;
+ }
+
+ private void showRequestTxtBox()
+ {
+ this.requestTextBox.Text = requestStrByThead;
+ }
+
+ private void showResultTxtBox()
+ {
+ this.result1TextBox.Text = showResultStr;
+ }
+
+ private void PortNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ this.n5CoreInitSuccess = false;
+ }
+ }
+}
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/AssemblyInfo.cs b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..933cd17
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("ECR_N5_DLL_TestUI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ECR_N5_DLL_TestUI")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 CultureYouAreCodingWith
+//例如,如果您在源文件中使用的是美国英语,
+//使用的是美国英语,请将 设置为 en-US。 然后取消
+//对以下 NeutralResourceLanguage 特性的注释。 更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //或应用程序资源字典中找到时使用)
+ ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Resources.Designer.cs b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..3cd4630
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace ECR_N5_DLL_TestUI.Properties {
+ using System;
+
+
+ ///
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// 返回此类使用的缓存的 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ECR_N5_DLL_TestUI.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性
+ /// 重写当前线程的 CurrentUICulture 属性。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Resources.resx b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Settings.Designer.cs b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..cc560ad
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace ECR_N5_DLL_TestUI.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Settings.settings b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/DLLSample_HK_MTR/ECR_N5_DLL_TestUI/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DLLSample_HK_MTR/n5coredll.dll b/DLLSample_HK_MTR/n5coredll.dll
new file mode 100644
index 0000000..42772fb
Binary files /dev/null and b/DLLSample_HK_MTR/n5coredll.dll differ
diff --git a/ECR_N5_DLL_TestUI/MainWindow.xaml b/ECR_N5_DLL_TestUI/MainWindow.xaml
index 4fb6ca6..d920c10 100644
--- a/ECR_N5_DLL_TestUI/MainWindow.xaml
+++ b/ECR_N5_DLL_TestUI/MainWindow.xaml
@@ -14,24 +14,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -43,13 +43,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -71,30 +71,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ECR_N5_DLL_TestUI/MainWindow.xaml.cs b/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
index 369ef04..cde91d5 100644
--- a/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
+++ b/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
@@ -27,7 +27,7 @@ namespace ECR_N5_DLL_TestUI
private string dataBits = "8";
private string stopBits = "One";
private string parity = "None";
- private string timeOut = "180000";
+ private string timeOut = "12000";
private string thisEvent;
@@ -46,6 +46,9 @@ namespace ECR_N5_DLL_TestUI
public string batchIdTextBoxValue = null;
public string settleDateTextBoxValue = null;
public string expDateTextBoxValue = null;
+ public string oriTxnDateTextBoxValue = null;
+ public string hostRefNoTextBoxValue = null;
+ public string paymentTypeTextBoxValue = null;
private n5coredll.N5Core n5Core = null;
private bool n5CoreInitSuccess = false;
@@ -54,16 +57,21 @@ namespace ECR_N5_DLL_TestUI
private string txnIdForPreAuth = null;
private string txnIdForOffline = null;
private string txnIdForAdjust = null;
+ private string txnIdForCreateOrder = null;
+ private string enquiryPeriod = null;
private string saleRequestMsg = null;
private string preAuthRequestMsg = null;
private string offlineRequestMsg = null;
private string adjustRequestMsg = null;
-
+ private string createOrderRequestMsg = null;
private string refundRequestMsg = null;
private string retrievalRequestMsg = null;
private string voidRequestMsg = null;
private string settlementRequestMsg = null;
+ private string getInfoRequestMsg = null;
+ private string checkUpdateRequestMsg = null;
+ private string executeUpdateRequestMsg = null;
private string linkTestRequestMsg = null;
private string reprintRequestMsg = null;
private string terminaionRequestMsg = null;
@@ -72,50 +80,43 @@ namespace ECR_N5_DLL_TestUI
private string addPointRequestMsg = null;
private string batchEnquiryRequestMsg = null;
private string settleEnquiryRequestMsg = null;
+ private string summaryEnquiryRequestMsg = null;
+ private string checkHealthRequestMsg = null;
private Boolean isRepeatSubmit = false;
+ private string timeout = "300000";
public MainWindow()
{
InitializeComponent();
}
- private void requestSaleThead()
+
+ protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
- if (panTextBoxValue!=null && panTextBoxValue!= "" && expDateTextBoxValue!=null && expDateTextBoxValue!="")
- jsonResultByThead = n5Core.requestSale(txnIdForSale, txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- else
- jsonResultByThead = n5Core.requestSale(txnIdForSale, txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.requestStrByThead = this.saleRequestMsg;
- showResult();
+ System.Diagnostics.Process.GetCurrentProcess().Kill();
}
- private void requestPreauthThead()
+ private void requestSummaryEnquiryThead()
{
- jsonResultByThead = n5Core.processPreauth(txnIdForPreAuth, txnAmtTextBoxValue, paymentAppIdComboBoxValue, panTextBoxValue, expDateTextBoxValue);
- this.requestStrByThead = this.preAuthRequestMsg;
+
+ jsonResultByThead = n5Core.sendSummaryEnquiryRequest(enquiryPeriod, timeout);
+ this.requestStrByThead = this.summaryEnquiryRequestMsg;
showResult();
}
- private void requestOfflineThead()
+ private void requestSaleThead()
{
-
- jsonResultByThead = n5Core.processOffline(txnIdForOffline, txnAmtTextBoxValue, paymentAppIdComboBoxValue, authCodeTextBoxValue, panTextBoxValue, expDateTextBoxValue);
- this.requestStrByThead = this.offlineRequestMsg;
+ jsonResultByThead = n5Core.requestSale(txnIdForSale, txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue, timeout);
+ this.requestStrByThead = this.saleRequestMsg;
showResult();
}
- private void requestAdjustThead()
- {
-
- //jsonResultByThead = n5Core.processOffline(txnIdForOffline, txnAmtTextBoxValue, paymentAppIdComboBoxValue, "123456", panTextBoxValue, expDateTextBoxValue);
- // this.requestStrByThead = this.offlineRequestMsg;
- // showResult();
- }
+
private void requestRefundThead()
{
- jsonResultByThead = n5Core.requestRefund(txnIdForRefund, txnAmtTextBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue);
+ jsonResultByThead = n5Core.requestRefund(txnIdForRefund, txnAmtTextBoxValue, paymentAppIdComboBoxValue, qrValueTextBoxValue, oriTxnDateTextBoxValue, hostRefNoTextBoxValue , timeout);
this.requestStrByThead = this.refundRequestMsg;
showResult();
}
private void requestRetrievalThead()
{
- jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
+ jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, timeout);
this.requestStrByThead = this.retrievalRequestMsg;
showResult();
}
@@ -123,17 +124,18 @@ namespace ECR_N5_DLL_TestUI
{
while (isRepeatSubmit)
{
+ /*
String result = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 10000);
addRepeatLog("=============================count" + repeatCount + "=============================");
addRepeatLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(result);
- if (retrievalResult != null && retrievalResult.Status.Equals("00"))
- {
- addRepeatLog("Retrieval Success!");
- }
- else
- addRepeatLog("Retrieval Failed!");
+ RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(result);*/
+ String result = n5Core.requestSale(getTxnId(), "10", "0", "CC", "", "30000");
+ addRepeatLog("=============================count" + repeatCount + "=============================");
+ addRepeatLog("ecrTxnId = " + ecrTxnIdTextBoxValue);
+
+ SaleResult saleResult = SaleResult.toSaleResultFromJsonMsg(result);
+ addRepeatLog("Sale Result:" + saleResult.Status);
}
@@ -141,69 +143,70 @@ namespace ECR_N5_DLL_TestUI
}
private void requestVoidThead()
{
- jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue);
+ jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue, timeout);
this.requestStrByThead = this.voidRequestMsg;
showResult();
}
+
private void requestSettlementThead()
{
- jsonResultByThead = n5Core.sendSettlementtRequest();
+ jsonResultByThead = n5Core.sendSettlementtRequest(timeout);
this.requestStrByThead = this.settlementRequestMsg;
showResult();
}
- private void requestLinkRequestThead()
+ private void requesGetInfoThead()
{
- jsonResultByThead = n5Core.sendLinkTestRequest();
- this.requestStrByThead = this.linkTestRequestMsg;
+ jsonResultByThead = n5Core.requestGetInfo(timeout);
+ this.requestStrByThead = this.getInfoRequestMsg;
showResult();
}
- private void requestReprintThead()
+ private void requesCheckUpdateThead()
{
- jsonResultByThead = n5Core.sendReprintRequest();
- this.requestStrByThead = this.reprintRequestMsg;
+ jsonResultByThead = n5Core.checkUpdate(timeout);
+ this.requestStrByThead = this.checkUpdateRequestMsg;
showResult();
}
- private void requestTerminaionThead()
+ private void requesExecuteUpdateThead()
{
- jsonResultByThead = n5Core.sendAbortRequest();
- this.requestStrByThead = this.terminaionRequestMsg;
+ jsonResultByThead = n5Core.executeUpdate(timeout);
+ this.requestStrByThead = this.executeUpdateRequestMsg;
showResult();
}
- private void requestScanThread()
+ private void requestLinkRequestThead()
{
- jsonResultByThead = n5Core.sendScanRequest();
- this.requestStrByThead = this.scanRequestMsg;
+ jsonResultByThead = n5Core.sendLinkTestRequest(timeout);
+ this.requestStrByThead = this.linkTestRequestMsg;
showResult();
}
- private void requestReadCardNFCThead()
+ private void requestReprintThead()
{
- jsonResultByThead = n5Core.sendReadCardNFCRequest();
- this.requestStrByThead = this.readCardRequestMsg;
+ jsonResultByThead = n5Core.sendReprintRequest(ecrTxnIdTextBoxValue, timeout);
+ this.requestStrByThead = this.reprintRequestMsg;
showResult();
}
- private void requestAddPointThead()
+ private void requestTerminaionThead()
{
- jsonResultByThead = n5Core.sendAddPointRequest(ecrTxnIdTextBoxValue, txnAmtTextBoxValue);
- this.requestStrByThead = this.addPointRequestMsg;
+ jsonResultByThead = n5Core.sendAbortRequest();
+ this.requestStrByThead = this.terminaionRequestMsg;
showResult();
}
private void requestBatchEnquiryThead()
{
- jsonResultByThead = n5Core.sendBatchEnquiryRequest(settleDateTextBoxValue);
+ jsonResultByThead = n5Core.sendBatchEnquiryRequest(settleDateTextBoxValue, timeout);
this.requestStrByThead = this.batchEnquiryRequestMsg;
showResult();
}
private void requestSettleEnquiryThead()
{
- jsonResultByThead = n5Core.sendSettleEnquiryRequest(batchIdTextBoxValue);
+ jsonResultByThead = n5Core.sendSettleEnquiryRequest(batchIdTextBoxValue, timeout);
this.requestStrByThead = this.settleEnquiryRequestMsg;
showResult();
}
@@ -220,28 +223,9 @@ namespace ECR_N5_DLL_TestUI
n5CoreInitSuccess = true;
}
}
- /*
- if (!n5CoreInitSuccess)
- {
- this.requestStrByThead = "n5coredll init fail.";
- this.jsonResultByThead = string.Empty;
- showResult();
- return;
- }*/
- if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.ecrTxnIdTextBox.Focus();
- return;
- }
- else
- {
ecrTxnIdTextBoxValue = ecrTxnIdTextBox.Text;
Thread th = new Thread(requestRepeatRetrievalThead);
th.Start();
- }
}
@@ -264,10 +248,10 @@ namespace ECR_N5_DLL_TestUI
{
n5Core = n5coredll.N5Core.getInstance();
int initResult = n5Core.initN5Core(portName, baudRate, dataBits, stopBits, parity, timeOut);
- if (initResult == 0)
- {
+ //if (initResult == 0)
+ //{
n5CoreInitSuccess = true;
- }
+ //}
}
if (!n5CoreInitSuccess)
{
@@ -314,127 +298,11 @@ namespace ECR_N5_DLL_TestUI
this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForSale + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
showResult();
addLog("txnId = " + txnIdForSale + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
this.saleRequestMsg = this.requestStrByThead;
-
Thread th = new Thread(requestSaleThead);
th.Start();
}
- }
- else if("Adjust".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- return;
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- qrValueTextBoxValue = this.qrValueTextBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
- txnIdForSale = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForPreAuth + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
- showResult();
- addLog("txnId = " + txnIdForPreAuth + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue + ",qrValue = " + qrValueTextBoxValue);
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.preAuthRequestMsg = this.requestStrByThead;
-
- Thread th = new Thread(requestPreauthThead);
- th.Start();
- }
-
- }
- else if ("PreAuth".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- return;
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
- txnIdForPreAuth = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForPreAuth + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue;
- showResult();
- addLog("txnId = " + txnIdForPreAuth + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue);
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.preAuthRequestMsg = this.requestStrByThead;
-
- Thread th = new Thread(requestPreauthThead);
- th.Start();
- }
-
- }
- else if ("Offline".Equals(this.thisEvent))
- {
- if (this.txnAmtTextBox.Text == null || "".Equals(this.txnAmtTextBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.txnAmtTextBox.Focus();
- return;
- }
- else if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text.Trim()))
- {
- this.requestStrByThead = "Please input parameter.";
- this.jsonResultByThead = "Please input parameter.";
- showResult();
- this.paymentAppIdComboBox.Focus();
- return;
- }
- else
- {
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
- paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
- qrValueTextBoxValue = this.qrValueTextBox.Text;
- panTextBoxValue = this.panTextBox.Text;
- authCodeTextBoxValue = this.authCodeTextBox.Text;
- expDateTextBoxValue = this.expDateTextBox.Text;
-
- txnIdForOffline = this.getTxnId();
- this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForOffline + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue;
- showResult();
- addLog("txnId = " + txnIdForOffline + ", txnAmt = " + txnAmtTextBoxValue + ", paymentAppId = " + paymentAppIdComboBoxValue );
- //jsonResultByThead = n5Core.requestSale(this.getTxnId(), txnAmtTextBoxValue, "0", paymentAppIdComboBoxValue, qrValueTextBoxValue);
- this.offlineRequestMsg = this.requestStrByThead;
-
- Thread th = new Thread(requestOfflineThead);
- th.Start();
- }
-
}
else if ("Refund".Equals(this.thisEvent))
{
@@ -458,6 +326,8 @@ namespace ECR_N5_DLL_TestUI
txnAmtTextBoxValue = this.txnAmtTextBox.Text;
paymentAppIdComboBoxValue = this.paymentAppIdComboBox.Text;
qrValueTextBoxValue = this.qrValueTextBox.Text;
+ oriTxnDateTextBoxValue = this.oriTxnDateTextBox.Text;
+ hostRefNoTextBoxValue = this.hostRefNoTextBox.Text;
txnIdForRefund = this.getTxnId();
this.requestStrByThead = "Test Function : " + currEventName + "\n txnId = " + txnIdForRefund + "\n txnAmt = " + txnAmtTextBoxValue + "\n paymentAppId = " + paymentAppIdComboBoxValue + "\n qrValue = " + qrValueTextBoxValue;
@@ -493,6 +363,16 @@ namespace ECR_N5_DLL_TestUI
th.Start();
}
}
+ else if ("SummaryEnquiry".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ enquiryPeriod = periodTextBox.Text;
+ //jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
+ this.summaryEnquiryRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestSummaryEnquiryThead);
+ th.Start();
+ }
else if ("Void".Equals(this.thisEvent))
{
if (this.ecrTxnIdTextBox.Text == null || "".Equals(this.ecrTxnIdTextBox.Text.Trim()))
@@ -527,60 +407,62 @@ namespace ECR_N5_DLL_TestUI
Thread th = new Thread(requestSettlementThead);
th.Start();
}
- else if ("Link Request".Equals(this.thisEvent))
+ else if ("GetInfo".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
- //jsonResultByThead = n5Core.sendLinkTestRequest();
- this.linkTestRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestLinkRequestThead);
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.getInfoRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requesGetInfoThead);
th.Start();
}
- else if ("Reprint".Equals(this.thisEvent))
+ else if ("CheckUpdate".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
- //jsonResultByThead = n5Core.sendReprintRequest();
- this.reprintRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestReprintThead);
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.checkUpdateRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requesCheckUpdateThead);
th.Start();
}
- else if ("Terminaion".Equals(this.thisEvent))
+ else if ("ExecuteUpdate".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.terminaionRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestTerminaionThead);
+
+ //jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.executeUpdateRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requesExecuteUpdateThead);
th.Start();
}
- else if ("Scan".Equals(this.thisEvent))
+ else if ("Link Request".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.scanRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestScanThread);
+ //jsonResultByThead = n5Core.sendLinkTestRequest();
+ this.linkTestRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestLinkRequestThead);
th.Start();
}
- else if ("ReadCard".Equals(this.thisEvent))
+ else if ("Reprint".Equals(this.thisEvent))
{
+ ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
this.requestStrByThead = "Test Function : " + currEventName;
showResult();
- //jsonResultByThead = n5Core.sendAbortRequest();
- this.readCardRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestReadCardNFCThead);
+ //jsonResultByThead = n5Core.sendReprintRequest();
+ this.reprintRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestReprintThead);
th.Start();
}
- else if ("AddPoint".Equals(this.thisEvent))
+ else if ("Terminaion".Equals(this.thisEvent))
{
this.requestStrByThead = "Test Function : " + currEventName;
- ecrTxnIdTextBoxValue = this.ecrTxnIdTextBox.Text;
- txnAmtTextBoxValue = this.txnAmtTextBox.Text;
showResult();
//jsonResultByThead = n5Core.sendAbortRequest();
- this.addPointRequestMsg = this.requestStrByThead;
- Thread th = new Thread(requestAddPointThead);
+ this.terminaionRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestTerminaionThead);
th.Start();
}
else if ("BatchEnquiry".Equals(this.thisEvent))
@@ -667,6 +549,25 @@ namespace ECR_N5_DLL_TestUI
this.batchIdTextBox.IsEnabled = false;
this.settleDateTextBox.IsEnabled = false;
}
+ else if ("CreateOrder".Equals(this.thisEvent))
+ {
+ this.ecrTxnIdTextBox.Text = "";
+ this.txnAmtTextBox.IsEnabled = true;
+ this.paymentTypeTextBox.IsEnabled = true;
+ if (this.paymentAppIdComboBox.Text == null || "".Equals(this.paymentAppIdComboBox.Text))
+ {
+ this.paymentAppIdComboBox.Text = "CC";
+ }
+ this.batchIdTextBox.Text = "";
+ this.settleDateTextBox.Text = "";
+ this.paymentAppIdComboBox.IsEnabled = true;
+ this.qrValueTextBox.IsEnabled = true;
+ this.panTextBox.IsEnabled = true;
+ this.expDateTextBox.IsEnabled = true;
+ this.ecrTxnIdTextBox.IsEnabled = false;
+ this.batchIdTextBox.IsEnabled = false;
+ this.settleDateTextBox.IsEnabled = false;
+ }
else if("PreAuth".Equals(this.thisEvent))
{
this.ecrTxnIdTextBox.Text = "";
@@ -891,27 +792,7 @@ namespace ECR_N5_DLL_TestUI
this.settleDateTextBox.IsEnabled = false;
}
}
-
- private void Submit_Repeat_Button_Click(object sender, RoutedEventArgs e)
- {
- this.requestTextBox.Text = string.Empty;
- this.result1TextBox.Text = string.Empty;
- if (!isRepeatSubmit)
- {
- this.submit_repeat_Button.Content = "Stop Repeat";
- isRepeatSubmit = true;
- addRepeatLog("==========Repeat start========== ");
- this.sendRepeatSubmit();
- }
- else
- {
- this.submit_repeat_Button.Content = "Start Repeat";
- isRepeatSubmit = false;
- this.stopRepeatSubmit();
- addRepeatLog("==========Repeat end========== ");
- }
- }
-
+
private void Submit_1_Button_Click(object sender, RoutedEventArgs e)
{
this.requestTextBox.Text = string.Empty;
@@ -923,6 +804,16 @@ namespace ECR_N5_DLL_TestUI
this.submit_1_Button.IsEnabled = true;
}
+ private void Abort_Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ //showResult();
+ //jsonResultByThead = n5Core.sendAbortRequest();
+ this.terminaionRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestTerminaionThead);
+ th.Start();
+ }
+
private void Reset_Button_Click(object sender, RoutedEventArgs e)
{
this.requestTextBox.Text = string.Empty;
@@ -966,7 +857,7 @@ namespace ECR_N5_DLL_TestUI
}
}
- public string getTxnId()
+ private string getTxnId()
{
StringBuilder txnIdSb = new StringBuilder();
DateTime dt = DateTime.Now;
@@ -993,31 +884,6 @@ namespace ECR_N5_DLL_TestUI
return txnIdResult;
}
- // public delegate void UpdateTextCallback(string message);
-
- // private void UpdateTextThread()
- // {
-
- // this.requestTextBox.Dispatcher.Invoke(
- // new UpdateTextCallback(this.UpdateRequestText),
- // new object[] { "" });
- //
- // this.result1TextBox.Dispatcher.Invoke(
- // new UpdateTextCallback(this.UpdateRequestText),
- // new object[] { "" });
- //
- // }
- // private int UpdateRequestText()
- // {
- // this.requestTextBox.Text = this.requestStrByThead;
- // this.result1TextBox.Text = this.jsonResultByThead;
- // if (this.logPathTextBox.Text == null || "".Equals(this.logPathTextBox.Text.Trim()))
- // {
- // this.logPathTextBox.Text = "Log Path : " + System.IO.Path.GetTempPath() + "\\myN5TestWin.log";
- // }
- // return 0;
- // }
-
private int showResult()
{
//this.requestTextBox.Text = this.requestStrByThead;
diff --git a/n5coredll.dll b/n5coredll.dll
new file mode 100644
index 0000000..42772fb
Binary files /dev/null and b/n5coredll.dll differ
diff --git a/n5coredll/InstllResult.cs b/n5coredll/InstllResult.cs
new file mode 100644
index 0000000..f9bfc0e
--- /dev/null
+++ b/n5coredll/InstllResult.cs
@@ -0,0 +1,321 @@
+using System;
+using System.Text;
+namespace n5coredll
+{
+ public class InstllResult {
+ private static string TXN_ID = "TXN_ID";
+ private static string STATUS = "STATUS";
+ private static string TXN_AMT = "TXN_AMT";
+ private static string PAYMENT_TYPE = "PAYMENT_TYPE";
+ private static string RESP_CODE = "RESP_CODE";
+ private static string TRACE_NO = "TRACE_NO";
+ private static string TXN_DATE = "TXN_DATE";
+ private static string TXN_TIME = "TXN_TIME";
+ private static string HOST_REF = "HOST_REF";
+ private static string AUTH_CODE = "AUTH_CODE";
+
+ private static string MID = "MID";
+ private static string TID = "TID";
+ private static string PAN = "PAN";
+ private static string EXPIRY_DATE = "EXPIRY_DATE";
+ private static string AID = "AID";
+ private static string ENTRY_MODE = "ENTRY_MODE";
+ private static string BATCH_NO = "BATCH_NO";
+ private static string TC = "TC";
+ private static string APP = "APP";
+ private static string ACQUIRER = "ACQUIRER";
+
+ private string ecrRefTxnId;
+ private string status;
+ private decimal txnAmt;
+ private PaymentType paymentType;
+ private string respCode;
+ private string traceNo;
+ private string txnDate;
+ private string txnTime;
+ private string hostRef;
+ private string couponId;
+ private string authCode;
+
+ private string mid;
+ private string tid;
+ private string pan;
+ private string expiryDate;
+ private string aid;
+ private string entryMode;
+ private string batchNo;
+ private string tc;
+ private string app;
+ private string acquirer;
+
+ private void setEcrRefTxnId(string pEcrRefTxnId) {
+ ecrRefTxnId = pEcrRefTxnId;
+ }
+
+ public string EcrRefTxnId {
+ get { return ecrRefTxnId; }
+ }
+
+ public string Status {
+ get { return status; }
+ }
+ private void setStatus(string pStatus) {
+ this.status = pStatus;
+ }
+ public decimal TxnAmt {
+ get { return txnAmt; }
+ }
+ private void setTxnAmt(decimal pTxnAmt) {
+ this.txnAmt = pTxnAmt;
+ }
+ public PaymentType PaymentType {
+ get { return paymentType; }
+ }
+ private void setPaymentType(PaymentType pPaymentType) {
+ this.paymentType = pPaymentType;
+ }
+ public string RespCode {
+ get { return respCode; }
+ }
+ private void setRespCode(string pRespCode) {
+ this.respCode = pRespCode;
+ }
+ public string TraceNo {
+ get { return traceNo; }
+ }
+ private void setTraceNo(string pTraceNo) {
+ this.traceNo = pTraceNo;
+ }
+ public string TxnDate {
+ get { return txnDate; }
+ }
+ private void setTxnDate(string pTxnDate) {
+ this.txnDate = pTxnDate;
+ }
+ public string TxnTime {
+ get { return txnTime; }
+ }
+ private void setTxnTime(string pTxnTime) {
+ this.txnTime = pTxnTime;
+ }
+ public string HostRef {
+ get { return hostRef; }
+ }
+ private void setHostRef(string pHostRef) {
+ this.hostRef = pHostRef;
+ }
+ public string CouponId {
+ get { return couponId; }
+ }
+ private void setCouponId(string pCouponId) {
+ this.couponId = pCouponId;
+ }
+ public string AuthCode {
+ get { return authCode; }
+ }
+ private void setAuthCode(string pAuthCode) {
+ this.authCode = pAuthCode;
+ }
+ public string Mid {
+ get { return mid; }
+ }
+ private void setMid(string pMid) {
+ this.mid = pMid;
+ }
+ public string Tid {
+ get { return tid; }
+ }
+ private void setTid(string pTid) {
+ this.tid = pTid;
+ }
+ public string Pan {
+ get { return pan; }
+ }
+ private void setPan(string pPan) {
+ this.pan = pPan;
+ }
+ public string ExpiryDate {
+ get { return expiryDate; }
+ }
+ private void setExpiryDate(string pExpiryDate) {
+ this.expiryDate = pExpiryDate;
+ }
+ public string Aid {
+ get { return aid; }
+ }
+ private void setAid(string pAid) {
+ this.aid = pAid;
+ }
+ public string EntryMode {
+ get { return entryMode; }
+ }
+ private void setEntryMode(string pEntryMode) {
+ this.entryMode = pEntryMode;
+ }
+ public string BatchNo {
+ get { return batchNo; }
+ }
+ private void setBatchNo(string pBatchNo) {
+ this.batchNo = pBatchNo;
+ }
+ public string Tc {
+ get { return tc; }
+ }
+ private void setTc(string pTc) {
+ this.tc = pTc;
+ }
+ public string App {
+ get { return app; }
+ }
+ private void setApp(string pApp) {
+ this.app = pApp;
+ }
+ public string Acquirer {
+ get { return acquirer; }
+ }
+ private void setAcquirer(string pAcquirer) {
+ this.acquirer = pAcquirer;
+ }
+
+ private static string curTxnId;
+ public static string getCurTxnId()
+ {
+ return curTxnId;
+ }
+
+ public static string toJsonForInstl(string thisTxnId, decimal txnAmt, string tender, PaymentApp appId, string qrcValue) {
+ if (thisTxnId == null || "".Equals(thisTxnId)) {
+ Console.WriteLine("getTxnId is null ");
+ return null;
+ }
+ string instlMsg;
+ if (tender == null || tender.Equals(string.Empty))
+ instlMsg = "{\"EVENT_NAME\":\"INSTL\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + thisTxnId + "\",\"QRC_VALUE\":\"" + qrcValue + "\",\"TXN_AMT\":" + txnAmt.ToString() + "}";
+ else
+ instlMsg = "{\"EVENT_NAME\":\"INSTL\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TENDER\":\"" + tender + "\",\"TXN_ID\":\"" + thisTxnId + "\",\"QRC_VALUE\":\"" + qrcValue + "\",\"TXN_AMT\":" + txnAmt.ToString() + "}";
+ return instlMsg;
+ }
+
+ private static string getTxnId() {
+ StringBuilder txnIdSb = new StringBuilder();
+ DateTime dt = DateTime.Now;
+ txnIdSb.Append(dt.ToString("yyyyMMddHHmmssfff"));
+ Console.WriteLine("txnIdSb = " + txnIdSb.ToString());
+ int randomTime = 0;
+ if (dt.Ticks.ToString().Length > 8) {
+ Console.WriteLine("Ticks.Length > 8 = " + dt.Ticks.ToString());
+ randomTime = int.Parse(dt.Ticks.ToString().Substring(0, 8));
+ }
+ else {
+ randomTime = int.Parse(dt.Ticks.ToString());
+ }
+
+ if (randomTime > 0) {
+ Random random = new Random(randomTime);
+ for (int i = 0; i < 15; i++) {
+ int thidRandom = random.Next(10);
+ txnIdSb.Append(thidRandom);
+ }
+ Console.WriteLine("txnIdSb.ToString = " + txnIdSb.ToString());
+ return txnIdSb.ToString();
+ }
+ else {
+ Console.WriteLine("randomTime is error = " + randomTime);
+ }
+
+ return "";
+ }
+
+ public static InstllResult toInstllResultFromJsonMsg(string jsonMsg) {
+ if (jsonMsg == null || !jsonMsg.StartsWith("{") || !jsonMsg.EndsWith("}")) {
+ return null;
+ }
+ int jsonLength = jsonMsg.Length;
+ jsonMsg = jsonMsg.Substring(0, jsonLength - 1);
+ jsonMsg = jsonMsg.Substring(1, jsonLength - 2);
+ string[] column = jsonMsg.Split(',');
+ string[] valueColumn = null;
+ string valueColumn0 = null;
+ string valueColumn1 = null;
+ InstllResult result = new InstllResult();
+
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (InstllResult.TXN_ID.Equals(valueColumn0)) {
+ result.setEcrRefTxnId(valueColumn1);
+ }
+ if (InstllResult.STATUS.Equals(valueColumn0)) {
+ result.setStatus(valueColumn1);
+ }
+
+ if (InstllResult.TXN_AMT.Equals(valueColumn0)) {
+ if (valueColumn1 == null || "".Equals(valueColumn1)) {
+ result.setTxnAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else {
+ result.setTxnAmt(decimal.Parse(valueColumn1));
+ }
+ }
+
+ if (InstllResult.PAYMENT_TYPE.Equals(valueColumn0)) {
+ result.setPaymentType(ObjectUtil.getPaymentType(valueColumn1));
+ }
+
+ if (InstllResult.RESP_CODE.Equals(valueColumn0)) {
+ result.setRespCode(valueColumn1);
+ }
+
+ if (InstllResult.TRACE_NO.Equals(valueColumn0)) {
+ result.setTraceNo(valueColumn1);
+ }
+ if (InstllResult.TXN_DATE.Equals(valueColumn0)) {
+ result.setTxnDate(valueColumn1);
+ }
+ if (InstllResult.TXN_TIME.Equals(valueColumn0)) {
+ result.setTxnTime(valueColumn1);
+ }
+
+ if (InstllResult.HOST_REF.Equals(valueColumn0)) {
+ result.setHostRef(valueColumn1);
+ }
+ if (InstllResult.AUTH_CODE.Equals(valueColumn0)) {
+ result.setAuthCode(valueColumn1);
+ }
+ if (InstllResult.MID.Equals(valueColumn0)) {
+ result.setMid(valueColumn1);
+ }
+ if (InstllResult.TID.Equals(valueColumn0)) {
+ result.setTid(valueColumn1);
+ }
+ if (InstllResult.PAN.Equals(valueColumn0)) {
+ result.setPan(valueColumn1);
+ }
+ if (InstllResult.EXPIRY_DATE.Equals(valueColumn0)) {
+ result.setExpiryDate(valueColumn1);
+ }
+ if (InstllResult.AID.Equals(valueColumn0)) {
+ result.setAid(valueColumn1);
+ }
+ if (InstllResult.ENTRY_MODE.Equals(valueColumn0)) {
+ result.setEntryMode(valueColumn1);
+ }
+ if (InstllResult.BATCH_NO.Equals(valueColumn0)) {
+ result.setBatchNo(valueColumn1);
+ }
+ if (InstllResult.APP.Equals(valueColumn0)) {
+ result.setApp(valueColumn1);
+ }
+ if (InstllResult.TC.Equals(valueColumn0)) {
+ result.setTc(valueColumn1);
+ }
+ if (InstllResult.ACQUIRER.Equals(valueColumn0)) {
+ result.setAcquirer(valueColumn1);
+ }
+
+ }
+ return result;
+ }
+ }
+}
diff --git a/n5coredll/LogUtil.cs b/n5coredll/LogUtil.cs
deleted file mode 100644
index b4726dd..0000000
--- a/n5coredll/LogUtil.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace n5coredll
-{
- public class LogUtil
- {
- private static String mLogPath;
- private static LogUtil mInstance;
- public static LogUtil getInstance()
- {
- if (mInstance == null)
- mInstance = new LogUtil();
-
- return mInstance;
- }
-
- public void setLogPath(String logPath)
- {
- if (logPath.EndsWith(@"\"))
- mLogPath = logPath;
- else
- mLogPath = logPath + @"\";
- }
-
- private String getCurLogFile()
- {
-
- StringBuilder txnIdSb = new StringBuilder();
- DateTime dt = DateTime.Now;
- return ("n5dll" + "_" + dt.ToString("yyyyMMdd") +".log");
- }
-
- public void addRepeatLog(string logInfo)
- {
- try
- {
- String path = mLogPath + getCurLogFile();
- //path = @"C:\Users\rexli\AppData\Local\Temp\test.log";
- if (!File.Exists(path))
- {
- using (StreamWriter sw = File.CreateText(path))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff") + " [LOGGER] " + logInfo);
- sw.Flush();
- sw.Close();
- }
-
- }
- else
- {
- using (StreamWriter sw = File.AppendText(path))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff") + " [LOGGER] " + logInfo);
- sw.Flush();
- sw.Close();
- }
-
- }
- // Console.WriteLine(logInfo);
-
- }
- catch (Exception err)
- {
- Console.WriteLine("Exception = " + err);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/n5coredll/N5Core.cs b/n5coredll/N5Core.cs
index d8c9125..d18a438 100644
--- a/n5coredll/N5Core.cs
+++ b/n5coredll/N5Core.cs
@@ -2,10 +2,11 @@
using System.IO.Ports;
using System.Runtime.InteropServices;
using System.Text;
+using System.Threading;
namespace n5coredll
{
-
+
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("92138541-8E7B-43FD-A4A4-748F28A934CD")]
[ProgId("n5coredll.N5Core")]
@@ -20,9 +21,8 @@ namespace n5coredll
private int mRecvTimes;
private byte[] mTotalRecvResult = new byte[10000];
private int mRecvIndex = 0;
-
+
private bool isReadyBack = false;
- private int timeOut = 1200000;
private bool isGetACK = false;
//for serial port config
@@ -80,28 +80,15 @@ namespace n5coredll
else
this.parity = "None";
- if (pTimeOut != null && !pTimeOut.Equals(string.Empty))
- try
- {
- this.timeOut = int.Parse(pTimeOut);
-
- if (this.timeOut < 120000)
- this.timeOut = 120000;
- }
- catch {
- this.timeOut = 120000;
- }
-
- else
- this.timeOut = 120000;
+
bool result = openSerialPort();
if (result)
{
- String echoResult = sendLinkTestRequest();
+ String echoResult = sendLinkTestRequest(pTimeOut);
if (RequestResult.toReqResultFromJsonMsg(echoResult).Status == STATUS_SUCC)
return 0;
else
- return - 1;
+ return -1;
}
else
return -1;
@@ -143,54 +130,25 @@ namespace n5coredll
return "";
}
-
- // For Pacific Coffee only
- /*
- public string requestSale(string dtxnAmt, string dtipAmt, string appId, string qrcValue)
- {
- return processSale(null,dtxnAmt,dtipAmt,appId,qrcValue);
- }
-
- public string requestRefund(string dtxnAmt, string appId, string qrcValue)
- {
- return processRefund(null, dtxnAmt, appId, qrcValue);
- }*/
- //For Pacific Coffee only
-
- public string requestManualSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate)
- {
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, pan, expDate);
- }
-
- public string requestSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue)
- {
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "","");
- }
-
public string requestSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pTimeout)
{
return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "", "", pTimeout);
}
- public string requestSaleWithTimeout(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pTimeout)
+ public string requestRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue, string txnDate, string hostRefNo, string timeout)
{
- return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "", "", pTimeout);
+ return processRefund(dtxnId, dtxnAmt, appId, qrcValue, txnDate, hostRefNo, timeout);
}
- public string requestRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue)
- {
- return processRefund(dtxnId, dtxnAmt, appId, qrcValue);
- }
-
- private string processSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate)
+ private string processSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate, string pTimeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_BUSY);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_BUSY);
ifBusy = true;
SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- decimal tipAmt = decimal.Parse(dtipAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1 || tipAmt.CompareTo(decimal.Parse("0")) < 0)
+ int txnAmt = int.Parse(dtxnAmt);
+ int tipAmt = int.Parse(dtipAmt);
+ if (txnAmt.CompareTo(int.Parse("0")) < 1 || tipAmt.CompareTo(int.Parse("0")) < 0)
{
Console.WriteLine("dtxnAmt or dtipAmt parameter error");
closeSerialPort();
@@ -198,6 +156,25 @@ namespace n5coredll
return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
}
+ int iTimeout = 0;
+ if (pTimeout != null && !pTimeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(pTimeout);
+
+ if (iTimeout < 120000)
+ pTimeout = "120000";
+ else if (iTimeout > 300000)
+ pTimeout = "300000";
+ }
+ catch
+ {
+ pTimeout = "120000";
+ }
+
+ else
+ pTimeout = "120000";
+
sendTime = 0;
isSending = false;
mRecvTimes = 0;
@@ -227,7 +204,7 @@ namespace n5coredll
if (dtxnId == null)
dtxnId = getTxnId();
- string reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue,pan,expDate);
+ string reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue, pan, expDate);
Console.WriteLine("reqSaleStr = " + reqSaleStr);
if (reqSaleStr == null || "".Equals(reqSaleStr))
{
@@ -258,12 +235,17 @@ namespace n5coredll
return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+
+ iTimeout = int.Parse(pTimeout);
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
Boolean ifEnd = false;
int inqCount = 0;
DateTime lastInqTime = DateTime.Now;
+ string retrivReusltStr;
+ RetrievalResult retrievalResult;
+
while (!ifEnd)
{
DateTime nowTime = DateTime.Now;
@@ -276,9 +258,11 @@ namespace n5coredll
this.resendReqMsg();
if (isReadyBack)
{
- closeSerialPort();
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
+ if (currResultJsonStr.StartsWith("SALE")) {
+ closeSerialPort();
+ }
ifBusy = false;
return currResultJsonStr;
}
@@ -286,18 +270,17 @@ namespace n5coredll
}
else
{
- closeSerialPort();
TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
+ //if (inqCount >= 12)
+ // ifEnd = true;
+ if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
{
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
+ retrivReusltStr = requestInnerRetrieval(dtxnId, 10000);
inqCount++;
lastInqTime = DateTime.Now;
if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
{
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
+ retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
if (retrievalResult.Status == STATUS_SUCC)
{
if (retrievalResult.TxnStatus != TxnStatus.Confirming)
@@ -311,6 +294,8 @@ namespace n5coredll
retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
}
ifBusy = false;
+
+ closeSerialPort();
return retrivReusltStr;
}
else if (retrievalResult.Status == STATUS_NO_TXN)
@@ -318,9 +303,11 @@ namespace n5coredll
string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
//String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
+ // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
//retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
ifBusy = false;
+
+ closeSerialPort();
return saleResultStr;
}
@@ -329,7 +316,40 @@ namespace n5coredll
isReadyBack = false;
}
}
-
+
+ //Do last txn inquiry
+ retrivReusltStr = requestInnerRetrieval(dtxnId, 10000);
+ retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
+ if (retrievalResult.Status == STATUS_SUCC)
+ {
+ if (retrievalResult.TxnStatus != TxnStatus.Confirming)
+ {
+ retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
+ String status = "10";
+ if (retrievalResult.TxnStatus == TxnStatus.Approved)
+ status = "00";
+ else
+ status = "10";
+ retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
+ }
+ ifBusy = false;
+
+ closeSerialPort();
+ return retrivReusltStr;
+ }
+ else if (retrievalResult.Status == STATUS_NO_TXN)
+ {
+ string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+
+ //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
+ // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
+ //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
+ ifBusy = false;
+
+ closeSerialPort();
+ return saleResultStr;
+ }
+
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
closeSerialPort();
@@ -337,20 +357,36 @@ namespace n5coredll
return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_TIMEOUT);
}
- private string processSale(string dtxnId, string dtxnAmt, string dtipAmt, string appId, string qrcValue, string pan, string expDate, string pTimeout)
+ public string requestVoid(string originalEcrRefTxnId, string qrcValue, string pTimeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (pTimeout != null && !pTimeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(pTimeout);
+
+ if (iTimeout < 120000)
+ pTimeout = "120000";
+ else if (iTimeout > 300000)
+ pTimeout = "300000";
+ }
+ catch
+ {
+ pTimeout = "120000";
+ }
+
+ else
+ pTimeout = "120000";
+
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_BUSY);
ifBusy = true;
- SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- decimal tipAmt = decimal.Parse(dtipAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1 || tipAmt.CompareTo(decimal.Parse("0")) < 0)
+ if (originalEcrRefTxnId == null || "".Equals(originalEcrRefTxnId.Trim()))
{
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
+ Console.WriteLine("parameter error");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
}
sendTime = 0;
@@ -360,49 +396,29 @@ namespace n5coredll
currReqByteArr = null;
currResultJsonStr = null;
isGetACK = false;
+
if (openSerialPort())
{
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue, pan, expDate);
- Console.WriteLine("reqSaleStr = " + reqSaleStr);
- if (reqSaleStr == null || "".Equals(reqSaleStr))
+ string reqVoidStr = VoidResult.toJsonForVoid(originalEcrRefTxnId, qrcValue);
+ Console.WriteLine("reqVoidStr = " + reqVoidStr);
+ if (reqVoidStr == null || "".Equals(reqVoidStr))
{
- Console.WriteLine("reqSaleStr is null. ");
+ Console.WriteLine("reqVoidStr is null. ");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
}
- currReqByteArr = packReqMsg(reqSaleStr);
+ currReqByteArr = packReqMsg(reqVoidStr);
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
Console.WriteLine("currReqByteArr is null. ");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
}
Console.WriteLine("currReqByteArr = " + currReqByteArr);
Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
this.sendReqMsg();
}
else
@@ -410,20 +426,15 @@ namespace n5coredll
Console.WriteLine("serialPort no open. ");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_OPENCOM);
}
-
- int iTimeout = int.Parse(pTimeout);
-
+ iTimeout = int.Parse(pTimeout);
int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
Boolean ifEnd = false;
int inqCount = 0;
DateTime lastInqTime = DateTime.Now;
- string retrivReusltStr;
- RetrievalResult retrievalResult;
-
while (!ifEnd)
{
DateTime nowTime = DateTime.Now;
@@ -436,9 +447,10 @@ namespace n5coredll
this.resendReqMsg();
if (isReadyBack)
{
- closeSerialPort();
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
+ if (currResultJsonStr.StartsWith("VOID"))
+ closeSerialPort();
ifBusy = false;
return currResultJsonStr;
}
@@ -448,40 +460,40 @@ namespace n5coredll
{
closeSerialPort();
TimeSpan txnInqSp = nowTime - lastInqTime;
- //if (inqCount >= 12)
- // ifEnd = true;
- if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
+ if (inqCount >= 12)
+ ifEnd = true;
+ else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
{
- retrivReusltStr = requestRetrieval(dtxnId, 10000);
+ string retrivReusltStr = requestInnerRetrieval(originalEcrRefTxnId, 10000);
inqCount++;
lastInqTime = DateTime.Now;
if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
{
- retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
+ RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
if (retrievalResult.Status == STATUS_SUCC)
{
if (retrievalResult.TxnStatus != TxnStatus.Confirming)
{
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
+ retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "VOID_RESP");
String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
+ if (retrievalResult.TxnStatus == TxnStatus.Voided || retrievalResult.TxnStatus == TxnStatus.Failed)
status = "00";
else
status = "10";
retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
}
ifBusy = false;
+ closeSerialPort();
return retrivReusltStr;
}
else if (retrievalResult.Status == STATUS_NO_TXN)
{
- string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+ string voidResultStr = "{\"EVENT_NAME\":\"VOID_RESP\",\"STATUS\":\"13\",\"TXN_ID\":\"" + originalEcrRefTxnId + "\"}";
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
+ //retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "VOID_RESP");
ifBusy = false;
- return saleResultStr;
+ closeSerialPort();
+ return voidResultStr;
}
}
@@ -490,55 +502,43 @@ namespace n5coredll
}
}
- //Do last txn inquiry
- retrivReusltStr = requestRetrieval(dtxnId, 10000);
- retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
-
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_TIMEOUT);
}
- public string processPreauth(string dtxnId, string dtxnAmt, string appId, string pan, string expDate)
+ private string processRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue, string txnDate, string hostRefNo, string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_BUSY);
ifBusy = true;
- SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1)
+ RefundResult refundResult;
+ int txnAmt = int.Parse(dtxnAmt);
+ if (txnAmt.CompareTo(int.Parse("0")) < 1)
{
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
+ Console.WriteLine("parameter error");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
}
sendTime = 0;
@@ -548,6 +548,7 @@ namespace n5coredll
currReqByteArr = null;
currResultJsonStr = null;
isGetACK = false;
+
if (openSerialPort())
{
PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
@@ -570,43 +571,46 @@ namespace n5coredll
if (dtxnId == null)
dtxnId = getTxnId();
- string reqPreauthStr = SaleResult.toJsonForPreauth(dtxnId, txnAmt, tmpAppId, pan, expDate);
- Console.WriteLine("reqPreauthStr = " + reqPreauthStr);
- if (reqPreauthStr == null || "".Equals(reqPreauthStr))
+ string reqRefundStr = RefundResult.toJsonForRefund(dtxnId, txnAmt, tmpAppId, qrcValue, txnDate, hostRefNo);
+ Console.WriteLine("reqRefundStr = " + reqRefundStr);
+ if (reqRefundStr == null || "".Equals(reqRefundStr))
{
- Console.WriteLine("reqPreauthStr is null. ");
+ Console.WriteLine("reqRefundStr is null. ");
+ refundResult = new RefundResult("99");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
}
- currReqByteArr = packReqMsg(reqPreauthStr);
+ currReqByteArr = packReqMsg(reqRefundStr);
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
Console.WriteLine("currReqByteArr is null. ");
+ refundResult = new RefundResult("99");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
}
Console.WriteLine("currReqByteArr = " + currReqByteArr);
Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
+
this.sendReqMsg();
}
else
{
Console.WriteLine("serialPort no open. ");
+ refundResult = new RefundResult("99");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_OPENCOM);
}
+ iTimeout = int.Parse(timeout);
+ int sleepTime = iTimeout / 1000;
- int sleepTime = timeOut / 1000;
DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
int inqCount = 0;
DateTime lastInqTime = DateTime.Now;
+ Boolean ifEnd = false;
while (!ifEnd)
{
DateTime nowTime = DateTime.Now;
@@ -619,9 +623,11 @@ namespace n5coredll
this.resendReqMsg();
if (isReadyBack)
{
- closeSerialPort();
+
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
+ if (currResultJsonStr.StartsWith("REFUND"))
+ closeSerialPort();
ifBusy = false;
return currResultJsonStr;
}
@@ -629,13 +635,12 @@ namespace n5coredll
}
else
{
- closeSerialPort();
TimeSpan txnInqSp = nowTime - lastInqTime;
if (inqCount >= 12)
ifEnd = true;
else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
{
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
+ string retrivReusltStr = requestInnerRetrieval(dtxnId, 10000);
inqCount++;
lastInqTime = DateTime.Now;
if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
@@ -645,7 +650,7 @@ namespace n5coredll
{
if (retrievalResult.TxnStatus != TxnStatus.Confirming)
{
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "PREAUTH_RESP");
+ retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "REFUND_RESP");
String status = "10";
if (retrievalResult.TxnStatus == TxnStatus.Approved)
status = "00";
@@ -654,16 +659,18 @@ namespace n5coredll
retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
}
ifBusy = false;
+ closeSerialPort();
return retrivReusltStr;
}
else if (retrievalResult.Status == STATUS_NO_TXN)
{
- string saleResultStr = "{\"EVENT_NAME\":\"PREAUTH_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + "}";
+ string saleResultStr = "{\"EVENT_NAME\":\"REFUND_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
//String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
// retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
//retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
ifBusy = false;
+ closeSerialPort();
return saleResultStr;
}
@@ -677,104 +684,82 @@ namespace n5coredll
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_TIMEOUT);
}
+
+ public string sendLinkTestRequest(string timeout)
+ {
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
-
- public string processOffline(string dtxnId, string dtxnAmt, string appId, string authCode, string pan, string expDate)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_BUSY);
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_BUSY);
ifBusy = true;
- SaleResult saleResult = null;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1 )
- {
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
- }
-
sendTime = 0;
isSending = false;
mRecvTimes = 0;
isReadyBack = false;
currReqByteArr = null;
currResultJsonStr = null;
+ RequestResult reqResult = null;
isGetACK = false;
if (openSerialPort())
{
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqOfflineStr = SaleResult.toJsonForOffline(dtxnId, txnAmt, tmpAppId, authCode, pan, expDate);
- Console.WriteLine("reqOfflineStr = " + reqOfflineStr);
- if (reqOfflineStr == null || "".Equals(reqOfflineStr))
- {
- Console.WriteLine("reqOfflineStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqOfflineStr);
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForLinkTest());
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
- Console.WriteLine("currReqByteArr is null. ");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
}
Console.WriteLine("currReqByteArr = " + currReqByteArr);
Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
this.sendReqMsg();
}
else
{
- Console.WriteLine("serialPort no open. ");
+
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
+
DateTime startTime = DateTime.Now;
Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
while (!ifEnd)
{
DateTime nowTime = DateTime.Now;
TimeSpan sp = nowTime - startTime;
if (sp.TotalSeconds > sleepTime)
ifEnd = true;
- else if (sp.TotalSeconds < 30)
+ else
{
if (!isSending && !isGetACK)
this.resendReqMsg();
if (isReadyBack)
{
+ Thread.Sleep(500);
closeSerialPort();
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
@@ -783,253 +768,54 @@ namespace n5coredll
}
}
}
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "OFFLINE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"OFFLINE_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + "}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
}
-
-
+ ifBusy = false;
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_TIMEOUT);
}
- public string processAdjust(string dtxnId, string dtotalTxnAmt, string dtotalForeignAmt, string appId)
+ public string sendSettlementtRequest(string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- SaleResult saleResult = null;
- decimal totalTxnAmt = decimal.Parse(dtotalTxnAmt);
- decimal totalForeignAmt = decimal.Parse(dtotalForeignAmt);
- if (totalTxnAmt.CompareTo(decimal.Parse("0")) < 0 || totalForeignAmt.CompareTo(decimal.Parse("0")) < 0)
- {
- Console.WriteLine("dtxnAmt or dtipAmt parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqAdjustStr = SaleResult.toJsonForAdjust(dtxnId, totalTxnAmt, totalForeignAmt, tmpAppId);
- Console.WriteLine("reqAdjustStr = " + reqAdjustStr);
- if (reqAdjustStr == null || "".Equals(reqAdjustStr))
- {
- Console.WriteLine("reqSaleStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqAdjustStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
{
- Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson(";", ERR_STATUS_PARAM);
- }
+ iTimeout = int.Parse(timeout);
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- saleResult = null;
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
}
- else
+ catch
{
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"ADJUST_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
+ timeout = "120000";
}
- }
-
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADJUST_RESP", ERR_STATUS_TIMEOUT);
- }
- public string requestVoid(string originalEcrRefTxnId, string qrcValue)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_BUSY);
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_BUSY);
ifBusy = true;
- if (originalEcrRefTxnId == null || "".Equals(originalEcrRefTxnId.Trim()))
- {
- Console.WriteLine("parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
- }
-
sendTime = 0;
isSending = false;
mRecvTimes = 0;
isReadyBack = false;
currReqByteArr = null;
currResultJsonStr = null;
+ RequestResult reqResult = null;
isGetACK = false;
-
if (openSerialPort())
{
- string reqVoidStr = VoidResult.toJsonForVoid(originalEcrRefTxnId, qrcValue);
- Console.WriteLine("reqVoidStr = " + reqVoidStr);
- if (reqVoidStr == null || "".Equals(reqVoidStr))
- {
- Console.WriteLine("reqVoidStr is null. ");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqVoidStr);
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForSettlement());
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
- Console.WriteLine("currReqByteArr is null. ");
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
}
Console.WriteLine("currReqByteArr = " + currReqByteArr);
@@ -1038,25 +824,23 @@ namespace n5coredll
}
else
{
- Console.WriteLine("serialPort no open. ");
- closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_OPENCOM);
+ closeSerialPort();
+ return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
+
DateTime startTime = DateTime.Now;
Boolean ifEnd = false;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
while (!ifEnd)
{
DateTime nowTime = DateTime.Now;
TimeSpan sp = nowTime - startTime;
if (sp.TotalSeconds > sleepTime)
ifEnd = true;
- else if (sp.TotalSeconds < 30)
+ else
{
if (!isSending && !isGetACK)
this.resendReqMsg();
@@ -1070,218 +854,36 @@ namespace n5coredll
}
}
}
- else
- {
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(originalEcrRefTxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "VOID_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Voided || retrievalResult.TxnStatus == TxnStatus.Failed)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string voidResultStr = "{\"EVENT_NAME\":\"VOID_RESP\",\"STATUS\":\"13\",\"TXN_ID\":\"" + originalEcrRefTxnId + "\"}";
-
- //retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "VOID_RESP");
- ifBusy = false;
- return voidResultStr;
- }
-
- }
- }
- isReadyBack = false;
- }
}
-
+
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_TIMEOUT);
}
- private string processRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue)
+ public string requestGetInfo(string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- RefundResult refundResult;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (txnAmt.CompareTo(decimal.Parse("0")) < 1)
- {
- Console.WriteLine("parameter error");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
- }
-
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
-
- if (openSerialPort())
- {
- PaymentApp tmpAppId = ObjectUtil.getPaymentApp(appId);
- /*
- if (appId == "CC")
- tmpAppId = PaymentApp.CC;
- else if (appId == "QRC")
- tmpAppId = PaymentApp.QRC;
- else if (appId == "AMEX")
- tmpAppId = PaymentApp.AMEX;
- else if (appId == "CPN")
- tmpAppId = PaymentApp.CPN;
- else if (appId == "DC")
- tmpAppId = PaymentApp.DC;
- else if (appId == "NONE")
- tmpAppId = PaymentApp.NONE;
- else
- tmpAppId = PaymentApp.NONE;
- */
- if (dtxnId == null)
- dtxnId = getTxnId();
-
- string reqRefundStr = RefundResult.toJsonForRefund(dtxnId, txnAmt, tmpAppId, qrcValue);
- Console.WriteLine("reqRefundStr = " + reqRefundStr);
- if (reqRefundStr == null || "".Equals(reqRefundStr))
- {
- Console.WriteLine("reqRefundStr is null. ");
- refundResult = new RefundResult("99");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
- }
- currReqByteArr = packReqMsg(reqRefundStr);
- if (currReqByteArr == null || currReqByteArr.Length == 0)
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
{
- Console.WriteLine("currReqByteArr is null. ");
- refundResult = new RefundResult("99");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_PARAM);
- }
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ iTimeout = int.Parse(timeout);
- this.sendReqMsg();
- }
- else
- {
- Console.WriteLine("serialPort no open. ");
- refundResult = new RefundResult("99");
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("REFUND_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
-
- DateTime startTime = DateTime.Now;
- int inqCount = 0;
- DateTime lastInqTime = DateTime.Now;
- Boolean ifEnd = false;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else if (sp.TotalSeconds < 30)
- {
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
}
- else
+ catch
{
- closeSerialPort();
- TimeSpan txnInqSp = nowTime - lastInqTime;
- if (inqCount >= 12)
- ifEnd = true;
- else if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
- {
- string retrivReusltStr = requestRetrieval(dtxnId, 10000);
- inqCount++;
- lastInqTime = DateTime.Now;
- if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
- {
- RetrievalResult retrievalResult = RetrievalResult.toRetrievalResultFromJsonMsg(retrivReusltStr);
- if (retrievalResult.Status == STATUS_SUCC)
- {
- if (retrievalResult.TxnStatus != TxnStatus.Confirming)
- {
- retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "REFUND_RESP");
- String status = "10";
- if (retrievalResult.TxnStatus == TxnStatus.Approved)
- status = "00";
- else
- status = "10";
- retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"00\"", "\"STATUS\":\"" + status + "\"");
- }
- ifBusy = false;
- return retrivReusltStr;
- }
- else if (retrievalResult.Status == STATUS_NO_TXN)
- {
- string saleResultStr = "{\"EVENT_NAME\":\"REFUND_RESP\",\"STATUS\":\"10\",\"TXN_ID\":\"" + dtxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
-
- //String saleResultStr = "\"EVENT_NAME\":\"SALE_RESP\",\"STATUS\":\"10\"";
- // retrivReusltStr = retrivReusltStr.Replace("RETRIEVAL_RESP", "SALE_RESP");
- //retrivReusltStr = retrivReusltStr.Replace("\"STATUS\":\"13\"", "\"STATUS\":\"10\"");
- ifBusy = false;
- return saleResultStr;
- }
-
- }
- }
- isReadyBack = false;
+ timeout = "120000";
}
- }
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_TIMEOUT);
- }
-
- int linkTimeout = 10000;
- public string sendLinkTestRequest()
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_BUSY);
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("GETDEVICEINFO_RESP", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -1293,12 +895,12 @@ namespace n5coredll
isGetACK = false;
if (openSerialPort())
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForLinkTest());
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonGetInfo());
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("GETDEVICEINFO_RESP", ERR_STATUS_PARAM);
//return "Request failed: params error";
}
@@ -1308,13 +910,12 @@ namespace n5coredll
}
else
{
-
- closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_OPENCOM);
+ closeSerialPort();
+ return RequestResult.createRespErrJson("GETDEVICEINFO_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = linkTimeout / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -1340,16 +941,35 @@ namespace n5coredll
}
}
}
- ifBusy = false;
+
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_TIMEOUT);
+ ifBusy = false;
+ return RequestResult.createRespErrJson("GETDEVICEINFO_RESP", ERR_STATUS_TIMEOUT);
}
- public string sendSettlementtRequest()
+ public string checkUpdate(string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("CHECKUPDATE", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -1361,12 +981,12 @@ namespace n5coredll
isGetACK = false;
if (openSerialPort())
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForSettlement());
+ currReqByteArr = this.packReqMsg(RequestResult.toCheckUpdate());
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("CHECKUPDATE", ERR_STATUS_PARAM);
//return "Request failed: params error";
}
@@ -1378,10 +998,10 @@ namespace n5coredll
{
ifBusy = false;
closeSerialPort();
- return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("CHECKUPDATE", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -1410,13 +1030,32 @@ namespace n5coredll
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
ifBusy = false;
- return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("CHECKUPDATE", ERR_STATUS_TIMEOUT);
}
- public string sendParam()
+ public string executeUpdate(string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("EXECUTEUPDATE", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -1428,12 +1067,12 @@ namespace n5coredll
isGetACK = false;
if (openSerialPort())
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonParam());
+ currReqByteArr = this.packReqMsg(RequestResult.toExecuteUpdate());
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("EXECUTEUPDATE", ERR_STATUS_PARAM);
//return "Request failed: params error";
}
@@ -1445,10 +1084,10 @@ namespace n5coredll
{
ifBusy = false;
closeSerialPort();
- return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("EXECUTEUPDATE", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -1477,11 +1116,32 @@ namespace n5coredll
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
ifBusy = false;
- return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("EXECUTEUPDATE", ERR_STATUS_TIMEOUT);
}
- public string requestRetrieval(string txnId, int pTimeOut)
+ public string requestRetrieval(string txnId, string timeout)
{
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_BUSY);
RetrievalResult retrievalResult = null;
if (txnId == null || "".Equals(txnId.Trim()))
{
@@ -1528,7 +1188,7 @@ namespace n5coredll
return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = pTimeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -1539,7 +1199,7 @@ namespace n5coredll
TimeSpan sp = nowTime - startTime;
if (sp.TotalSeconds > sleepTime)
ifEnd = true;
- else
+ else
{
if (!isSending && !isGetACK)
this.resendReqMsg();
@@ -1583,15 +1243,21 @@ namespace n5coredll
}
}*/
- //
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ //
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
closeSerialPort();
return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_TIMEOUT);
}
- int abortTimeout = 10000;
- public string sendAbortRequest()
+ private string requestInnerRetrieval(string txnId, int pTimeOut)
{
+ RetrievalResult retrievalResult = null;
+ if (txnId == null || "".Equals(txnId.Trim()))
+ {
+ Console.WriteLine("parameter error");
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_PARAM);
+ }
+
sendTime = 0;
isSending = false;
mRecvTimes = 0;
@@ -1602,20 +1268,18 @@ namespace n5coredll
if (openSerialPort())
{
- string abortStr = RequestResult.toJsonForAbort();
- Console.WriteLine("abortStr = " + abortStr);
- if (abortStr == null || "".Equals(abortStr))
+ string reqRetrievalStr = RetrievalResult.toJsonForRetrieval(txnId);
+ Console.WriteLine("reqRetrievalStr = " + reqRetrievalStr);
+ if (reqRetrievalStr == null || "".Equals(reqRetrievalStr))
{
- Console.WriteLine("abortStr is null. ");
- closeSerialPort();
- return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_PARAM);
+ Console.WriteLine("reqRetrievalStr is null. ");
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_PARAM);
}
- currReqByteArr = packReqMsg(abortStr);
+ currReqByteArr = packReqMsg(reqRetrievalStr);
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
Console.WriteLine("currReqByteArr is null. ");
- closeSerialPort();
- return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_PARAM);
}
Console.WriteLine("currReqByteArr = " + currReqByteArr);
@@ -1625,11 +1289,10 @@ namespace n5coredll
else
{
Console.WriteLine("serialPort no open. ");
- closeSerialPort();
- return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = abortTimeout / 1000;
+ int sleepTime = pTimeOut / 1000;
DateTime startTime = DateTime.Now;
@@ -1646,7 +1309,6 @@ namespace n5coredll
this.resendReqMsg();
if (isReadyBack)
{
- closeSerialPort();
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
ifBusy = false;
@@ -1686,33 +1348,36 @@ namespace n5coredll
//
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- closeSerialPort();
- return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_TIMEOUT);
}
- int reprintTimeout = 60000;
- public string sendReprintRequest()
+ int abortTimeout = 10000;
+ public string sendAbortRequest()
{
- if (ifBusy)
- return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
sendTime = 0;
isSending = false;
mRecvTimes = 0;
isReadyBack = false;
currReqByteArr = null;
currResultJsonStr = null;
- RequestResult reqResult = null;
isGetACK = false;
+
if (openSerialPort())
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForReprint());
+ string abortStr = RequestResult.toJsonForAbort();
+ Console.WriteLine("abortStr = " + abortStr);
+ if (abortStr == null || "".Equals(abortStr))
+ {
+ Console.WriteLine("abortStr is null. ");
+ closeSerialPort();
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_PARAM);
+ }
+ currReqByteArr = packReqMsg(abortStr);
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
+ Console.WriteLine("currReqByteArr is null. ");
closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_PARAM);
- //return "Request failed: params error";
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_PARAM);
}
Console.WriteLine("currReqByteArr = " + currReqByteArr);
@@ -1721,12 +1386,12 @@ namespace n5coredll
}
else
{
- ifBusy = false;
+ Console.WriteLine("serialPort no open. ");
closeSerialPort();
- return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = reprintTimeout / 1000;
+ int sleepTime = abortTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -1743,92 +1408,74 @@ namespace n5coredll
this.resendReqMsg();
if (isReadyBack)
{
- closeSerialPort();
if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
- ifBusy = false;
+ if (ifBusy)
+ closeSerialPort();
+ //ifBusy = false;
return currResultJsonStr;
}
}
}
}
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- ifBusy = false;
- return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_TIMEOUT);
- }
-
- public string sendScanRequest()
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_BUSY);
- ifBusy = true;
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- RequestResult reqResult = null;
- isGetACK = false;
- if (openSerialPort())
+ /*
+ for (int i = 0; i < sleepTime; i++)
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForScan());
- if (currReqByteArr == null || currReqByteArr.Length == 0)
+ Console.WriteLine("retrievalResult = " + retrievalResult);
+ if (!isReadyBack)
{
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_PARAM);
- //return "Request failed: params error";
+ if (i > 9 && i % 10 == 0 && !isGetACK)
+ {
+ this.resendReqMsg();
+ }
+ Console.WriteLine("Sleep i = " + i + ", " + DateTime.Now.ToString());
+ System.Threading.Thread.Sleep(1000);
}
-
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- this.sendReqMsg();
- }
- else
- {
- ifBusy = false;
- closeSerialPort();
- return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
-
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
else
{
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
+ closeSerialPort();
+ if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
{
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
+ return currResultJsonStr;
+ }
+ else
+ {
+ //return "Request failed: sytem error";
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_SYSTEM);
}
+
}
- }
+ }*/
+ //
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- ifBusy = false;
- return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_TIMEOUT);
+ closeSerialPort();
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_TIMEOUT);
}
-
- public string sendReadCardNFCRequest()
+
+ public string sendReprintRequest(string txnId, string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("READ_CARD", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -1840,12 +1487,12 @@ namespace n5coredll
isGetACK = false;
if (openSerialPort())
{
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForReadCardNFC());
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForReprint(txnId));
if (currReqByteArr == null || currReqByteArr.Length == 0)
{
closeSerialPort();
ifBusy = false;
- return RequestResult.createRespErrJson("READ_CARD", ERR_STATUS_PARAM);
+ return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_PARAM);
//return "Request failed: params error";
}
@@ -1857,10 +1504,10 @@ namespace n5coredll
{
ifBusy = false;
closeSerialPort();
- return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_OPENCOM);
+ return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -1889,80 +1536,32 @@ namespace n5coredll
Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
ifBusy = false;
- return RequestResult.createRespErrJson("READ_CARD", ERR_STATUS_TIMEOUT);
+ return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_TIMEOUT);
}
- public string sendAddPointRequest(string dtxnId, string dtxnAmt)
+ public string sendBatchEnquiryRequest(string dsettleDate, string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("ADD_POINT", ERR_STATUS_BUSY);
- ifBusy = true;
- sendTime = 0;
- isSending = false;
- mRecvTimes = 0;
- isReadyBack = false;
- currReqByteArr = null;
- currResultJsonStr = null;
- isGetACK = false;
- decimal txnAmt = decimal.Parse(dtxnAmt);
- if (openSerialPort())
- {
- currReqByteArr = this.packReqMsg(RequestResult.toJsonForAddPoint(dtxnId, txnAmt));
- if (currReqByteArr == null || currReqByteArr.Length == 0)
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
{
- closeSerialPort();
- ifBusy = false;
- return RequestResult.createRespErrJson("ADD_POINT", ERR_STATUS_PARAM);
- //return "Request failed: params error";
- }
+ iTimeout = int.Parse(timeout);
- Console.WriteLine("currReqByteArr = " + currReqByteArr);
- Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
- this.sendReqMsg();
- }
- else
- {
- ifBusy = false;
- closeSerialPort();
- return RequestResult.createRespErrJson("ADD_POINT", ERR_STATUS_OPENCOM);
- }
-
- int sleepTime = timeOut / 1000;
-
- DateTime startTime = DateTime.Now;
-
- Boolean ifEnd = false;
- while (!ifEnd)
- {
- DateTime nowTime = DateTime.Now;
- TimeSpan sp = nowTime - startTime;
- if (sp.TotalSeconds > sleepTime)
- ifEnd = true;
- else
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
{
- if (!isSending && !isGetACK)
- this.resendReqMsg();
- if (isReadyBack)
- {
- closeSerialPort();
- if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
- {
- ifBusy = false;
- return currResultJsonStr;
- }
- }
+ timeout = "120000";
}
- }
-
- Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
- ifBusy = false;
- return RequestResult.createRespErrJson("ADD_POINT", ERR_STATUS_TIMEOUT);
- }
- public string sendBatchEnquiryRequest(String dsettleDate)
- {
- if (ifBusy)
- return RequestResult.createRespErrJson("BATCH_ENQUIRY", ERR_STATUS_BUSY);
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("BATCH_ENQUIRY", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -1993,7 +1592,7 @@ namespace n5coredll
return RequestResult.createRespErrJson("BATCH_ENQUIRY", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -2025,10 +1624,29 @@ namespace n5coredll
return RequestResult.createRespErrJson("BATCH_ENQUIRY", ERR_STATUS_TIMEOUT);
}
- public string sendSettleEnquiryRequest(string dbatchId)
+ public string sendSettleEnquiryRequest(string dbatchId, string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -2059,7 +1677,7 @@ namespace n5coredll
return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -2091,10 +1709,29 @@ namespace n5coredll
return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_TIMEOUT);
}
- public string sendSummaryEnquiryRequest(string period)
+ public string sendSummaryEnquiryRequest(string period, string timeout)
{
- if (ifBusy)
- return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", ERR_STATUS_BUSY);
+ int iTimeout = 0;
+ if (timeout != null && !timeout.Equals(string.Empty))
+ try
+ {
+ iTimeout = int.Parse(timeout);
+
+ if (iTimeout < 120000)
+ timeout = "120000";
+ else if (iTimeout > 300000)
+ timeout = "300000";
+ }
+ catch
+ {
+ timeout = "120000";
+ }
+
+ else
+ timeout = "120000";
+ iTimeout = int.Parse(timeout);
+ //if (ifBusy)
+ // return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", ERR_STATUS_BUSY);
ifBusy = true;
sendTime = 0;
isSending = false;
@@ -2125,7 +1762,7 @@ namespace n5coredll
return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", ERR_STATUS_OPENCOM);
}
- int sleepTime = timeOut / 1000;
+ int sleepTime = iTimeout / 1000;
DateTime startTime = DateTime.Now;
@@ -2162,7 +1799,12 @@ namespace n5coredll
if (serialPort1 != null && serialPort1.IsOpen)
{
Console.WriteLine("SerialPort Close ");
- serialPort1.Close();
+ try
+ {
+ serialPort1.Close();
+ }catch(Exception ex){
+ Console.WriteLine("Exception = " + ex);
+ }
}
}
@@ -2193,7 +1835,7 @@ namespace n5coredll
serialPort1.Parity = (Parity)Enum.Parse(typeof(Parity), parity);
serialPort1.ReceivedBytesThreshold = 1;
serialPort1.DataReceived += new SerialDataReceivedEventHandler(m_DataReceived);
-
+
if (!serialPort1.IsOpen)
{
serialPort1.Open();
@@ -2244,7 +1886,7 @@ namespace n5coredll
mTotalRecvCount += recvCount;
Console.WriteLine("mTotalRecvCount = " + mTotalRecvCount);
- if (recvResult[0] == 0x06 && mRecvTimes ==1)
+ if (recvResult[0] == 0x06 && mRecvTimes == 1)
{
isGetACK = true;
Console.WriteLine("ACK!");
@@ -2344,7 +1986,7 @@ namespace n5coredll
Console.WriteLine("Check LRC success! LRC is [" + ObjectUtil.desToHex(new byte[] { nlrc }) + "]");
sendAck();
//string jsonMsg = System.Text.Encoding.Default.GetString(msg);
- string jsonMsg = System.Text.Encoding.UTF8.GetString(msg);
+ string jsonMsg = System.Text.Encoding.GetEncoding("BIG5").GetString(msg);
onMsgReceived(jsonMsg);
reset();
return;
@@ -2371,7 +2013,7 @@ namespace n5coredll
}
catch { }
}
-
+
private void reset()
{
mTotalRecvResult = new byte[4096];
@@ -2395,6 +2037,7 @@ namespace n5coredll
private void resendReqMsg()
{
+ Console.WriteLine("Execute resendReqMsg!");
if (!isSending || sendTime > 3)
{
this.isReadyBack = true;
@@ -2426,7 +2069,9 @@ namespace n5coredll
isSending = true;
serialPort1.Write(currReqByteArr, 0, currReqByteArr.Length);
}
- catch { };
+ catch(Exception ex) {
+ Console.WriteLine("error:" + ex.Message);
+ };
Console.WriteLine("serialPort1 Write end ");
}
diff --git a/n5coredll/RefundResult.cs b/n5coredll/RefundResult.cs
index d03f67d..8df6a3b 100644
--- a/n5coredll/RefundResult.cs
+++ b/n5coredll/RefundResult.cs
@@ -237,6 +237,12 @@ namespace n5coredll
return cardRefundMsg;
}
+ public static string toJsonForRefund(string txnIId, decimal txnAmt, PaymentApp appId, string qrcValue, string txnDate, string hostRefNo)
+ {
+ string cardRefundMsg = "{\"EVENT_NAME\":\"REFUND\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnIId + "\",\"QRC_VALUE\":\"" + qrcValue + "\",\"TXN_AMT\":" + txnAmt.ToString() + ",\"TXN_DATE\":\"" + txnDate + "\",\"HOST_REF\":\"" + hostRefNo + "\"}";
+ return cardRefundMsg;
+ }
+
private static string getTxnId() {
StringBuilder txnIdSb = new StringBuilder();
DateTime dt = DateTime.Now;
diff --git a/n5coredll/RequestResult.cs b/n5coredll/RequestResult.cs
index f874082..9819896 100644
--- a/n5coredll/RequestResult.cs
+++ b/n5coredll/RequestResult.cs
@@ -30,14 +30,33 @@ namespace n5coredll
return "{\"EVENT_NAME\":\"SETTLE\"}";
}
+ public static string toJsonGetInfo()
+ {
+ // return "{\"EVENT_NAME\":\"GET_INFO\"}";
+ return "{\"EVENT_NAME\":\"GETDEVICEINFO\",\"PAYMENT_APP_ID\":\"CC\"}";
+ }
+
+ public static string toCheckUpdate()
+ {
+ // return "{\"EVENT_NAME\":\"GET_INFO\"}";
+ return "{\"EVENT_NAME\":\"CHECKUPDATE\"}";
+ }
+
+
+ public static string toExecuteUpdate()
+ {
+ // return "{\"EVENT_NAME\":\"GET_INFO\"}";
+ return "{\"EVENT_NAME\":\"EXECUTEUPDATE\"}";
+ }
+
public static string toJsonParam()
{
return "{\"EVENT_NAME\":\"PARAM\",\"PAYMENT_APP_ID\":\"CC\"}";
}
- public static string toJsonForReprint()
+ public static string toJsonForReprint(String txnId)
{
- return "{\"EVENT_NAME\":\"PRINT\",\"IS_REPRINT\":true}";
+ return "{\"EVENT_NAME\":\"PRINT\",\"TXN_ID\":\"" + txnId + "\",\"IS_REPRINT\":true}";
}
public static string toJsonForAbort()
@@ -61,6 +80,13 @@ namespace n5coredll
return cardSaleMsg;
}
+ public static string toJsonForCreateOrder(string inputTxnId, decimal txnAmt, string paymentType)
+ {
+ string cardSaleMsg = "{\"EVENT_NAME\":\"CREATE_ORDER\",\"TXN_ID\":\"" + inputTxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"PAYMENT_TYPE\":\"" +paymentType + "\",\"PAYMENT_APP_ID\":\"QRC\"}";
+ return cardSaleMsg;
+ }
+
+
public static string toJsonForBatchEnquiry(string settleDate)
{
return "{\"EVENT_NAME\":\"BATCH_ENQUIRY\",\"SETTLE_DATE\":\"" + settleDate + "\"}";
@@ -75,6 +101,12 @@ namespace n5coredll
{
return "{\"EVENT_NAME\":\"SUMMARY_ENQUIRY\",\"TXN_DATE_START_TO_END\":\"" + period + "\"}";
}
+
+ public static string toJsonHealthCheck()
+ {
+ return "{\"EVENT_NAME\":\"HEALTH_CHECK\"}";
+ }
+
public static RequestResult toReqResultFromJsonMsg(string jsonMsg) {
if (jsonMsg == null || !jsonMsg.StartsWith("{") || !jsonMsg.EndsWith("}")) {
return null;
diff --git a/n5coredll/RetrievalResult.cs b/n5coredll/RetrievalResult.cs
index 38cdaae..de0f4c9 100644
--- a/n5coredll/RetrievalResult.cs
+++ b/n5coredll/RetrievalResult.cs
@@ -354,19 +354,19 @@ namespace n5coredll
if (RetrievalResult.TXN_AMT.Equals(valueColumn0)) {
if (valueColumn1 == null || "".Equals(valueColumn1)) {
- retrievalResult.setTxnAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ retrievalResult.setTxnAmt(int.Parse("0", System.Globalization.NumberStyles.AllowDecimalPoint));
}
else {
- retrievalResult.setTxnAmt(decimal.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
+ retrievalResult.setTxnAmt(int.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
}
}
if (RetrievalResult.TIPS.Equals(valueColumn0)) {
if (valueColumn1 == null || "".Equals(valueColumn1)) {
- retrievalResult.setTipAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ retrievalResult.setTipAmt(int.Parse("0", System.Globalization.NumberStyles.AllowDecimalPoint));
}
else {
- retrievalResult.setTipAmt(decimal.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
+ retrievalResult.setTipAmt(int.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
}
}
diff --git a/n5coredll/dll/IbmsSerialPort.dll b/n5coredll/dll/IbmsSerialPort.dll
new file mode 100644
index 0000000..2817e8a
Binary files /dev/null and b/n5coredll/dll/IbmsSerialPort.dll differ
diff --git a/n5coredll/dll/IbmsSerialPort.lib b/n5coredll/dll/IbmsSerialPort.lib
new file mode 100644
index 0000000..721ca5f
Binary files /dev/null and b/n5coredll/dll/IbmsSerialPort.lib differ
diff --git a/n5coredll/n5coredll.csproj b/n5coredll/n5coredll.csproj
index 4fd4891..269e558 100644
--- a/n5coredll/n5coredll.csproj
+++ b/n5coredll/n5coredll.csproj
@@ -9,7 +9,7 @@
Properties
n5coredll
n5coredll
- v4.0
+ v3.5
512
@@ -23,6 +23,7 @@
4
AnyCPU
true
+ true
pdbonly
@@ -49,7 +50,6 @@
-
@@ -62,6 +62,7 @@
True
Settings.settings
+