resend
This commit is contained in:
@@ -47,10 +47,12 @@ namespace SafeBagDE70.API
|
||||
TaskSendHealthCheck(deviceStatus).ContinueWith(t => {
|
||||
if (t.IsCompletedSuccessfully)
|
||||
{
|
||||
AppData.IsInternetOk = true;
|
||||
Log.Information("Send HealthCheck Success");
|
||||
}
|
||||
else
|
||||
{
|
||||
AppData.IsInternetOk = false;
|
||||
Log.Information("Send HealthCheck Fail");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace SafeBagDE70
|
||||
public static int MaxNotes = 300;
|
||||
public static string BaseURL = "";
|
||||
public static int TenantId = 0;
|
||||
public static bool IsInternetOk = false;
|
||||
public static DeviceStatus? _DeviceStatus = null;
|
||||
public static DeviceStatus? DeviceStatus
|
||||
{
|
||||
|
||||
+24
-14
@@ -392,11 +392,30 @@ namespace SafeBagDE70
|
||||
AppData.DeviceStatus.DeviceTime = DateTime.Now;
|
||||
APIModels.SendHealthCheck(AppData.DeviceStatus);
|
||||
}
|
||||
if (countSensorTimer % 1800 == 0)
|
||||
if (countSensorTimer % 300 == 0)
|
||||
{
|
||||
if (!AppData.IsInTransaction)
|
||||
ResenData();
|
||||
}
|
||||
countSensorTimer++;
|
||||
sensorTimer.IsEnabled = false;
|
||||
GetSensorValue();
|
||||
sensorTimer.IsEnabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
Log.Fatal(ex, "Sensor_Timer");
|
||||
}
|
||||
sensorTimer.IsEnabled = true;
|
||||
}
|
||||
static Task? resendTask=null;
|
||||
private static void ResenData()
|
||||
{
|
||||
if (!AppData.IsInTransaction && AppData.IsInternetOk)
|
||||
{
|
||||
|
||||
if(resendTask==null || resendTask.IsCompleted)
|
||||
{
|
||||
resendTask = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -429,21 +448,12 @@ namespace SafeBagDE70
|
||||
{
|
||||
Log.Fatal(ex, "Resend failed");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
countSensorTimer++;
|
||||
sensorTimer.IsEnabled = false;
|
||||
GetSensorValue();
|
||||
sensorTimer.IsEnabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Sensor_Timer");
|
||||
}
|
||||
sensorTimer.IsEnabled = true;
|
||||
}
|
||||
|
||||
Stopwatch watch = new Stopwatch();
|
||||
private void GetSensorValue()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user