Change Init Users

This commit is contained in:
Nguyen Dinh Thuan
2024-09-11 16:06:27 +07:00
parent b8d7056e42
commit 409d942352
6 changed files with 132 additions and 45 deletions
+13 -8
View File
@@ -39,6 +39,7 @@ namespace SafeBagDE70
{
try
{
InitUsers();
CDMSTATE = new CDMSTATE();
DeviceStatus = new DeviceStatus
{
@@ -51,12 +52,10 @@ namespace SafeBagDE70
Notes = "",
OtherError = 0,
};
InitUsers();
}
catch (Exception ex)
{
Log.Fatal(ex, "AppInit");
Log.Fatal(ex, "AppInit: "+ex.Message);
}
}
@@ -85,12 +84,18 @@ namespace SafeBagDE70
public static CDMSTATE? CDMSTATE = null;
private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time
public static string GetNumberPartFromMerchantCode(string merchantCode)
{
if (merchantCode == null) return "";
var match = Regex.Match(merchantCode, @"\d+$");
string merchantCode_part = match.Value;
return merchantCode_part;
}
public static void CreateNewTransactionCode()
{
DateTime transactionDateTime = DateTime.Now;
var match = Regex.Match(CurrentCustomerAccount.CustomerId, @"\d+$");
string merchantCode_part = match.Value;
string merchantCode_part = GetNumberPartFromMerchantCode(CurrentCustomerAccount.CustomerId);
// Adjust transaction date if it's past cut-off time (12:00 noon)
DateTime prevadjustedDate = CurrentCustomerAccount.TransactionTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1);
@@ -142,7 +147,7 @@ namespace SafeBagDE70
AppData.CDMSTATE.IsNotesInHopper = data[3] & 0x01;
AppData.CDMSTATE.IsStackerFull = (data[2] == 0x43?1:0);
if (data[0] == 0x40 && data[1] == 0x07)
if (data[0] == 0x40 && (data[1] == 0x07 || data[1]==0x09))
AppData.CDMSTATE.IsError = 0;
else
AppData.CDMSTATE.IsError = 1;
@@ -351,8 +356,8 @@ namespace SafeBagDE70
if (RecvDat.leng > 18)
{
var dat = RecvDat.dat;
strStatus += "S1: "+ AppData.cCmdRsp.GetD1Summary(dat[17]);
strStatus += "\r\nS2: " + AppData.cCmdRsp.GetD2Summary(dat[18]);
strStatus += "S1: "+ AppData.cCmdRsp.GetS1Summary(dat[17]);
strStatus += "\r\nS2: " + AppData.cCmdRsp.GetS2Summary(dat[18]);
}
}
return strStatus;