From c04d43fa63cb0600def393bad909762cf07e6c98 Mon Sep 17 00:00:00 2001 From: Nguyen Dinh Thuan Date: Tue, 17 Sep 2024 15:51:44 +0700 Subject: [PATCH] check only InitDE70 to continue --- Admin/AdminWindow.xaml | 7 +++- Admin/AdminWindow.xaml.cs | 5 ++- App.config | 3 ++ AppData.cs | 65 ++++++++++++++++++++++++++++++++- DepositSMUCv2.xaml.cs | 6 ++- Properties/Settings.Designer.cs | 12 ++++++ Properties/Settings.settings | 3 ++ 7 files changed, 94 insertions(+), 7 deletions(-) diff --git a/Admin/AdminWindow.xaml b/Admin/AdminWindow.xaml index edf5f8f..f001882 100644 --- a/Admin/AdminWindow.xaml +++ b/Admin/AdminWindow.xaml @@ -16,7 +16,7 @@ - + @@ -86,7 +86,10 @@ - + + + + diff --git a/Admin/AdminWindow.xaml.cs b/Admin/AdminWindow.xaml.cs index cc59835..09478ce 100644 --- a/Admin/AdminWindow.xaml.cs +++ b/Admin/AdminWindow.xaml.cs @@ -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) diff --git a/App.config b/App.config index 4ba075d..cdf5802 100644 --- a/App.config +++ b/App.config @@ -10,6 +10,9 @@ + + 0 + \ No newline at end of file diff --git a/AppData.cs b/AppData.cs index 898f0a5..b22643f 100644 --- a/AppData.cs +++ b/AppData.cs @@ -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; diff --git a/DepositSMUCv2.xaml.cs b/DepositSMUCv2.xaml.cs index fbd02dd..6b56f34 100644 --- a/DepositSMUCv2.xaml.cs +++ b/DepositSMUCv2.xaml.cs @@ -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) { diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index f12ef61..9673d48 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -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; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 8146184..dd57286 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -5,5 +5,8 @@ + + 0 + \ No newline at end of file