diff --git a/PARR.API/Controllers/V1/Statistics/StatWorkloadController.cs b/PARR.API/Controllers/V1/Statistics/StatWorkloadController.cs index d9fedf61..d75a9cd1 100644 --- a/PARR.API/Controllers/V1/Statistics/StatWorkloadController.cs +++ b/PARR.API/Controllers/V1/Statistics/StatWorkloadController.cs @@ -5,8 +5,8 @@ using PARR.API.Contracts.V1.Responses.Base; using PARR.API.Controllers.V1.Base; using PARR.API.Services.Interfaces; using PARR.API.Settings; -using PARR.Core.Services.Task.Interfaces; -using PARR.Core.Services.Task.Providers; +using PARR.Core.Services.TaskServices.Interfaces; +using PARR.Core.Services.TaskServices.Providers; using PARR.Domain.Common.Roles; using PARR.Domain.Entities.Base.History; using PARR.Domain.Enums; diff --git a/PARR.Core/DependencyInjection.cs b/PARR.Core/DependencyInjection.cs index 7bbd7f2b..caad7159 100644 --- a/PARR.Core/DependencyInjection.cs +++ b/PARR.Core/DependencyInjection.cs @@ -3,12 +3,12 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using PARR.Core.Common.Implementations; using PARR.Core.Common.Interfaces; -using PARR.Core.Services.Task.Handlers; -using PARR.Core.Services.Task.Handlers.Factory; -using PARR.Core.Services.Task.Implementations; -using PARR.Core.Services.Task.Interfaces; -using PARR.Core.Services.Task.Providers; -using PARR.Core.Services.Task.ReconciliationHosted; +using PARR.Core.Services.TaskServices.Handlers; +using PARR.Core.Services.TaskServices.Handlers.Factory; +using PARR.Core.Services.TaskServices.Implementations; +using PARR.Core.Services.TaskServices.Interfaces; +using PARR.Core.Services.TaskServices.Providers; +using PARR.Core.Services.TaskServices.ReconciliationHosted; using PARR.Core.Services.Workload.Implementations; using PARR.Core.Services.Workload.Interfaces; using PARR.Domain.Enums; @@ -67,6 +67,7 @@ namespace PARR.Core //services.AddScoped(); + //services.AddTransient(); #endregion diff --git a/PARR.Core/Services/Task/Handlers/BaseTaskHandler.cs b/PARR.Core/Services/TaskServices/Handlers/BaseTaskHandler.cs similarity index 99% rename from PARR.Core/Services/Task/Handlers/BaseTaskHandler.cs rename to PARR.Core/Services/TaskServices/Handlers/BaseTaskHandler.cs index e79e9ac3..80796717 100644 --- a/PARR.Core/Services/Task/Handlers/BaseTaskHandler.cs +++ b/PARR.Core/Services/TaskServices/Handlers/BaseTaskHandler.cs @@ -4,7 +4,7 @@ using PARR.Core.Repositories.Interfaces.TaskRepositories; using PARR.Domain.Entities.TaskEntities; using PARR.Domain.Enums; -namespace PARR.Core.Services.Task.Handlers +namespace PARR.Core.Services.TaskServices.Handlers { /// /// Базовый класс для всех обработчиков задач. diff --git a/PARR.Core/Services/Task/Handlers/Factory/ITaskHandlerFactory.cs b/PARR.Core/Services/TaskServices/Handlers/Factory/ITaskHandlerFactory.cs similarity index 81% rename from PARR.Core/Services/Task/Handlers/Factory/ITaskHandlerFactory.cs rename to PARR.Core/Services/TaskServices/Handlers/Factory/ITaskHandlerFactory.cs index 013b95ef..2402ffac 100644 --- a/PARR.Core/Services/Task/Handlers/Factory/ITaskHandlerFactory.cs +++ b/PARR.Core/Services/TaskServices/Handlers/Factory/ITaskHandlerFactory.cs @@ -1,6 +1,7 @@ -using PARR.Domain.Enums; +using PARR.Core.Services.TaskServices.Handlers; +using PARR.Domain.Enums; -namespace PARR.Core.Services.Task.Handlers.Factory +namespace PARR.Core.Services.TaskServices.Handlers.Factory { /// /// Фабрика обработчиков diff --git a/PARR.Core/Services/Task/Handlers/Factory/TaskHandlerFactory.cs b/PARR.Core/Services/TaskServices/Handlers/Factory/TaskHandlerFactory.cs similarity index 94% rename from PARR.Core/Services/Task/Handlers/Factory/TaskHandlerFactory.cs rename to PARR.Core/Services/TaskServices/Handlers/Factory/TaskHandlerFactory.cs index b6294859..ef477e96 100644 --- a/PARR.Core/Services/Task/Handlers/Factory/TaskHandlerFactory.cs +++ b/PARR.Core/Services/TaskServices/Handlers/Factory/TaskHandlerFactory.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using PARR.Domain.Enums; -namespace PARR.Core.Services.Task.Handlers.Factory +namespace PARR.Core.Services.TaskServices.Handlers.Factory { public class TaskHandlerFactory : ITaskHandlerFactory { diff --git a/PARR.Core/Services/Task/Handlers/HandlerResult.cs b/PARR.Core/Services/TaskServices/Handlers/HandlerResult.cs similarity index 96% rename from PARR.Core/Services/Task/Handlers/HandlerResult.cs rename to PARR.Core/Services/TaskServices/Handlers/HandlerResult.cs index 932e77b2..86ff9d68 100644 --- a/PARR.Core/Services/Task/Handlers/HandlerResult.cs +++ b/PARR.Core/Services/TaskServices/Handlers/HandlerResult.cs @@ -1,4 +1,4 @@ -namespace PARR.Core.Services.Task.Handlers +namespace PARR.Core.Services.TaskServices.Handlers { /// /// Результат выполнения задачи обработчиком. diff --git a/PARR.Core/Services/Task/Handlers/WorkloadReportHandler.cs b/PARR.Core/Services/TaskServices/Handlers/WorkloadReportHandler.cs similarity index 96% rename from PARR.Core/Services/Task/Handlers/WorkloadReportHandler.cs rename to PARR.Core/Services/TaskServices/Handlers/WorkloadReportHandler.cs index 708ca3e5..70471c56 100644 --- a/PARR.Core/Services/Task/Handlers/WorkloadReportHandler.cs +++ b/PARR.Core/Services/TaskServices/Handlers/WorkloadReportHandler.cs @@ -3,7 +3,7 @@ using PARR.Core.Repositories.Interfaces.TaskRepositories; using PARR.Domain.Entities.TaskEntities; using PARR.Domain.Enums; -namespace PARR.Core.Services.Task.Handlers +namespace PARR.Core.Services.TaskServices.Handlers { /// /// Обработчик задачаи формирования отчета по загруженности (формирование КЭШ). diff --git a/PARR.Core/Services/Task/Implementations/TaskManagementService.cs b/PARR.Core/Services/TaskServices/Implementations/TaskManagementService.cs similarity index 98% rename from PARR.Core/Services/Task/Implementations/TaskManagementService.cs rename to PARR.Core/Services/TaskServices/Implementations/TaskManagementService.cs index c6b33a06..51c0496c 100644 --- a/PARR.Core/Services/Task/Implementations/TaskManagementService.cs +++ b/PARR.Core/Services/TaskServices/Implementations/TaskManagementService.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using PARR.Core.Common.Interfaces.RabbitServices; using PARR.Core.Repositories.Interfaces.TaskRepositories; -using PARR.Core.Services.Task.Interfaces; +using PARR.Core.Services.TaskServices.Interfaces; using PARR.Domain.Common.Rabbit.Messages; using PARR.Domain.Entities.Base.History; using PARR.Domain.Entities.TaskEntities; @@ -11,7 +11,7 @@ using PARR.Domain.Settings; using System.Text.Encodings.Web; using System.Text.Json; -namespace PARR.Core.Services.Task.Implementations +namespace PARR.Core.Services.TaskServices.Implementations { internal class TaskManagementService : ITaskManagementService { diff --git a/PARR.Core/Services/Task/Implementations/TaskReconciliationService.cs b/PARR.Core/Services/TaskServices/Implementations/TaskReconciliationService.cs similarity index 97% rename from PARR.Core/Services/Task/Implementations/TaskReconciliationService.cs rename to PARR.Core/Services/TaskServices/Implementations/TaskReconciliationService.cs index 2a00d5ae..f0820e29 100644 --- a/PARR.Core/Services/Task/Implementations/TaskReconciliationService.cs +++ b/PARR.Core/Services/TaskServices/Implementations/TaskReconciliationService.cs @@ -2,15 +2,15 @@ using Microsoft.Extensions.Logging; using PARR.Core.Common.Interfaces.RabbitServices; using PARR.Core.Repositories.Interfaces.TaskRepositories; -using PARR.Core.Services.Task.Interfaces; -using PARR.Core.Services.Task.Models; -using PARR.Core.Services.Task.Providers; +using PARR.Core.Services.TaskServices.Interfaces; +using PARR.Core.Services.TaskServices.Models; +using PARR.Core.Services.TaskServices.Providers; using PARR.Domain.Common.Rabbit.Messages; using PARR.Domain.Entities.TaskEntities; using PARR.Domain.Enums; using PARR.Domain.Settings; -namespace PARR.Core.Services.Task.Implementations +namespace PARR.Core.Services.TaskServices.Implementations { internal class TaskReconciliationService : ITaskReconciliationService { diff --git a/PARR.Core/Services/Task/Interfaces/ITaskManagementService.cs b/PARR.Core/Services/TaskServices/Interfaces/ITaskManagementService.cs similarity index 94% rename from PARR.Core/Services/Task/Interfaces/ITaskManagementService.cs rename to PARR.Core/Services/TaskServices/Interfaces/ITaskManagementService.cs index 6f8a06a5..e558d175 100644 --- a/PARR.Core/Services/Task/Interfaces/ITaskManagementService.cs +++ b/PARR.Core/Services/TaskServices/Interfaces/ITaskManagementService.cs @@ -2,7 +2,7 @@ using PARR.Domain.Enums; using PARR.Domain.Settings; -namespace PARR.Core.Services.Task.Interfaces +namespace PARR.Core.Services.TaskServices.Interfaces { /// /// Управления задачами (очередями) diff --git a/PARR.Core/Services/Task/Interfaces/ITaskReconciliationService.cs b/PARR.Core/Services/TaskServices/Interfaces/ITaskReconciliationService.cs similarity index 82% rename from PARR.Core/Services/Task/Interfaces/ITaskReconciliationService.cs rename to PARR.Core/Services/TaskServices/Interfaces/ITaskReconciliationService.cs index 69d6e02f..53e49380 100644 --- a/PARR.Core/Services/Task/Interfaces/ITaskReconciliationService.cs +++ b/PARR.Core/Services/TaskServices/Interfaces/ITaskReconciliationService.cs @@ -1,6 +1,6 @@ -using PARR.Core.Services.Task.Models; +using PARR.Core.Services.TaskServices.Models; -namespace PARR.Core.Services.Task.Interfaces +namespace PARR.Core.Services.TaskServices.Interfaces { /// /// Сервис для проверки и исправления зависших задач. diff --git a/PARR.Core/Services/Task/Models/ReconciliationReport.cs b/PARR.Core/Services/TaskServices/Models/ReconciliationReport.cs similarity index 97% rename from PARR.Core/Services/Task/Models/ReconciliationReport.cs rename to PARR.Core/Services/TaskServices/Models/ReconciliationReport.cs index c910409d..ab07215f 100644 --- a/PARR.Core/Services/Task/Models/ReconciliationReport.cs +++ b/PARR.Core/Services/TaskServices/Models/ReconciliationReport.cs @@ -1,4 +1,4 @@ -namespace PARR.Core.Services.Task.Models +namespace PARR.Core.Services.TaskServices.Models { /// /// Отчет о выполнении Reconciliation Job. diff --git a/PARR.Core/Services/Task/Providers/ITaskMqSettingsProvider.cs b/PARR.Core/Services/TaskServices/Providers/ITaskMqSettingsProvider.cs similarity index 90% rename from PARR.Core/Services/Task/Providers/ITaskMqSettingsProvider.cs rename to PARR.Core/Services/TaskServices/Providers/ITaskMqSettingsProvider.cs index 8b67a6b1..d966c43b 100644 --- a/PARR.Core/Services/Task/Providers/ITaskMqSettingsProvider.cs +++ b/PARR.Core/Services/TaskServices/Providers/ITaskMqSettingsProvider.cs @@ -1,7 +1,7 @@ using PARR.Domain.Enums; using PARR.Domain.Settings; -namespace PARR.Core.Services.Task.Providers +namespace PARR.Core.Services.TaskServices.Providers { /// /// Провайдер настроек очереди для задач Tasks diff --git a/PARR.Core/Services/Task/Providers/TaskMqSettingsProvider.cs b/PARR.Core/Services/TaskServices/Providers/TaskMqSettingsProvider.cs similarity index 91% rename from PARR.Core/Services/Task/Providers/TaskMqSettingsProvider.cs rename to PARR.Core/Services/TaskServices/Providers/TaskMqSettingsProvider.cs index 5a3f48b6..eaaf32e2 100644 --- a/PARR.Core/Services/Task/Providers/TaskMqSettingsProvider.cs +++ b/PARR.Core/Services/TaskServices/Providers/TaskMqSettingsProvider.cs @@ -1,7 +1,7 @@ using PARR.Domain.Enums; using PARR.Domain.Settings; -namespace PARR.Core.Services.Task.Providers +namespace PARR.Core.Services.TaskServices.Providers { internal class TaskMqSettingsProvider : ITaskMqSettingsProvider { diff --git a/PARR.Core/Services/Task/ReconciliationHosted/ReconciliationHostedService.cs b/PARR.Core/Services/TaskServices/ReconciliationHosted/ReconciliationHostedService.cs similarity index 91% rename from PARR.Core/Services/Task/ReconciliationHosted/ReconciliationHostedService.cs rename to PARR.Core/Services/TaskServices/ReconciliationHosted/ReconciliationHostedService.cs index f378f1ec..e90f45ea 100644 --- a/PARR.Core/Services/Task/ReconciliationHosted/ReconciliationHostedService.cs +++ b/PARR.Core/Services/TaskServices/ReconciliationHosted/ReconciliationHostedService.cs @@ -2,10 +2,10 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using PARR.Core.Common.Interfaces; -using PARR.Core.Services.Task.Interfaces; +using PARR.Core.Services.TaskServices.Interfaces; using PARR.Domain.Settings; -namespace PARR.Core.Services.Task.ReconciliationHosted +namespace PARR.Core.Services.TaskServices.ReconciliationHosted { /// /// Фоновая задача для периодического запуска Reconciliation Job. @@ -33,7 +33,7 @@ namespace PARR.Core.Services.Task.ReconciliationHosted this.intervalService = intervalService; } - protected override async System.Threading.Tasks.Task ExecuteAsync(CancellationToken stoppingToken) + protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await intervalService.IntervalInitAsync(async () => { diff --git a/PARR.Core/Services/Workload/Implementations/WorkloadCacheBuilderService.cs b/PARR.Core/Services/Workload/Implementations/WorkloadCacheBuilderService.cs index 57cfbdef..12e96866 100644 --- a/PARR.Core/Services/Workload/Implementations/WorkloadCacheBuilderService.cs +++ b/PARR.Core/Services/Workload/Implementations/WorkloadCacheBuilderService.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using PARR.Core.Common.Interfaces; using PARR.Core.Common.Interfaces.RabbitServices; -using PARR.Core.Services.Task.Handlers.Factory; +using PARR.Core.Services.TaskServices.Handlers.Factory; using PARR.Core.Services.Workload.Interfaces; using PARR.Domain.Common.Rabbit.Messages; using PARR.Domain.Enums; diff --git a/PARR.Core/Services/Workload/Implementations/WorkloadCacheService.cs b/PARR.Core/Services/Workload/Implementations/WorkloadCacheService.cs index 61d7dc95..9ff1f4a6 100644 --- a/PARR.Core/Services/Workload/Implementations/WorkloadCacheService.cs +++ b/PARR.Core/Services/Workload/Implementations/WorkloadCacheService.cs @@ -1,5 +1,8 @@ -using Microsoft.Extensions.Logging; +using InfluxDB.Client.Api.Service; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using PARR.Core.Common.Interfaces; +using PARR.Core.Repositories.Interfaces; namespace PARR.Core.Services.Workload.Implementations { @@ -10,15 +13,18 @@ namespace PARR.Core.Services.Workload.Implementations { private readonly ILogger logger; private readonly IRedisCacheService redisCacheService; + private readonly ITemplateRepository templateRepository; public WorkloadCacheService( ILogger logger, - IRedisCacheService redisCacheService + IRedisCacheService redisCacheService, + ITemplateRepository templateRepository //IShortcodeService ) { this.logger = logger; this.redisCacheService = redisCacheService; + this.templateRepository = templateRepository; } @@ -27,11 +33,18 @@ namespace PARR.Core.Services.Workload.Implementations /// КЭШ рабочих групп и зон ответственности /// /// - public async System.Threading.Tasks.Task CreateTemplateCacheAsync() + public async Task CreateTemplateCacheAsync() { await DeleteTemplateCacheAsync(); + await DeleteWorkloadCacheAsync(); - //1. Получить из БД все шаблоны - НЕТ РЕПЫ + //1. Получить из БД все шаблоны (тяжелый запрос, тянет вообще все данные, 8 сек) + var templates = await templateRepository.Get() + .AsNoTracking() + .Include(t=>t.Job) + .ToListAsync(); + + //2. Получить по каждому шаблону ЗО и РГ //3. Сохранить в Redis @@ -42,11 +55,20 @@ namespace PARR.Core.Services.Workload.Implementations /// Удалить КЭШ шаблонов. /// /// - private async System.Threading.Tasks.Task DeleteTemplateCacheAsync() + public async Task DeleteTemplateCacheAsync() { } + /// + /// Удалить КЭШ отчетов + /// + /// + public async Task DeleteWorkloadCacheAsync() + { + + } + }