Add receiver (not complete)

This commit is contained in:
parallelbgls
2023-10-12 15:16:48 +08:00
parent 511434d18a
commit d23b942464
41 changed files with 1592 additions and 42 deletions

View File

@@ -0,0 +1,38 @@
using ModbusTcpToRtu;
using Serilog;
IHost host = Host.CreateDefaultBuilder(args).UseWindowsService()
.ConfigureAppConfiguration((hostingContext, config) =>
{
var configuration = config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? "Production"}.json", true)
.AddEnvironmentVariables()
.Build();
Directory.SetCurrentDirectory(hostingContext.HostingEnvironment.ContentRootPath);
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.File("Log\\log..txt", Serilog.Events.LogEventLevel.Error, shared: true, rollingInterval: RollingInterval.Day)
.CreateLogger();
var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);
Quartz.Logging.LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());
Modbus.Net.LogProvider.SetLogProvider(loggerFactory);
}
)
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(Log.Logger, true));
})
.Build();
await host.RunAsync();