Add project files.
This commit is contained in:
38
EpsonPrintService/EpsonPrintService.csproj
Normal file
38
EpsonPrintService/EpsonPrintService.csproj
Normal 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>
|
||||
8
EpsonPrintService/IPrintJobSource.cs
Normal file
8
EpsonPrintService/IPrintJobSource.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Threading.Channels;
|
||||
|
||||
namespace EpsonPrintService;
|
||||
|
||||
public interface IPrintJobSource
|
||||
{
|
||||
Task<PrintJob> GetNextJobAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
66
EpsonPrintService/Program.cs
Normal file
66
EpsonPrintService/Program.cs
Normal 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
|
||||
}
|
||||
|
||||
5
EpsonPrintService/config.json
Normal file
5
EpsonPrintService/config.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"GroupId": "67e534f8e86e816689323023",
|
||||
"RestaurantId": "63e37295bd6f26dbd36164c0",
|
||||
"PrinterConfigurations": {}
|
||||
}
|
||||
12
EpsonPrintService/epson.service
Normal file
12
EpsonPrintService/epson.service
Normal 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
|
||||
5
EpsonPrintService/postinst
Normal file
5
EpsonPrintService/postinst
Normal 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
2
EpsonPrintService/prem
Normal file
@@ -0,0 +1,2 @@
|
||||
systemctl stop epson.service
|
||||
systemctl disable epson.service
|
||||
2
EpsonPrintService/start.sh
Normal file
2
EpsonPrintService/start.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
/root/.dotnet/dotnet /home/oem/epson_service/EpsonPrintService.dll
|
||||
BIN
EpsonPrintService/test.png
Normal file
BIN
EpsonPrintService/test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 486 KiB |
Reference in New Issue
Block a user