PARR.EsppTemplateSyncWorker
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Worker">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>dotnet-PARR.EsppTemplateSyncWorker-33871a7f-fda7-4371-a369-a7ce886efbec</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PARR.EsppTemplateSync\PARR.EsppTemplateSync.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
20
PARR.EsppTemplateSyncWorker/Program.cs
Normal file
20
PARR.EsppTemplateSyncWorker/Program.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using PARR.EsppTemplateSync;
|
||||
using PARR.EsppTemplateSyncWorker;
|
||||
using Serilog;
|
||||
|
||||
IHost host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.InstallEsppTemplateSyncServices(hostContext.Configuration);
|
||||
|
||||
services.AddHostedService<Worker>();
|
||||
})
|
||||
.UseSerilog((hostContext, services, config) =>
|
||||
{
|
||||
config
|
||||
.WriteTo.Console()
|
||||
.ReadFrom.Configuration(hostContext.Configuration);
|
||||
})
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
11
PARR.EsppTemplateSyncWorker/Properties/launchSettings.json
Normal file
11
PARR.EsppTemplateSyncWorker/Properties/launchSettings.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"profiles": {
|
||||
"PARR.EsppTemplateSyncWorker": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"environmentVariables": {
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
PARR.EsppTemplateSyncWorker/Worker.cs
Normal file
40
PARR.EsppTemplateSyncWorker/Worker.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using PARR.EsppTemplateSync;
|
||||
|
||||
namespace PARR.EsppTemplateSyncWorker
|
||||
{
|
||||
public class Worker : BackgroundService
|
||||
{
|
||||
private readonly ILogger<Worker> _logger;
|
||||
private readonly ITemplateSyncer templateSyncer;
|
||||
|
||||
public Worker(ILogger<Worker> logger, ITemplateSyncer templateSyncer)
|
||||
{
|
||||
_logger = logger;
|
||||
this.templateSyncer = templateSyncer;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
//var task = new Task(() =>
|
||||
//{
|
||||
// templateSyncer.StartWatching();
|
||||
//});
|
||||
//task.Start();
|
||||
|
||||
templateSyncer.StartWatching();
|
||||
|
||||
//while (!stoppingToken.IsCancellationRequested)
|
||||
//{
|
||||
// _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
// await Task.Delay(1 * 1000, stoppingToken);
|
||||
//}
|
||||
}
|
||||
|
||||
public override Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
templateSyncer.StopWatching();
|
||||
|
||||
return base.StopAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
PARR.EsppTemplateSyncWorker/appsettings.Development.json
Normal file
11
PARR.EsppTemplateSyncWorker/appsettings.Development.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"StorageSettings": {
|
||||
"StoragePath": "W:\\"
|
||||
}
|
||||
}
|
||||
34
PARR.EsppTemplateSyncWorker/appsettings.json
Normal file
34
PARR.EsppTemplateSyncWorker/appsettings.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Debug",
|
||||
"Override": {
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Debug"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "log/log-.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"StorageSettings": {
|
||||
"StoragePath": "Data",
|
||||
"EsppTemplates": {
|
||||
"AllowedExtensions": [ ".csv" ],
|
||||
"MaxFileSizeMb": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user