job status reporter

This commit is contained in:
EugeneTes
2026-02-05 08:42:34 +01:00
parent 1c0c95842a
commit 08da2c1e3e
3 changed files with 33 additions and 25 deletions

View File

@@ -36,14 +36,14 @@ var config = new EpsonPrintServiceConfiguration
Console.WriteLine($"Restaurant: {config.RestaurantId}"); Console.WriteLine($"Restaurant: {config.RestaurantId}");
Console.WriteLine($"API URL: {config.ApiUrl}"); Console.WriteLine($"API URL: {config.ApiUrl}");
//kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope(); kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
var discovery = new PreconfiguredDiscoveryService(); //var discovery = new PreconfiguredDiscoveryService();
discovery.AddPrinter("192.168.50.176", "TM-T30III", port: 9100); //discovery.AddPrinter("192.168.50.176", "TM-T30III", port: 9100);
discovery.AddPrinter("192.168.50.60", "TM-T30III", port: 9100); //discovery.AddPrinter("192.168.50.60", "TM-T30III", port: 9100);
discovery.AddPrinter("192.168.50.61", "TM-T30III", port: 9100); //discovery.AddPrinter("192.168.50.61", "TM-T30III", port: 9100);
discovery.AddPrinter("192.168.50.80", "TM-U220II", port: 9100); //discovery.AddPrinter("192.168.50.80", "TM-U220II", port: 9100);
kernel.Bind<IDiscoveryService>().ToConstant(discovery); //kernel.Bind<IDiscoveryService>().ToConstant(discovery);
kernel.Bind<HttpClient>().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope(); kernel.Bind<HttpClient>().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope();
@@ -85,7 +85,7 @@ var heartbeatTask = kernel.Get<HeartbeatBackgroundTask>();
//printServer.RegisterPrinter("10.0.20.12"); //printServer.RegisterPrinter("10.0.20.12");
await printLoop.StartAsync();
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
@@ -100,6 +100,12 @@ Console.CancelKeyPress += (sender, e) =>
_ = discoveryTask.StartAsync(cts.Token); _ = discoveryTask.StartAsync(cts.Token);
_ = heartbeatTask.StartAsync(cts.Token); _ = heartbeatTask.StartAsync(cts.Token);
// delay for a moment to allow discovery to find printers
Console.WriteLine("Waiting for printer discovery...");
await Task.Delay(3000);
await printLoop.StartAsync();
try try
{ {
await Task.Delay(Timeout.Infinite, cts.Token); await Task.Delay(Timeout.Infinite, cts.Token);

View File

@@ -7,17 +7,17 @@ var templatesDir = Path.Combine(AppContext.BaseDirectory, "Templates");
// ============================================================================ // ============================================================================
// FINAL RECEIPT - HTML PRINTER // FINAL RECEIPT - HTML PRINTER
// ============================================================================ // ============================================================================
var json = TestHelpers.BuildFinalReceiptJson(includeTax: true); //var json = TestHelpers.BuildFinalReceiptJson(includeTax: true);
var template = File.ReadAllText(Path.Combine(templatesDir, "FinalReceipt.xml")); //var template = File.ReadAllText(Path.Combine(templatesDir, "FinalReceipt.xml"));
var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24); //var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24);
TestHelpers.PrintCommandsToConsole(printCommands); //TestHelpers.PrintCommandsToConsole(printCommands);
var printer = await TestHelpers.CreateHtmlPrinterAsync(); //var printer = await TestHelpers.CreateHtmlPrinterAsync();
await TestHelpers.PrintCommandsToHtmlPrinterAsync( //await TestHelpers.PrintCommandsToHtmlPrinterAsync(
printer, // printer,
printCommands, // printCommands,
logoPath: "ristorante-klinglers.ch-logo_white_bg.png"); // logoPath: "ristorante-klinglers.ch-logo_white_bg.png");
// ============================================================================ // ============================================================================
@@ -65,16 +65,16 @@ await TestHelpers.PrintCommandsToHtmlPrinterAsync(
// ============================================================================ // ============================================================================
// KITCHEN RECEIPT - HTML PRINTER // KITCHEN RECEIPT - HTML PRINTER
// ============================================================================ // ============================================================================
//var json = TestHelpers.BuildKitchenReceiptJson(); var json = TestHelpers.BuildKitchenReceiptJson();
//var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml")); var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml"));
//var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20); var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20);
//TestHelpers.PrintCommandsToConsole(printCommands); TestHelpers.PrintCommandsToConsole(printCommands);
//var printer = await TestHelpers.CreateHtmlPrinterAsync( var printer = await TestHelpers.CreateHtmlPrinterAsync(
// path: @".\kitchen_test.html", path: @".\kitchen_test.html",
// paperWidth: TestHelpers.KitchenPaperWidth); paperWidth: TestHelpers.KitchenPaperWidth);
//await TestHelpers.PrintKitchenCommandsToHtmlPrinterAsync(printer, printCommands); await TestHelpers.PrintKitchenCommandsToHtmlPrinterAsync(printer, printCommands);
// ============================================================================ // ============================================================================

View File

@@ -33,6 +33,8 @@ public class JamesStatusReporter : IJobStatusReporter
var response = await _httpClient.SendAsync(request); var response = await _httpClient.SendAsync(request);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
var text = await response.Content.ReadAsStringAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {