diff --git a/DLL_HK.sln b/DLL_HK.sln
new file mode 100644
index 0000000..c0e0d66
--- /dev/null
+++ b/DLL_HK.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.539
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "n5coredll", "n5coredll\n5coredll.csproj", "{1F0C1D84-FD97-41F1-BC8B-F2F22C1997A1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECR_N5_DLL_TestUI", "ECR_N5_DLL_TestUI\ECR_N5_DLL_TestUI.csproj", "{DEF387D0-3F98-4720-874D-8A753399B206}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1F0C1D84-FD97-41F1-BC8B-F2F22C1997A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F0C1D84-FD97-41F1-BC8B-F2F22C1997A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F0C1D84-FD97-41F1-BC8B-F2F22C1997A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F0C1D84-FD97-41F1-BC8B-F2F22C1997A1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DEF387D0-3F98-4720-874D-8A753399B206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DEF387D0-3F98-4720-874D-8A753399B206}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DEF387D0-3F98-4720-874D-8A753399B206}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DEF387D0-3F98-4720-874D-8A753399B206}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {09A4E58D-A17A-46E6-A4C0-323D0C8C2E63}
+ EndGlobalSection
+EndGlobal
diff --git a/ECR_N5_DLL_TestUI/App.config b/ECR_N5_DLL_TestUI/App.config
new file mode 100644
index 0000000..74ade9d
--- /dev/null
+++ b/ECR_N5_DLL_TestUI/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/ECR_N5_DLL_TestUI/App.xaml b/ECR_N5_DLL_TestUI/App.xaml
new file mode 100644
index 0000000..c414142
--- /dev/null
+++ b/ECR_N5_DLL_TestUI/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/ECR_N5_DLL_TestUI/App.xaml.cs b/ECR_N5_DLL_TestUI/App.xaml.cs
new file mode 100644
index 0000000..64291ff
--- /dev/null
+++ b/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/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj b/ECR_N5_DLL_TestUI/ECR_N5_DLL_TestUI.csproj
new file mode 100644
index 0000000..8389570
--- /dev/null
+++ b/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/ECR_N5_DLL_TestUI/MainWindow.xaml b/ECR_N5_DLL_TestUI/MainWindow.xaml
new file mode 100644
index 0000000..4fb6ca6
--- /dev/null
+++ b/ECR_N5_DLL_TestUI/MainWindow.xaml
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ECR_N5_DLL_TestUI/MainWindow.xaml.cs b/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
new file mode 100644
index 0000000..369ef04
--- /dev/null
+++ b/ECR_N5_DLL_TestUI/MainWindow.xaml.cs
@@ -0,0 +1,1050 @@
+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 = "180000";
+
+ 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;
+ 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 saleRequestMsg = null;
+ private string preAuthRequestMsg = null;
+ private string offlineRequestMsg = null;
+ private string adjustRequestMsg = null;
+
+ private string refundRequestMsg = null;
+ private string retrievalRequestMsg = null;
+ private string voidRequestMsg = null;
+ private string settlementRequestMsg = 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 Boolean isRepeatSubmit = false;
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ private void requestSaleThead()
+ {
+ 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();
+ }
+ private void requestPreauthThead()
+ {
+ jsonResultByThead = n5Core.processPreauth(txnIdForPreAuth, txnAmtTextBoxValue, paymentAppIdComboBoxValue, panTextBoxValue, expDateTextBoxValue);
+ this.requestStrByThead = this.preAuthRequestMsg;
+ showResult();
+ }
+ private void requestOfflineThead()
+ {
+
+ jsonResultByThead = n5Core.processOffline(txnIdForOffline, txnAmtTextBoxValue, paymentAppIdComboBoxValue, authCodeTextBoxValue, panTextBoxValue, expDateTextBoxValue);
+ this.requestStrByThead = this.offlineRequestMsg;
+ 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);
+ this.requestStrByThead = this.refundRequestMsg;
+ showResult();
+ }
+ private void requestRetrievalThead()
+ {
+ jsonResultByThead = n5Core.requestRetrieval(ecrTxnIdTextBoxValue, 180000);
+ 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);
+ if (retrievalResult != null && retrievalResult.Status.Equals("00"))
+ {
+ addRepeatLog("Retrieval Success!");
+ }
+ else
+ addRepeatLog("Retrieval Failed!");
+
+ }
+
+
+ }
+ private void requestVoidThead()
+ {
+ jsonResultByThead = n5Core.requestVoid(ecrTxnIdTextBoxValue, qrValueTextBoxValue);
+ this.requestStrByThead = this.voidRequestMsg;
+ showResult();
+ }
+ private void requestSettlementThead()
+ {
+ jsonResultByThead = n5Core.sendSettlementtRequest();
+ this.requestStrByThead = this.settlementRequestMsg;
+ showResult();
+ }
+
+ private void requestLinkRequestThead()
+ {
+ jsonResultByThead = n5Core.sendLinkTestRequest();
+ this.requestStrByThead = this.linkTestRequestMsg;
+ showResult();
+ }
+
+ private void requestReprintThead()
+ {
+ jsonResultByThead = n5Core.sendReprintRequest();
+ this.requestStrByThead = this.reprintRequestMsg;
+ showResult();
+ }
+
+ private void requestTerminaionThead()
+ {
+ jsonResultByThead = n5Core.sendAbortRequest();
+ this.requestStrByThead = this.terminaionRequestMsg;
+ showResult();
+ }
+
+ private void requestScanThread()
+ {
+ jsonResultByThead = n5Core.sendScanRequest();
+ this.requestStrByThead = this.scanRequestMsg;
+ showResult();
+ }
+
+ private void requestReadCardNFCThead()
+ {
+ jsonResultByThead = n5Core.sendReadCardNFCRequest();
+ this.requestStrByThead = this.readCardRequestMsg;
+ showResult();
+ }
+
+ private void requestAddPointThead()
+ {
+ jsonResultByThead = n5Core.sendAddPointRequest(ecrTxnIdTextBoxValue, txnAmtTextBoxValue);
+ this.requestStrByThead = this.addPointRequestMsg;
+ showResult();
+ }
+
+ private void requestBatchEnquiryThead()
+ {
+ jsonResultByThead = n5Core.sendBatchEnquiryRequest(settleDateTextBoxValue);
+ this.requestStrByThead = this.batchEnquiryRequestMsg;
+ showResult();
+ }
+
+ private void requestSettleEnquiryThead()
+ {
+ jsonResultByThead = n5Core.sendSettleEnquiryRequest(batchIdTextBoxValue);
+ 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;
+ }
+ }
+ /*
+ 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();
+ }
+
+ }
+
+ 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);
+ //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))
+ {
+ 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;
+
+ 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 ("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 ("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))
+ {
+ 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 ("Scan".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ //jsonResultByThead = n5Core.sendAbortRequest();
+ this.scanRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestScanThread);
+ th.Start();
+ }
+ else if ("ReadCard".Equals(this.thisEvent))
+ {
+ this.requestStrByThead = "Test Function : " + currEventName;
+ showResult();
+ //jsonResultByThead = n5Core.sendAbortRequest();
+ this.readCardRequestMsg = this.requestStrByThead;
+ Thread th = new Thread(requestReadCardNFCThead);
+ th.Start();
+ }
+ else if ("AddPoint".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);
+ 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("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_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;
+ 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);
+ }
+ }
+
+ public 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;
+ }
+
+ // 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;
+ 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/ECR_N5_DLL_TestUI/Properties/AssemblyInfo.cs b/ECR_N5_DLL_TestUI/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..933cd17
--- /dev/null
+++ b/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/ECR_N5_DLL_TestUI/Properties/Resources.Designer.cs b/ECR_N5_DLL_TestUI/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..3cd4630
--- /dev/null
+++ b/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/ECR_N5_DLL_TestUI/Properties/Resources.resx b/ECR_N5_DLL_TestUI/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/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/ECR_N5_DLL_TestUI/Properties/Settings.Designer.cs b/ECR_N5_DLL_TestUI/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..cc560ad
--- /dev/null
+++ b/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/ECR_N5_DLL_TestUI/Properties/Settings.settings b/ECR_N5_DLL_TestUI/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/ECR_N5_DLL_TestUI/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/n5coredll/LoyaltyType.cs b/n5coredll/LoyaltyType.cs
new file mode 100644
index 0000000..820a33e
--- /dev/null
+++ b/n5coredll/LoyaltyType.cs
@@ -0,0 +1,6 @@
+using System;
+namespace n5coredll {
+ public enum LoyaltyType {
+ UP, MT, BK, LM, NONE
+ }
+}
diff --git a/n5coredll/N5Core.cs b/n5coredll/N5Core.cs
new file mode 100644
index 0000000..2d910cc
--- /dev/null
+++ b/n5coredll/N5Core.cs
@@ -0,0 +1,2434 @@
+using System;
+using System.IO.Ports;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace n5coredll
+{
+
+ [ClassInterface(ClassInterfaceType.AutoDual)]
+ [Guid("92138541-8E7B-43FD-A4A4-748F28A934CD")]
+ [ProgId("n5coredll.N5Core")]
+ public class N5Core
+ {
+ private System.IO.Ports.SerialPort serialPort1;
+ private int sendTime;
+ private int mTotalRecvCount = 0;
+ private Byte[] currReqByteArr;
+ private string currResultJsonStr;
+ private bool isSending = false;
+ 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
+ private string portName = null;
+ private string baudRate = null;
+ private string dataBits = null;
+ private string stopBits = null;
+ private string parity = null;
+
+ private static String STATUS_SUCC = "00";
+ private static String STATUS_NO_TXN = "13";
+ private static String ERR_STATUS_BUSY = "98";
+ private static String ERR_STATUS_PARAM = "100";
+ private static String ERR_STATUS_SYSTEM = "101";
+ private static String ERR_STATUS_OPENCOM = "102";
+ private static String ERR_STATUS_TIMEOUT = "103";
+ private Boolean ifBusy = false;
+
+ private static N5Core myInstance;
+ public N5Core()
+ {
+ }
+
+ public static N5Core getInstance()
+ {
+ if (myInstance == null)
+ myInstance = new N5Core();
+ return myInstance;
+ }
+
+ public int initN5Core(string pPortName, string pBaudRate, string pDataBits, string pStopBits, string pParity, string pTimeOut)
+ {
+ if (pPortName != null && !pPortName.Equals(string.Empty))
+ this.portName = pPortName;
+ else
+ this.portName = "COM1";
+
+ if (pBaudRate != null && !pBaudRate.Equals(string.Empty))
+ this.baudRate = pBaudRate;
+ else
+ this.baudRate = "9600";
+
+ if (pDataBits != null && !pDataBits.Equals(string.Empty))
+ this.dataBits = pDataBits;
+ else
+ this.dataBits = "8";
+
+ if (pStopBits != null && !pStopBits.Equals(string.Empty))
+ this.stopBits = pStopBits;
+ else
+ this.stopBits = "One";
+
+ if (pParity != null && !pParity.Equals(string.Empty))
+ this.parity = pParity;
+ 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();
+ if (RequestResult.toReqResultFromJsonMsg(echoResult).Status == STATUS_SUCC)
+ return 0;
+ else
+ return - 1;
+ }
+ else
+ return -1;
+ }
+
+ 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();
+ 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 "";
+ }
+
+
+ // 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)
+ {
+ return processSale(dtxnId, dtxnAmt, dtipAmt, appId, qrcValue, "", "", pTimeout);
+ }
+
+ 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)
+ {
+ 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)
+ {
+ Console.WriteLine("dtxnAmt or dtipAmt parameter error");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SALE_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 reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue,pan,expDate);
+ Console.WriteLine("reqSaleStr = " + reqSaleStr);
+ if (reqSaleStr == null || "".Equals(reqSaleStr))
+ {
+ Console.WriteLine("reqSaleStr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ }
+ currReqByteArr = packReqMsg(reqSaleStr);
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ }
+
+ 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("SALE_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;
+ }
+ }
+ }
+ 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", "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;
+ }
+
+ }
+ }
+ isReadyBack = false;
+ }
+ }
+
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ closeSerialPort();
+ ifBusy = false;
+ 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)
+ {
+ 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)
+ {
+ Console.WriteLine("dtxnAmt or dtipAmt parameter error");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SALE_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 reqSaleStr = SaleResult.toJsonForSale(dtxnId, txnAmt, tipAmt, tmpAppId, qrcValue, pan, expDate);
+ Console.WriteLine("reqSaleStr = " + reqSaleStr);
+ if (reqSaleStr == null || "".Equals(reqSaleStr))
+ {
+ Console.WriteLine("reqSaleStr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ }
+ currReqByteArr = packReqMsg(reqSaleStr);
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SALE_RESP", ERR_STATUS_PARAM);
+ }
+
+ 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("SALE_RESP", ERR_STATUS_OPENCOM);
+ }
+
+ int 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;
+ 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;
+ }
+ }
+ }
+ else
+ {
+ closeSerialPort();
+ TimeSpan txnInqSp = nowTime - lastInqTime;
+ //if (inqCount >= 12)
+ // ifEnd = true;
+ if (inqCount == 0 || (inqCount > 0 && txnInqSp.TotalSeconds > 5))
+ {
+ retrivReusltStr = requestRetrieval(dtxnId, 10000);
+ inqCount++;
+ lastInqTime = DateTime.Now;
+ if (retrivReusltStr != null && !"".Equals(retrivReusltStr))
+ {
+ 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;
+ }
+
+ }
+ }
+ isReadyBack = false;
+ }
+ }
+
+ //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);
+ }
+
+ public string processPreauth(string dtxnId, string dtxnAmt, string appId, string pan, string expDate)
+ {
+ if (ifBusy)
+ return RequestResult.createRespErrJson("PREAUTH_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("PREAUTH_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 reqPreauthStr = SaleResult.toJsonForPreauth(dtxnId, txnAmt, tmpAppId, pan, expDate);
+ Console.WriteLine("reqPreauthStr = " + reqPreauthStr);
+ if (reqPreauthStr == null || "".Equals(reqPreauthStr))
+ {
+ Console.WriteLine("reqPreauthStr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
+ }
+ currReqByteArr = packReqMsg(reqPreauthStr);
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_PARAM);
+ }
+
+ 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("PREAUTH_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;
+ }
+ }
+ }
+ 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", "PREAUTH_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\":\"PREAUTH_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;
+ }
+ }
+
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("PREAUTH_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+
+
+ 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);
+ 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;
+ 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);
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_PARAM);
+ }
+
+ 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);
+ }
+
+ 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;
+ }
+ }
+ }
+ 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;
+ }
+ }
+
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("OFFLINE_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+ public string processAdjust(string dtxnId, string dtotalTxnAmt, string dtotalForeignAmt, string appId)
+ {
+ 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)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson(";", ERR_STATUS_PARAM);
+ }
+
+ 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;
+ }
+ }
+ }
+ 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", "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;
+ }
+ }
+
+
+ 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);
+ 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;
+ 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);
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("VOID_RESP", ERR_STATUS_PARAM);
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ Console.WriteLine("serialPort no open. ");
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("VOID_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;
+ }
+ }
+ }
+ 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);
+ }
+
+ private string processRefund(string dtxnId, string dtxnAmt, string appId, string qrcValue)
+ {
+ 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)
+ {
+ 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);
+
+ 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;
+ }
+ }
+ }
+ 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", "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;
+ }
+ }
+
+
+ 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);
+ 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.toJsonForLinkTest());
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_OPENCOM);
+ }
+
+ int sleepTime = linkTimeout / 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+ ifBusy = false;
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ closeSerialPort();
+ return RequestResult.createRespErrJson("ECHO_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+ public string sendSettlementtRequest()
+ {
+ if (ifBusy)
+ return RequestResult.createRespErrJson("SETTLE_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.toJsonForSettlement());
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ ifBusy = false;
+ closeSerialPort();
+ return RequestResult.createRespErrJson("SETTLE_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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+ public string requestRetrieval(string txnId, int pTimeOut)
+ {
+ RetrievalResult retrievalResult = null;
+ if (txnId == null || "".Equals(txnId.Trim()))
+ {
+ Console.WriteLine("parameter error");
+ closeSerialPort();
+ //return "Request failed: params error";
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_PARAM);
+ }
+
+ sendTime = 0;
+ isSending = false;
+ mRecvTimes = 0;
+ isReadyBack = false;
+ currReqByteArr = null;
+ currResultJsonStr = null;
+ isGetACK = false;
+
+ if (openSerialPort())
+ {
+ string reqRetrievalStr = RetrievalResult.toJsonForRetrieval(txnId);
+ Console.WriteLine("reqRetrievalStr = " + reqRetrievalStr);
+ if (reqRetrievalStr == null || "".Equals(reqRetrievalStr))
+ {
+ Console.WriteLine("reqRetrievalStr is null. ");
+ closeSerialPort();
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_PARAM);
+ }
+ currReqByteArr = packReqMsg(reqRetrievalStr);
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ Console.WriteLine("currReqByteArr is null. ");
+ closeSerialPort();
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_PARAM);
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ Console.WriteLine("serialPort no open. ");
+ closeSerialPort();
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_OPENCOM);
+ }
+
+ int sleepTime = pTimeOut / 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+ /*
+ for (int i = 0; i < sleepTime; i++)
+ {
+ Console.WriteLine("retrievalResult = " + retrievalResult);
+ if (!isReadyBack)
+ {
+ if (i > 9 && i % 10 == 0 && !isGetACK)
+ {
+ this.resendReqMsg();
+ }
+ Console.WriteLine("Sleep i = " + i + ", " + DateTime.Now.ToString());
+ System.Threading.Thread.Sleep(1000);
+ }
+ else
+ {
+ closeSerialPort();
+ if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
+ {
+ return currResultJsonStr;
+ }
+ else
+ {
+ //return "Request failed: sytem error";
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_SYSTEM);
+ }
+
+ }
+ }*/
+
+ //
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ closeSerialPort();
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+ int abortTimeout = 10000;
+ public string sendAbortRequest()
+ {
+ sendTime = 0;
+ isSending = false;
+ mRecvTimes = 0;
+ isReadyBack = false;
+ currReqByteArr = null;
+ currResultJsonStr = null;
+ isGetACK = false;
+
+ if (openSerialPort())
+ {
+ 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();
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_PARAM);
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ Console.WriteLine("serialPort no open. ");
+ closeSerialPort();
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_OPENCOM);
+ }
+
+ int sleepTime = abortTimeout / 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+ /*
+ for (int i = 0; i < sleepTime; i++)
+ {
+ Console.WriteLine("retrievalResult = " + retrievalResult);
+ if (!isReadyBack)
+ {
+ if (i > 9 && i % 10 == 0 && !isGetACK)
+ {
+ this.resendReqMsg();
+ }
+ Console.WriteLine("Sleep i = " + i + ", " + DateTime.Now.ToString());
+ System.Threading.Thread.Sleep(1000);
+ }
+ else
+ {
+ closeSerialPort();
+ if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
+ {
+ return currResultJsonStr;
+ }
+ else
+ {
+ //return "Request failed: sytem error";
+ return RequestResult.createRespErrJson("RETRIEVAL_RESP", ERR_STATUS_SYSTEM);
+ }
+
+ }
+ }*/
+
+ //
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ closeSerialPort();
+ return RequestResult.createRespErrJson("ABORT_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+ int reprintTimeout = 60000;
+ public string sendReprintRequest()
+ {
+ 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());
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ ifBusy = false;
+ closeSerialPort();
+ return RequestResult.createRespErrJson("PRINT_RESP", ERR_STATUS_OPENCOM);
+ }
+
+ int sleepTime = reprintTimeout / 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))
+ {
+ 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())
+ {
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForScan());
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SCAN_RESP", ERR_STATUS_TIMEOUT);
+ }
+
+ public string sendReadCardNFCRequest()
+ {
+ if (ifBusy)
+ return RequestResult.createRespErrJson("READ_CARD", 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.toJsonForReadCardNFC());
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("READ_CARD", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ ifBusy = false;
+ return RequestResult.createRespErrJson("READ_CARD", ERR_STATUS_TIMEOUT);
+ }
+
+ public string sendAddPointRequest(string dtxnId, string dtxnAmt)
+ {
+ 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)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("ADD_POINT", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ 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 (!isSending && !isGetACK)
+ this.resendReqMsg();
+ if (isReadyBack)
+ {
+ closeSerialPort();
+ if (currResultJsonStr != null && !"".Equals(currResultJsonStr))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ 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);
+ ifBusy = true;
+ sendTime = 0;
+ isSending = false;
+ mRecvTimes = 0;
+ isReadyBack = false;
+ currReqByteArr = null;
+ currResultJsonStr = null;
+ isGetACK = false;
+ if (openSerialPort())
+ {
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForBatchEnquiry(dsettleDate));
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("BATCH_ENQUIRY", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ ifBusy = false;
+ closeSerialPort();
+ return RequestResult.createRespErrJson("BATCH_ENQUIRY", 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ ifBusy = false;
+ return RequestResult.createRespErrJson("BATCH_ENQUIRY", ERR_STATUS_TIMEOUT);
+ }
+
+ public string sendSettleEnquiryRequest(string dbatchId)
+ {
+ if (ifBusy)
+ return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_BUSY);
+ ifBusy = true;
+ sendTime = 0;
+ isSending = false;
+ mRecvTimes = 0;
+ isReadyBack = false;
+ currReqByteArr = null;
+ currResultJsonStr = null;
+ isGetACK = false;
+ if (openSerialPort())
+ {
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForSettleEnquiry(dbatchId));
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ ifBusy = false;
+ closeSerialPort();
+ return RequestResult.createRespErrJson("SETTLE_ENQUIRY", 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SETTLE_ENQUIRY", ERR_STATUS_TIMEOUT);
+ }
+
+ public string sendSummaryEnquiryRequest(string period)
+ {
+ if (ifBusy)
+ return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", ERR_STATUS_BUSY);
+ ifBusy = true;
+ sendTime = 0;
+ isSending = false;
+ mRecvTimes = 0;
+ isReadyBack = false;
+ currReqByteArr = null;
+ currResultJsonStr = null;
+ isGetACK = false;
+ if (openSerialPort())
+ {
+ currReqByteArr = this.packReqMsg(RequestResult.toJsonForSummaryEnquiry(period));
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", ERR_STATUS_PARAM);
+ //return "Request failed: params error";
+ }
+
+ Console.WriteLine("currReqByteArr = " + currReqByteArr);
+ Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length);
+ this.sendReqMsg();
+ }
+ else
+ {
+ ifBusy = false;
+ closeSerialPort();
+ return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", 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))
+ {
+ ifBusy = false;
+ return currResultJsonStr;
+ }
+ }
+ }
+ }
+
+ Console.WriteLine("Timeout return : " + DateTime.Now.ToString());
+ ifBusy = false;
+ return RequestResult.createRespErrJson("SUMMARY_ENQUIRY", ERR_STATUS_TIMEOUT);
+ }
+
+ private void closeSerialPort()
+ {
+ if (serialPort1 != null && serialPort1.IsOpen)
+ {
+ Console.WriteLine("SerialPort Close ");
+ serialPort1.Close();
+ }
+ }
+
+ private bool openSerialPort()
+ {
+ if (serialPort1 != null && serialPort1.IsOpen)
+ {
+ return true;
+ }
+
+ Console.WriteLine("portName = " + portName + ", baudRate = " + baudRate + ", dataBits = " + dataBits + ", stopBits = " + stopBits + ", parity = " + parity);
+ if (ObjectUtil.isNull(portName) || ObjectUtil.isNull(baudRate) || ObjectUtil.isNull(dataBits) || ObjectUtil.isNull(stopBits) || ObjectUtil.isNull(parity))
+ {
+ Console.WriteLine("No config data.");
+ return false;
+ }
+
+ try
+ {
+ if (serialPort1 == null)
+ serialPort1 = new System.IO.Ports.SerialPort();
+
+ serialPort1.PortName = portName;
+ Console.WriteLine("serialPort1.PortName = " + serialPort1.PortName);
+ serialPort1.BaudRate = Convert.ToInt32(baudRate);
+ serialPort1.DataBits = Convert.ToInt32(dataBits);
+ serialPort1.StopBits = (StopBits)Enum.Parse(typeof(StopBits), stopBits);
+ serialPort1.Parity = (Parity)Enum.Parse(typeof(Parity), parity);
+ serialPort1.ReceivedBytesThreshold = 1;
+ serialPort1.DataReceived += new SerialDataReceivedEventHandler(m_DataReceived);
+
+ if (!serialPort1.IsOpen)
+ {
+ serialPort1.Open();
+ }
+ return true;
+ }
+ catch (Exception err)
+ {
+ Console.WriteLine("Exception = " + err);
+
+ serialPort1 = null;
+ return false;
+ }
+ }
+
+ private void m_DataReceived(object sender, SerialDataReceivedEventArgs eventArgs)
+ {
+ Console.WriteLine("****** m_DataReceived *******");
+ try
+ {
+ if (serialPort1.IsOpen)
+ {
+ int recvCount = serialPort1.BytesToRead;
+ Console.WriteLine("recvCount = " + recvCount);
+ if (recvCount > 0)
+ {
+ mRecvTimes++;
+ Console.WriteLine("mRecvTimes = " + mRecvTimes);
+ byte[] recvResult = new byte[recvCount];
+
+ serialPort1.Read(recvResult, 0, recvCount);
+
+ Console.WriteLine("**********recvResult.Length = " + recvResult.Length);
+ StringBuilder recvResultSB = new StringBuilder();
+ for (int i = 0; i < recvResult.Length; i++)
+ {
+ if (recvResult[i].ToString().Length == 1)
+ {
+ recvResultSB.Append("0");
+ }
+ recvResultSB.Append(recvResult[i].ToString());
+ }
+ Console.WriteLine("**********recvResult = " + recvResultSB.ToString());
+ // string recvResultStr = System.Text.Encoding.Default.GetString(recvResult);
+ //Console.WriteLine("read result = " + recvResultStr);
+ //int thisRecvInt = Int32.Parse(recvResultStr, System.Globalization.NumberStyles.HexNumber);
+
+ mTotalRecvCount += recvCount;
+ Console.WriteLine("mTotalRecvCount = " + mTotalRecvCount);
+
+ if (recvResult[0] == 0x06 && mRecvTimes ==1)
+ {
+ isGetACK = true;
+ Console.WriteLine("ACK!");
+ reset();
+ if (isSending)
+ {
+ sendTime = 0;
+ isSending = false;
+ }
+ return;
+ }
+ if (recvResult[0] == 0x15)
+ {
+ Console.WriteLine("NAK!");
+
+ reset();
+ resendReqMsg();
+ return;
+ }
+ if (mRecvTimes == 1)
+ {
+ if (recvResult[0] == 0x02)
+ {
+ Console.WriteLine("STX found!");
+ }
+ else
+ {
+ Console.WriteLine("STX not found!");
+ sendNak();
+ reset();
+ return;
+ }
+ }
+ if (mTotalRecvCount > 4 && (recvResult[recvCount - 1] == 0x03 || (recvCount > 1 && recvResult[recvCount - 2] == 0x03)))
+ {
+ if (recvResult[recvCount - 1] == 0x03)
+ {
+ Console.WriteLine("ETX found but has no LRC!");
+
+ System.Array.Copy(recvResult, 0, mTotalRecvResult, mRecvIndex, recvCount);
+ mRecvIndex += recvCount;
+
+ byte[] lrcRecvResult = new byte[1];
+ int lrcRecvCount = readFromSerialPort(lrcRecvResult);
+ if (lrcRecvCount > 0)
+ {
+ mRecvTimes += 1;
+
+ Console.WriteLine("LRC found!");
+ Console.WriteLine("Total receive times is " + mRecvTimes);
+
+ System.Array.Copy(lrcRecvResult, 0, mTotalRecvResult, mRecvIndex, lrcRecvCount);
+ }
+ }
+ else if (recvCount > 1 && recvResult[recvCount - 2] == 0x03)
+ {
+ Console.WriteLine("ETX found!");
+ Console.WriteLine("Total receive times is " + mRecvTimes);
+
+ System.Array.Copy(recvResult, 0, mTotalRecvResult, mRecvIndex, recvCount);
+ }
+
+ byte[] len = new byte[] { mTotalRecvResult[1], mTotalRecvResult[2] };
+ int length = 0;
+ String lenStr = ObjectUtil.bcd2Str(len);
+ Console.WriteLine("Length string is [" + lenStr + "]");
+ try
+ {
+ length = int.Parse(lenStr);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Msg length format has error : " + e);
+ sendNak();
+ reset();
+ return;
+ }
+ if (length != mTotalRecvCount - 5)
+ {
+ Console.WriteLine("Length not match! length = " + length + ", mTotalRecvCount = " + mTotalRecvCount);
+ Console.WriteLine("msg: " + System.Text.Encoding.Default.GetString(mTotalRecvResult));
+ sendNak();
+ reset();
+ return;
+ }
+ byte[] msg = new byte[length];
+ for (int i = 3; i < length + 3; i++)
+ {
+ msg[i - 3] = mTotalRecvResult[i];
+ }
+ byte olrc = mTotalRecvResult[4 + length];
+ byte[] lrcMsg = new byte[1 + len.Length + msg.Length]; // including ETX, no STX
+ System.Array.Copy(mTotalRecvResult, 1, lrcMsg, 0, lrcMsg.Length);
+ byte nlrc = ObjectUtil.lrc(lrcMsg);
+ if (nlrc == olrc)
+ {
+ Console.WriteLine("Check LRC success! LRC is [" + ObjectUtil.desToHex(new byte[] { nlrc }) + "]");
+ sendAck();
+ string jsonMsg = System.Text.Encoding.Default.GetString(msg);
+
+ onMsgReceived(jsonMsg);
+ reset();
+ return;
+ }
+ else
+ {
+ Console.WriteLine("Check LRC failed! LRC is [" + ObjectUtil.desToHex(new byte[] { nlrc }) + "]");
+ sendNak();
+ reset();
+ return;
+ }
+ }
+ else
+ {
+ Console.WriteLine("ETX not found!");
+
+ System.Array.Copy(recvResult, 0, mTotalRecvResult, mRecvIndex, recvCount);
+ mRecvIndex += recvCount;
+ }
+
+ System.Threading.Thread.Sleep(100);
+ }
+ }
+ }
+ catch { }
+ }
+
+ private void reset()
+ {
+ mTotalRecvResult = new byte[4096];
+ mTotalRecvCount = 0;
+ mRecvIndex = 0;
+ mRecvTimes = 0;
+ }
+
+ private void sendToSerialPort(byte[] msg)
+ {
+ try
+ {
+ if (!serialPort1.IsOpen)
+ {
+ serialPort1.Open();
+ }
+ serialPort1.Write(msg, 0, msg.Length);
+ }
+ catch { }
+ }
+
+ private void resendReqMsg()
+ {
+ if (!isSending || sendTime > 3)
+ {
+ this.isReadyBack = true;
+ return;
+ }
+ sendReqMsg();
+ }
+
+ private void sendAck()
+ {
+ Console.WriteLine("Execute sendAck!");
+
+ sendToSerialPort(new byte[] { 0x06 });
+ }
+
+ private void sendNak()
+ {
+ Console.WriteLine("Execute sendNak!");
+
+ sendToSerialPort(new byte[] { 0x15 });
+ }
+
+ private void sendReqMsg()
+ {
+ try
+ {
+ sendTime++;
+ Console.WriteLine("serialPort1 Write start ");
+ isSending = true;
+ serialPort1.Write(currReqByteArr, 0, currReqByteArr.Length);
+ }
+ catch { };
+ Console.WriteLine("serialPort1 Write end ");
+ }
+
+ private Byte[] packReqMsg(string reqJson)
+ {
+ Console.WriteLine("packReqMsg -> " + reqJson);
+ byte[] bytesJsonReq = System.Text.Encoding.Default.GetBytes(reqJson);
+
+ //Step 1: Add STX 0x02 in 1st byte and msgLength with BCD format in 2-3 byte
+ int msgLength = bytesJsonReq.Length;
+ string msgLengthStrWithZeorLeft = msgLength.ToString().PadLeft(4, '0');
+ Byte[] msgLengthBCD = ObjectUtil.ConvertFrom(msgLengthStrWithZeorLeft);
+ byte[] bytesAddSTXAddMsgLenReq = new byte[bytesJsonReq.Length + 1 + 2];
+ bytesAddSTXAddMsgLenReq[0] = 0x02;
+ bytesAddSTXAddMsgLenReq[1] = msgLengthBCD[0];
+ bytesAddSTXAddMsgLenReq[2] = msgLengthBCD[1];
+ System.Array.Copy(bytesJsonReq, 0, bytesAddSTXAddMsgLenReq, 3, bytesJsonReq.Length);
+
+ //Step 2: calculate LRC
+ byte[] bytesAddETXAddMsgLenReq = new byte[bytesJsonReq.Length + 1 + 2];
+
+ bytesAddETXAddMsgLenReq[0] = msgLengthBCD[0];
+ bytesAddETXAddMsgLenReq[1] = msgLengthBCD[1];
+ System.Array.Copy(bytesJsonReq, 0, bytesAddETXAddMsgLenReq, 2, bytesJsonReq.Length);
+ bytesAddETXAddMsgLenReq[bytesAddETXAddMsgLenReq.Length - 1] = 0x03;
+ Byte result_lrc = ObjectUtil.lrc(bytesAddETXAddMsgLenReq);
+
+ //Step 3: pack
+ byte[] finalMsg = new byte[bytesJsonReq.Length + 5];
+ System.Array.Copy(bytesAddSTXAddMsgLenReq, 0, finalMsg, 0, bytesAddSTXAddMsgLenReq.Length);
+ finalMsg[finalMsg.Length - 2] = 0x03;
+ finalMsg[finalMsg.Length - 1] = result_lrc;
+
+ StringBuilder reqMsgSb = new StringBuilder();
+ for (int i = 0; i < finalMsg.Length; i++)
+ {
+ if (finalMsg[i].ToString().Length == 1)
+ {
+ reqMsgSb.Append("0");
+ }
+ reqMsgSb.Append(finalMsg[i].ToString());
+ }
+ Console.WriteLine("finalMsg = " + reqMsgSb.ToString());
+ return finalMsg;
+ }
+
+ private int readFromSerialPort(byte[] msg)
+ {
+ Console.WriteLine("Execute readFromSerialPort!");
+ int recvCount = serialPort1.BytesToRead;
+
+ if (recvCount > 0)
+ {
+ byte[] recvResult = new byte[recvCount];
+ serialPort1.Read(recvResult, 0, recvCount);
+ string recvResultStr = System.Text.Encoding.Default.GetString(recvResult);
+
+ System.Array.Copy(recvResult, 0, msg, 0, recvCount);
+ }
+
+ return recvCount;
+ }
+
+ private void onMsgReceived(string msgReceived)
+ {
+ Console.WriteLine("msgReceived = " + msgReceived);
+ this.currResultJsonStr = msgReceived;
+ this.isReadyBack = true;
+ }
+
+ }
+}
diff --git a/n5coredll/N5PropertyOper.cs b/n5coredll/N5PropertyOper.cs
new file mode 100644
index 0000000..268286d
--- /dev/null
+++ b/n5coredll/N5PropertyOper.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Collections;
+using System.IO;
+
+namespace n5coredll
+{
+ class N5PropertyOper : System.Collections.Hashtable {
+ private string fileName = "";
+ private ArrayList list = new ArrayList();
+ public ArrayList List {
+ get { return list; }
+ set { list = value; }
+ }
+ public N5PropertyOper(string fileName) {
+ this.fileName = fileName;
+ this.Load(fileName);
+ }
+
+ public override void Add(object key, object value) {
+ base.Add(key, value);
+ list.Add(key);
+
+ }
+
+ public override ICollection Keys {
+ get {
+ return list;
+ }
+ }
+
+ private void Load(string filePath) {
+ char[] convertBuf = new char[1024];
+ int limit;
+ int keyLen;
+ int valueStart;
+ char c;
+ string bufLine = string.Empty;
+ bool hasSep;
+ bool precedingBackslash;
+ using (StreamReader sr = new StreamReader(filePath)) {
+ while (sr.Peek() >= 0) {
+ bufLine = sr.ReadLine();
+ limit = bufLine.Length;
+ keyLen = 0;
+ valueStart = limit;
+ hasSep = false;
+ precedingBackslash = false;
+ if (bufLine.StartsWith("#"))
+ keyLen = bufLine.Length;
+ while (keyLen < limit) {
+ c = bufLine[keyLen];
+ if ((c == '=' || c == ':') & !precedingBackslash) {
+ valueStart = keyLen + 1;
+ hasSep = true;
+ break;
+ }
+ else if ((c == ' ' || c == '\t' || c == '\f') & !precedingBackslash) {
+ valueStart = keyLen + 1;
+ break;
+ }
+ if (c == '\\') {
+ precedingBackslash = !precedingBackslash;
+ }
+ else {
+ precedingBackslash = false;
+ }
+ keyLen++;
+ }
+ while (valueStart < limit) {
+ c = bufLine[valueStart];
+ if (c != ' ' && c != '\t' && c != '\f') {
+ if (!hasSep && (c == '=' || c == ':')) {
+ hasSep = true;
+ }
+ else {
+ break;
+ }
+ }
+ valueStart++;
+ }
+ string key = bufLine.Substring(0, keyLen);
+ string values = bufLine.Substring(valueStart, limit - valueStart);
+ if (key == "")
+ key += "#";
+ while (key.StartsWith("#") & this.Contains(key)) {
+ key += "#";
+ }
+ this.Add(key, values);
+ }
+ }
+ }
+ }
+}
diff --git a/n5coredll/ObjectUtil.cs b/n5coredll/ObjectUtil.cs
new file mode 100644
index 0000000..4f5311c
--- /dev/null
+++ b/n5coredll/ObjectUtil.cs
@@ -0,0 +1,239 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace n5coredll
+{
+ class ObjectUtil {
+
+ public static bool isNull(object obj) {
+ if (obj == null || "".Equals(obj.ToString())) {
+ return true;
+ }
+ return false;
+ }
+
+ public static TxnType getTxnType(String pTxnType) {
+ switch (pTxnType) {
+ case "SALE":
+ return TxnType.SALE;
+ case "REFUND":
+ return TxnType.REFUND;
+ default:
+ return TxnType.NONE;
+ }
+ }
+
+ public static string getTxnTypeValue(TxnType pTxnType) {
+ switch (pTxnType) {
+ case TxnType.SALE:
+ return "SALE";
+ case TxnType.REFUND:
+ return "REFUND";
+ default:
+ return "";
+ }
+ }
+
+ public static TxnStatus getTxnStatus(String pTxnStatus)
+ {
+ switch (pTxnStatus)
+ {
+ case "A":
+ return TxnStatus.Approved;
+ case "P":
+ return TxnStatus.Confirming;
+ case "V":
+ return TxnStatus.Voided;
+ case "S":
+ return TxnStatus.Settled;
+ default:
+ return TxnStatus.Failed;
+ }
+ }
+
+ public static LoyaltyType getLoyaltyType(String pLoyalType) {
+ switch (pLoyalType) {
+ case "UP":
+ return LoyaltyType.UP;
+ case "MT":
+ return LoyaltyType.MT;
+ case "BK":
+ return LoyaltyType.BK;
+ case "LM":
+ return LoyaltyType.LM;
+ default:
+ return LoyaltyType.NONE;
+ }
+ }
+
+ public static string getLoyaltyTypeValue(LoyaltyType pLoyalType) {
+ switch (pLoyalType) {
+ case LoyaltyType.UP:
+ return "UP";
+ case LoyaltyType.MT:
+ return "MT";
+ case LoyaltyType.BK:
+ return "BK";
+ case LoyaltyType.LM:
+ return "LM";
+ default:
+ return "";
+ }
+ }
+
+ public static PaymentApp getPaymentApp(String pPaymentApp) {
+ switch (pPaymentApp) {
+ case "CC":
+ return PaymentApp.CC;
+ case "QRC":
+ return PaymentApp.QRC;
+ case "CPN":
+ return PaymentApp.CPN;
+ case "AE":
+ return PaymentApp.AMEX;
+ case "DC":
+ return PaymentApp.DC;
+ case "FPS":
+ return PaymentApp.FPS;
+ case "EPS":
+ return PaymentApp.EPS;
+ case "OPS":
+ return PaymentApp.OPS;
+ default:
+ return PaymentApp.NONE;
+ }
+ }
+
+ public static string getPaymentAppValue(PaymentApp pPaymentApp) {
+ switch (pPaymentApp) {
+ case PaymentApp.CC:
+ return "CC";
+ case PaymentApp.QRC:
+ return "QRC";
+ case PaymentApp.CPN:
+ return "CPN";
+ case PaymentApp.AMEX:
+ return "AE";
+ case PaymentApp.DC:
+ return "DC";
+ case PaymentApp.FPS:
+ return "FPS";
+ case PaymentApp.EPS:
+ return "EPS";
+ case PaymentApp.OPS:
+ return "OPS";
+ default:
+ return "NONE";
+ }
+ }
+
+ public static PaymentType getPaymentType(String pPaymentType) {
+ switch (pPaymentType) {
+ case "VC":
+ return PaymentType.VC;
+ case "VC-QR":
+ return PaymentType.VC_QR;
+ case "MC":
+ return PaymentType.MC;
+ case "MC-QR":
+ return PaymentType.MC_QR;
+ case "JCB":
+ return PaymentType.JCB;
+ case "JCB-QR":
+ return PaymentType.JCB_QR;
+ case "UP":
+ return PaymentType.UP;
+ case "UP-QR":
+ return PaymentType.UP_QR;
+ case "AE":
+ return PaymentType.AE;
+ case "DC":
+ return PaymentType.DC;
+ case "ALP":
+ return PaymentType.ALP;
+ case "WCP":
+ return PaymentType.WCP;
+ default:
+ return PaymentType.NONE;
+ }
+ }
+
+ public static string getPaymentTypeValue(PaymentType pPaymentType) {
+ switch (pPaymentType) {
+ case PaymentType.VC:
+ return "VC";
+ case PaymentType.VC_QR:
+ return "VC-QR";
+ case PaymentType.MC:
+ return "MC";
+ case PaymentType.MC_QR:
+ return "MC-QR";
+ case PaymentType.JCB:
+ return "JCB";
+ case PaymentType.JCB_QR:
+ return "JCB-QR";
+ case PaymentType.UP:
+ return "UP";
+ case PaymentType.UP_QR:
+ return "UP-QR";
+ case PaymentType.AE:
+ return "AE";
+ case PaymentType.DC:
+ return "DC";
+ case PaymentType.ALP:
+ return "ALP";
+ case PaymentType.WCP:
+ return "WCP";
+ default:
+ return "";
+ }
+ }
+
+ public static Byte[] ConvertFrom(string strTemp) {
+ try {
+ if (Convert.ToBoolean(strTemp.Length & 1))//数字的二进制码最后1位是1则为奇数
+ {
+ strTemp = "0" + strTemp;//数位为奇数时前面补0
+ }
+ Byte[] aryTemp = new Byte[strTemp.Length / 2];
+ for (int i = 0; i < (strTemp.Length / 2); i++) {
+ aryTemp[i] = (Byte)(((strTemp[i * 2] - '0') << 4) | (strTemp[i * 2 + 1] - '0'));
+ }
+ return aryTemp;//高位在前
+ }
+ catch { return null; }
+ }
+
+ public static Byte lrc(Byte[] datas) {
+ byte tmp = 0;
+ for (int i = 0; i < datas.Length; i++) {
+ tmp ^= datas[i];
+ }
+ return tmp;
+ }
+
+ public static string bcd2Str(byte[] bytes) {
+ Console.WriteLine("Execute bcd2Str!");
+
+ StringBuilder temp = new StringBuilder();
+ for (int i = 0; i < bytes.Length; i++) {
+ int h = ((bytes[i] & 0xff) >> 4) + 48;
+ temp.Append((char)h);
+ int l = ((bytes[i] & 0x0f)) + 48;
+ temp.Append((char)l);
+ }
+ return temp.ToString();
+ }
+
+ public static string desToHex(byte[] bytes) {
+ StringBuilder sb = new StringBuilder("");
+ for (int i = 0; i < bytes.Length; i++) {
+ string st = string.Format("%02X", bytes[i]);
+ sb.Append(st);
+ }
+ return sb.ToString();
+ }
+ }
+}
diff --git a/n5coredll/PaymentApp.cs b/n5coredll/PaymentApp.cs
new file mode 100644
index 0000000..b8bed5a
--- /dev/null
+++ b/n5coredll/PaymentApp.cs
@@ -0,0 +1,15 @@
+using System;
+namespace n5coredll
+{
+ public enum PaymentApp {
+ CC,
+ QRC,
+ CPN,
+ AMEX,
+ DC,
+ FPS,
+ EPS,
+ OPS,
+ NONE
+ }
+}
diff --git a/n5coredll/PaymentType.cs b/n5coredll/PaymentType.cs
new file mode 100644
index 0000000..156ee8b
--- /dev/null
+++ b/n5coredll/PaymentType.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace n5coredll
+{
+ public enum PaymentType {
+ VC,
+ VC_QR,
+ MC,
+ MC_QR,
+ JCB,
+ JCB_QR,
+ UP,
+ UP_QR,
+ AE,
+ DC,
+ ALP,
+ WCP,
+ NONE
+ }
+}
diff --git a/n5coredll/Properties/AssemblyInfo.cs b/n5coredll/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1625255
--- /dev/null
+++ b/n5coredll/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("n5coredll")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Home")]
+[assembly: AssemblyProduct("n5coredll")]
+[assembly: AssemblyCopyright("Copyright © Home 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(true)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1f0c1d84-fd97-41f1-bc8b-f2f22c1997a1")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/n5coredll/Properties/Settings.Designer.cs b/n5coredll/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..277cf71
--- /dev/null
+++ b/n5coredll/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace n5coredll.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/n5coredll/Properties/Settings.settings b/n5coredll/Properties/Settings.settings
new file mode 100644
index 0000000..049245f
--- /dev/null
+++ b/n5coredll/Properties/Settings.settings
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/n5coredll/RefundResult.cs b/n5coredll/RefundResult.cs
new file mode 100644
index 0000000..d03f67d
--- /dev/null
+++ b/n5coredll/RefundResult.cs
@@ -0,0 +1,374 @@
+using System;
+using System.Text;
+namespace n5coredll
+{
+ public class RefundResult {
+ 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 LOCAL_CUR = "LOCAL_CUR";
+ private static string FOREIGN_CUR = "FOREIGN_CUR";
+ private static string FXRATE = "FXRATE";
+ private static string FOREIGN_AMT = "FOREIGN_AMT";
+ 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 localCur;
+ private string foreignCur;
+ private string fxRate;
+ private string foreignAmt;
+ 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 LocalCur {
+ get { return localCur; }
+ }
+ private void setLocalCur(string pLocalCur) {
+ this.localCur = pLocalCur;
+ }
+ public string ForeignCur {
+ get { return foreignCur; }
+ }
+ private void setForeignCur(string pForeignCur) {
+ this.foreignCur = pForeignCur;
+ }
+ public string FxRate {
+ get { return fxRate; }
+ }
+ private void setFxRate(string pFxRate) {
+ this.fxRate = pFxRate;
+ }
+ public string ForeignAmt {
+ get { return foreignAmt; }
+ }
+ private void setForeignAmt(string pForeignAmt) {
+ this.foreignAmt = pForeignAmt;
+ }
+ 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;
+ }
+
+ public RefundResult() {
+ }
+
+ public RefundResult(string pStatus) {
+ this.setStatus(pStatus);
+ }
+
+ private static string curTxnId;
+ public static string getCurTxnId()
+ {
+ return curTxnId;
+ }
+
+ public static string toJsonForRefund(decimal txnAmt, PaymentApp appId, string qrcValue) {
+ string thisTxnId = getTxnId();
+ if (thisTxnId == null || "".Equals(thisTxnId)) {
+ Console.WriteLine("getTxnId is null ");
+ return null;
+ }
+ curTxnId = thisTxnId;
+ string cardRefundMsg = "{\"EVENT_NAME\":\"REFUND\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + thisTxnId + "\",\"QRC_VALUE\":\"" + qrcValue + "\",\"TXN_AMT\":" + txnAmt.ToString() + "}";
+ return cardRefundMsg;
+ }
+
+ public static string toJsonForRefund(string txnIId, decimal txnAmt, PaymentApp appId, string qrcValue)
+ {
+ string cardRefundMsg = "{\"EVENT_NAME\":\"REFUND\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnIId + "\",\"QRC_VALUE\":\"" + qrcValue + "\",\"TXN_AMT\":" + txnAmt.ToString() + "}";
+ return cardRefundMsg;
+ }
+
+ 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 RefundResult toRefundResultFromJsonMsg(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;
+ RefundResult RefundResult = new RefundResult();
+
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (RefundResult.TXN_ID.Equals(valueColumn0)) {
+ RefundResult.setEcrRefTxnId(valueColumn1);
+ }
+ if (RefundResult.STATUS.Equals(valueColumn0)) {
+ RefundResult.setStatus(valueColumn1);
+ }
+
+ if (RefundResult.TXN_AMT.Equals(valueColumn0)) {
+ if (valueColumn1 == null || "".Equals(valueColumn1)) {
+ RefundResult.setTxnAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else {
+ RefundResult.setTxnAmt(decimal.Parse(valueColumn1));
+ }
+ }
+
+ if (RefundResult.PAYMENT_TYPE.Equals(valueColumn0)) {
+ RefundResult.setPaymentType(ObjectUtil.getPaymentType(valueColumn1));
+ }
+
+ if (RefundResult.RESP_CODE.Equals(valueColumn0)) {
+ RefundResult.setRespCode(valueColumn1);
+ }
+
+ if (RefundResult.TRACE_NO.Equals(valueColumn0)) {
+ RefundResult.setTraceNo(valueColumn1);
+ }
+ if (RefundResult.TXN_DATE.Equals(valueColumn0)) {
+ RefundResult.setTxnDate(valueColumn1);
+ }
+ if (RefundResult.TXN_TIME.Equals(valueColumn0)) {
+ RefundResult.setTxnTime(valueColumn1);
+ }
+
+ if (RefundResult.HOST_REF.Equals(valueColumn0)) {
+ RefundResult.setHostRef(valueColumn1);
+ }
+ if (RefundResult.AUTH_CODE.Equals(valueColumn0)) {
+ RefundResult.setAuthCode(valueColumn1);
+ }
+ if (RefundResult.LOCAL_CUR.Equals(valueColumn0)) {
+ RefundResult.setLocalCur(valueColumn1);
+ }
+ if (RefundResult.FOREIGN_CUR.Equals(valueColumn0)) {
+ RefundResult.setForeignCur(valueColumn1);
+ }
+ if (RefundResult.FXRATE.Equals(valueColumn0)) {
+ RefundResult.setFxRate(valueColumn1);
+ }
+ if (RefundResult.FOREIGN_AMT.Equals(valueColumn0)) {
+ RefundResult.setForeignAmt(valueColumn1);
+ }
+ if (RefundResult.MID.Equals(valueColumn0)) {
+ RefundResult.setMid(valueColumn1);
+ }
+ if (RefundResult.TID.Equals(valueColumn0)) {
+ RefundResult.setTid(valueColumn1);
+ }
+ if (RefundResult.PAN.Equals(valueColumn0)) {
+ RefundResult.setPan(valueColumn1);
+ }
+ if (RefundResult.EXPIRY_DATE.Equals(valueColumn0)) {
+ RefundResult.setExpiryDate(valueColumn1);
+ }
+ if (RefundResult.AID.Equals(valueColumn0)) {
+ RefundResult.setAid(valueColumn1);
+ }
+ if (RefundResult.ENTRY_MODE.Equals(valueColumn0)) {
+ RefundResult.setEntryMode(valueColumn1);
+ }
+ if (RefundResult.BATCH_NO.Equals(valueColumn0)) {
+ RefundResult.setBatchNo(valueColumn1);
+ }
+ if (RefundResult.APP.Equals(valueColumn0)) {
+ RefundResult.setApp(valueColumn1);
+ }
+ if (RefundResult.TC.Equals(valueColumn0)) {
+ RefundResult.setTc(valueColumn1);
+ }
+ if (RefundResult.ACQUIRER.Equals(valueColumn0)) {
+ RefundResult.setAcquirer(valueColumn1);
+ }
+
+ }
+ return RefundResult;
+ }
+ }
+}
diff --git a/n5coredll/RequestResult.cs b/n5coredll/RequestResult.cs
new file mode 100644
index 0000000..fe57b84
--- /dev/null
+++ b/n5coredll/RequestResult.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Text;
+namespace n5coredll
+{
+ public class RequestResult {
+ private static string STATUS = "STATUS";
+
+ private string status;
+
+ public string Status {
+ get { return status; }
+ }
+ private void setStatus(string pStatus) {
+ this.status = pStatus;
+ }
+
+ public RequestResult() {
+ }
+
+ public RequestResult(string pStatus) {
+ this.setStatus(pStatus);
+ }
+
+ public static string toJsonForLinkTest() {
+ return "{\"EVENT_NAME\":\"ECHO\"}";
+ }
+
+ public static string toJsonForSettlement()
+ {
+ return "{\"EVENT_NAME\":\"SETTLE\"}";
+ }
+
+ public static string toJsonForReprint()
+ {
+ return "{\"EVENT_NAME\":\"PRINT\",\"IS_REPRINT\":true}";
+ }
+
+ public static string toJsonForAbort()
+ {
+ return "{\"EVENT_NAME\":\"ABORT\"}";
+ }
+
+ public static string toJsonForScan()
+ {
+ return "{\"EVENT_NAME\":\"SCAN\"}";
+ }
+
+ public static string toJsonForReadCardNFC()
+ {
+ return "{\"EVENT_NAME\":\"READ_CARD\"}";
+ }
+
+ public static string toJsonForAddPoint(string inputTxnId, decimal txnAmt)
+ {
+ string cardSaleMsg = "{\"EVENT_NAME\":\"ADD_POINT\",\"TXN_ID\":\"" + inputTxnId + "\",\"TXN_AMT\":" + txnAmt + "}";
+ return cardSaleMsg;
+ }
+
+ public static string toJsonForBatchEnquiry(string settleDate)
+ {
+ return "{\"EVENT_NAME\":\"BATCH_ENQUIRY\",\"SETTLE_DATE\":\"" + settleDate + "\"}";
+ }
+
+ public static string toJsonForSettleEnquiry(string batchId)
+ {
+ return "{\"EVENT_NAME\":\"SETTLE_ENQUIRY\",\"BATCH_ID\":\"" + batchId + "\"}";
+ }
+
+ public static string toJsonForSummaryEnquiry(string period)
+ {
+ return "{\"EVENT_NAME\":\"SUMMARY_ENQUIRY\",\"TXN_DATE_START_TO_END\":\"" + period + "\"}";
+ }
+ public static RequestResult toReqResultFromJsonMsg(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;
+ RequestResult reqResult = new RequestResult();
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (RequestResult.STATUS.Equals(valueColumn0)) {
+ reqResult.setStatus(valueColumn1);
+ }
+ }
+ return reqResult;
+ }
+
+ public static String createRespErrJson(String eventName, String status)
+ {
+ return "{\"EVENT_NAME\":\"" +eventName + "\",\"STATUS\":\"" + status + "\"}";
+ }
+
+ }
+}
diff --git a/n5coredll/RetrievalResult.cs b/n5coredll/RetrievalResult.cs
new file mode 100644
index 0000000..38cdaae
--- /dev/null
+++ b/n5coredll/RetrievalResult.cs
@@ -0,0 +1,468 @@
+using System;
+using System.Text;
+
+namespace n5coredll
+{
+ public class RetrievalResult {
+ private static string EVENT_NAME = "EVENT_NAME";
+ private static string TXN_TYPE = "TXN_TYPE";
+ private static string TXN_ID = "TXN_ID";
+ private static string STATUS = "STATUS";
+ private static string TXN_STATUS = "TXN_STATUS";
+ private static string TXN_AMT = "TXN_AMT";
+ private static string TIPS = "TIPS";
+ private static string PAYMENT_TYPE = "PAYMENT_TYPE";
+ private static string RESP_CODE = "RESP_CODE";
+ private static string LOYALTY_TYPE = "LOYALTY_TYPE";
+ private static string CAMPAIGN_ID = "CAMPAIGN_ID";
+ 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 COUPON_ID = "COUPON_ID";
+ private static string AUTH_CODE = "AUTH_CODE";
+ private static string TENDER = "TENDER";
+ private static string AUTH_AMT = "AUTH_AMT";
+ private static string DISCOUNT = "DISCOUNT";
+ private static string LOCAL_CUR = "LOCAL_CUR";
+ private static string FOREIGN_CUR = "FOREIGN_CUR";
+ private static string FXRATE = "FXRATE";
+ private static string FOREIGN_AMT = "FOREIGN_AMT";
+ 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 LOYALTY_REF = "LOYALTY_REF";
+ 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 eventName;
+ private TxnType txnType;
+ private string ecrRefTxnId;
+ private string status;
+ private TxnStatus txnStatus;
+ private decimal txnAmt;
+ private decimal tipAmt;
+ private PaymentType paymentType;
+ private string respCode;
+ private LoyaltyType loyaltyType;
+ private string campaignId;
+ private string traceNo;
+ private string txnDate;
+ private string txnTime;
+ private string hostRef;
+ private string couponId;
+ private string authCode;
+ private string tender;
+ private string authAmt;
+ private string discAmt;
+ private string localCur;
+ private string foreignCur;
+ private string fxRate;
+ private string foreignAmt;
+ private string mid;
+ private string tid;
+ private string pan;
+ private string expiryDate;
+ private string loyaltyRef;
+ private string aid;
+ private string entryMode;
+ private string batchNo;
+ private string tc;
+ private string app;
+ private string acquirer;
+
+ public void setEventName(string pEventName)
+ {
+ eventName = pEventName;
+ }
+
+ public string EventName
+ {
+ get { return eventName; }
+ }
+
+ private void setTxnType(TxnType pTxnType) {
+ txnType = pTxnType;
+ }
+
+ public TxnType TxnType {
+ get { return txnType; }
+ }
+
+ private void setTxnStatus(TxnStatus pTxnStatus) {
+ txnStatus = pTxnStatus;
+ }
+
+ public TxnStatus TxnStatus {
+ get { return txnStatus; }
+ }
+
+ private void setTender(string pTender) {
+ tender = pTender;
+ }
+
+ public string Tender {
+ get { return tender; }
+ }
+
+ 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 decimal TipAmt {
+ get { return tipAmt; }
+ }
+ private void setTipAmt(decimal pTipAmt) {
+ this.tipAmt = pTipAmt;
+ }
+ 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 LoyaltyType LoyaltyType {
+ get { return loyaltyType; }
+ }
+ private void setLoyaltyType(LoyaltyType pLoyaltyType) {
+ this.loyaltyType = pLoyaltyType;
+ }
+ public string CampaignId {
+ get { return campaignId; }
+ }
+ private void setCampaignId(string pCampaignId) {
+ this.campaignId = pCampaignId;
+ }
+ 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 AuthAmt {
+ get { return authAmt; }
+ }
+ private void setAuthAmt(string pAuthAmt) {
+ this.authAmt = pAuthAmt;
+ }
+ public string DiscAmt {
+ get { return discAmt; }
+ }
+ private void setDiscAmt(string pDiscAmt) {
+ this.discAmt = pDiscAmt;
+ }
+ public string LocalCur {
+ get { return localCur; }
+ }
+ private void setLocalCur(string pLocalCur) {
+ this.localCur = pLocalCur;
+ }
+ public string ForeignCur {
+ get { return foreignCur; }
+ }
+ private void setForeignCur(string pForeignCur) {
+ this.foreignCur = pForeignCur;
+ }
+ public string FxRate {
+ get { return fxRate; }
+ }
+ private void setFxRate(string pFxRate) {
+ this.fxRate = pFxRate;
+ }
+ public string ForeignAmt {
+ get { return foreignAmt; }
+ }
+ private void setForeignAmt(string pForeignAmt) {
+ this.foreignAmt = pForeignAmt;
+ }
+ 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 LoyaltyRef {
+ get { return loyaltyRef; }
+ }
+ private void setLoyaltyRef(string pLoyaltyRef) {
+ this.loyaltyRef = pLoyaltyRef;
+ }
+ 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;
+ }
+
+ public RetrievalResult() {
+ }
+
+ public RetrievalResult(string pStatus) {
+ this.setStatus(pStatus);
+ }
+
+ public static string toJsonForRetrieval(string txnId) {
+
+ if (txnId == null || "".Equals(txnId)) {
+ Console.WriteLine("txnId is null ");
+ return null;
+ }
+ string cardSaleMsg = "{\"EVENT_NAME\":\"RETRIEVAL\",\"TXN_ID\":\"" + txnId + "\"}";
+ return cardSaleMsg;
+ }
+
+ public static RetrievalResult toRetrievalResultFromJsonMsg(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;
+ RetrievalResult retrievalResult = new RetrievalResult();
+
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (RetrievalResult.EVENT_NAME.Equals(valueColumn0))
+ {
+ retrievalResult.setEventName(valueColumn1);
+ }
+ if (RetrievalResult.TXN_TYPE.Equals(valueColumn0)) {
+ retrievalResult.setTxnType(ObjectUtil.getTxnType(valueColumn1));
+ }
+
+ if (RetrievalResult.TXN_ID.Equals(valueColumn0)) {
+ retrievalResult.setEcrRefTxnId(valueColumn1);
+ }
+ if (RetrievalResult.STATUS.Equals(valueColumn0)) {
+ retrievalResult.setStatus(valueColumn1);
+ }
+
+ if (RetrievalResult.TXN_STATUS.Equals(valueColumn0)) {
+ retrievalResult.setTxnStatus(ObjectUtil.getTxnStatus(valueColumn1));
+ }
+
+ if (RetrievalResult.TXN_AMT.Equals(valueColumn0)) {
+ if (valueColumn1 == null || "".Equals(valueColumn1)) {
+ retrievalResult.setTxnAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else {
+ retrievalResult.setTxnAmt(decimal.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));
+ }
+ else {
+ retrievalResult.setTipAmt(decimal.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ }
+
+ if (RetrievalResult.PAYMENT_TYPE.Equals(valueColumn0)) {
+ retrievalResult.setPaymentType(ObjectUtil.getPaymentType(valueColumn1));
+ }
+
+ if (RetrievalResult.RESP_CODE.Equals(valueColumn0)) {
+ retrievalResult.setRespCode(valueColumn1);
+ }
+
+ if (RetrievalResult.LOYALTY_TYPE.Equals(valueColumn0)) {
+ retrievalResult.setLoyaltyType(ObjectUtil.getLoyaltyType(valueColumn1));
+ }
+
+ if (RetrievalResult.CAMPAIGN_ID.Equals(valueColumn0)) {
+ retrievalResult.setCampaignId(valueColumn1);
+ }
+
+ if (RetrievalResult.TRACE_NO.Equals(valueColumn0)) {
+ retrievalResult.setTraceNo(valueColumn1);
+ }
+ if (RetrievalResult.TXN_DATE.Equals(valueColumn0)) {
+ retrievalResult.setTxnDate(valueColumn1);
+ }
+ if (RetrievalResult.TXN_TIME.Equals(valueColumn0)) {
+ retrievalResult.setTxnTime(valueColumn1);
+ }
+
+ if (RetrievalResult.HOST_REF.Equals(valueColumn0)) {
+ retrievalResult.setHostRef(valueColumn1);
+ }
+ if (RetrievalResult.COUPON_ID.Equals(valueColumn0)) {
+ retrievalResult.setCouponId(valueColumn1);
+ }
+ if (RetrievalResult.AUTH_CODE.Equals(valueColumn0)) {
+ retrievalResult.setAuthCode(valueColumn1);
+ }
+
+ if (RetrievalResult.TENDER.Equals(valueColumn0)) {
+ retrievalResult.setTender(valueColumn1);
+ }
+ if (RetrievalResult.AUTH_AMT.Equals(valueColumn0)) {
+ retrievalResult.setAuthAmt(valueColumn1);
+ }
+ if (RetrievalResult.DISCOUNT.Equals(valueColumn0)) {
+ retrievalResult.setDiscAmt(valueColumn1);
+ }
+ if (RetrievalResult.LOCAL_CUR.Equals(valueColumn0)) {
+ retrievalResult.setLocalCur(valueColumn1);
+ }
+ if (RetrievalResult.FOREIGN_CUR.Equals(valueColumn0)) {
+ retrievalResult.setForeignCur(valueColumn1);
+ }
+ if (RetrievalResult.FXRATE.Equals(valueColumn0)) {
+ retrievalResult.setFxRate(valueColumn1);
+ }
+ if (RetrievalResult.FOREIGN_AMT.Equals(valueColumn0)) {
+ retrievalResult.setForeignAmt(valueColumn1);
+ }
+ if (RetrievalResult.MID.Equals(valueColumn0)) {
+ retrievalResult.setMid(valueColumn1);
+ }
+ if (RetrievalResult.TID.Equals(valueColumn0)) {
+ retrievalResult.setTid(valueColumn1);
+ }
+ if (RetrievalResult.PAN.Equals(valueColumn0)) {
+ retrievalResult.setPan(valueColumn1);
+ }
+ if (RetrievalResult.EXPIRY_DATE.Equals(valueColumn0)) {
+ retrievalResult.setExpiryDate(valueColumn1);
+ }
+ if (RetrievalResult.LOYALTY_REF.Equals(valueColumn0)) {
+ retrievalResult.setLoyaltyRef(valueColumn1);
+ }
+ if (RetrievalResult.AID.Equals(valueColumn0)) {
+ retrievalResult.setAid(valueColumn1);
+ }
+ if (RetrievalResult.ENTRY_MODE.Equals(valueColumn0)) {
+ retrievalResult.setEntryMode(valueColumn1);
+ }
+ if (RetrievalResult.BATCH_NO.Equals(valueColumn0)) {
+ retrievalResult.setBatchNo(valueColumn1);
+ }
+ if (RetrievalResult.APP.Equals(valueColumn0)) {
+ retrievalResult.setApp(valueColumn1);
+ }
+ if (RetrievalResult.TC.Equals(valueColumn0)) {
+ retrievalResult.setTc(valueColumn1);
+ }
+ if (RetrievalResult.ACQUIRER.Equals(valueColumn0)) {
+ retrievalResult.setAcquirer(valueColumn1);
+ }
+ }
+
+ return retrievalResult;
+ }
+ }
+}
diff --git a/n5coredll/SaleResult.cs b/n5coredll/SaleResult.cs
new file mode 100644
index 0000000..107ab85
--- /dev/null
+++ b/n5coredll/SaleResult.cs
@@ -0,0 +1,461 @@
+using System;
+using System.Text;
+
+namespace n5coredll
+{
+ public class SaleResult {
+ private static string TXN_ID = "TXN_ID";
+ private static string STATUS = "STATUS";
+ private static string TXN_AMT = "TXN_AMT";
+ private static string TIPS = "TIPS";
+ private static string PAYMENT_TYPE = "PAYMENT_TYPE";
+ private static string RESP_CODE = "RESP_CODE";
+ private static string LOYALTY_TYPE = "LOYALTY_TYPE";
+ private static string CAMPAIGN_ID = "CAMPAIGN_ID";
+ 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 COUPON_ID = "COUPON_ID";
+ private static string AUTH_CODE = "AUTH_CODE";
+ private static string AUTH_AMT = "AUTH_AMT";
+ private static string DISCOUNT = "DISCOUNT";
+ private static string LOCAL_CUR = "LOCAL_CUR";
+ private static string FOREIGN_CUR = "FOREIGN_CUR";
+ private static string FXRATE = "FXRATE";
+ private static string FOREIGN_AMT = "FOREIGN_AMT";
+ 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 LOYALTY_REF = "LOYALTY_REF";
+ 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 decimal tipAmt;
+ private PaymentType paymentType;
+ private string respCode;
+ private LoyaltyType loyaltyType;
+ private string campaignId;
+ private string traceNo;
+ private string txnDate;
+ private string txnTime;
+ private string hostRef;
+ private string couponId;
+ private string authCode;
+ private string authAmt;
+ private string discAmt;
+ private string localCur;
+ private string foreignCur;
+ private string fxRate;
+ private string foreignAmt;
+ private string mid;
+ private string tid;
+ private string pan;
+ private string expiryDate;
+ private string loyaltyRef;
+ 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 decimal TipAmt {
+ get { return tipAmt; }
+ }
+ private void setTipAmt(decimal pTipAmt) {
+ this.tipAmt = pTipAmt;
+ }
+ 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 LoyaltyType LoyaltyType {
+ get { return loyaltyType; }
+ }
+ private void setLoyaltyType(LoyaltyType pLoyaltyType) {
+ this.loyaltyType = pLoyaltyType;
+ }
+ public string CampaignId {
+ get { return campaignId; }
+ }
+ private void setCampaignId(string pCampaignId) {
+ this.campaignId = pCampaignId;
+ }
+ 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 AuthAmt {
+ get { return authAmt; }
+ }
+ private void setAuthAmt(string pAuthAmt) {
+ this.authAmt = pAuthAmt;
+ }
+ public string DiscAmt {
+ get { return discAmt; }
+ }
+ private void setDiscAmt(string pDiscAmt) {
+ this.discAmt = pDiscAmt;
+ }
+ public string LocalCur {
+ get { return localCur; }
+ }
+ private void setLocalCur(string pLocalCur) {
+ this.localCur = pLocalCur;
+ }
+ public string ForeignCur {
+ get { return foreignCur; }
+ }
+ private void setForeignCur(string pForeignCur) {
+ this.foreignCur = pForeignCur;
+ }
+ public string FxRate {
+ get { return fxRate; }
+ }
+ private void setFxRate(string pFxRate) {
+ this.fxRate = pFxRate;
+ }
+ public string ForeignAmt {
+ get { return foreignAmt; }
+ }
+ private void setForeignAmt(string pForeignAmt) {
+ this.foreignAmt = pForeignAmt;
+ }
+ public string getMid() {
+ return mid;
+ }
+ private void setMid(string pMid) {
+ this.mid = pMid;
+ }
+ public string getTid() {
+ return tid;
+ }
+ private void setTid(string pTid) {
+ this.tid = pTid;
+ }
+ public string getPan() {
+ return pan;
+ }
+ private void setPan(string pPan) {
+ this.pan = pPan;
+ }
+ public string getExpiryDate() {
+ return expiryDate;
+ }
+ private void setExpiryDate(string pExpiryDate) {
+ this.expiryDate = pExpiryDate;
+ }
+ public string getLoyaltyRef() {
+ return loyaltyRef;
+ }
+ private void setLoyaltyRef(string pLoyaltyRef) {
+ this.loyaltyRef = pLoyaltyRef;
+ }
+ public string getAid() {
+ 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 toJsonForSale(string txnId, decimal txnAmt, decimal tipAmt, PaymentApp appId, string qrcValue) {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"SALE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TIPS\":" + tipAmt + ",\"TXN_AMT\":" + txnAmt + ",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+ return cardSaleMsg;
+ }
+
+ public static string toJsonForSale(string txnId, decimal txnAmt, decimal tipAmt, PaymentApp appId, string qrcValue, string pan, string expDate)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"SALE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TIPS\":" + tipAmt + ",\"TXN_AMT\":" + txnAmt + ",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\",\"QRC_VALUE\":\"" + qrcValue + "\"}";
+ return cardSaleMsg;
+ }
+ public static string toJsonForPreauth(string txnId, decimal txnAmt, PaymentApp appId, string pan, string expDate)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"PREAUTH\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TXN_AMT\":" + txnAmt + ",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\"}";
+ return cardSaleMsg;
+ }
+ public static string toJsonForOffline(string txnId, decimal txnAmt, PaymentApp appId, string authCode, string pan, string expDate)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"OFFLINE\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TXN_AMT\":" + txnAmt + ",\"AUTH_CODE\":\"" + authCode + "\""+ ",\"PAN\":\"" + pan + "\",\"EXPIRY_DATE\":\"" + expDate + "\"}";
+ return cardSaleMsg;
+ }
+ public static string toJsonForAdjust(string txnId, decimal totalAmt, decimal totalForeignAmt, PaymentApp appId)
+ {
+
+ string cardSaleMsg = "{\"EVENT_NAME\":\"ADJUST\",\"PAYMENT_APP_ID\":\"" + ObjectUtil.getPaymentAppValue(appId) + "\",\"TXN_ID\":\"" + txnId + "\",\"TOTAL_TXN_AMT\":" + totalAmt + ",\"TOTAL_FOREIGN_AMT\":" + totalForeignAmt + "}";
+ return cardSaleMsg;
+ }
+ 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 SaleResult() {
+ }
+
+ public SaleResult(string pStatus) {
+ this.setStatus(pStatus);
+ }
+
+ public static SaleResult toSaleResultFromJsonMsg(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;
+ SaleResult saleResult = new SaleResult();
+
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+ if (SaleResult.TXN_ID.Equals(valueColumn0)) {
+ saleResult.setEcrRefTxnId(valueColumn1);
+ }
+ if (SaleResult.STATUS.Equals(valueColumn0)) {
+ saleResult.setStatus(valueColumn1);
+ }
+
+ if (SaleResult.TXN_AMT.Equals(valueColumn0)) {
+ if (valueColumn1 == null || "".Equals(valueColumn1)) {
+ saleResult.setTxnAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else {
+ saleResult.setTxnAmt(decimal.Parse(valueColumn1));
+ }
+ }
+
+ if (SaleResult.TIPS.Equals(valueColumn0)) {
+ if (valueColumn1 == null || "".Equals(valueColumn1)) {
+ saleResult.setTipAmt(decimal.Parse("0.00", System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ else {
+ saleResult.setTipAmt(decimal.Parse(valueColumn1, System.Globalization.NumberStyles.AllowDecimalPoint));
+ }
+ }
+
+ if (SaleResult.PAYMENT_TYPE.Equals(valueColumn0)) {
+ saleResult.setPaymentType(ObjectUtil.getPaymentType(valueColumn1));
+ }
+
+ if (SaleResult.RESP_CODE.Equals(valueColumn0)) {
+ saleResult.setRespCode(valueColumn1);
+ }
+
+ if (SaleResult.LOYALTY_TYPE.Equals(valueColumn0)) {
+ saleResult.setLoyaltyType(ObjectUtil.getLoyaltyType(valueColumn1));
+ }
+
+ if (SaleResult.CAMPAIGN_ID.Equals(valueColumn0)) {
+ saleResult.setCampaignId(valueColumn1);
+ }
+
+ if (SaleResult.TRACE_NO.Equals(valueColumn0)) {
+ saleResult.setTraceNo(valueColumn1);
+ }
+ if (SaleResult.TXN_DATE.Equals(valueColumn0)) {
+ saleResult.setTxnDate(valueColumn1);
+ }
+ if (SaleResult.TXN_TIME.Equals(valueColumn0)) {
+ saleResult.setTxnTime(valueColumn1);
+ }
+
+ if (SaleResult.HOST_REF.Equals(valueColumn0)) {
+ saleResult.setHostRef(valueColumn1);
+ }
+ if (SaleResult.COUPON_ID.Equals(valueColumn0)) {
+ saleResult.setCouponId(valueColumn1);
+ }
+ if (SaleResult.AUTH_CODE.Equals(valueColumn0)) {
+ saleResult.setAuthCode(valueColumn1);
+ }
+ if (SaleResult.AUTH_AMT.Equals(valueColumn0)) {
+ saleResult.setAuthAmt(valueColumn1);
+ }
+ if (SaleResult.DISCOUNT.Equals(valueColumn0)) {
+ saleResult.setDiscAmt(valueColumn1);
+ }
+ if (SaleResult.LOCAL_CUR.Equals(valueColumn0)) {
+ saleResult.setLocalCur(valueColumn1);
+ }
+ if (SaleResult.FOREIGN_CUR.Equals(valueColumn0)) {
+ saleResult.setForeignCur(valueColumn1);
+ }
+ if (SaleResult.FXRATE.Equals(valueColumn0)) {
+ saleResult.setFxRate(valueColumn1);
+ }
+ if (SaleResult.FOREIGN_AMT.Equals(valueColumn0)) {
+ saleResult.setForeignAmt(valueColumn1);
+ }
+ if (SaleResult.MID.Equals(valueColumn0)) {
+ saleResult.setMid(valueColumn1);
+ }
+ if (SaleResult.TID.Equals(valueColumn0)) {
+ saleResult.setTid(valueColumn1);
+ }
+ if (SaleResult.PAN.Equals(valueColumn0)) {
+ saleResult.setPan(valueColumn1);
+ }
+ if (SaleResult.EXPIRY_DATE.Equals(valueColumn0)) {
+ saleResult.setExpiryDate(valueColumn1);
+ }
+ if (SaleResult.LOYALTY_REF.Equals(valueColumn0)) {
+ saleResult.setLoyaltyRef(valueColumn1);
+ }
+ if (SaleResult.AID.Equals(valueColumn0)) {
+ saleResult.setAid(valueColumn1);
+ }
+ if (SaleResult.ENTRY_MODE.Equals(valueColumn0)) {
+ saleResult.setEntryMode(valueColumn1);
+ }
+ if (SaleResult.BATCH_NO.Equals(valueColumn0)) {
+ saleResult.setBatchNo(valueColumn1);
+ }
+ if (SaleResult.APP.Equals(valueColumn0)) {
+ saleResult.setApp(valueColumn1);
+ }
+ if (SaleResult.TC.Equals(valueColumn0)) {
+ saleResult.setTc(valueColumn1);
+ }
+ if (SaleResult.ACQUIRER.Equals(valueColumn0)) {
+ saleResult.setAcquirer(valueColumn1);
+ }
+
+ }
+ return saleResult;
+ }
+ }
+}
diff --git a/n5coredll/TxnStatus.cs b/n5coredll/TxnStatus.cs
new file mode 100644
index 0000000..6c2ca64
--- /dev/null
+++ b/n5coredll/TxnStatus.cs
@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace n5coredll
+{
+ public enum TxnStatus { Approved, Confirming, Voided, Settled, Failed }
+}
diff --git a/n5coredll/TxnType.cs b/n5coredll/TxnType.cs
new file mode 100644
index 0000000..5a14909
--- /dev/null
+++ b/n5coredll/TxnType.cs
@@ -0,0 +1,5 @@
+using System;
+namespace n5coredll
+{
+ public enum TxnType { SALE, REFUND, NONE }
+}
diff --git a/n5coredll/Util.cs b/n5coredll/Util.cs
new file mode 100644
index 0000000..2553a89
--- /dev/null
+++ b/n5coredll/Util.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace n5coredll
+{
+ public class Util
+ {
+ public static string bcd2Str(byte[] bytes)
+ {
+ Console.WriteLine("Execute bcd2Str!");
+
+ StringBuilder temp = new StringBuilder();
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ int h = ((bytes[i] & 0xff) >> 4) + 48;
+ temp.Append((char)h);
+ int l = ((bytes[i] & 0x0f)) + 48;
+ temp.Append((char)l);
+ }
+ return temp.ToString();
+ }
+
+ public static string desToHex(byte[] bytes)
+ {
+ StringBuilder sb = new StringBuilder("");
+ for (int i = 0; i < bytes.Length; i++)
+ {
+ string st = string.Format("%02X", bytes[i]);
+ sb.Append(st);
+ }
+ return sb.ToString();
+ }
+ }
+}
diff --git a/n5coredll/VoidResult.cs b/n5coredll/VoidResult.cs
new file mode 100644
index 0000000..647cf73
--- /dev/null
+++ b/n5coredll/VoidResult.cs
@@ -0,0 +1,169 @@
+using System;
+using System.Text;
+
+namespace n5coredll
+{
+ public class VoidResult {
+ private static string TXN_ID = "TXN_ID";
+ private static string STATUS = "STATUS";
+ private static string PAYMENT_TYPE = "PAYMENT_TYPE";
+ private static string RESP_CODE = "RESP_CODE";
+ private static string TXN_DATE = "TXN_DATE";
+ private static string TXN_TIME = "TXN_TIME";
+ private static string HOST_REF = "HOST_REF";
+ private static string TC = "TC";
+ private static string APP = "APP";
+ private static string ACQUIRER = "ACQUIRER";
+
+ private string ecrRefTxnId;
+ private string status;
+ private PaymentType paymentType;
+ private string respCode;
+ private string txnDate;
+ private string txnTime;
+ private string hostRef;
+ 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 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 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 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;
+ }
+
+ public VoidResult() {
+ }
+
+ public VoidResult(string pStatus) {
+ this.setStatus(pStatus);
+ }
+
+ public static string toJsonForVoid(string txnId, string qrcValue) {
+ if (txnId == null || "".Equals(txnId)) {
+ Console.WriteLine("txnId is null ");
+ return null;
+ }
+
+ string cardVoidMsg = "{\"EVENT_NAME\":\"VOID\",\"TXN_ID\":\"" + txnId + "\",\"QRC_VALUE\":\"" + qrcValue + "\",\"PAYMENT_APP_ID\":\"CC\"}";
+ return cardVoidMsg;
+ }
+
+ public static VoidResult toVoidResultFromJsonMsg(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;
+ VoidResult VoidResult = new VoidResult();
+
+ for (int i = 0; i < column.Length; i++) {
+ valueColumn = column[i].Split(':');
+ valueColumn0 = valueColumn[0].Replace('"', ' ').Trim();
+ valueColumn1 = valueColumn[1].Replace('"', ' ').Trim();
+
+ if (VoidResult.TXN_ID.Equals(valueColumn0)) {
+ VoidResult.setEcrRefTxnId(valueColumn1);
+ }
+ if (VoidResult.STATUS.Equals(valueColumn0)) {
+ VoidResult.setStatus(valueColumn1);
+ }
+
+ if (VoidResult.PAYMENT_TYPE.Equals(valueColumn0)) {
+ VoidResult.setPaymentType(ObjectUtil.getPaymentType(valueColumn1));
+ }
+
+ if (VoidResult.RESP_CODE.Equals(valueColumn0)) {
+ VoidResult.setRespCode(valueColumn1);
+ }
+ if (VoidResult.TXN_DATE.Equals(valueColumn0)) {
+ VoidResult.setTxnDate(valueColumn1);
+ }
+ if (VoidResult.TXN_TIME.Equals(valueColumn0)) {
+ VoidResult.setTxnTime(valueColumn1);
+ }
+
+ if (VoidResult.HOST_REF.Equals(valueColumn0)) {
+ VoidResult.setHostRef(valueColumn1);
+ }
+
+ if (VoidResult.APP.Equals(valueColumn0)) {
+ VoidResult.setApp(valueColumn1);
+ }
+ if (VoidResult.TC.Equals(valueColumn0)) {
+ VoidResult.setTc(valueColumn1);
+ }
+ if (VoidResult.ACQUIRER.Equals(valueColumn0)) {
+ VoidResult.setAcquirer(valueColumn1);
+ }
+ }
+
+ return VoidResult;
+ }
+ }
+}
diff --git a/n5coredll/app.config b/n5coredll/app.config
new file mode 100644
index 0000000..49cc43e
--- /dev/null
+++ b/n5coredll/app.config
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/n5coredll/n5codedll.snk b/n5coredll/n5codedll.snk
new file mode 100644
index 0000000..bd8dde0
Binary files /dev/null and b/n5coredll/n5codedll.snk differ
diff --git a/n5coredll/n5coredll.csproj b/n5coredll/n5coredll.csproj
new file mode 100644
index 0000000..1709a56
--- /dev/null
+++ b/n5coredll/n5coredll.csproj
@@ -0,0 +1,88 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {1F0C1D84-FD97-41F1-BC8B-F2F22C1997A1}
+ Library
+ Properties
+ n5coredll
+ n5coredll
+ v4.0
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ AnyCPU
+ true
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ true
+ AnyCPU
+
+
+ true
+
+
+ n5codedll.snk
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
\ No newline at end of file