Retry lấy số tiền trong két

Hiển thị giao dịch trong log
This commit is contained in:
Nguyen Dinh Thuan
2024-09-27 14:40:35 +07:00
parent d648718824
commit 3b93564587
2 changed files with 21 additions and 5 deletions
+11 -2
View File
@@ -12,6 +12,7 @@ using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
using System.Text.RegularExpressions;
@@ -266,10 +267,18 @@ namespace SafeBagDE70
}
public static byte[] GetCassetteData()
{
for(int i = 0; i < 2; i++)//Retry if failed
{
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_READ_CASSETTE);
if (cCmdRsp.recv_dat.dat[0] != 0x40)
{
Thread.Sleep(1000);
}
else
break;
}
var data = cCmdRsp.recv_dat.dat;
StringBuilder str = new StringBuilder();
var recv_dat = cCmdRsp.recv_dat;
@@ -477,7 +486,7 @@ namespace SafeBagDE70
Log.Error("GetandExecuteCommands error: "+str);
}
}
static string deviceStatusFileName = "device_status.txt";
static string deviceStatusFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"device_status.txt");
public static void GetDeviceStatusFromFile()
{
try
+9 -2
View File
@@ -98,10 +98,16 @@ namespace SafeBagDE70
string? transactionCode = null;
if (AppData.IsAuthenticated)
{
transactionCode = AppData.GetTransactionCode();
lblUser.Content = $"Xin chào khách hàng: {AppData.CurrentCustomerAccount.Name} (Gian hàng {AppData.CurrentCustomerAccount.CustomerId})";
lblTransactionCode.Content = $"Mã GD: {transactionCode}";
AppData.IsInTransaction = true;
var str = $"MÃ GD: {AppData.GetTransactionCode()} " +
$"\r\nMÁY: {Environment.MachineName}" +
$"\r\nMÃ NV: {AppData.CurrentCustomerAccount.CustomerId}";
Log.Information(str);
}
cCmdRsp = new CCmdRsp(serialPortDE70);
AppData.cCmdRsp = cCmdRsp;
@@ -1040,7 +1046,7 @@ namespace SafeBagDE70
var str = "BEFORE STORE [CASSETTE]" + AppData.GetNotesString(previousCassetData);
str += "\r\nSTORED: " + GetQuantityFromSessions(sessions, true);
str += "\r\nSTACKER: " + GetQuantityFromSessions(sessions, false);
Log.Information(str);
AppData.DeviceStatus.Description = str;
APIModels.SendEvent(AppData.DeviceStatus);
@@ -1072,13 +1078,14 @@ namespace SafeBagDE70
}
else
{
Log.Information(str);
Dispatcher.Invoke(() =>
{
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ÁY: {Environment.MachineName}" +
$"\r\nMÃ NV: {AppData.CurrentCustomerAccount.CustomerId}";
Log.Information(str);
ShowError(str);
});