diff --git a/n5coredll/LogUtil.cs b/n5coredll/LogUtil.cs
new file mode 100644
index 0000000..b4726dd
--- /dev/null
+++ b/n5coredll/LogUtil.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace n5coredll
+{
+ public class LogUtil
+ {
+ private static String mLogPath;
+ private static LogUtil mInstance;
+ public static LogUtil getInstance()
+ {
+ if (mInstance == null)
+ mInstance = new LogUtil();
+
+ return mInstance;
+ }
+
+ public void setLogPath(String logPath)
+ {
+ if (logPath.EndsWith(@"\"))
+ mLogPath = logPath;
+ else
+ mLogPath = logPath + @"\";
+ }
+
+ private String getCurLogFile()
+ {
+
+ StringBuilder txnIdSb = new StringBuilder();
+ DateTime dt = DateTime.Now;
+ return ("n5dll" + "_" + dt.ToString("yyyyMMdd") +".log");
+ }
+
+ public void addRepeatLog(string logInfo)
+ {
+ try
+ {
+ String path = mLogPath + getCurLogFile();
+ //path = @"C:\Users\rexli\AppData\Local\Temp\test.log";
+ if (!File.Exists(path))
+ {
+ using (StreamWriter sw = File.CreateText(path))
+ {
+ sw.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff") + " [LOGGER] " + logInfo);
+ sw.Flush();
+ sw.Close();
+ }
+
+ }
+ else
+ {
+ using (StreamWriter sw = File.AppendText(path))
+ {
+ sw.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:ffff") + " [LOGGER] " + logInfo);
+ sw.Flush();
+ sw.Close();
+ }
+
+ }
+ // Console.WriteLine(logInfo);
+
+ }
+ catch (Exception err)
+ {
+ Console.WriteLine("Exception = " + err);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/n5coredll/N5Core.cs b/n5coredll/N5Core.cs
index 2d910cc..d8c9125 100644
--- a/n5coredll/N5Core.cs
+++ b/n5coredll/N5Core.cs
@@ -1413,6 +1413,73 @@ namespace n5coredll
return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_TIMEOUT);
}
+ public string sendParam()
+ {
+ if (ifBusy)
+ return RequestResult.createRespErrJson("PARAM_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.toJsonParam());
+ if (currReqByteArr == null || currReqByteArr.Length == 0)
+ {
+ closeSerialPort();
+ ifBusy = false;
+ return RequestResult.createRespErrJson("PARAM_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("PARAM_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("PARAM_RESP", ERR_STATUS_TIMEOUT);
+ }
+
public string requestRetrieval(string txnId, int pTimeOut)
{
RetrievalResult retrievalResult = null;
@@ -2276,8 +2343,8 @@ namespace n5coredll
{
Console.WriteLine("Check LRC success! LRC is [" + ObjectUtil.desToHex(new byte[] { nlrc }) + "]");
sendAck();
- string jsonMsg = System.Text.Encoding.Default.GetString(msg);
-
+ //string jsonMsg = System.Text.Encoding.Default.GetString(msg);
+ string jsonMsg = System.Text.Encoding.UTF8.GetString(msg);
onMsgReceived(jsonMsg);
reset();
return;
diff --git a/n5coredll/RequestResult.cs b/n5coredll/RequestResult.cs
index fe57b84..f874082 100644
--- a/n5coredll/RequestResult.cs
+++ b/n5coredll/RequestResult.cs
@@ -30,6 +30,11 @@ namespace n5coredll
return "{\"EVENT_NAME\":\"SETTLE\"}";
}
+ public static string toJsonParam()
+ {
+ return "{\"EVENT_NAME\":\"PARAM\",\"PAYMENT_APP_ID\":\"CC\"}";
+ }
+
public static string toJsonForReprint()
{
return "{\"EVENT_NAME\":\"PRINT\",\"IS_REPRINT\":true}";
diff --git a/n5coredll/n5coredll.csproj b/n5coredll/n5coredll.csproj
index 1709a56..4fd4891 100644
--- a/n5coredll/n5coredll.csproj
+++ b/n5coredll/n5coredll.csproj
@@ -49,6 +49,7 @@
+