You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
7.6 KiB
164 lines
7.6 KiB
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 toJsonForHealthCheck()
|
|
{
|
|
return "{\"EVENT_NAME\":\"HEALTH_CHECK\"}";
|
|
}
|
|
|
|
public static string toJsonForCreateOrder(string txnId, decimal txnAmt, string paymentType, string billType)
|
|
{
|
|
|
|
string cardSaleMsg = "{\"EVENT_NAME\":\"CREATE_ORDER\",\"TXN_ID\":\"" + txnId + "\",\"TXN_AMT\":" + txnAmt + ",\"PAYMENT_TYPE\":\"" + paymentType + "\",\"BILL_TYPE_ID\":\"" + billType + "\"}";
|
|
return cardSaleMsg;
|
|
}
|
|
|
|
public static string toJsonForSettlement()
|
|
{
|
|
return "{\"EVENT_NAME\":\"SETTLE\"}";
|
|
}
|
|
|
|
public static string toJsonForSummaryEnquiry(String txnDateRange)
|
|
{
|
|
return "{\"EVENT_NAME\":\"SUMMARY_ENQUIRY\",\"TXN_DATE_START_TO_END\":\"" + txnDateRange + "\"}";
|
|
}
|
|
|
|
public static string toJsonForReprint(String txnId)
|
|
{
|
|
return "{\"EVENT_NAME\":\"PRINT\",\"TXN_ID\":\"" + txnId + "\",\"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 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 + "\"}";
|
|
}
|
|
|
|
public static String createRespErrJson(String eventName, String status, String respCode, String errMsg)
|
|
{
|
|
return "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}";
|
|
}
|
|
|
|
public static String createRespErrJson(String functionName, String eventName, String status, String respCode, String errMsg)
|
|
{
|
|
LogUtil.getInstance().addRepeatLog("[result]: " + "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}");
|
|
LogUtil.getInstance().addRepeatLog("<<<<<<<<<<<<<<<< End Event [" + functionName + "] <<<<<<<<<<<<<<<<");
|
|
|
|
return "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}";
|
|
}
|
|
|
|
public static String createRespErrJson(String functionName, String eventName, String txnId, String paymentType, String txnAmt, String status, String respCode, String errMsg)
|
|
{
|
|
LogUtil.getInstance().addRepeatLog("[result]: " + "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}");
|
|
LogUtil.getInstance().addRepeatLog("<<<<<<<<<<<<<<<< End Event [" + functionName + "] <<<<<<<<<<<<<<<<");
|
|
if (txnId == null || txnId == "")
|
|
txnId = "";
|
|
return "{\"EVENT_NAME\":\"" + eventName + "\",\"TXN_ID\":\"" + txnId + "\",\"PAYMENT_TYPE\":\"" + paymentType + "\",\"TXN_AMT\":\"" + txnAmt + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}";
|
|
}
|
|
|
|
public static String createRespErrJson(String functionName, String eventName, String txnId, String status, String respCode, String errMsg)
|
|
{
|
|
LogUtil.getInstance().addRepeatLog("[result]: " + "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}");
|
|
LogUtil.getInstance().addRepeatLog("<<<<<<<<<<<<<<<< End Event [" + functionName + "] <<<<<<<<<<<<<<<<");
|
|
if (txnId == null || txnId == "")
|
|
txnId = "";
|
|
return "{\"EVENT_NAME\":\"" + eventName + "\",\"TXN_ID\":\"" + txnId + "\",\"STATUS\":\"" + status + "\",\"RESP_CODE\":\"" + respCode + "\",\"ERR_MSG\":\"" + errMsg + "\"}";
|
|
}
|
|
|
|
public static String createRespProcessingJson(String functionName, String eventName, String txnId, String paymentType, String txnAmt)
|
|
{
|
|
LogUtil.getInstance().addRepeatLog("[result]: " + "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + "03" + "\"}");
|
|
LogUtil.getInstance().addRepeatLog("<<<<<<<<<<<<<<<< End Event [" + functionName + "] <<<<<<<<<<<<<<<<");
|
|
if (txnId == null || txnId == "")
|
|
txnId = "";
|
|
return "{\"EVENT_NAME\":\"" + eventName + "\",\"TXN_ID\":\"" + txnId + "\",\"PAYMENT_TYPE\":\"" + paymentType + "\",\"TXN_AMT\":\"" + txnAmt + "\",\"STATUS\":\"" + "03" + "\"}";
|
|
}
|
|
|
|
public static String createRespProcessingJson(String functionName, String eventName, String txnId, String paymentType, String txnAmt, String respCode)
|
|
{
|
|
LogUtil.getInstance().addRepeatLog("[result]: " + "{\"EVENT_NAME\":\"" + eventName + "\",\"STATUS\":\"" + "03" + "\",\"RESP_CODE\":\"" + respCode + "\"}");
|
|
LogUtil.getInstance().addRepeatLog("<<<<<<<<<<<<<<<< End Event [" + functionName + "] <<<<<<<<<<<<<<<<");
|
|
if (txnId == null || txnId == "")
|
|
txnId = "";
|
|
return "{\"EVENT_NAME\":\"" + eventName + "\",\"TXN_ID\":\"" + txnId + "\",\"PAYMENT_TYPE\":\"" + paymentType + "\",\"TXN_AMT\":\"" + txnAmt + "\",\"STATUS\":\"" + "03" + "\",\"RESP_CODE\":\"" + respCode + "\"}";
|
|
}
|
|
}
|
|
}
|
|
|