diff --git a/PARR.API/Validators/GeneratorTemplateRequestValidator.cs b/PARR.API/Validators/GeneratorTemplateRequestValidator.cs index 25ea8fca..d834c93f 100644 --- a/PARR.API/Validators/GeneratorTemplateRequestValidator.cs +++ b/PARR.API/Validators/GeneratorTemplateRequestValidator.cs @@ -24,7 +24,7 @@ namespace PARR.API.Validators .WithMessage("У данного приложения нет связанных работ"); //TODO: возможно сделать проверку, по данному выражению есть ли ЭК - RuleFor(t => t.Ek).NotEmpty().WithMessage("ЭК, принимает регулярное выражение. Например: *, ВРТ-*-ДВС"); + RuleFor(t => t.Ek).NotEmpty().WithMessage("Недопустимое значение ЭК. Возможные значения: *, ВРТ-*-ДВС"); RuleFor(t => t.Action) .Must(t => t.ToLower() == GenerateTemplateActionsEnum.create.ToString() || t.ToLower() == GenerateTemplateActionsEnum.deactivate.ToString()) diff --git a/PARR.GeneratorTemplates/GeneratorTemplate.cs b/PARR.GeneratorTemplates/GeneratorTemplate.cs index f26cbc64..f63dea56 100644 --- a/PARR.GeneratorTemplates/GeneratorTemplate.cs +++ b/PARR.GeneratorTemplates/GeneratorTemplate.cs @@ -46,7 +46,7 @@ namespace PARR.GeneratorTemplates //string msg = "{\"WorkId\":\"91219bec-e5f7-4a1a-b4c9-c135035d2498\",\"ApplicationId\":\"13044a1f-fa0c-476f-b501-2b8d06bac9f8\",\"Action\":\"create\",\"Ek\":\"вРТ-*RZD\"}"; string msg = "{\"WorkId\":\"91219bec-e5f7-4a1a-b4c9-c135035d2498\",\"ApplicationId\":\"13044a1f-fa0c-476f-b501-2b8d06bac9f8\",\"Action\":\"create\",\"Ek\":\"*ДВС\"}"; - //string msg = "{\"WorkId\":\"91219bec-e5f7-4a1a-b4c9-c135035d2498\",\"ApplicationId\":\"13044a1f-fa0c-476f-b501-2b8d06bac9f8\",\"Action\":\"deactivate\",\"Ek\":\"вРТ-*RZD\"}"; + //string msg = "{\"WorkId\":\"91219bec-e5f7-4a1a-b4c9-c135035d2498\",\"ApplicationId\":\"13044a1f-fa0c-476f-b501-2b8d06bac9f8\",\"Action\":\"deactivate\",\"Ek\":\"*\"}"; await GenerateTemplates(msg); // // проверить как ту дела с асинком @@ -72,7 +72,7 @@ namespace PARR.GeneratorTemplates private async Task GenerateTemplates(string msg) { - logger.LogDebug($"Получили запрос: {msg}"); + logger.LogInformation($"Получили запрос: {msg}"); var query = transformService.GetModelFromJson(msg); if (query == null) diff --git a/PARR.GeneratorTemplatesWorker/Program.cs b/PARR.GeneratorTemplatesWorker/Program.cs index d911047a..efa43ace 100644 --- a/PARR.GeneratorTemplatesWorker/Program.cs +++ b/PARR.GeneratorTemplatesWorker/Program.cs @@ -3,32 +3,60 @@ using PARR.GeneratorTemplatesWorker; using Serilog; -IHost host = Host.CreateDefaultBuilder(args) - .ConfigureServices((hostContext, services) => - { - services.InstallGeneratorTemplateServices(hostContext.Configuration); - //hostContext.Configuration.AddGeneratorTemplateConfigurations(services); - //services.AddGeneratorTemplateSettings(hostContext.Configuration); +var builder = Host.CreateApplicationBuilder(); - //services.AddHostedService(); - }) - //.ConfigureAppConfiguration((hostContext, configBuilder) => - //{ - //TODO: !!! !!! !!! не смог прикрутить AddGeneratorTemplateConfigurations, не могу прокинуть туда сервисы - // configBuilder.AddGeneratorTemplateConfigurations(hostContext.Services); - //}) - .ConfigureServices((hostContext, services) => - { - services.AddGeneratorTemplateSettings(hostContext.Configuration); +builder.Services.AddLogging(config => +{ + config.ClearProviders(); + var logger = new LoggerConfiguration() + .WriteTo.Console() + .ReadFrom.Configuration(builder.Configuration) + .CreateLogger(); + config.AddSerilog(logger); +}); - services.AddHostedService(); - }) - .UseSerilog((hostContext, services, config) => - { - config - .WriteTo.Console() - .ReadFrom.Configuration(hostContext.Configuration); - }) - .Build(); +builder.Services.InstallGeneratorTemplateServices(builder.Configuration); +builder.Configuration.AddGeneratorTemplateConfigurations(builder.Services); +builder.Services.AddGeneratorTemplateSettings(builder.Configuration); +builder.Services.AddHostedService(); + +var host = builder.Build(); host.Run(); + + + + + + + + +//IHost host = Host.CreateDefaultBuilder(args) +// .ConfigureServices((hostContext, services) => +// { +// services.InstallGeneratorTemplateServices(hostContext.Configuration); +// //hostContext.Configuration.AddGeneratorTemplateConfigurations(services); +// //services.AddGeneratorTemplateSettings(hostContext.Configuration); + +// //services.AddHostedService(); +// }) +// .ConfigureAppConfiguration((hostContext, configBuilder) => +// { +// //TODO: !!!!!!!!!не смог прикрутить AddGeneratorTemplateConfigurations, не могу прокинуть туда сервисы +// configBuilder.AddGeneratorTemplateConfigurations(hostContext.Services); +// }) +// .ConfigureServices((hostContext, services) => +// { +// services.AddGeneratorTemplateSettings(hostContext.Configuration); + +// services.AddHostedService(); +// }) +// .UseSerilog((hostContext, services, config) => +// { +// config +// .WriteTo.Console() +// .ReadFrom.Configuration(hostContext.Configuration); +// }) +// .Build(); + +//host.Run();