fix lỗi báo máy in gần hết giấy còn 20 lần in

This commit is contained in:
thuannd88
2024-09-26 13:50:21 +07:00
parent f9f9ba3d49
commit d648718824
3 changed files with 9 additions and 7 deletions
+1
View File
@@ -206,6 +206,7 @@ namespace SafeBagDE70
protected override void OnExit(ExitEventArgs e) protected override void OnExit(ExitEventArgs e)
{ {
// Release the mutex when the application is closed // Release the mutex when the application is closed
AppData.UpdateDeviceStatusToFile();
mutex?.ReleaseMutex(); mutex?.ReleaseMutex();
base.OnExit(e); base.OnExit(e);
} }
-3
View File
@@ -550,13 +550,10 @@ namespace SafeBagDE70
try try
{ {
lock (deviceStatusFileName) lock (deviceStatusFileName)
{
if (File.Exists(deviceStatusFileName))
{ {
var fileContent = JsonConvert.SerializeObject(DeviceStatusFile); var fileContent = JsonConvert.SerializeObject(DeviceStatusFile);
File.WriteAllText(deviceStatusFileName, fileContent); File.WriteAllText(deviceStatusFileName, fileContent);
} }
}
Log.Information("UpdatePrinterStatusFromFile success"); Log.Information("UpdatePrinterStatusFromFile success");
} }
catch (Exception ex) catch (Exception ex)
+6 -2
View File
@@ -448,10 +448,14 @@ namespace SafeBagDE70
private void GetPrinterStatus() private void GetPrinterStatus()
{ {
var status = printerManager.GetStatus(); var status = printerManager.GetStatus();
var strPrinterMessage = ""; var strPrinterMessage = "";
if (status != null) if (status != null)
{ {
if (status.StsNOPAPER|| AppData.IsStopPrinting()) bool StsNOPAPER = status.StsNOPAPER;
bool StsNEARENDPAP = status.StsNEARENDPAP;
if (StsNOPAPER || (StsNEARENDPAP && AppData.IsStopPrinting()))
{ {
AppData.DeviceStatus.PrinterStatus = (int)PrinterStatusCode.PAPEROUT; AppData.DeviceStatus.PrinterStatus = (int)PrinterStatusCode.PAPEROUT;
StopTimers(); StopTimers();
@@ -459,7 +463,7 @@ namespace SafeBagDE70
ShowError(strPrinterMessage); ShowError(strPrinterMessage);
AppData.ADMINDEVICESTATUS.PrinterStatus = strPrinterMessage; AppData.ADMINDEVICESTATUS.PrinterStatus = strPrinterMessage;
} }
else if (status.StsNEARENDPAP) else if (StsNEARENDPAP)
{ {
AppData.UpdatePrinterStatus(true); AppData.UpdatePrinterStatus(true);
strPrinterMessage = "MÁY IN: GẦN HẾT GIẤY"; strPrinterMessage = "MÁY IN: GẦN HẾT GIẤY";