try catch Init printer

Đảo thử tự InitUsers
Kiểm tra đầu đọc QR
This commit is contained in:
Nguyen Dinh Thuan
2024-09-16 15:08:10 +07:00
parent 409d942352
commit 2b4a509e3a
4 changed files with 105 additions and 72 deletions
+14 -4
View File
@@ -1,5 +1,6 @@
using Custom.CuCustomWndAPI;
using HandyControl.Data;
using SafeBagDE70.API;
using Serilog;
using System;
using System.Collections.Generic;
@@ -23,18 +24,27 @@ namespace SafeBagDE70.Services
customWndAPIWrap.InitLibrary();
USBDevice[] usbArray = customWndAPIWrap.EnumUSBDevices();
dev = customWndAPIWrap.OpenPrinterUSB(usbArray[0]);
Log.Information("[PRINTER] Init Printer Successfully");
Log.Information("[PRINTER] Khởi tạo thành công");
}
catch (Exception ex)
{
// System.Windows.MessageBox.Show(ex.ToString());
Log.Information("[PRINTER] Không thể khởi tạo máy in");
AppData.DeviceStatus.PrinterStatus = 3;
AppData.DeviceStatus.Description = "[PRINTER] Không thể khởi tạo máy in";
APIModels.SendEvent(AppData.DeviceStatus);
}
}
public PrinterStatus? GetStatus()
{
var status = dev.GetPrinterFullStatus();
return status;
if(dev!=null)
{
var status = dev.GetPrinterFullStatus();
return status;
}
return null;
}
public bool IsNearPaperOut()
{