From 01e63a0f4e1708bedc63f492b70dd26d47ce8803 Mon Sep 17 00:00:00 2001 From: thuannd88 Date: Tue, 22 Oct 2024 18:18:50 +0700 Subject: [PATCH] fix Abnormal Storate --- Admin/AdminConfigurationUC.xaml.cs | 18 ++++++++++-- AppData.cs | 46 +++++++++++++++++++++--------- UserControl/DepositSMUCv2.xaml.cs | 5 ++-- appsettings.json | 2 +- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/Admin/AdminConfigurationUC.xaml.cs b/Admin/AdminConfigurationUC.xaml.cs index 69af356..2a5d8be 100644 --- a/Admin/AdminConfigurationUC.xaml.cs +++ b/Admin/AdminConfigurationUC.xaml.cs @@ -101,19 +101,26 @@ namespace SafeBagDE70.Admin private void btnSoftImportantError_Click(object sender, RoutedEventArgs e) { var state = AppData.GetCDMState(); - if(state.IsNotesInEscrow>0|| + + if (state.IsNotesInEscrow>0|| state.IsNotesInRejectPocket>0|| state.IsNotesInHopper>0) { + lblCounterStatus.Foreground = new SolidColorBrush(Colors.Red); lblCounterStatus.Text = "Vẫn còn tiền trong máy, đề nghị lấy tiền ra khỏi các ngăn và kiểm tra tiền kẹt"; } else { + lblCounterStatus.Foreground = new SolidColorBrush(Colors.Green); + lblCounterStatus.Text = "Đang thực hiện Reset lỗi"; + Log.Information("[ADMIN] Reset CDM Error"); var bSuccess = AppData.ResetAbnormalStorage605(); - if(bSuccess) + if (bSuccess) { Log.Information("[ADMIN] Reset CDM AbnormalStorage successfully"); + + lblCounterStatus.Foreground = new SolidColorBrush(Colors.Green); lblCounterStatus.Text = "Reset lỗi thành công"; ((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen(); Task.Run(() => @@ -124,7 +131,12 @@ namespace SafeBagDE70.Admin lblCounterStatus.Text = ""; }); }); - } + } + else + { + lblCounterStatus.Foreground = new SolidColorBrush(Colors.Red); + lblCounterStatus.Text = "Reset lỗi không thành công"; + } } } } diff --git a/AppData.cs b/AppData.cs index ecc472f..d51993d 100644 --- a/AppData.cs +++ b/AppData.cs @@ -708,15 +708,18 @@ namespace SafeBagDE70 } public static bool ResetAbnormalStorage605() { - + + var cCmdRsp = AppData.cCmdRsp; bool bSuccess = false; if (cCmdRsp != null) { + Log.Information("START ABNORMAL STORAGE RESET PROC"); cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE); LogCmdData(); - if (cCmdRsp.recv_dat != null &&(cCmdRsp.recv_dat.dat[1] == 0x1C && cCmdRsp.recv_dat.dat[2] == 0x4C)) + if (cCmdRsp.recv_dat != null && + ((cCmdRsp.recv_dat.dat[18] & 0xF0) == 0xE0)) { //0. Check notes in escrow or not? @@ -748,38 +751,55 @@ namespace SafeBagDE70 LogCmdData(); recvData = cCmdRsp.recv_dat; var SR2 = recvData.dat[1]; - var S2 = recvData.dat[recvData.leng - 1]; + var S2 = recvData.dat[18]; if (SR2 == 0x1C && (S2==0xE2 || S2==0xE4)) { cCmdRsp.SendXXCmd((byte)Command.CMD_DE_RESET); LogCmdData(); + Thread.Sleep(1000); for (int i=0;i<10;i++) { cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE); LogCmdData(); Thread.Sleep(1000); - S2 = recvData.dat[recvData.leng - 1]; - if (S2 == 0xE7) + S2 = recvData.dat[18]; + SR2 = recvData.dat[1]; + if (SR2 == 0x07) break; - } - - Thread.Sleep(1000); + } + Thread.Sleep(2000); + cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART); LogCmdData(); - Thread.Sleep(1000); + Thread.Sleep(2000); + cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART); + Thread.Sleep(2000); LogCmdData(); - if (cCmdRsp.recv_dat.dat[1] == 0x04 && cCmdRsp.recv_dat.dat[2] == 0x41) + if ((cCmdRsp.recv_dat.dat[1] == 0x07 || cCmdRsp.recv_dat.dat[1]==0x09) && cCmdRsp.recv_dat.dat[2] == 0x41) { - bSuccess = true; + //Wait until SR2=0x04 + for(int i = 0; i < 10; i++) + { + cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE); + LogCmdData(); + Thread.Sleep(1000); + + SR2 = recvData.dat[1]; + if (SR2 == 0x04) + { + bSuccess = true; + } + } + } } else { } - + Log.Information("END ABNORMAL STORAGE RESET PROC"); } } return bSuccess; @@ -1072,7 +1092,7 @@ namespace SafeBagDE70 public int PrintingCountFromNPO = 0;//Transaction Count From Near Paper Out public bool IsStopPrinting() { - if (IsPrinterNearPaperOut && PrintingCountFromNPO >= 20) + if (IsPrinterNearPaperOut && PrintingCountFromNPO >= 50) { return true; } diff --git a/UserControl/DepositSMUCv2.xaml.cs b/UserControl/DepositSMUCv2.xaml.cs index d7eecb0..4fc125c 100644 --- a/UserControl/DepositSMUCv2.xaml.cs +++ b/UserControl/DepositSMUCv2.xaml.cs @@ -1145,10 +1145,11 @@ namespace SafeBagDE70 Dispatcher.Invoke(() => { + var customerId = AppData.CurrentCustomerAccount == null ? "" : AppData.CurrentCustomerAccount.CustomerId; str = $"PHIÊN GIAO DỊCH KHÔNG HỢP LỆ (SỐ TIỀN GIAO DỊCH KHÔNG KHỚP), VUI LÒNG BÁO CÁO LẠI CHI NHÁNH" + - $"\r\n MÃ GD: {AppData.GetTransactionCode()} " + + $"\r\nMÃ GD: {AppData.GetTransactionCode()} " + $"\r\nMÁY: {Environment.MachineName}" + - $"\r\nMÃ NV: {AppData.CurrentCustomerAccount.CustomerId}"; + $"\r\nMÃ NV: {customerId}"; Log.Information(str); ShowError(str); }); diff --git a/appsettings.json b/appsettings.json index 62ae404..058e287 100644 --- a/appsettings.json +++ b/appsettings.json @@ -16,7 +16,7 @@ }, "CDM": { "MaxNotes": 9999 - }, + }, "Device": { "BaseURL": "http://203.171.20.94:9103/Safebag/", "TenantId": 5