1.0.7
This commit is contained in:
@@ -5,7 +5,7 @@ namespace EpsonPrintService;
|
|||||||
public static class ConfigurationPaths
|
public static class ConfigurationPaths
|
||||||
{
|
{
|
||||||
private const string LinuxConfigDir = "/root/epsonprintservice";
|
private const string LinuxConfigDir = "/root/epsonprintservice";
|
||||||
private const string LocalConfigFileName = "config.json";
|
private const string LocalConfigFileName = "config.txt";
|
||||||
|
|
||||||
public static string GetConfigPath()
|
public static string GetConfigPath()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>1.0.6</Version>
|
<Version>1.0.7</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -25,6 +25,9 @@
|
|||||||
<None Update="config.json">
|
<None Update="config.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="config.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="epson.service">
|
<None Update="epson.service">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Threading.Channels;
|
using System.Threading.Channels;
|
||||||
using Inspectron.Epson.PrintServer;
|
using Inspectron.Epson.PrintServer;
|
||||||
using Inspectron.Epson.PrintServer.ConfigurationSources;
|
using Inspectron.Epson.PrintServer.ConfigurationSources;
|
||||||
@@ -19,8 +17,22 @@ StandardKernel kernel = new StandardKernel();
|
|||||||
|
|
||||||
var configPath = ConfigurationPaths.GetConfigPath();
|
var configPath = ConfigurationPaths.GetConfigPath();
|
||||||
Console.WriteLine($"Loading configuration from: {configPath}");
|
Console.WriteLine($"Loading configuration from: {configPath}");
|
||||||
var config = JsonSerializer.Deserialize<EpsonPrintServiceConfiguration>(
|
|
||||||
File.ReadAllText(configPath));
|
var base64Line = File.ReadAllText(configPath).Trim();
|
||||||
|
var decodedConfig = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(base64Line));
|
||||||
|
var configParts = decodedConfig.Split(';');
|
||||||
|
if (configParts.Length != 3)
|
||||||
|
throw new InvalidOperationException($"Invalid configuration format. Expected 'apiUrl;restaurantId;apiKey', got {configParts.Length} parts.");
|
||||||
|
|
||||||
|
var config = new EpsonPrintServiceConfiguration
|
||||||
|
{
|
||||||
|
ApiUrl = configParts[0],
|
||||||
|
RestaurantId = configParts[1],
|
||||||
|
ApiKey = configParts[2]
|
||||||
|
};
|
||||||
|
|
||||||
|
Console.WriteLine($"Restaurant: {config.RestaurantId}");
|
||||||
|
Console.WriteLine($"API URL: {config.ApiUrl}");
|
||||||
|
|
||||||
kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
|
kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
|
||||||
kernel.Bind<HttpClient>().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope();
|
kernel.Bind<HttpClient>().ToConstant(new HttpClient { Timeout = TimeSpan.FromSeconds(30) }).InSingletonScope();
|
||||||
|
|||||||
1
EpsonPrintService/config.txt
Normal file
1
EpsonPrintService/config.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
aHR0cDovL2xvY2FsaG9zdDo1MDAyOzY1YzM2MDYyZDM2ZTRjZmVlNmVjZjIyODtvWTVpcjViQi9pMXlSeFdpQ2FRTE1QdkFsS0dBaVVjNy8yK0IyczhXcUJzPQ==
|
||||||
@@ -8,17 +8,17 @@ public class PrintLoop
|
|||||||
private readonly global::PrintServer _printServer;
|
private readonly global::PrintServer _printServer;
|
||||||
private readonly IPrintService _printService;
|
private readonly IPrintService _printService;
|
||||||
private readonly IPrintJobSource _jobSource;
|
private readonly IPrintJobSource _jobSource;
|
||||||
private readonly IAssignedPrinterRepository _assignedPrinterRepository;
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private CancellationTokenSource? _cancellationSource;
|
private CancellationTokenSource? _cancellationSource;
|
||||||
private CancellationToken _cancellationToken;
|
private CancellationToken _cancellationToken;
|
||||||
|
|
||||||
public PrintLoop(global::PrintServer printServer,IPrintService printService, IPrintJobSource jobSource, IAssignedPrinterRepository assignedPrinterRepository, ILogger logger)
|
public PrintLoop(global::PrintServer printServer,IPrintService printService, IPrintJobSource jobSource, ILogger logger)
|
||||||
{
|
{
|
||||||
_printServer = printServer;
|
_printServer = printServer;
|
||||||
_printService = printService;
|
_printService = printService;
|
||||||
_jobSource = jobSource;
|
_jobSource = jobSource;
|
||||||
_assignedPrinterRepository = assignedPrinterRepository;
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user