try catch init

This commit is contained in:
thuannd88
2024-09-09 11:35:03 +07:00
parent 7f0a9bf1c8
commit b8d7056e42
+26 -12
View File
@@ -37,7 +37,32 @@ namespace SafeBagDE70
public static void Init() public static void Init()
{ {
try
{
CDMSTATE = new CDMSTATE();
DeviceStatus = new DeviceStatus
{
Device = Environment.MachineName,
TenantId = AppData.TenantId,
Status = 0,
CDMStatus = 0,
PrinterStatus = 0,
SensorStatus = 0,
Notes = "",
OtherError = 0,
};
InitUsers();
}
catch (Exception ex)
{
Log.Fatal(ex, "AppInit");
}
}
private static void InitUsers()
{
customerAccounts = new List<CustomerAccount>(); customerAccounts = new List<CustomerAccount>();
using (var context = new CDMDbContext()) using (var context = new CDMDbContext())
{ {
@@ -55,19 +80,8 @@ namespace SafeBagDE70
} }
} }
CurrentCustomerAccount = customerAccounts[0]; CurrentCustomerAccount = customerAccounts[0];
CDMSTATE=new CDMSTATE();
DeviceStatus = new DeviceStatus
{
Device = Environment.MachineName,
TenantId = AppData.TenantId,
Status = 0,
CDMStatus = 0,
PrinterStatus = 0,
SensorStatus = 0,
Notes = "",
OtherError = 0,
};
} }
public static CDMSTATE? CDMSTATE = null; public static CDMSTATE? CDMSTATE = null;
private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time