diff --git a/EpsonPrintService/Program.cs b/EpsonPrintService/Program.cs index 299aef1..a2c274b 100644 --- a/EpsonPrintService/Program.cs +++ b/EpsonPrintService/Program.cs @@ -36,14 +36,14 @@ var config = new EpsonPrintServiceConfiguration Console.WriteLine($"Restaurant: {config.RestaurantId}"); Console.WriteLine($"API URL: {config.ApiUrl}"); -//kernel.Bind().To().InSingletonScope(); +kernel.Bind().To().InSingletonScope(); -var discovery = new PreconfiguredDiscoveryService(); -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.61", "TM-T30III", port: 9100); -discovery.AddPrinter("192.168.50.80", "TM-U220II", port: 9100); -kernel.Bind().ToConstant(discovery); +//var discovery = new PreconfiguredDiscoveryService(); +//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.61", "TM-T30III", port: 9100); +//discovery.AddPrinter("192.168.50.80", "TM-U220II", port: 9100); +//kernel.Bind().ToConstant(discovery); kernel.Bind().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope(); @@ -85,7 +85,7 @@ var heartbeatTask = kernel.Get(); //printServer.RegisterPrinter("10.0.20.12"); -await printLoop.StartAsync(); + var cts = new CancellationTokenSource(); @@ -100,6 +100,12 @@ Console.CancelKeyPress += (sender, e) => _ = discoveryTask.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 { await Task.Delay(Timeout.Infinite, cts.Token); diff --git a/EpsonTest.Templates/Program.cs b/EpsonTest.Templates/Program.cs index b684ac9..9b45aeb 100644 --- a/EpsonTest.Templates/Program.cs +++ b/EpsonTest.Templates/Program.cs @@ -7,17 +7,17 @@ var templatesDir = Path.Combine(AppContext.BaseDirectory, "Templates"); // ============================================================================ // FINAL RECEIPT - HTML PRINTER // ============================================================================ -var json = TestHelpers.BuildFinalReceiptJson(includeTax: true); -var template = File.ReadAllText(Path.Combine(templatesDir, "FinalReceipt.xml")); -var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24); +//var json = TestHelpers.BuildFinalReceiptJson(includeTax: true); +//var template = File.ReadAllText(Path.Combine(templatesDir, "FinalReceipt.xml")); +//var printCommands = engine.Render(template, json, lineWidth: 48, bigFontLineWidth: 24); -TestHelpers.PrintCommandsToConsole(printCommands); +//TestHelpers.PrintCommandsToConsole(printCommands); -var printer = await TestHelpers.CreateHtmlPrinterAsync(); -await TestHelpers.PrintCommandsToHtmlPrinterAsync( - printer, - printCommands, - logoPath: "ristorante-klinglers.ch-logo_white_bg.png"); +//var printer = await TestHelpers.CreateHtmlPrinterAsync(); +//await TestHelpers.PrintCommandsToHtmlPrinterAsync( +// printer, +// printCommands, +// logoPath: "ristorante-klinglers.ch-logo_white_bg.png"); // ============================================================================ @@ -65,16 +65,16 @@ await TestHelpers.PrintCommandsToHtmlPrinterAsync( // ============================================================================ // KITCHEN RECEIPT - HTML PRINTER // ============================================================================ -//var json = TestHelpers.BuildKitchenReceiptJson(); -//var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml")); -//var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20); +var json = TestHelpers.BuildKitchenReceiptJson(); +var template = File.ReadAllText(Path.Combine(templatesDir, "KitchenReceipt.xml")); +var printCommands = engine.Render(template, json, lineWidth: 33, bigFontLineWidth: 20); -//TestHelpers.PrintCommandsToConsole(printCommands); +TestHelpers.PrintCommandsToConsole(printCommands); -//var printer = await TestHelpers.CreateHtmlPrinterAsync( -// path: @".\kitchen_test.html", -// paperWidth: TestHelpers.KitchenPaperWidth); -//await TestHelpers.PrintKitchenCommandsToHtmlPrinterAsync(printer, printCommands); +var printer = await TestHelpers.CreateHtmlPrinterAsync( + path: @".\kitchen_test.html", + paperWidth: TestHelpers.KitchenPaperWidth); +await TestHelpers.PrintKitchenCommandsToHtmlPrinterAsync(printer, printCommands); // ============================================================================ diff --git a/Inspectron.Epson/PrintServer/JobStatusReporters/JamesStatusReporter.cs b/Inspectron.Epson/PrintServer/JobStatusReporters/JamesStatusReporter.cs index 19df45e..81ae662 100644 --- a/Inspectron.Epson/PrintServer/JobStatusReporters/JamesStatusReporter.cs +++ b/Inspectron.Epson/PrintServer/JobStatusReporters/JamesStatusReporter.cs @@ -33,6 +33,8 @@ public class JamesStatusReporter : IJobStatusReporter var response = await _httpClient.SendAsync(request); response.EnsureSuccessStatusCode(); + var text = await response.Content.ReadAsStringAsync(); + } catch (Exception ex) {