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.
140 lines
4.4 KiB
140 lines
4.4 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 toJsonForSettlement()
|
|
{
|
|
return "{\"EVENT_NAME\":\"SETTLE\"}";
|
|
}
|
|
|
|
public static string toJsonGetInfo()
|
|
{
|
|
// return "{\"EVENT_NAME\":\"GET_INFO\"}";
|
|
return "{\"EVENT_NAME\":\"GETDEVICEINFO\",\"PAYMENT_APP_ID\":\"CC\"}";
|
|
}
|
|
|
|
public static string toCheckUpdate()
|
|
{
|
|
// return "{\"EVENT_NAME\":\"GET_INFO\"}";
|
|
return "{\"EVENT_NAME\":\"CHECKUPDATE\"}";
|
|
}
|
|
|
|
|
|
public static string toExecuteUpdate()
|
|
{
|
|
// return "{\"EVENT_NAME\":\"GET_INFO\"}";
|
|
return "{\"EVENT_NAME\":\"EXECUTEUPDATE\"}";
|
|
}
|
|
|
|
public static string toJsonParam()
|
|
{
|
|
return "{\"EVENT_NAME\":\"PARAM\",\"PAYMENT_APP_ID\":\"CC\"}";
|
|
}
|
|
|
|
public static string toJsonForReprint(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 toJsonForCreateOrder(string inputTxnId, decimal txnAmt, string paymentType)
|
|
{
|
|
string cardSaleMsg = "{\"EVENT_NAME\":\"CREATE_ORDER\",\"TXN_ID\":\"" + inputTxnId + "\",\"TXN_AMT\":" + txnAmt + ",\"PAYMENT_TYPE\":\"" +paymentType + "\",\"PAYMENT_APP_ID\":\"QRC\"}";
|
|
return cardSaleMsg;
|
|
}
|
|
|
|
|
|
public static string toJsonForBatchEnquiry(string settleDate)
|
|
{
|
|
return "{\"EVENT_NAME\":\"BATCH_ENQUIRY\",\"SETTLE_DATE\":\"" + settleDate + "\"}";
|
|
}
|
|
|
|
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 string toJsonHealthCheck()
|
|
{
|
|
return "{\"EVENT_NAME\":\"HEALTH_CHECK\"}";
|
|
}
|
|
|
|
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 + "\"}";
|
|
}
|
|
|
|
}
|
|
}
|
|
|