wait sql init successfully

This commit is contained in:
thuannd88
2024-09-16 19:19:00 +07:00
parent 87896e8def
commit 26ba949d1f
6 changed files with 105 additions and 68 deletions
+6 -4
View File
@@ -37,12 +37,11 @@ namespace SafeBagDE70
public static string BaseURL = "";
public static int TenantId = 0;
public static DeviceStatus? DeviceStatus = null;
public static bool bInitUser = false;
public static void Init()
{
try
{
CDMSTATE = new CDMSTATE();
DeviceStatus = new DeviceStatus
{
@@ -55,7 +54,7 @@ namespace SafeBagDE70
Notes = "",
OtherError = 0,
};
InitUsers();
bInitUser=InitUsers();
}
catch (Exception ex)
{
@@ -69,7 +68,7 @@ namespace SafeBagDE70
}
private static void InitUsers()
private static bool InitUsers()
{
int retryCount = 0;
int maxRetries = 20; // Max retries before giving up
@@ -97,6 +96,8 @@ namespace SafeBagDE70
}
CurrentCustomerAccount = customerAccounts[0];
Log.Information("InitUsers thành công");
bInitUser = true;
break;
}
catch (Exception ex)
{
@@ -116,6 +117,7 @@ namespace SafeBagDE70
Thread.Sleep(delay);
}
}
return bInitUser;
}
public static CDMSTATE? CDMSTATE = null;
private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time