Add project files.

This commit is contained in:
EugeneTes
2026-01-13 09:06:47 +01:00
parent dd935fe1fa
commit 7390693f50
187 changed files with 83457 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.22" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="Ninject" Version="3.3.6" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Inspectron.Epson\Inspectron.Epson.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="epson.service">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="start.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="test.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
using System.Threading.Channels;
namespace EpsonPrintService;
public interface IPrintJobSource
{
Task<PrintJob> GetNextJobAsync(CancellationToken cancellationToken);
}

View File

@@ -0,0 +1,66 @@
using Inspectron.Epson;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Logging;
using Ninject;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Channels;
using Inspectron.Epson.PrintServer;
using Inspectron.Epson.PrintServer.ConfigurationSources;
using Inspectron.Epson.PrintServer.JobSources;
using Inspectron.Epson.PrintServer.PrinterAssinment;
using Inspectron.Epson.PrintServer.Printers;
using Inspectron.Epson.PrintServer.PrintServices;
StandardKernel kernel = new StandardKernel();
//var config = new EpsonPrintServiceConfiguration()
//{
// GroupId = "67e534f8e86e816689323023",
// RestaurantId = "63e37295bd6f26dbd36164c0"
//};
//File.WriteAllText("config.json",JsonSerializer.Serialize(config,new JsonSerializerOptions(){WriteIndented = true}));
var config = JsonSerializer.Deserialize<EpsonPrintServiceConfiguration>(
File.ReadAllText("config.json"));
kernel.Bind<EpsonPrintServiceConfiguration>().ToConstant(config);
kernel.Bind<IPrintJobSource, SignalRPrintJobSource>().To<SignalRPrintJobSource>().InSingletonScope();
kernel.Bind<IPrintService>().To<Inspectron.Epson.PrintServer.PrintServices.EpsonPrintService>();
kernel.Bind<ILogger>().ToMethod(ctx =>
{
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole();
});
return loggerFactory.CreateLogger("EpsonPrintService");
});
kernel.Bind<IAssignedPrinterRepository>().ToConstant(config);
kernel.Bind<IPrinterFactory>().To<PrinterFactory>().InSingletonScope();
kernel.Bind<IPrinterConfigurationSource>().To<FixedConfigurationSource>();
kernel.Bind<PrintServer>().ToSelf().InSingletonScope();
var printLoop = kernel.Get<PrintLoop>();
var printServer = kernel.Get<PrintServer>();
printServer.RegisterPrinter("127.0.0.1");
await printLoop.StartAsync();
var cts = new CancellationTokenSource();
Console.CancelKeyPress += (sender, e) =>
{
Console.WriteLine("\nShutting down...");
e.Cancel = true;
cts.Cancel();
};
try
{
await Task.Delay(Timeout.Infinite, cts.Token);
}
catch (TaskCanceledException)
{
// Expected when Ctrl+C is pressed
}

View File

@@ -0,0 +1,5 @@
{
"GroupId": "67e534f8e86e816689323023",
"RestaurantId": "63e37295bd6f26dbd36164c0",
"PrinterConfigurations": {}
}

View File

@@ -0,0 +1,12 @@
[Unit]
Description=epson service
[Service]
Restart=always
RestartSec=1
WorkingDirectory=/home/pi/epson_service/
Type=simple
ExecStart=/bin/bash /home/pi/epson_service/start.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,5 @@
chmod +x start.sh
cp -rf epson.service /etc/systemd/system/epson.service
systemctl enable epson.service
systemctl start epson.service
systemctl daemon-reload

2
EpsonPrintService/prem Normal file
View File

@@ -0,0 +1,2 @@
systemctl stop epson.service
systemctl disable epson.service

View File

@@ -0,0 +1,2 @@
#!/bin/bash
/root/.dotnet/dotnet /home/oem/epson_service/EpsonPrintService.dll

BIN
EpsonPrintService/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 KiB