- 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
+9 -1
View File
@@ -214,7 +214,15 @@ namespace SafeBagDE70.API
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
bSuccess = true;
if(jsonResponse!=null)
{
var countingRecv=JsonConvert.DeserializeObject<CountingData2Send>(jsonResponse);
if (countingRecv!=null && countingRecv.TransactionCode == data2Send.TransactionCode)
{
bSuccess = true;
}
}
}
}
catch(Exception ex)
+21 -12
View File
@@ -19,6 +19,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
namespace SafeBagDE70
{
@@ -85,21 +86,29 @@ namespace SafeBagDE70
}
}
public static void RestartApp()
public static void RestartApp(bool bAutoRestart=false)
{
if (AppData.IsInTransaction)
Application.Current.Dispatcher.Invoke(() =>
{
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);
}
else
{
string exePath = Process.GetCurrentProcess().MainModule.FileName;
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. " +
"HÃY HOÀN TẤT GIAO DỊCH ĐỂ TIẾP TỤC", "CẢNH BÁO", MessageBoxButton.OK);
}
}
else
{
Process.Start(exePath);
string exePath = Process.GetCurrentProcess().MainModule.FileName;
System.Windows.Application.Current.Shutdown();
}
Process.Start(exePath);
System.Windows.Application.Current.Shutdown();
}
});
}
public static void InitDeviceStatus()
{
@@ -439,7 +448,7 @@ namespace SafeBagDE70
if (!IsInTransaction)
{
await APIModels.UpdateDeviceCommand(command.Id,1);
RestartApp();
RestartApp(true);
}
break;
}