- fix Restart app

- Check thêm gửi giao dịch thành công
This commit is contained in:
thuannd88
2024-09-24 18:05:46 +07:00
parent a55e7de435
commit 055c6b6343
2 changed files with 30 additions and 13 deletions
+8
View File
@@ -214,9 +214,17 @@ namespace SafeBagDE70.API
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK) if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
{ {
var jsonResponse = await response.Content.ReadAsStringAsync(); var jsonResponse = await response.Content.ReadAsStringAsync();
if(jsonResponse!=null)
{
var countingRecv=JsonConvert.DeserializeObject<CountingData2Send>(jsonResponse);
if (countingRecv!=null && countingRecv.TransactionCode == data2Send.TransactionCode)
{
bSuccess = true; bSuccess = true;
} }
} }
}
}
catch(Exception ex) catch(Exception ex)
{ {
+11 -2
View File
@@ -19,6 +19,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Threading;
namespace SafeBagDE70 namespace SafeBagDE70
{ {
@@ -85,21 +86,29 @@ namespace SafeBagDE70
} }
} }
public static void RestartApp() public static void RestartApp(bool bAutoRestart=false)
{
Application.Current.Dispatcher.Invoke(() =>
{ {
if (AppData.IsInTransaction) if (AppData.IsInTransaction)
{
if (!bAutoRestart)
{ {
MessageBox.Show("LƯU Ý, THAO TÁC NÀY SẼ LÀM MẤT TẤT CẢ DỮ LIỆU ĐANG THAO TÁC. " + MessageBox.Show("LƯU Ý, THAO TÁC NÀY SẼ LÀM MẤT TẤT CẢ DỮ LIỆU ĐANG THAO TÁC. " +
"HÃY HOÀN TẤT GIAO DỊCH ĐỂ TIẾP TỤC", "CẢNH BÁO", MessageBoxButton.OK); "HÃY HOÀN TẤT GIAO DỊCH ĐỂ TIẾP TỤC", "CẢNH BÁO", MessageBoxButton.OK);
} }
}
else else
{ {
string exePath = Process.GetCurrentProcess().MainModule.FileName; string exePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(exePath); Process.Start(exePath);
System.Windows.Application.Current.Shutdown(); System.Windows.Application.Current.Shutdown();
} }
});
} }
public static void InitDeviceStatus() public static void InitDeviceStatus()
{ {
@@ -439,7 +448,7 @@ namespace SafeBagDE70
if (!IsInTransaction) if (!IsInTransaction)
{ {
await APIModels.UpdateDeviceCommand(command.Id,1); await APIModels.UpdateDeviceCommand(command.Id,1);
RestartApp(); RestartApp(true);
} }
break; break;
} }