- Dừng máy khi phát hiện lỗi

- Log thông tin khi đăng nhập
This commit is contained in:
Nguyen Dinh Thuan
2024-10-04 16:47:50 +07:00
parent ac6074c9bf
commit 8a710a40f1
5 changed files with 45 additions and 16 deletions
+25 -4
View File
@@ -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;
}
}
}
+17 -7
View File
@@ -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.";
//});
}