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

@@ -12,10 +12,10 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -9,9 +9,9 @@ using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -16,7 +16,6 @@ using PARR.BLL.Domain.Mq;
using PARR.BLL.Helpers;
using PARR.BLL.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.DomainServices.Interfaces;
using PARR.DAL.DomainServices.UnitFilterService;
using PARR.DAL.Extensions;
@@ -24,6 +23,7 @@ using PARR.DAL.Models.Job;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;

View File

@@ -16,13 +16,13 @@ using PARR.BLL.Domain.Mq;
using PARR.BLL.Helpers;
using PARR.BLL.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.DomainServices.Interfaces;
using PARR.DAL.Models;
using PARR.DAL.Models.Job;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Schedule;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;

View File

@@ -9,9 +9,9 @@ using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -12,9 +12,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -12,9 +12,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -12,9 +12,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -13,11 +13,11 @@ using PARR.API.Services.Interfaces;
using PARR.BLL.Helpers;
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
using PARR.DAL.DomainServices.Shortcodes;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Schedule;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;

View File

@@ -9,9 +9,9 @@ using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -12,9 +12,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -10,9 +10,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.BLL.Helpers;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models.Unit;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -10,9 +10,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.BLL.Helpers;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models.Unit;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -12,9 +12,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -12,9 +12,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Controllers.V1
{

View File

@@ -10,9 +10,9 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Enums;
namespace PARR.API.Controllers.V1

View File

@@ -1,5 +1,5 @@
using PARR.API.Contracts.V1.Responses.Base;
using PARR.DAL.DomainModels;
using PARR.Domain.Common.Pagination;
namespace PARR.API.Extensions
{

View File

@@ -1,8 +1,8 @@
using AutoMapper;
using PARR.API.Contracts.V1.Requests;
using PARR.API.Contracts.V1.Requests.Queries;
using PARR.DAL.DomainModels;
using PARR.DAL.Models.Job;
using PARR.Domain.Common.Pagination;
namespace PARR.API.MappingProfiles
{

View File

@@ -10,7 +10,6 @@
<Folder Include="Infrastructure\" />
<Folder Include="Common\" />
<Folder Include="Services\" />
<Folder Include="Repositories\" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,26 @@
using PARR.Domain.Common.Pagination;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
namespace PARR.Core.Repositories.Base
{
public interface IBaseRepository<T> where T : class, IBaseEntity
{
Task<T?> GetAsync(Guid id);
IQueryable<T> Get();
IQueryable<T> GetPage(IQueryable<T> query, PaginationFilter paginationFilter);
Task<bool> CreateAsync(T obj);
Task<bool> AddRangeAsync(List<T> objs);
Task<bool> DeleteAsync(Guid id);
bool Delete(T obj);
//Task<bool> CommitAsync();
Task<bool> CommitAsync(IHistoryInitiator? initiator = null);
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.Core.Repositories.Interfaces.TaskRepositories
{
public interface ITaskErrorRepository : IBaseRepository<TaskError>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.Core.Repositories.Interfaces.TaskRepositories
{
public interface ITaskRepository : IBaseRepository<TaskItem>
{
}
}

View File

@@ -0,0 +1,9 @@
using PARR.Domain.Entities.TaskEntities;
namespace PARR.Core.Repositories.Interfaces.TaskRepositories
{
public interface ITaskTypeRepository
{
IQueryable<TaskType> Get();
}
}

View File

@@ -1,10 +0,0 @@
namespace PARR.DAL.DomainModels
{
public class PaginationFilter
{
public int PageNumber { get; set; }
public int PageSize { get; set; }
//public bool IsDisabledPagination { get; set; }
}
}

View File

@@ -51,7 +51,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TemplateId");
b.ToTable("AgentHistories");
b.ToTable("AgentHistories", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.AgentHistoryLevel", b =>
@@ -72,7 +72,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Id");
b.ToTable("AgentHistoryLevels");
b.ToTable("AgentHistoryLevels", (string)null);
b.HasData(
new
@@ -101,7 +101,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("WorkGroupId");
b.ToTable("AppInWorkInWorkGroups");
b.ToTable("AppInWorkInWorkGroups", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
@@ -130,7 +130,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("Name", "ApplicationTypeId")
.IsUnique();
b.ToTable("Applications");
b.ToTable("Applications", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b =>
@@ -157,7 +157,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("HostId");
b.ToTable("ApplicationsInHost");
b.ToTable("ApplicationsInHost", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b =>
@@ -181,7 +181,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Id");
b.ToTable("ApplicationTypes");
b.ToTable("ApplicationTypes", (string)null);
b.HasData(
new
@@ -294,7 +294,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("WorkId", "ApplicationId")
.IsUnique();
b.ToTable("ApplicationsInWorks");
b.ToTable("ApplicationsInWorks", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.DistributionPeriod", b =>
@@ -397,7 +397,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Code");
b.ToTable("EkStatuses");
b.ToTable("EkStatuses", (string)null);
b.HasData(
new
@@ -1516,7 +1516,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("WorkGroupId");
b.ToTable("Hosts");
b.ToTable("Hosts", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
@@ -1912,7 +1912,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TemplateId");
b.ToTable("Orders");
b.ToTable("Orders", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.OrderStatus", b =>
@@ -1933,7 +1933,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Code");
b.ToTable("OrderStatuses");
b.ToTable("OrderStatuses", (string)null);
b.HasData(
new
@@ -1986,7 +1986,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("Name")
.IsUnique();
b.ToTable("ParrComponents");
b.ToTable("ParrComponents", (string)null);
b.HasData(
new
@@ -2099,7 +2099,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("EsppId")
.IsUnique();
b.ToTable("Processes");
b.ToTable("Processes", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.ResponseArea", b =>
@@ -2116,7 +2116,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Code");
b.ToTable("ResponseAreas");
b.ToTable("ResponseAreas", (string)null);
b.HasData(
new
@@ -2242,7 +2242,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("Name")
.IsUnique();
b.ToTable("Robots");
b.ToTable("Robots", (string)null);
b.HasData(
new
@@ -2301,7 +2301,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TemplateId", "TaskStatusCode");
b.ToTable("RobotConfigurations");
b.ToTable("RobotConfigurations", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.RobotHistory", b =>
@@ -2339,7 +2339,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("TaskStatusCode");
b.ToTable("RobotHistories");
b.ToTable("RobotHistories", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.RobotHistoryLevel", b =>
@@ -2360,7 +2360,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Level");
b.ToTable("RobotHistoryLevels");
b.ToTable("RobotHistoryLevels", (string)null);
b.HasData(
new
@@ -2407,7 +2407,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Code");
b.ToTable("RobotStatuses");
b.ToTable("RobotStatuses", (string)null);
b.HasData(
new
@@ -2455,7 +2455,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Id");
b.ToTable("Roles");
b.ToTable("Roles", (string)null);
b.HasData(
new
@@ -2624,7 +2624,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Name");
b.ToTable("Settings");
b.ToTable("Settings", (string)null);
b.HasData(
new
@@ -2748,7 +2748,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("ProcessId");
b.ToTable("Subprocesses");
b.ToTable("Subprocesses", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.TaskModels.TaskError", b =>
@@ -2941,7 +2941,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Code");
b.ToTable("TaskStatuses");
b.ToTable("TaskStatuses", (string)null);
b.HasData(
new
@@ -3027,7 +3027,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("Name", "Index")
.IsUnique();
b.ToTable("Templates");
b.ToTable("Templates", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.TemplateHistory", b =>
@@ -3080,7 +3080,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("ParentId");
b.ToTable("TemplateHistories");
b.ToTable("TemplateHistories", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.TemplateStatusType", b =>
@@ -3098,7 +3098,7 @@ namespace PARR.DAL.Migrations
b.HasKey("Id");
b.ToTable("TemplateStatusTypes", t =>
b.ToTable("TemplateStatusTypes", null, t =>
{
t.HasComment("Таблица описания критериев выборки аттрибутов ЭК");
});
@@ -3159,7 +3159,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("SubprocessId");
b.ToTable("Tnks");
b.ToTable("Tnks", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.Unit.Unit", b =>
@@ -3425,7 +3425,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("Ip")
.IsUnique();
b.ToTable("Users");
b.ToTable("Users", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.UsersInRole", b =>
@@ -3440,7 +3440,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("UserId");
b.ToTable("UsersInRoles");
b.ToTable("UsersInRoles", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.WeekendDay", b =>
@@ -3480,7 +3480,7 @@ namespace PARR.DAL.Migrations
b.HasIndex("ResponseAreaCode");
b.ToTable("WorkGroups");
b.ToTable("WorkGroups", (string)null);
});
modelBuilder.Entity("PARR.DAL.Models.AgentHistory", b =>

View File

@@ -26,8 +26,4 @@
<ProjectReference Include="..\PARR.Core\PARR.Core.csproj" />
<ProjectReference Include="..\PARR.Domain\PARR.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Repositories\Base\" />
</ItemGroup>
</Project>

View File

@@ -2,6 +2,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PARR.Core.Repositories.Interfaces.TaskRepositories;
using PARR.DAL.Cache.Services.Base;
using PARR.DAL.Configurations.DbSettings;
using PARR.DAL.Context;
@@ -14,16 +15,15 @@ using PARR.DAL.DomainServices.UnitFilterService.Models;
using PARR.DAL.InfluxDbServices;
using PARR.DAL.NextRunServices;
using PARR.DAL.NextRunServices.Subservices;
using PARR.DAL.Repositories.TaskRepositories;
using PARR.DAL.Services.Implementation;
using PARR.DAL.Services.Implementations;
using PARR.DAL.Services.Implementations.Job;
using PARR.DAL.Services.Implementations.Schedule;
using PARR.DAL.Services.Implementations.TaskServices;
using PARR.DAL.Services.Implementations.Unit;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Schedule;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.DAL.Settings;
using PARR.DAL.TaskServices;
@@ -154,9 +154,9 @@ namespace PARR.DAL
#region Task
services.AddTransient<ITaskErrorService, TaskErrorService>();
services.AddTransient<ITaskService, TaskService>();
services.AddTransient<ITaskTypeService, TaskTypeService>();
services.AddScoped<ITaskErrorRepository, TaskErrorRepository>();
services.AddScoped<ITaskRepository, TaskRepository>();
services.AddScoped<ITaskTypeRepository, TaskTypeRepository>();
services.AddTransient<ITaskManagementService, TaskManagementService>();

View File

@@ -1,28 +1,40 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.Extensions.Logging;
using PARR.Core.Repositories.Base;
using PARR.DAL.Context;
using PARR.DAL.DomainModels;
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.Base.History.Base;
using System.Reflection;
namespace PARR.DAL.Services.Abstracts
namespace PARR.DAL.Repositories.Base
{
internal abstract class BaseService<T> : IBaseService<T> where T : class, IBaseEntity
internal abstract class BaseRepository<T> : IBaseRepository<T> where T : class, IBaseEntity
{
private readonly ILogger<BaseService<T>> logger;
//private readonly ILogger<BaseRepository<T>> logger;
protected abstract DbSet<T> EntitySet { get; }
protected abstract DataContext EntitiContext { get; }
//protected abstract DbSet<T> EntitySet { get; }
//protected abstract DataContext EntitiContext { get; }
public BaseService(ILogger<BaseService<T>> logger)
//public BaseRepository(ILogger<BaseRepository<T>> logger)
//{
// this.logger = logger;
//}
protected readonly ILogger logger;
protected readonly DbSet<T> EntitySet;
protected readonly DataContext EntityContext;
protected BaseRepository(ILogger logger, DataContext dataContext)
{
this.logger = logger;
this.EntityContext = dataContext;
this.EntitySet = dataContext.Set<T>();
}
public virtual async Task<bool> AddRangeAsync(List<T> objs)
{
logger.LogDebug("Начинаю добавление диапазона объектов типа {EntityType}, количество: {Count}",
@@ -49,7 +61,7 @@ namespace PARR.DAL.Services.Abstracts
logger.LogDebug("Начинаю сохранение изменений в БД для объектов типа {EntityType}", typeof(T).Name);
#region Изменения
var modifiedEntrities = EntitiContext.ChangeTracker.Entries()
var modifiedEntrities = EntityContext.ChangeTracker.Entries()
.Where(t => t.State == EntityState.Modified/* || t.State == EntityState.Deleted*/);
logger.LogDebug("Найдено {Count} измененных сущностей для обработки истории", modifiedEntrities.Count());
@@ -68,7 +80,7 @@ namespace PARR.DAL.Services.Abstracts
try
{
var changedCount = await EntitiContext.SaveChangesAsync();
var changedCount = await EntityContext.SaveChangesAsync();
logger.LogDebug("Успешно сохранено {ChangedCount} изменений в БД для объектов типа {EntityType}",
changedCount, typeof(T).Name);
return true;
@@ -90,7 +102,7 @@ namespace PARR.DAL.Services.Abstracts
logger.LogDebug("Устанавливаю инициатора для изменений");
// Задаем инициатора только для новых и измененных записей
var entrities = EntitiContext.ChangeTracker.Entries()
var entrities = EntityContext.ChangeTracker.Entries()
.Where(t => t.State == EntityState.Modified || t.State == EntityState.Added);
var entityCount = entrities.Count();
@@ -172,7 +184,7 @@ namespace PARR.DAL.Services.Abstracts
try
{
EntitiContext.Add(historyInstance);
EntityContext.Add(historyInstance);
logger.LogDebug("История добавлена для сущности типа {EntityType}", obj.Entity.GetType().Name);
}
catch (Exception ex)

View File

@@ -0,0 +1,13 @@
using Microsoft.Extensions.Logging;
using PARR.Core.Repositories.Interfaces.TaskRepositories;
using PARR.DAL.Context;
using PARR.DAL.Repositories.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Repositories.TaskRepositories
{
internal class TaskErrorRepository : BaseRepository<TaskError>, ITaskErrorRepository
{
public TaskErrorRepository(DataContext dataContext, ILogger<TaskErrorRepository> logger) : base(logger, dataContext) { }
}
}

View File

@@ -0,0 +1,16 @@
using Microsoft.Extensions.Logging;
using PARR.Core.Repositories.Interfaces.TaskRepositories;
using PARR.DAL.Context;
using PARR.DAL.Repositories.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Repositories.TaskRepositories
{
internal class TaskRepository : BaseRepository<TaskItem>, ITaskRepository
{
public TaskRepository(DataContext dataContext, ILogger<TaskRepository> logger) : base(logger, dataContext) { }
// метод атомарного взятия в работу
}
}

View File

@@ -1,14 +1,14 @@
using PARR.DAL.Context;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Core.Repositories.Interfaces.TaskRepositories;
using PARR.DAL.Context;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
namespace PARR.DAL.Repositories.TaskRepositories
{
internal class TaskTypeService : ITaskTypeService
internal class TaskTypeRepository : ITaskTypeRepository
{
private readonly DataContext dataContext;
public TaskTypeService(DataContext dataContext)
public TaskTypeRepository(DataContext dataContext)
{
this.dataContext = dataContext;
}

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,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)

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);

View File

@@ -1,22 +1,41 @@
using PARR.DAL.DomainModels;
using PARR.Core.Repositories.Base;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
namespace PARR.DAL.Services.Interfaces.Base
{
public interface IBaseService<T> where T : class, IBaseEntity
public interface IBaseService<T> : IBaseRepository<T> where T : class, IBaseEntity
{
Task<T?> GetAsync(Guid id);
IQueryable<T> Get();
IQueryable<T> GetPage(IQueryable<T> query, PaginationFilter paginationFilter);
// TODO: позже удалить этот интерфейс, когда изменим все сервисы на репозитории
Task<bool> CreateAsync(T obj);
Task<bool> AddRangeAsync(List<T> objs);
//Task<T?> GetAsync(Guid id);
//IQueryable<T> Get();
//IQueryable<T> GetPage(IQueryable<T> query, PaginationFilter paginationFilter);
Task<bool> DeleteAsync(Guid id);
bool Delete(T obj);
//Task<bool> CreateAsync(T obj);
//Task<bool> AddRangeAsync(List<T> objs);
//Task<bool> CommitAsync();
Task<bool> CommitAsync(IHistoryInitiator? initiator = null);
//Task<bool> DeleteAsync(Guid id);
//bool Delete(T obj);
////Task<bool> CommitAsync();
//Task<bool> CommitAsync(IHistoryInitiator? initiator = null);
}
//public interface IBaseService<T> where T : class, IBaseEntity
//{
// Task<T?> GetAsync(Guid id);
// IQueryable<T> Get();
// IQueryable<T> GetPage(IQueryable<T> query, PaginationFilter paginationFilter);
// Task<bool> CreateAsync(T obj);
// Task<bool> AddRangeAsync(List<T> objs);
// Task<bool> DeleteAsync(Guid id);
// bool Delete(T obj);
// //Task<bool> CommitAsync();
// Task<bool> CommitAsync(IHistoryInitiator? initiator = null);
//}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Interfaces.TaskServices
{
public interface ITaskErrorService : IBaseService<TaskError>
{
}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Interfaces.TaskServices
{
public interface ITaskService : IBaseService<TaskItem>
{
}
}

View File

@@ -1,9 +0,0 @@
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Interfaces.TaskServices
{
public interface ITaskTypeService
{
IQueryable<TaskType> Get();
}
}

View File

@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.BLL.Contracts.Interfaces;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Core.Repositories.Interfaces.TaskRepositories;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.TaskEntities;
using PARR.Domain.Enums;
@@ -13,13 +13,13 @@ namespace PARR.DAL.TaskServices
internal class TaskManagementService : ITaskManagementService
{
private readonly ILogger<TaskManagementService> logger;
private readonly ITaskTypeService taskTypeService;
private readonly ITaskService taskService;
private readonly ITaskTypeRepository taskTypeService;
private readonly ITaskRepository taskService;
public TaskManagementService(
ILogger<TaskManagementService> logger,
ITaskTypeService taskTypeService,
ITaskService taskService
ITaskTypeRepository taskTypeService,
ITaskRepository taskService
)
{
this.logger = logger;

View File

@@ -0,0 +1,11 @@
namespace PARR.Domain.Common.Pagination
{
/// <summary>
/// Параметры пагинации
/// </summary>
public record PaginationFilter
{
public int PageNumber { get; init; }
public int PageSize { get; init; }
}
}