update trạng thái trang sau

This commit is contained in:
thuannd88
2024-09-17 17:21:40 +07:00
parent c04d43fa63
commit 47d2bc19c9
3 changed files with 23 additions and 11 deletions
+6 -7
View File
@@ -16,7 +16,7 @@
<!-- Top Bar -->
<RowDefinition Height="*"/>
<!-- Main Content Area -->
<RowDefinition Height="150"/>
<RowDefinition Height="100"/>
<!-- Footer -->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -84,12 +84,11 @@
<ContentControl Grid.Row="1" Grid.Column="1" x:Name="MainContentControl" Margin="10"/>
<!-- Footer -->
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal" Background="LightGray">
<TextBlock Text="Admin Panel" VerticalAlignment="Center" Margin="10" Foreground="White" FontSize="14"/>
<TextBlock x:Name="lblCDMStatus" Text="{Binding CDMStatus}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Foreground="Red" FontSize="20"/>
<TextBlock x:Name="lblPrinterStatus" Text="{Binding PrinterStatus}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Foreground="Red" FontSize="20"/>
<TextBlock x:Name="lblSensorStatus" Text="{Binding SensorStatus}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Foreground="Red" FontSize="20"/>
<TextBlock x:Name="lblDeviceStatus" Text="{Binding DeviceStatus}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Foreground="Red" FontSize="20"/>
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Background="LightGray">
<TextBlock x:Name="lblPrinterStatus" Text="{Binding PrinterStatus}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,10,0" Foreground="Red" FontSize="16"/>
<TextBlock x:Name="lblCDMStatus" Text="{Binding CDMStatus}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,10,0" Foreground="Red" FontSize="16"/>
<TextBlock x:Name="lblSensorStatus" Text="{Binding SensorStatus}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,10,0" Foreground="Red" FontSize="16"/>
<TextBlock x:Name="lblDeviceStatus" Text="{Binding DeviceStatus}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,10,0" Foreground="Red" FontSize="16"/>
</StackPanel>
</Grid>
</hc:Window>
+2 -2
View File
@@ -423,7 +423,7 @@ namespace SafeBagDE70
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private string? _PrinterStatus;
public string? Printertatus
public string? PrinterStatus
{
get
{
@@ -435,7 +435,7 @@ namespace SafeBagDE70
{
_PrinterStatus = value;
OnPropertyChanged(nameof(Printertatus));
OnPropertyChanged(nameof(PrinterStatus));
}
}
}
+15 -2
View File
@@ -180,6 +180,7 @@ namespace SafeBagDE70
if (!serialPortSensor.IsOpen)
serialPortSensor.Open();
}
AppData.ADMINDEVICESTATUS.SensorStatus = "Sensor: OK";
return true;
}catch(Exception ex)
{
@@ -187,6 +188,7 @@ namespace SafeBagDE70
AppData.DeviceStatus.Description = ex.Message;
APIModels.SendEvent(AppData.DeviceStatus);
Log.Information(ex, "LỖI KẾT NỐI SENSOR");
AppData.ADMINDEVICESTATUS.SensorStatus = "Sensor: Error";
}
return false;
}
@@ -214,6 +216,7 @@ namespace SafeBagDE70
if (!serialPortDE70.IsOpen)
serialPortDE70.Open();
}
return true;
}
catch(Exception ex)
@@ -222,6 +225,7 @@ namespace SafeBagDE70
AppData.DeviceStatus.Description = ex.Message;
APIModels.SendEvent(AppData.DeviceStatus);
Log.Information(ex, "LỖI KẾT NỐI CDM");
AppData.CDMSTATE.CDMStatus = "CDM: Error";
}
return false;
}
@@ -400,13 +404,18 @@ namespace SafeBagDE70
StopTimers();
strPrinterMessage = "MÁY IN HẾT GIẤY! ĐỀ NGHỊ THAY GIẤY";
ShowError(strPrinterMessage);
AppData.ADMINDEVICESTATUS.Printertatus = strPrinterMessage;
AppData.ADMINDEVICESTATUS.PrinterStatus = strPrinterMessage;
}
else if (status.StsNEARENDPAP)
{
strPrinterMessage = "MÁY IN GẦN HẾT GIẤY";
AppData.DeviceStatus.PrinterStatus = (int)PrinterStatusCode.NEARPAPEROUT;
AppData.ADMINDEVICESTATUS.Printertatus = strPrinterMessage;
AppData.ADMINDEVICESTATUS.PrinterStatus = strPrinterMessage;
}
else
{
AppData.ADMINDEVICESTATUS.PrinterStatus = "MÁY IN OK";
}
if (AppData.DeviceStatus.PrinterStatus != prevPrinterStatus)
{
@@ -420,6 +429,10 @@ namespace SafeBagDE70
AppData.DeviceStatus.DeviceTime = DateTime.Now;
APIModels.SendHealthCheck(AppData.DeviceStatus);
}
if(countSensorTimer%5==0)
{
AppData.ADMINDEVICESTATUS.DeviceStatus = AppData.IsInternetOk == false ? "Kết nối Internet: Không" : "Kết nối Internet: OK";
}
if (countSensorTimer % 300 == 0)
{
AppData.ResendData();