out of paper detection
This commit is contained in:
@@ -42,7 +42,8 @@ public class EpsonPrintService: IPrintService
|
||||
var status = await epsonPrinter.GetPrinterStatusAsync();
|
||||
if (!status.IsOnline)
|
||||
{
|
||||
throw new InvalidOperationException("Printer is offline or out of paper.");
|
||||
_logger.LogWarning("Printer {PrinterIp} is out of paper", printerIp);
|
||||
return PrintResult.Fail(PrintErrorType.OutOfPaper);
|
||||
}
|
||||
var printerAdapter = _wrapperPrinterFactory.CreatePrinterFromId(printerId.Value, epsonPrinter);
|
||||
|
||||
@@ -101,11 +102,17 @@ public class EpsonPrintService: IPrintService
|
||||
status = await epsonPrinter.GetPrinterStatusAsync();
|
||||
if (!status.IsOnline)
|
||||
{
|
||||
throw new InvalidOperationException("Printer is offline or out of paper.");
|
||||
_logger.LogWarning("Printer {PrinterIp} is out of paper", printerIp);
|
||||
return PrintResult.Fail(PrintErrorType.OutOfPaper);
|
||||
}
|
||||
|
||||
await printerAdapter.Cut();
|
||||
}
|
||||
catch (EpsonConnectionException e)
|
||||
{
|
||||
_logger.LogWarning(e, "Printer {PrinterIp} is offline", printerIp);
|
||||
return PrintResult.Fail(PrintErrorType.Offline);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogWarning(e, "Failed to print job for printer {PrinterUid}", printerIp);
|
||||
|
||||
@@ -4,5 +4,7 @@ public enum PrintErrorType
|
||||
{
|
||||
None,
|
||||
ConversionError,
|
||||
Offline,
|
||||
OutOfPaper,
|
||||
Other
|
||||
}
|
||||
@@ -86,6 +86,11 @@ public class PrinterQueue
|
||||
_logger.LogWarning("Job failed due to conversion error, not re-queuing");
|
||||
await _statusReporter.ReportStatusAsync(job, PrintJobStatus.Failed);
|
||||
}
|
||||
else if (result.ErrorType == PrintErrorType.Offline)
|
||||
{
|
||||
_logger.LogWarning("Printer is offline, job failed");
|
||||
await _statusReporter.ReportStatusAsync(job, PrintJobStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Re-queue with retry logic
|
||||
|
||||
Reference in New Issue
Block a user