test run works

This commit is contained in:
EugeneTes
2026-01-20 10:11:04 +01:00
parent 4720ca2d57
commit 6f5116736c
22 changed files with 351 additions and 441 deletions

View File

@@ -12,6 +12,7 @@ public class PrinterDiscoveryBackgroundTask
private readonly IDiscoveryService _discoveryService;
private readonly IDiscoveredPrintersReceiver _receiver;
private readonly ILogger _logger;
private readonly PrintServer _printServer;
private readonly TimeSpan _interval;
private readonly TimeSpan _discoveryTimeout;
@@ -21,11 +22,13 @@ public class PrinterDiscoveryBackgroundTask
public PrinterDiscoveryBackgroundTask(
IDiscoveryService discoveryService,
IDiscoveredPrintersReceiver receiver,
ILogger logger)
ILogger logger,
PrintServer printServer)
{
_discoveryService = discoveryService;
_receiver = receiver;
_logger = logger;
_printServer = printServer;
_interval = TimeSpan.FromSeconds(30);
_discoveryTimeout = TimeSpan.FromSeconds(3);
}
@@ -67,13 +70,14 @@ public class PrinterDiscoveryBackgroundTask
try
{
var printers = await _discoveryService.DiscoverPrintersAsync(_discoveryTimeout);
printers.Add(new DiscoveredPrinter()
{
IPAddress = "127.0.0.1",
ModelName = "TM-T30III",
});
var currentIps = printers.Select(p => p.IPAddress).ToHashSet();
foreach (string currentIp in currentIps)
{
_printServer.RegisterPrinter(currentIp);
}
if (HasConfigurationChanged(currentIps))
{
_logger.LogInformation("Discovered printer configuration changed: {Count} printer(s)", printers.Count);

View File

@@ -10,6 +10,7 @@ using Inspectron.Epson.PrintServer.ConfigurationSources;
using Inspectron.Epson.PrintServer.JobSources;
using Inspectron.Epson.PrintServer.PrinterAssinment;
using Inspectron.Epson.PrintServer.Printers;
using Inspectron.Epson.PrintServer.Printers.Utils;
using Inspectron.Epson.PrintServer.PrintServices;
using EpsonPrintService;
@@ -40,6 +41,7 @@ kernel.Bind<ILogger>().ToMethod(ctx =>
kernel.Bind<IAssignedPrinterRepository>().ToConstant(config);
kernel.Bind<IWrapperPrinterFactory>().To<PrinterWrapperFactory>().InSingletonScope();
kernel.Bind<IPrinterConfigurationSource>().To<FixedConfigurationSource>();
kernel.Bind<IReceiptConverterFactory>().To<ReceiptConverterFactory>().InSingletonScope();
kernel.Bind<PrintServer>().ToSelf().InSingletonScope();
kernel.Bind<IDiscoveredPrintersReceiver>().To<JamesDiscoveredPrintersReceiver>().InSingletonScope();
kernel.Bind<PrinterDiscoveryBackgroundTask>().ToSelf().InSingletonScope();

View File

@@ -1,6 +1,6 @@
{
"GroupId": "64a3d9f0876bc5d1704bce43",
"RestaurantId": "64a3d9f0876bc5d1704bce43",
"ApiKey": "LBOACMlvFEgDbZqt24uW0LjiFv0LKU5DT94g0JDoBnI=",
"GroupId": "63e37295bd6f26dbd36164c0",
"RestaurantId": "63e37295bd6f26dbd36164c0",
"ApiKey": "Pd8X/VtXLWgl5Djy4ksjdHC3xboeoh5Jig3Qo4277GQ=",
"PrinterConfigurations": {}
}