2023-05-17 16:30:13 +10:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2026-02-13 15:39:21 +10:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2026-01-15 15:01:56 +10:00
|
|
|
|
using PARR.DAL.Cache.Services.Base;
|
2023-09-19 14:34:55 +10:00
|
|
|
|
using PARR.DAL.Configurations.DbSettings;
|
2023-05-17 16:30:13 +10:00
|
|
|
|
using PARR.DAL.Context;
|
2023-09-19 14:34:55 +10:00
|
|
|
|
using PARR.DAL.Contracts;
|
2025-08-12 11:50:29 +10:00
|
|
|
|
using PARR.DAL.DomainServices.Implementations;
|
|
|
|
|
|
using PARR.DAL.DomainServices.Interfaces;
|
2025-12-23 18:27:31 +10:00
|
|
|
|
using PARR.DAL.DomainServices.Shortcodes;
|
2026-01-21 18:25:09 +10:00
|
|
|
|
using PARR.DAL.DomainServices.UnitFilterService;
|
2026-02-19 17:28:12 +10:00
|
|
|
|
using PARR.DAL.DomainServices.UnitFilterService.Models;
|
2024-05-28 14:35:39 +10:00
|
|
|
|
using PARR.DAL.InfluxDbServices;
|
2025-12-22 17:03:41 +10:00
|
|
|
|
using PARR.DAL.NextRunServices;
|
|
|
|
|
|
using PARR.DAL.NextRunServices.Subservices;
|
2023-08-14 15:24:57 +10:00
|
|
|
|
using PARR.DAL.Services.Implementation;
|
2023-06-01 12:30:38 +10:00
|
|
|
|
using PARR.DAL.Services.Implementations;
|
2025-06-04 11:55:23 +10:00
|
|
|
|
using PARR.DAL.Services.Implementations.Job;
|
2025-12-25 17:01:42 +10:00
|
|
|
|
using PARR.DAL.Services.Implementations.Schedule;
|
2025-05-14 15:13:30 +10:00
|
|
|
|
using PARR.DAL.Services.Implementations.Unit;
|
2023-06-01 12:30:38 +10:00
|
|
|
|
using PARR.DAL.Services.Interfaces;
|
2025-06-04 11:55:23 +10:00
|
|
|
|
using PARR.DAL.Services.Interfaces.Job;
|
2025-12-25 17:01:42 +10:00
|
|
|
|
using PARR.DAL.Services.Interfaces.Schedule;
|
2025-05-14 15:13:30 +10:00
|
|
|
|
using PARR.DAL.Services.Interfaces.Unit;
|
2023-10-24 15:40:52 +10:00
|
|
|
|
using PARR.DAL.Settings;
|
2023-05-17 16:30:13 +10:00
|
|
|
|
|
|
|
|
|
|
namespace PARR.DAL
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class ParrDalInstaller
|
|
|
|
|
|
{
|
2023-09-19 14:34:55 +10:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Устанавливает Dal сервисы (1)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
|
/// <param name="configuration"></param>
|
2023-05-17 16:30:13 +10:00
|
|
|
|
public static void InstallDalServices(this IServiceCollection services, IConfiguration configuration)
|
|
|
|
|
|
{
|
2023-10-10 15:52:34 +10:00
|
|
|
|
//.EnableSensitiveDataLogging() - вкл подробное логирование при применении миграций, на проде выключить
|
2023-05-17 16:30:13 +10:00
|
|
|
|
services.AddDbContext<DataContext>(opt =>
|
2023-10-10 15:52:34 +10:00
|
|
|
|
opt
|
|
|
|
|
|
.EnableSensitiveDataLogging()
|
|
|
|
|
|
.UseNpgsql(configuration.GetConnectionString("DefaultConnection"))
|
2023-09-19 14:34:55 +10:00
|
|
|
|
);
|
2023-05-17 16:30:13 +10:00
|
|
|
|
|
2026-01-15 15:01:56 +10:00
|
|
|
|
#region Redis + cache services
|
2024-05-28 14:35:39 +10:00
|
|
|
|
|
2023-11-30 16:18:14 +10:00
|
|
|
|
services.AddStackExchangeRedisCache(opt =>
|
|
|
|
|
|
{
|
|
|
|
|
|
opt.Configuration = configuration.GetConnectionString("RedisConnection");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-12-23 18:27:31 +10:00
|
|
|
|
var groupedShortcodesCacheSettings = new GroupedShortcodesCacheSettings();
|
|
|
|
|
|
configuration.GetSection(nameof(GroupedShortcodesCacheSettings)).Bind(groupedShortcodesCacheSettings);
|
|
|
|
|
|
services.AddSingleton(groupedShortcodesCacheSettings);
|
|
|
|
|
|
|
2023-11-30 16:18:14 +10:00
|
|
|
|
services.AddTransient<IRedisCacheService, RedisCacheService>();
|
|
|
|
|
|
|
2024-05-28 14:35:39 +10:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region InfluxDb
|
|
|
|
|
|
|
|
|
|
|
|
var influxDbSettings = new InfluxDbSettings();
|
|
|
|
|
|
configuration.GetSection(nameof(InfluxDbSettings)).Bind(influxDbSettings);
|
|
|
|
|
|
services.AddSingleton(influxDbSettings);
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IInfluxDbService, InfluxDbService>();
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-18 09:40:13 +10:00
|
|
|
|
// Entity services
|
2023-06-01 12:30:38 +10:00
|
|
|
|
services.AddTransient<IHostService, HostService>();
|
2024-06-03 15:17:14 +10:00
|
|
|
|
services.AddTransient<IWorkGroupService, WorkGroupService>();
|
2023-06-13 15:04:47 +10:00
|
|
|
|
services.AddTransient<IApplicationService, ApplicationService>();
|
|
|
|
|
|
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
|
|
|
|
|
|
services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
|
2023-09-20 14:48:58 +10:00
|
|
|
|
services.AddTransient<IApplicationsInWorkService, ApplicationsInWorkService>();
|
|
|
|
|
|
services.AddTransient<IApplicationService, ApplicationService>();
|
|
|
|
|
|
services.AddTransient<IProcessService, ProcessService>();
|
|
|
|
|
|
services.AddTransient<ISubprocessService, SubprocessService>();
|
|
|
|
|
|
services.AddTransient<ITnkService, TnkService>();
|
2023-09-01 16:19:32 +10:00
|
|
|
|
services.AddTransient<ITemplateService, TemplateService>();
|
2023-09-15 16:32:46 +10:00
|
|
|
|
services.AddTransient<IStatusTemplateService, StatusTemplateService>();
|
2023-10-03 14:30:54 +10:00
|
|
|
|
services.AddTransient<IRobotHistoryLevelService, RobotHistoryLevelService>();
|
|
|
|
|
|
services.AddTransient<IRobotStatusService, RobotStatusService>();
|
2023-10-05 12:28:31 +10:00
|
|
|
|
services.AddTransient<IRobotService, RobotService>();
|
|
|
|
|
|
services.AddTransient<IRobotConfigurationService, RobotConfigurationService>();
|
|
|
|
|
|
services.AddTransient<IRobotHistoryService, RobotHistoryService>();
|
2023-10-11 11:10:35 +10:00
|
|
|
|
services.AddTransient<IEsppSchTypeConfigService, EsppSchTypeConfigService>();
|
2023-10-19 11:22:35 +10:00
|
|
|
|
services.AddTransient<IAgentHistoryService, AgentHistoryService>();
|
2023-10-23 16:17:42 +10:00
|
|
|
|
services.AddTransient<IOrderService, OrderService>();
|
|
|
|
|
|
services.AddTransient<IOrderStatusService, OrderStatusService>();
|
2023-12-01 16:41:37 +10:00
|
|
|
|
services.AddTransient<IUserService, UserService>();
|
2023-12-05 16:32:34 +10:00
|
|
|
|
services.AddTransient<IRoleService, RoleService>();
|
2023-12-12 15:56:42 +10:00
|
|
|
|
services.AddTransient<ITaskStatusService, TaskStatusService>();
|
2024-04-08 12:16:14 +10:00
|
|
|
|
services.AddTransient<IEkStatusService, EkStatusService>();
|
|
|
|
|
|
services.AddTransient<IEsppSchTypeScheduleService, EsppSchTypeScheduleService>();
|
2024-07-01 11:32:19 +10:00
|
|
|
|
services.AddTransient<IWeekendDayService, WeekendDayService>();
|
2024-07-01 12:09:01 +10:00
|
|
|
|
services.AddTransient<IDistributionPeriodService, DistributionPeriodService>();
|
2024-07-03 10:16:54 +10:00
|
|
|
|
services.AddTransient<IEsppSchTypeValueService, EsppSchTypeValueService>();
|
2024-08-16 13:59:27 +10:00
|
|
|
|
services.AddTransient<IResponseAreaService, ResponseAreaService>();
|
2024-10-08 10:29:34 +10:00
|
|
|
|
services.AddTransient<ITemplateHistoryService, TemplateHistoryService>();
|
2024-10-08 13:53:57 +10:00
|
|
|
|
services.AddTransient<IParrComponentService, ParrComponentService>();
|
2025-12-02 09:49:08 +10:00
|
|
|
|
services.AddTransient<ITemplateStatusTypeService, TemplateStatusTypeService>();
|
2024-08-06 10:52:27 +10:00
|
|
|
|
|
2025-12-25 17:01:42 +10:00
|
|
|
|
#region Schedule
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IScheduleExcludeTypeService, ScheduleExcludeTypeService>();
|
|
|
|
|
|
services.AddTransient<IScheduleExcludeTypeCalendarService, ScheduleExcludeTypeCalendarService>();
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2025-05-14 15:13:30 +10:00
|
|
|
|
#region Unit
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IUnitService, UnitService>();
|
|
|
|
|
|
services.AddTransient<IUnitFieldValueService, UnitFieldValueService>();
|
|
|
|
|
|
services.AddTransient<IUnitFieldService, UnitFieldService>();
|
2025-12-09 16:50:35 +10:00
|
|
|
|
services.AddTransient<IUnitInUnitService, UnitInUnitService>();
|
|
|
|
|
|
services.AddTransient<IUnitInValueService, UnitInValueService>();
|
2025-12-18 16:48:48 +10:00
|
|
|
|
services.AddTransient<IUnitRegionalEkPtkGroupService, UnitRegionalEkPtkGroupService>();
|
2025-12-19 09:09:22 +10:00
|
|
|
|
services.AddTransient<IUnitKiiUnitService, UnitKiiUnitService>();
|
2025-05-14 15:13:30 +10:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2025-06-04 11:55:23 +10:00
|
|
|
|
#region Job
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IJobService, JobService>();
|
2025-06-25 14:17:34 +10:00
|
|
|
|
services.AddTransient<IJobGroupService, JobGroupService>();
|
2025-11-14 14:48:56 +10:00
|
|
|
|
services.AddTransient<IJobGroupTypeService, JobGroupTypeService>();
|
2025-06-25 14:17:34 +10:00
|
|
|
|
services.AddTransient<IJobUnitFilterService, JobUnitFilterService>();
|
2025-06-04 11:55:23 +10:00
|
|
|
|
services.AddTransient<IFieldFilterService, FieldFilterService>();
|
2025-06-25 14:17:34 +10:00
|
|
|
|
services.AddTransient<IJobUnitFilterService, JobUnitFilterService>();
|
2025-12-08 14:23:08 +10:00
|
|
|
|
services.AddTransient<IJobAutoControlService, JobAutoControlService>();
|
2025-06-04 11:55:23 +10:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2024-08-06 10:52:27 +10:00
|
|
|
|
|
2026-02-03 16:15:19 +10:00
|
|
|
|
//services.AddTransient<INextRunModifierService, NextRunModifierService>();
|
2025-06-18 09:58:23 +10:00
|
|
|
|
|
2025-12-22 17:03:41 +10:00
|
|
|
|
#region NextRun Services
|
|
|
|
|
|
|
2026-02-03 16:15:19 +10:00
|
|
|
|
services.AddTransient<IEsppScheduleTransformService, EsppScheduleTransformService>();
|
2025-12-22 17:03:41 +10:00
|
|
|
|
services.AddTransient<ITemplateDistributor, TemplateDistributor>();
|
2026-03-05 10:19:54 +10:00
|
|
|
|
services.AddTransient<INextRunService, NextRunService>();
|
2025-12-22 17:03:41 +10:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-18 09:58:23 +10:00
|
|
|
|
#region DomainServces
|
2025-08-01 09:02:01 +10:00
|
|
|
|
services.AddTransient<IShortcodesService, ShortcodesService>();
|
2025-08-22 11:25:51 +10:00
|
|
|
|
services.AddTransient<IUnitFilterService, UnitFilterService>();
|
2026-01-16 11:04:26 +10:00
|
|
|
|
services.AddTransient<IMatchingStatusService, MatchingStatusService>();
|
2026-02-19 17:28:12 +10:00
|
|
|
|
|
|
|
|
|
|
services.AddSingleton(new UnitFilterServiceOptions { LoadBatchSize = 1000 });
|
2025-06-18 09:58:23 +10:00
|
|
|
|
#endregion
|
2026-01-15 15:01:56 +10:00
|
|
|
|
|
|
|
|
|
|
|
2023-05-17 16:30:13 +10:00
|
|
|
|
}
|
2023-09-19 14:34:55 +10:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Добавляет конфигурацию Dal (2)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="builder"></param>
|
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IConfigurationBuilder AddDalConfigurations(this IConfigurationBuilder builder, IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
builder.Add(new DBConfigurationSource(services));
|
|
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Добавляет конфигурацию в сервисы (3)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
|
/// <param name="configuration"></param>
|
|
|
|
|
|
public static void AddDallSettings(this IServiceCollection services, IConfiguration configuration)
|
|
|
|
|
|
{
|
|
|
|
|
|
//SettingsFromDb configuration
|
|
|
|
|
|
var settingsFromDb = new SettingsFromDb();
|
|
|
|
|
|
configuration.GetSection(nameof(SettingsFromDb)).Bind(settingsFromDb);
|
|
|
|
|
|
services.AddSingleton(settingsFromDb);
|
|
|
|
|
|
|
2024-02-13 15:28:32 +10:00
|
|
|
|
PrefixSettings.PrefixWithoutVariable = settingsFromDb.TemplatePrefixWithoutVariable;
|
2026-02-03 16:15:19 +10:00
|
|
|
|
|
|
|
|
|
|
// Сервис - Расписание в ЕСПП. Смещение часового пояса относительно МСК для зоны ответственности рабочей группы
|
|
|
|
|
|
services.AddSingleton<IScheduleResponseAreaTimeOffsetService>(provider =>
|
|
|
|
|
|
{
|
|
|
|
|
|
using var scope = provider.CreateScope();
|
|
|
|
|
|
var dbContext = scope.ServiceProvider.GetRequiredService<DataContext>();
|
|
|
|
|
|
var settingsFromDb = scope.ServiceProvider.GetRequiredService<SettingsFromDb>();
|
2026-02-13 15:39:21 +10:00
|
|
|
|
var logger = scope.ServiceProvider.GetRequiredService<ILogger<ScheduleResponseAreaTimeOffsetService>>();
|
2026-02-03 16:15:19 +10:00
|
|
|
|
|
2026-02-13 15:39:21 +10:00
|
|
|
|
return new ScheduleResponseAreaTimeOffsetService(dbContext, settingsFromDb, logger);
|
2026-02-03 16:15:19 +10:00
|
|
|
|
});
|
2023-10-24 15:40:52 +10:00
|
|
|
|
}
|
2023-09-19 14:34:55 +10:00
|
|
|
|
|
2023-05-17 16:30:13 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|