2023-05-17 16:30:13 +10:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2023-11-30 16:18:14 +10:00
|
|
|
|
using PARR.DAL.CacheServices;
|
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-06-18 09:58:23 +10:00
|
|
|
|
using PARR.DAL.DomainServices;
|
2024-05-28 14:35:39 +10:00
|
|
|
|
using PARR.DAL.InfluxDbServices;
|
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-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-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-10-17 09:42:18 +10:00
|
|
|
|
using PARR.DAL.TransformServices;
|
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
|
|
|
|
|
2024-05-28 14:35:39 +10:00
|
|
|
|
#region Redis
|
|
|
|
|
|
|
2023-11-30 16:18:14 +10:00
|
|
|
|
services.AddStackExchangeRedisCache(opt =>
|
|
|
|
|
|
{
|
|
|
|
|
|
opt.Configuration = configuration.GetConnectionString("RedisConnection");
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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<IWorkService, WorkService>();
|
|
|
|
|
|
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-09-09 10:08:07 +10:00
|
|
|
|
services.AddTransient<IJobAutoControlService, JobAutoControlService>();
|
|
|
|
|
|
services.AddTransient<IJobEkMaskService, JobEkMaskService>();
|
2024-10-08 10:29:34 +10:00
|
|
|
|
services.AddTransient<ITemplateHistoryService, TemplateHistoryService>();
|
2024-10-08 13:53:57 +10:00
|
|
|
|
services.AddTransient<IParrComponentService, ParrComponentService>();
|
2024-08-06 10:52:27 +10:00
|
|
|
|
|
2025-05-14 15:13:30 +10:00
|
|
|
|
#region Unit
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IUnitService, UnitService>();
|
|
|
|
|
|
services.AddTransient<IUnitFieldValueService, UnitFieldValueService>();
|
|
|
|
|
|
services.AddTransient<IUnitFieldService, UnitFieldService>();
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2025-06-04 11:55:23 +10:00
|
|
|
|
#region Job
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IJobService, JobService>();
|
|
|
|
|
|
services.AddTransient<IJobDetailsService, JobDetailsService>();
|
|
|
|
|
|
services.AddTransient<IFieldFilterService, FieldFilterService>();
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2024-08-06 10:52:27 +10:00
|
|
|
|
|
2023-10-17 09:42:18 +10:00
|
|
|
|
// TransformServices
|
|
|
|
|
|
services.AddTransient<IEsppScheduleTransformService, EsppScheduleTransformService>();
|
2024-08-06 10:52:27 +10:00
|
|
|
|
services.AddTransient<INextRunModifierService, NextRunModifierService>();
|
2025-06-18 09:58:23 +10:00
|
|
|
|
|
|
|
|
|
|
#region DomainServces
|
|
|
|
|
|
services.AddTransient<ITemplateNameGeneratorService, TemplateNameGeneratorService>();
|
|
|
|
|
|
#endregion
|
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;
|
2023-10-24 15:40:52 +10:00
|
|
|
|
}
|
2023-09-19 14:34:55 +10:00
|
|
|
|
|
2023-05-17 16:30:13 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|