AppData --> lấy trạng thái gán thời gian
APIModels--> Bỏ gán thời gian DepositSMUCv2--> Báo đang trong giao dịch chỉ khi đăng nhập thành công
This commit is contained in:
+44
-3
@@ -100,8 +100,8 @@ namespace SafeBagDE70
|
||||
{
|
||||
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;
|
||||
}
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
AppData.cCmdRsp = cCmdRsp;
|
||||
@@ -114,7 +114,7 @@ namespace SafeBagDE70
|
||||
notesInSession = new NotesInSession();
|
||||
spNotesInSession.DataContext = notesInSession;
|
||||
|
||||
AppData.IsInTransaction = true;
|
||||
|
||||
ResetButtons();
|
||||
btnStart.IsEnabled = true;
|
||||
btnLogout.IsEnabled = true;
|
||||
@@ -359,7 +359,7 @@ namespace SafeBagDE70
|
||||
sensorTimer.IsEnabled = false;
|
||||
try
|
||||
{
|
||||
countSensorTimer++;
|
||||
|
||||
|
||||
if (countSensorTimer % 10 == 0)
|
||||
{
|
||||
@@ -392,7 +392,48 @@ namespace SafeBagDE70
|
||||
AppData.DeviceStatus.DeviceTime = DateTime.Now;
|
||||
APIModels.SendHealthCheck(AppData.DeviceStatus);
|
||||
}
|
||||
if (countSensorTimer % 1800 == 0)
|
||||
{
|
||||
if (!AppData.IsInTransaction)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var context = new CDMDbContext())
|
||||
{
|
||||
var startTime = DateTime.Now.Date.AddDays(-2).Date;
|
||||
var unsentHist = context.Histories
|
||||
.Where(x => x.DepositTime >= startTime)
|
||||
.Where(x => ((x.IsSent == null || x.IsSent == false)))
|
||||
.ToList();
|
||||
foreach(var item in unsentHist)
|
||||
{
|
||||
var data2Send = JsonConvert.DeserializeObject<CountingData2Send>(item.Data);
|
||||
var bResult = await APIModels.SendCountingData(data2Send);
|
||||
if (bResult)
|
||||
{
|
||||
item.IsSent = true;
|
||||
context.Update(item);
|
||||
context.SaveChanges();
|
||||
Log.Information("Resend: " + data2Send + " successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("Resend: " + data2Send + " failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex,"Resend failed");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
countSensorTimer++;
|
||||
sensorTimer.IsEnabled = false;
|
||||
GetSensorValue();
|
||||
sensorTimer.IsEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user