feat: разделение на repository - services

This commit is contained in:
Mikhail Trubnikov
2026-04-14 09:56:31 +10:00
parent da83aff19c
commit 734c2e3c99
71 changed files with 333 additions and 605 deletions

View File

@@ -1,23 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class AgentHistoryService : BaseService<AgentHistory>, IAgentHistoryService
internal class AgentHistoryService : BaseRepository<AgentHistory>, IAgentHistoryService
{
private readonly DataContext dataContext;
public AgentHistoryService(DataContext dataContext, ILogger<AgentHistoryService> logger) : base(logger, dataContext) { }
public AgentHistoryService(DataContext dataContext, ILogger<AgentHistoryService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<AgentHistory> EntitySet => dataContext.AgentHistories;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -1,25 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationInHostService : BaseService<ApplicationInHost>, IApplicationInHostService
internal class ApplicationInHostService : BaseRepository<ApplicationInHost>, IApplicationInHostService
{
private readonly DataContext dataContext;
private readonly ILogger<ApplicationInHostService> logger;
public ApplicationInHostService(DataContext dataContext, ILogger<ApplicationInHostService> logger) : base(logger, dataContext) { }
public ApplicationInHostService(DataContext dataContext, ILogger<ApplicationInHostService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -2,25 +2,14 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationService : BaseService<Application>, IApplicationService
internal class ApplicationService : BaseRepository<Application>, IApplicationService
{
private readonly DataContext dataContext;
private readonly ILogger<ApplicationService> logger;
public ApplicationService(DataContext dataContext, ILogger<ApplicationService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<Application> EntitySet => dataContext.Applications;
protected override DataContext EntitiContext => dataContext;
public ApplicationService(DataContext dataContext, ILogger<ApplicationService> logger) : base(logger, dataContext) { }
public async Task<Application?> GetByNameAsync(string appName, Guid typeId)
{

View File

@@ -1,25 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementation
{
internal class ApplicationTypeService : BaseService<ApplicationType>, IApplicationTypeService
internal class ApplicationTypeService : BaseRepository<ApplicationType>, IApplicationTypeService
{
private readonly DataContext dataContext;
private readonly ILogger<ApplicationTypeService> logger;
public ApplicationTypeService(DataContext dataContext, ILogger<ApplicationTypeService> logger) : base(logger, dataContext) { }
public ApplicationTypeService(DataContext dataContext, ILogger<ApplicationTypeService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<ApplicationType> EntitySet => dataContext.ApplicationTypes;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -2,26 +2,14 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationsInWorkService : BaseService<ApplicationsInWork>, IApplicationsInWorkService
internal class ApplicationsInWorkService : BaseRepository<ApplicationsInWork>, IApplicationsInWorkService
{
private readonly DataContext dataContext;
private readonly ILogger<ApplicationsInWorkService> logger;
public ApplicationsInWorkService(DataContext dataContext, ILogger<ApplicationsInWorkService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<ApplicationsInWork> EntitySet => dataContext.ApplicationsInWorks;
protected override DataContext EntitiContext => dataContext;
public ApplicationsInWorkService(DataContext dataContext, ILogger<ApplicationsInWorkService> logger) : base(logger, dataContext) { }
public async Task<ApplicationsInWork?> GetAsync(Guid applicationId, Guid workId)
{

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class DistributionPeriodService : BaseService<DistributionPeriod>, IDistributionPeriodService
internal class DistributionPeriodService : BaseRepository<DistributionPeriod>, IDistributionPeriodService
{
private readonly DataContext dataContext;
protected override DbSet<DistributionPeriod> EntitySet => dataContext.DistributionPeriods;
protected override DataContext EntitiContext => dataContext;
public DistributionPeriodService(DataContext dataContext, ILogger<DistributionPeriodService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public DistributionPeriodService(DataContext dataContext, ILogger<DistributionPeriodService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -3,23 +3,14 @@ using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class EsppSchTypeConfigService : BaseService<EsppSchTypeConfig>, IEsppSchTypeConfigService
internal class EsppSchTypeConfigService : BaseRepository<EsppSchTypeConfig>, IEsppSchTypeConfigService
{
private readonly DataContext dataContext;
public EsppSchTypeConfigService(DataContext dataContext, ILogger<EsppSchTypeConfigService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<EsppSchTypeConfig> EntitySet => dataContext.EsppSchTypeConfigs;
protected override DataContext EntitiContext => dataContext;
public EsppSchTypeConfigService(DataContext dataContext, ILogger<EsppSchTypeConfigService> logger) : base(logger, dataContext) { }
public IQueryable<EsppSchTypeConfig> GetWithSchIncludes()
{
@@ -36,7 +27,7 @@ namespace PARR.DAL.Services.Implementations
{
//Формирует расписание в нормальном понятном виде из БД
var items = await dataContext.EsppSchValues.Where(t => t.JobGroupId == jobGroupId)
var items = await EntityContext.EsppSchValues.Where(t => t.JobGroupId == jobGroupId)
.Select(t => new
{
t.EsppSchTypeConfig!.Order,

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class EsppSchTypeValueService : BaseService<EsppSchTypeValue>, IEsppSchTypeValueService
internal class EsppSchTypeValueService : BaseRepository<EsppSchTypeValue>, IEsppSchTypeValueService
{
private readonly DataContext dataContext;
protected override DbSet<EsppSchTypeValue> EntitySet => dataContext.EsppSchTypeValues;
protected override DataContext EntitiContext => dataContext;
public EsppSchTypeValueService(DataContext dataContext, ILogger<EsppSchTypeValueService> logger): base(logger)
{
this.dataContext = dataContext;
}
public EsppSchTypeValueService(DataContext dataContext, ILogger<EsppSchTypeValueService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -2,24 +2,14 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class HostService : BaseService<Host>, IHostService
internal class HostService : BaseRepository<Host>, IHostService
{
private readonly DataContext dataContext;
private readonly ILogger<HostService> logger;
protected override DbSet<Host> EntitySet => dataContext.Hosts;
protected override DataContext EntitiContext => dataContext;
public HostService(DataContext dataContext, ILogger<HostService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
public HostService(DataContext dataContext, ILogger<HostService> logger) : base(logger, dataContext) { }
public async Task<Host?> GetHostWithAppsByIpAsync(string ip)

View File

@@ -1,21 +1,12 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Job;
namespace PARR.DAL.Services.Implementations.Job
{
internal class FieldFilterService : BaseService<Models.Job.JobFieldFilter>, IFieldFilterService
internal class FieldFilterService : BaseRepository<Models.Job.JobFieldFilter>, IFieldFilterService
{
private readonly DataContext dataContext;
protected override DbSet<Models.Job.JobFieldFilter> EntitySet => dataContext.FieldFilters;
protected override DataContext EntitiContext => dataContext;
public FieldFilterService(DataContext dataContext, ILogger<FieldFilterService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public FieldFilterService(DataContext dataContext, ILogger<FieldFilterService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Job;
namespace PARR.DAL.Services.Implementations.Job
{
internal class JobUnitFilterService : BaseService<JobUnitFilter>, IJobUnitFilterService
internal class JobUnitFilterService : BaseRepository<JobUnitFilter>, IJobUnitFilterService
{
private readonly DataContext dataContext;
protected override DbSet<JobUnitFilter> EntitySet => dataContext.JobUnitFilters;
protected override DataContext EntitiContext => dataContext;
public JobUnitFilterService(DataContext dataContext, ILogger<JobUnitFilterService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public JobUnitFilterService(DataContext dataContext, ILogger<JobUnitFilterService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,28 +1,19 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Job;
namespace PARR.DAL.Services.Implementations.Job
{
internal class JobGroupService : BaseService<Models.Job.JobGroup>, IJobGroupService
internal class JobGroupService : BaseRepository<Models.Job.JobGroup>, IJobGroupService
{
private readonly DataContext dataContext;
public JobGroupService(DataContext dataContext, ILogger<JobGroupService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<JobGroup> EntitySet => dataContext.JobGroups;
protected override DataContext EntitiContext => dataContext;
public JobGroupService(DataContext dataContext, ILogger<JobGroupService> logger) : base(logger, dataContext) { }
public void DeleteDistributionConfig(JobGroupDistributionConfig distributionConfig)
{
EntitiContext.JobGroupDistributionConfigs.Remove(distributionConfig);
EntityContext.JobGroupDistributionConfigs.Remove(distributionConfig);
}
}
}

View File

@@ -1,27 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Job;
namespace PARR.DAL.Services.Implementations.Job
{
internal class JobGroupTypeService : BaseService<JobGroupType>, IJobGroupTypeService
internal class JobGroupTypeService : BaseRepository<JobGroupType>, IJobGroupTypeService
{
private readonly DataContext dataContext;
private readonly ILogger<JobGroupTypeService> logger;
protected override DbSet<JobGroupType> EntitySet => dataContext.JobGroupTypes;
protected override DataContext EntitiContext => dataContext;
public JobGroupTypeService(
DataContext dataContext,
ILogger<JobGroupTypeService> logger
) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
public JobGroupTypeService(DataContext dataContext, ILogger<JobGroupTypeService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Job;
namespace PARR.DAL.Services.Implementations.Job
{
internal class JobService : BaseService<Models.Job.Job>, IJobService
internal class JobService : BaseRepository<Models.Job.Job>, IJobService
{
private readonly DataContext dataContext;
public JobService(DataContext dataContext, ILogger<JobService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<Models.Job.Job> EntitySet => dataContext.Jobs;
protected override DataContext EntitiContext => dataContext;
public JobService(DataContext dataContext, ILogger<JobService> logger) : base(logger, dataContext) { }
public override Task<bool> CreateAsync(Models.Job.Job obj)
{

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class OrderService : BaseService<Order>, IOrderService
internal class OrderService : BaseRepository<Order>, IOrderService
{
private readonly DataContext dataContext;
public OrderService(DataContext dataContext, ILogger<OrderService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<Order> EntitySet => dataContext.Orders;
protected override DataContext EntitiContext => dataContext;
public OrderService(DataContext dataContext, ILogger<OrderService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,24 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ProcessService : BaseService<Process>, IProcessService
internal class ProcessService : BaseRepository<Process>, IProcessService
{
private readonly ILogger<ProcessService> logger;
private readonly DataContext dataContext;
public ProcessService(ILogger<ProcessService> logger, DataContext dataContext) : base(logger, dataContext) { }
public ProcessService(ILogger<ProcessService> logger, DataContext dataContext) : base(logger)
{
this.logger = logger;
this.dataContext = dataContext;
}
protected override DbSet<Process> EntitySet => dataContext.Processes;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -3,26 +3,15 @@ using Microsoft.Extensions.Logging;
using PARR.Constants;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Enums;
namespace PARR.DAL.Services.Implementations
{
internal class RobotConfigurationService : BaseService<RobotConfiguration>, IRobotConfigurationService
internal class RobotConfigurationService : BaseRepository<RobotConfiguration>, IRobotConfigurationService
{
private readonly DataContext dataContext;
private readonly ILogger<RobotConfigurationService> logger;
public RobotConfigurationService(DataContext dataContext, ILogger<RobotConfigurationService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<RobotConfiguration> EntitySet => dataContext.RobotConfigurations;
protected override DataContext EntitiContext => dataContext;
public RobotConfigurationService(DataContext dataContext, ILogger<RobotConfigurationService> logger) : base(logger, dataContext) { }
public void ChangeTaskStatus(TaskStatusEnum taskStatus, RobotConfiguration configuration)

View File

@@ -1,23 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class RobotHistoryService : BaseService<RobotHistory>, IRobotHistoryService
internal class RobotHistoryService : BaseRepository<RobotHistory>, IRobotHistoryService
{
private readonly DataContext dataContext;
public RobotHistoryService(DataContext dataContext, ILogger<RobotHistoryService> logger) : base(logger, dataContext) { }
public RobotHistoryService(DataContext dataContext, ILogger<RobotHistoryService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<RobotHistory> EntitySet => dataContext.RobotHistories;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class RoleService : BaseService<Role>, IRoleService
internal class RoleService : BaseRepository<Role>, IRoleService
{
private readonly DataContext dataContext;
public RoleService(DataContext dataContext, ILogger<RoleService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<Role> EntitySet => dataContext.Roles;
protected override DataContext EntitiContext => dataContext;
public RoleService(DataContext dataContext, ILogger<RoleService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.DAL.Services.Implementations.Schedule
{
internal class ScheduleExcludeTypeCalendarService : BaseService<ScheduleExcludeTypeCalendar>, IScheduleExcludeTypeCalendarService
internal class ScheduleExcludeTypeCalendarService : BaseRepository<ScheduleExcludeTypeCalendar>, IScheduleExcludeTypeCalendarService
{
private readonly DataContext dataContext;
protected override DbSet<ScheduleExcludeTypeCalendar> EntitySet => dataContext.ScheduleExcludeTypeCalendars;
protected override DataContext EntitiContext => dataContext;
public ScheduleExcludeTypeCalendarService(DataContext dataContext, ILogger<ScheduleExcludeTypeCalendarService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public ScheduleExcludeTypeCalendarService(DataContext dataContext, ILogger<ScheduleExcludeTypeCalendarService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.DAL.Services.Implementations.Schedule
{
internal class ScheduleExcludeTypeService : BaseService<ScheduleExcludeType>, IScheduleExcludeTypeService
internal class ScheduleExcludeTypeService : BaseRepository<ScheduleExcludeType>, IScheduleExcludeTypeService
{
private readonly DataContext dataContext;
protected override DbSet<ScheduleExcludeType> EntitySet => dataContext.ScheduleExcludeTypes;
protected override DataContext EntitiContext => dataContext;
public ScheduleExcludeTypeService(DataContext dataContext, ILogger<ScheduleExcludeTypeService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public ScheduleExcludeTypeService(DataContext dataContext, ILogger<ScheduleExcludeTypeService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -10,10 +10,12 @@ namespace PARR.DAL.Services.Implementations.Schedule
internal sealed class ScheduleResponseAreaTimeOffsetService : IScheduleResponseAreaTimeOffsetService
{
private readonly IReadOnlyDictionary<string, ScheduleResponseAreaTimeOffset> offsetList;
/// <summary>
/// ЗО по умолчанию
/// </summary>
private readonly string defaultResponseArea;
/// <summary>
/// Настройки, если не нашли в offsetList
/// </summary>

View File

@@ -1,24 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class SubprocessService : BaseService<Subprocess>, ISubprocessService
internal class SubprocessService : BaseRepository<Subprocess>, ISubprocessService
{
private readonly ILogger<SubprocessService> logger;
private readonly DataContext dataContext;
public SubprocessService(ILogger<SubprocessService> logger, DataContext dataContext) : base(logger, dataContext) { }
public SubprocessService(ILogger<SubprocessService> logger, DataContext dataContext) : base(logger)
{
this.logger = logger;
this.dataContext = dataContext;
}
protected override DbSet<Subprocess> EntitySet => dataContext.Subprocesses;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -1,23 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
{
internal class TaskErrorService : BaseService<TaskError>, ITaskErrorService
{
private readonly DataContext dataContext;
protected override DbSet<TaskError> EntitySet => dataContext.TaskErrors;
protected override DataContext EntitiContext => dataContext;
public TaskErrorService(DataContext dataContext, ILogger<TaskErrorService> logger): base(logger)
{
this.dataContext = dataContext;
}
}
}

View File

@@ -1,26 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
{
internal class TaskService : BaseService<TaskItem>, ITaskService
{
private readonly DataContext dataContext;
protected override DbSet<TaskItem> EntitySet => dataContext.Tasks;
protected override DataContext EntitiContext => dataContext;
public TaskService(DataContext dataContext, ILogger<TaskService> logger) : base(logger)
{
this.dataContext = dataContext;
}
// метод атомарного взятия в работу
}
}

View File

@@ -1,21 +0,0 @@
using PARR.DAL.Context;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
{
internal class TaskTypeService : ITaskTypeService
{
private readonly DataContext dataContext;
public TaskTypeService(DataContext dataContext)
{
this.dataContext = dataContext;
}
public IQueryable<TaskType> Get()
{
return dataContext.TaskTypes;
}
}
}

View File

@@ -1,23 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class TemplateHistoryService : BaseService<TemplateHistory>, ITemplateHistoryService
internal class TemplateHistoryService : BaseRepository<TemplateHistory>, ITemplateHistoryService
{
private readonly DataContext dataContext;
protected override DbSet<TemplateHistory> EntitySet => dataContext.TemplateHistories;
protected override DataContext EntitiContext => dataContext;
public TemplateHistoryService(DataContext dataContext, ILogger<TemplateHistoryService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public TemplateHistoryService(DataContext dataContext, ILogger<TemplateHistoryService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -4,27 +4,16 @@ using Npgsql;
using PARR.Constants;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;
namespace PARR.DAL.Services.Implementations
{
internal class TemplateService : BaseService<Template>, ITemplateService
internal class TemplateService : BaseRepository<Template>, ITemplateService
{
private readonly DataContext dataContext;
private readonly ILogger<TemplateService> logger;
protected override DbSet<Template> EntitySet => dataContext.Templates;
protected override DataContext EntitiContext => dataContext;
public TemplateService(DataContext dataContext, ILogger<TemplateService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
public TemplateService(DataContext dataContext, ILogger<TemplateService> logger) : base(logger, dataContext) { }
public async Task<Template?> GetTemplateByNameAsync(string name)
{
@@ -167,7 +156,7 @@ namespace PARR.DAL.Services.Implementations
try
{
var result = await dataContext.Database
var result = await EntityContext.Database
.SqlQueryRaw<Guid>(sql, parameters)
.ToListAsync();

View File

@@ -1,24 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class TnkService : BaseService<Tnk>, ITnkService
internal class TnkService : BaseRepository<Tnk>, ITnkService
{
private readonly ILogger<TnkService> logger;
private readonly DataContext dataContext;
public TnkService(ILogger<TnkService> logger, DataContext dataContext) : base(logger, dataContext) { }
public TnkService(ILogger<TnkService> logger, DataContext dataContext) : base(logger)
{
this.logger = logger;
this.dataContext = dataContext;
}
protected override DbSet<Tnk> EntitySet => dataContext.Tnks;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -2,23 +2,14 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Unit;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Unit;
namespace PARR.DAL.Services.Implementations.Unit
{
internal class UnitFieldService : BaseService<UnitField>, IUnitFieldService
internal class UnitFieldService : BaseRepository<UnitField>, IUnitFieldService
{
private readonly DataContext dataContext;
protected override DbSet<UnitField> EntitySet => dataContext.UnitFields;
protected override DataContext EntitiContext => dataContext;
public UnitFieldService(DataContext dataContext, ILogger<UnitFieldService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public UnitFieldService(DataContext dataContext, ILogger<UnitFieldService> logger) : base(logger, dataContext) { }
public async Task<UnitField?> GetByAihitNameAsync(string name)
{

View File

@@ -2,23 +2,14 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.Unit;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Unit;
namespace PARR.DAL.Services.Implementations.Unit
{
internal class UnitFieldValueService : BaseService<UnitFieldValue>, IUnitFieldValueService
internal class UnitFieldValueService : BaseRepository<UnitFieldValue>, IUnitFieldValueService
{
private readonly DataContext dataContext;
protected override DbSet<UnitFieldValue> EntitySet => dataContext.UnitFieldValues;
protected override DataContext EntitiContext => dataContext;
public UnitFieldValueService(DataContext dataContext, ILogger<UnitFieldValueService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public UnitFieldValueService(DataContext dataContext, ILogger<UnitFieldValueService> logger) : base(logger, dataContext) { }
public async Task<UnitFieldValue?> GetByValueNameAsync(string? value)
@@ -26,7 +17,7 @@ namespace PARR.DAL.Services.Implementations.Unit
var query = EntitySet
.Include(v => v.FieldValues);
if (string.IsNullOrWhiteSpace(value))
if (string.IsNullOrWhiteSpace(value))
return await query.FirstOrDefaultAsync(uf => uf.Value == null);
return await query.FirstOrDefaultAsync(uf => uf.Value!.ToLower().Trim() == value.ToLower().Trim());

View File

@@ -1,23 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces.Unit;
namespace PARR.DAL.Services.Implementations.Unit
{
internal class UnitService : BaseService<Models.Unit.Unit>, IUnitService
internal class UnitService : BaseRepository<Models.Unit.Unit>, IUnitService
{
private readonly DataContext dataContext;
protected override DbSet<Models.Unit.Unit> EntitySet => dataContext.Units;
protected override DataContext EntitiContext => dataContext;
public UnitService(DataContext dataContext, ILogger<UnitService> logger) : base(logger)
{
this.dataContext = dataContext;
}
public UnitService(DataContext dataContext, ILogger<UnitService> logger) : base(logger, dataContext) { }
public IQueryable<Models.Unit.Unit> GetWithIncludes()

View File

@@ -2,23 +2,14 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class UserService : BaseService<User>, IUserService
internal class UserService : BaseRepository<User>, IUserService
{
private readonly DataContext dataContext;
public UserService(DataContext dataContext, ILogger<UserService> logger) : base(logger)
{
this.dataContext = dataContext;
}
protected override DbSet<User> EntitySet => dataContext.Users;
protected override DataContext EntitiContext => dataContext;
public UserService(DataContext dataContext, ILogger<UserService> logger) : base(logger, dataContext) { }
public async Task<User?> GetByIpWithRolesAsync(string ipAddress)
{

View File

@@ -4,31 +4,23 @@ using PARR.DAL.Cache.Services.Base;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class WeekendDayService : BaseService<WeekendDay>, IWeekendDayService
internal class WeekendDayService : BaseRepository<WeekendDay>, IWeekendDayService
{
private readonly DataContext dataContext;
private readonly ILogger<WeekendDayService> logger;
private readonly IRedisCacheService redisCacheService;
private readonly SettingsFromDb settings;
protected override DbSet<WeekendDay> EntitySet => dataContext.WeekendDays;
protected override DataContext EntitiContext => dataContext;
public WeekendDayService(
DataContext dataContext,
ILogger<WeekendDayService> logger,
IRedisCacheService redisCacheService,
SettingsFromDb settings
) : base(logger)
) : base(logger, dataContext)
{
this.dataContext = dataContext;
this.logger = logger;
this.redisCacheService = redisCacheService;
this.settings = settings;
}
@@ -102,12 +94,14 @@ namespace PARR.DAL.Services.Implementations
private string GetWeekendKey(DateOnly day)
{
return $"weekend_{day.ToString("yyyy-MM-dd")}";
// return $"weekend_{day.ToString("yyyy-MM-dd")}";
return redisCacheService.GetKey(new[] { "weekend", day.ToString("yyyy-MM-dd") });
}
private string GetWorkDayKey(DateOnly day)
{
return $"workday_{day.ToString("yyyy-MM-dd")}";
//return $"workday_{day.ToString("yyyy-MM-dd")}";
return redisCacheService.GetKey(new[] { "workday", day.ToString("yyyy-MM-dd") });
}
}

View File

@@ -2,24 +2,15 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class WorkGroupService : BaseService<WorkGroup>, IWorkGroupService
internal class WorkGroupService : BaseRepository<WorkGroup>, IWorkGroupService
{
private readonly DataContext dataContext;
private readonly ILogger<WorkGroupService> logger;
public WorkGroupService(DataContext dataContext, ILogger<WorkGroupService> logger) : base(logger, dataContext) { }
protected override DbSet<WorkGroup> EntitySet => dataContext.WorkGroups;
protected override DataContext EntitiContext => dataContext;
public WorkGroupService(DataContext dataContext, ILogger<WorkGroupService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
public async Task<WorkGroup?> GetByNameAsync(string name)
{
return await Get().FirstOrDefaultAsync(t => t.Name == name);