From 8a710a40f1bf9ee48d80c24562d6be9d5302090a Mon Sep 17 00:00:00 2001 From: Nguyen Dinh Thuan Date: Fri, 4 Oct 2024 16:47:50 +0700 Subject: [PATCH] =?UTF-8?q?-=20D=E1=BB=ABng=20m=C3=A1y=20khi=20ph=C3=A1t?= =?UTF-8?q?=20hi=E1=BB=87n=20l=E1=BB=97i=20-=20Log=20th=C3=B4ng=20tin=20kh?= =?UTF-8?q?i=20=C4=91=C4=83ng=20nh=E1=BA=ADp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.xaml.cs | 2 +- AppData.cs | 5 +---- SafeBagDE70.csproj | 1 + UserControl/DepositSMUCv2.xaml.cs | 29 +++++++++++++++++++++++++---- UserControl/WelcomeUC.xaml.cs | 24 +++++++++++++++++------- 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index c3f7f46..dad8a54 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -77,7 +77,7 @@ namespace SafeBagDE70 StateMachineConfig = new StateMachineConfig(); configuration.GetSection("StateMachine").Bind(StateMachineConfig); - Log.Information("START APP"); + Log.Information("START APP version: "+AppData.CurrentVersion); } catch (Exception ex) { diff --git a/AppData.cs b/AppData.cs index 3273854..a2d3f78 100644 --- a/AppData.cs +++ b/AppData.cs @@ -975,10 +975,6 @@ namespace SafeBagDE70 RecvDat=recv_data; if (AppData.cCmdRsp != null) { CDMStatus = RequestTime.ToString("yyyy/MM/dd HH:mm:ss ") + GetSRStatus(); - if (recv_data.leng > 18) - { - - } } } private string? _CDMStatus; @@ -1055,5 +1051,6 @@ namespace SafeBagDE70 { NORMAL = 0, DISCONNECT_SERIALPORT=1, + ERROR = 3, } } diff --git a/SafeBagDE70.csproj b/SafeBagDE70.csproj index f79f865..7e0b6ed 100644 --- a/SafeBagDE70.csproj +++ b/SafeBagDE70.csproj @@ -6,6 +6,7 @@ enable true icon\logo.ico + 1.1.0 diff --git a/UserControl/DepositSMUCv2.xaml.cs b/UserControl/DepositSMUCv2.xaml.cs index ff375bb..6ae6aa6 100644 --- a/UserControl/DepositSMUCv2.xaml.cs +++ b/UserControl/DepositSMUCv2.xaml.cs @@ -396,8 +396,6 @@ namespace SafeBagDE70 sensorTimer.IsEnabled = false; try { - - if (countSensorTimer % 10 == 0) { GetPrinterStatus(); @@ -435,17 +433,40 @@ namespace SafeBagDE70 AppData.GetCDMState(); if (AppData.cCmdRsp==null || AppData.cCmdRsp.cmd_result == SendStatus.SEND_DAT_ERR || AppData.cCmdRsp.cmd_result == SendStatus.SEND_ERR) { - AppData.CDMSTATE.CDMStatus = "CDM: LỖI"; + AppData.CDMSTATE.CDMStatus = "CDM: LỖI KẾT NỐI"; AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.DISCONNECT_SERIALPORT; } + else if (AppData.cCmdRsp.recv_dat.dat[1]==0x1C) + { + AppData.CDMSTATE.CDMStatus = "CDM: LỖI INITIALIZATION ERROR"; + AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.ERROR; + } else { AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.NORMAL; } if (AppData.DeviceStatus.CDMStatus != prevCDMState) { - prevCDMState = AppData.DeviceStatus.CDMStatus; APIModels.SendEvent(AppData.DeviceStatus); + + if (AppData.DeviceStatus.CDMStatus==(int)CDMStatusCode.ERROR|| + AppData.DeviceStatus.CDMStatus == (int)CDMStatusCode.DISCONNECT_SERIALPORT) + { + Log.Error(AppData.CDMSTATE.CDMStatus); + + StopTimers(); + ShowError(AppData.CDMSTATE.CDMStatus); + } + else + { + if(AppData.DeviceStatus.CDMStatus== (int)CDMStatusCode.NORMAL&& + ( prevCDMState == (int)CDMStatusCode.ERROR || + prevCDMState == (int)CDMStatusCode.DISCONNECT_SERIALPORT)) + { + mainWindow.ShowWelcomeScreen(); + } + } + prevCDMState = AppData.DeviceStatus.CDMStatus; } } } diff --git a/UserControl/WelcomeUC.xaml.cs b/UserControl/WelcomeUC.xaml.cs index 3851892..9d0d360 100644 --- a/UserControl/WelcomeUC.xaml.cs +++ b/UserControl/WelcomeUC.xaml.cs @@ -66,7 +66,7 @@ namespace SafeBagDE70 } private void LoginButton_Click(object sender, RoutedEventArgs e) { - + Log.Information("Login sử dụng PINCODE"); string pin = PinCodeBox.Text; if (ValidatePin(pin)) @@ -89,10 +89,14 @@ namespace SafeBagDE70 ((MainWindow)Application.Current.MainWindow).ShowDepositScreen(); //DialogResult = true; //this.Close(); + var str = "Login Pincode thành công"; + Log.Information(str); } else { - lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại"; + var str = "PINCODE không đúng, vui lòng thử lại"; + Log.Information(str); + lblPincodeError.Content =str ; } } } @@ -187,6 +191,8 @@ namespace SafeBagDE70 } private void OnBarcodeEvent(short eventType, ref string pscanData) { + var str = "Login QRCODE thành công"; + Log.Information(str); string xmlString = pscanData; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlString); @@ -216,10 +222,14 @@ namespace SafeBagDE70 AppData.CurrentCustomerAccount = cca; AppData.CreateNewTransactionCode(); ((MainWindow)Application.Current.MainWindow).ShowDepositScreen(); + str = "Login QRCode thành công"; + Log.Information(str); } else { - lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại"; + str = "QRCODE không đúng, vui lòng thử lại"; + Log.Information(str); + lblQRcodeError.Content = str; } } @@ -266,10 +276,10 @@ namespace SafeBagDE70 } else { - this.Dispatcher.Invoke(() => - { - lblQRcodeError.Content = "CRC is invalid."; - }); + //this.Dispatcher.Invoke(() => + //{ + // lblQRcodeError.Content = "CRC is invalid."; + //}); }