From b8d7056e424b5732a9282f0e935d3da14b657cff Mon Sep 17 00:00:00 2001 From: thuannd88 Date: Mon, 9 Sep 2024 11:35:03 +0700 Subject: [PATCH] try catch init --- AppData.cs | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/AppData.cs b/AppData.cs index 489cf3c..7503bea 100644 --- a/AppData.cs +++ b/AppData.cs @@ -37,12 +37,37 @@ namespace SafeBagDE70 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(); using (var context = new CDMDbContext()) { var customers = context.Customers; - foreach(var customer in customers) + foreach (var customer in customers) { var ca = new CustomerAccount { @@ -55,19 +80,8 @@ namespace SafeBagDE70 } } 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; private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time