From d50cb20c9502d902311945583cd83cb94d3bd624 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Wed, 20 Sep 2023 16:51:29 +1000 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PARR.API/Settings/MqSettings.cs | 12 +++------ PARR.BLL/Contracts/Interfaces/IMqSettings.cs | 13 ++++++++++ .../PARR.GeneratorTemplates.csproj | 9 +++++++ .../PARR.GeneratorTemplatesWorker.csproj | 13 ++++++++++ PARR.GeneratorTemplatesWorker/Program.cs | 17 ++++++++++++ .../Properties/launchSettings.json | 11 ++++++++ PARR.GeneratorTemplatesWorker/Worker.cs | 21 +++++++++++++++ .../appsettings.Development.json | 8 ++++++ .../appsettings.json | 26 +++++++++++++++++++ PARR.Worker/PARR.Worker/Program.cs | 3 --- 10 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 PARR.BLL/Contracts/Interfaces/IMqSettings.cs create mode 100644 PARR.GeneratorTemplates/PARR.GeneratorTemplates.csproj create mode 100644 PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj create mode 100644 PARR.GeneratorTemplatesWorker/Program.cs create mode 100644 PARR.GeneratorTemplatesWorker/Properties/launchSettings.json create mode 100644 PARR.GeneratorTemplatesWorker/Worker.cs create mode 100644 PARR.GeneratorTemplatesWorker/appsettings.Development.json create mode 100644 PARR.GeneratorTemplatesWorker/appsettings.json diff --git a/PARR.API/Settings/MqSettings.cs b/PARR.API/Settings/MqSettings.cs index db4d8e7e..4efd1fff 100644 --- a/PARR.API/Settings/MqSettings.cs +++ b/PARR.API/Settings/MqSettings.cs @@ -1,4 +1,6 @@ -namespace PARR.API.Settings +using PARR.BLL.Contracts.Interfaces; + +namespace PARR.API.Settings { public class MqSettings { @@ -12,12 +14,4 @@ public string User { get; set; } = string.Empty; public string Password { get; set; } = string.Empty; } - - public interface IMqSettings - { - string HostName { get; set; } - string QueueName { get; set; } - string User { get; set; } - string Password { get; set; } - } } diff --git a/PARR.BLL/Contracts/Interfaces/IMqSettings.cs b/PARR.BLL/Contracts/Interfaces/IMqSettings.cs new file mode 100644 index 00000000..ef0536c9 --- /dev/null +++ b/PARR.BLL/Contracts/Interfaces/IMqSettings.cs @@ -0,0 +1,13 @@ +namespace PARR.BLL.Contracts.Interfaces +{ + /// + /// Поля настроек MQ, используется для appsettings.json + /// + public interface IMqSettings + { + string HostName { get; set; } + string QueueName { get; set; } + string User { get; set; } + string Password { get; set; } + } +} diff --git a/PARR.GeneratorTemplates/PARR.GeneratorTemplates.csproj b/PARR.GeneratorTemplates/PARR.GeneratorTemplates.csproj new file mode 100644 index 00000000..cfadb03d --- /dev/null +++ b/PARR.GeneratorTemplates/PARR.GeneratorTemplates.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj b/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj new file mode 100644 index 00000000..245b1a44 --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/PARR.GeneratorTemplatesWorker.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + dotnet-PARR.GeneratorTemplatesWorker-deb14157-f207-44e0-8d4b-963c6066a75e + + + + + + diff --git a/PARR.GeneratorTemplatesWorker/Program.cs b/PARR.GeneratorTemplatesWorker/Program.cs new file mode 100644 index 00000000..a3ea5e29 --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/Program.cs @@ -0,0 +1,17 @@ +using PARR.GeneratorTemplatesWorker; +using Serilog; + +IHost host = Host.CreateDefaultBuilder(args) + .ConfigureServices(services => + { + services.AddHostedService(); + }) + .UseSerilog((hostContext, services, config) => + { + config + .WriteTo.Console() + .ReadFrom.Configuration(hostContext.Configuration); + }) + .Build(); + +host.Run(); diff --git a/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json b/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json new file mode 100644 index 00000000..06416c77 --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "PARR.GeneratorTemplatesWorker": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/PARR.GeneratorTemplatesWorker/Worker.cs b/PARR.GeneratorTemplatesWorker/Worker.cs new file mode 100644 index 00000000..9baaa069 --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/Worker.cs @@ -0,0 +1,21 @@ +namespace PARR.GeneratorTemplatesWorker +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + await Task.Delay(1000, stoppingToken); + } + } + } +} \ No newline at end of file diff --git a/PARR.GeneratorTemplatesWorker/appsettings.Development.json b/PARR.GeneratorTemplatesWorker/appsettings.Development.json new file mode 100644 index 00000000..b2dcdb67 --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/PARR.GeneratorTemplatesWorker/appsettings.json b/PARR.GeneratorTemplatesWorker/appsettings.json new file mode 100644 index 00000000..d250dadc --- /dev/null +++ b/PARR.GeneratorTemplatesWorker/appsettings.json @@ -0,0 +1,26 @@ +{ + "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" + } + } + ] + } +} diff --git a/PARR.Worker/PARR.Worker/Program.cs b/PARR.Worker/PARR.Worker/Program.cs index 7432b953..bdaf9c9b 100644 --- a/PARR.Worker/PARR.Worker/Program.cs +++ b/PARR.Worker/PARR.Worker/Program.cs @@ -1,7 +1,4 @@ -using Microsoft.EntityFrameworkCore; using PARR.AIHIT; -using PARR.DAL; -using PARR.Mail; using PARR.Worker; using PARR.Worker.Settings; using Serilog;