check only InitDE70 to continue

This commit is contained in:
Nguyen Dinh Thuan
2024-09-17 15:51:44 +07:00
parent 0ea0f79351
commit c04d43fa63
7 changed files with 94 additions and 7 deletions
+5 -2
View File
@@ -16,7 +16,7 @@
<!-- Top Bar -->
<RowDefinition Height="*"/>
<!-- Main Content Area -->
<RowDefinition Height="50"/>
<RowDefinition Height="150"/>
<!-- Footer -->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -86,7 +86,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="lblStatus" Text="{Binding CDMStatus}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Foreground="Red" 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>
</hc:Window>
+4 -1
View File
@@ -38,7 +38,10 @@ namespace SafeBagDE70.Admin
private void AdminWindow_Loaded(object sender, RoutedEventArgs e)
{
lblStatus.DataContext = AppData.CDMSTATE;
lblCDMStatus.DataContext = AppData.CDMSTATE;
lblDeviceStatus.DataContext = AppData.ADMINDEVICESTATUS;
lblPrinterStatus.DataContext = AppData.ADMINDEVICESTATUS;
lblSensorStatus.DataContext = AppData.ADMINDEVICESTATUS;
}
private void LogoutButton_Click(object sender, RoutedEventArgs e)
+3
View File
@@ -10,6 +10,9 @@
<setting name="RestartTime" serializeAs="String">
<value />
</setting>
<setting name="TransactionNoInDay" serializeAs="String">
<value>0</value>
</setting>
</SafeBagDE70.Properties.Settings>
</userSettings>
</configuration>
+63 -2
View File
@@ -60,6 +60,7 @@ namespace SafeBagDE70
static AppData()
{
CDMSTATE = new CDMSTATE();
ADMINDEVICESTATUS = new ADMINDEVICESTATUS();
//InitDeviceStatus();
}
public static void Init()
@@ -148,7 +149,8 @@ namespace SafeBagDE70
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
public static ADMINDEVICESTATUS? ADMINDEVICESTATUS = null;
private static DateTime CutOffTime = new DateTime(1, 1, 1, 11, 0, 0); // 11:00 a.m as cut-off time
public static string GetNumberPartFromMerchantCode(string merchantCode)
{
@@ -175,7 +177,7 @@ namespace SafeBagDE70
CurrentCustomerAccount.TransactionCount++;
}
var transactionCount = CurrentCustomerAccount.TransactionCount;
string datePart = adjustedDate.ToString("yyyyMMdd");
string datePart = transactionDateTime.ToString("yyyyMMdd");
string timePart = transactionDateTime.ToString("HHmmss");
string transactionCountPart = transactionCount.ToString("D2"); // Ensure 2 digits
@@ -413,6 +415,65 @@ namespace SafeBagDE70
AUTOEND=1,
FULLIFSTORE=2
}
public class ADMINDEVICESTATUS : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private string? _PrinterStatus;
public string? Printertatus
{
get
{
return _PrinterStatus;
}
set
{
if (_PrinterStatus != value)
{
_PrinterStatus = value;
OnPropertyChanged(nameof(Printertatus));
}
}
}
private string? _SensorStatus;
public string? SensorStatus
{
get
{
return _SensorStatus;
}
set
{
if (_SensorStatus != value)
{
_SensorStatus = value;
OnPropertyChanged(nameof(SensorStatus));
}
}
}
private string? _DeviceStatus;
public string? DeviceStatus
{
get
{
return _DeviceStatus;
}
set
{
if (_DeviceStatus != value)
{
_DeviceStatus = value;
OnPropertyChanged(nameof(DeviceStatus));
}
}
}
}
public class CDMSTATE : INotifyPropertyChanged
{
public int IsCassetteFull = 0;
+4 -2
View File
@@ -148,7 +148,7 @@ namespace SafeBagDE70
{
var bInitDE70=InitSerialPortDE70();
var bInitSensor = InitSerialPortSensor();
if (bInitDE70 && bInitSensor)
if (bInitDE70)
return true;
else
{
@@ -185,7 +185,7 @@ namespace SafeBagDE70
{
AppData.DeviceStatus.SensorStatus = (int)SensorStatusCode.ERROR;
AppData.DeviceStatus.Description = ex.Message;
APIModels.SendEvent(AppData.DeviceStatus);
APIModels.SendEvent(AppData.DeviceStatus);
Log.Information(ex, "LỖI KẾT NỐI SENSOR");
}
return false;
@@ -400,11 +400,13 @@ namespace SafeBagDE70
StopTimers();
strPrinterMessage = "MÁY IN HẾT GIẤY! ĐỀ NGHỊ THAY GIẤY";
ShowError(strPrinterMessage);
AppData.ADMINDEVICESTATUS.Printertatus = 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;
}
if (AppData.DeviceStatus.PrinterStatus != prevPrinterStatus)
{
+12
View File
@@ -33,5 +33,17 @@ namespace SafeBagDE70.Properties {
this["RestartTime"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int TransactionNoInDay {
get {
return ((int)(this["TransactionNoInDay"]));
}
set {
this["TransactionNoInDay"] = value;
}
}
}
}
+3
View File
@@ -5,5 +5,8 @@
<Setting Name="RestartTime" Type="System.DateTime" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="TransactionNoInDay" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>