feat(dal,api): Удалены старые таблицы AppInWorks

This commit is contained in:
Mikhail Trubnikov
2026-04-15 09:35:03 +10:00
parent 50358fd5bd
commit a93e8de4b0
91 changed files with 4855 additions and 2422 deletions

View File

@@ -1,102 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class ApplicationInWorkBaseResponse
{
public Guid Id { get; set; }
public required string TemplateDuration { get; set; }
public required string ShortDescription { get; set; }
public required string FullDescription { get; set; }
public required string Solution { get; set; }
public DateTimeOffset ReferenceDate { get; set; }
public bool IsAutoDistributionEnabled { get; set; }
public bool IsAgent { get; set; }
public ApplicationResponse? Application { get; set; }
}
public class ApplicationInWorkResponse : ApplicationInWorkBaseResponse
{
public string? AgentName { get; set; }
public int? AgentTimeOutSec { get; set; }
public string? AgentScript { get; set; }
//public WorkResponse? Work { get; set; }
public int TemplatesCount { get; set; }
#region Статистика
public TemplateStats? TemplateStatistics { get; set; }
public ScheduleStats? ScheduleStatistics { get; set; }
#endregion
public ApplicationInWorkScheduleResponse? Schedule { get; set; }
public List<WorkGroupResponse>? WorkGroups { get; set; }
//public JobAutoControlBaseResponse? AutoControl { get; set; }
}
public class ApplicationInWorkScheduleResponse
{
public string Timezone { get; set; } = string.Empty;
public EsppScheduleTypeScheduleResponse? TypeSchedule { get; set; }
public List<EsppScheduleValResponse>? Values { get; set; }
}
//public class TemplateStats
//{
// /// <summary>
// /// Активированных шаблонов
// /// </summary>
// public int Activated { get; set; }
// /// <summary>
// /// Синхронизировано шаблонов (TaskStatus = 30/Ok)
// /// </summary>
// public int Synchronized { get; set; }
// /// <summary>
// /// Ошибок синхронизации (RobotStatus = 33/Error)
// /// </summary>
// public int Errors { get; set; }
//}
//public class ScheduleStats
//{
// /// <summary>
// /// Активированных шаблонов
// /// </summary>
// public int Activated { get; set; }
// /// <summary>
// /// Синхронизировано шаблонов (TaskStatus = 30/Ok)
// /// </summary>
// public int Synchronized { get; set; }
// /// <summary>
// /// Ошибок синхронизации (RobotStatus = 33/Error)
// /// </summary>
// public int Errors { get; set; }
//}
}

View File

@@ -1,11 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class ApplicationResponse
{
public Guid Id { get; set; }
public required string Name { get; set; }
public ApplicationTypeResponse? Type { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class ApplicationTypeResponse
{
public Guid Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
}
}

View File

@@ -1,8 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class EkStatusResponse
{
public int Code { get; set; }
public required string Name { get; set; }
}
}

View File

@@ -1,43 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class HostBaseResponse
{
public Guid Id { get; set; }
public string Ek { get; set; } = string.Empty;
public required string IP { get; set; }
//TODO: Удалить поле Status, использовать EkStatus
public string? Status { get; set; }
public EkStatusResponse? EkStatus { get; set; }
public string? WorkGroupName { get; set; }
public WorkGroupResponse? WorkGroup { get; set; }
//TODO: Удалить поле ResponseArea, использовать EkResponseArea
public string? ResponseArea { get; set; }
public ResponseAreaResponse? EkResponseArea { get; set; }
public DateTimeOffset? LastLogon { get; set; }
}
/// <summary>
/// Респонс Хоста для Шаблона
/// </summary>
public class HostTemplateResponse : HostBaseResponse
{
}
/// <summary>
/// Респонс Хоста с приложениями (компнентном составе)
/// </summary>
public class HostWithApplicationsResponse : HostBaseResponse
{
public List<ApplicationResponse>? Applications { get; set; }
}
}

View File

@@ -1,9 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class ResponseAreaResponse
{
public int Code { get; set; }
public required string Name { get; set; }
}
}

View File

@@ -2,6 +2,6 @@
{
public class StatResponseAreaWorkLoadResponse : StatWorkLoadDataBaseResponse
{
public required ResponseAreaResponse ResponseArea { get; set; }
//public required ResponseAreaResponse ResponseArea { get; set; }
}
}

View File

@@ -2,6 +2,6 @@
{
public class StatWorkGroupWorkLoadResponse : StatWorkLoadDataBaseResponse
{
public required WorkGroupResponse WorkGroup { get; set; }
//public required WorkGroupResponse WorkGroup { get; set; }
}
}

View File

@@ -2,8 +2,8 @@
{
public class StatWorkWorkLoadResponse : StatWorkLoadDataBaseResponse
{
public required ApplicationInWorkBaseResponse Job { get; set; }
//public required ApplicationInWorkBaseResponse Job { get; set; }
public required WorkGroupResponse WorkGroup { get; set; }
//public required WorkGroupResponse WorkGroup { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
namespace PARR.API.Contracts.V1.Responses
{
public class WorkGroupResponse
{
public Guid Id { get; set; }
public required string Name { get; set; }
public ResponseAreaResponse? ResponseArea { get; set; }
}
}

View File

@@ -1,73 +0,0 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Requests.Queries;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Common.Roles;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Управление приложениями
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ApplicationController : BaseApiController
{
private readonly IMapper mapper;
private readonly IApplicationService applicationService;
public ApplicationController(
IMapper mapper,
IApplicationService applicationService
)
{
this.mapper = mapper;
this.applicationService = applicationService;
}
/// <summary>
/// Список приложений постранично
/// </summary>
/// <param name="paginationQuery"></param>
/// <returns></returns>
[HttpGet(ApiRoutes.Application.GetAll)]
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] ApplicationQuery filter)
{
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
IQueryable<Application> query = applicationService.Get()
.Include(t => t.ApplicationType)
.OrderBy(t => t.Name);
if (!string.IsNullOrWhiteSpace(filter.Name))
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
if (filter.TypeId.HasValue)
query = query.Where(t => t.ApplicationTypeId == filter.TypeId);
if (filter.Id.HasValue)
query = query.Where(t => t.Id == filter.Id);
var apps = await applicationService.GetPage(query, paginationFilter).ToListAsync();
if (!apps.Any())
return NoContent();
var appsResponse = mapper.Map<List<ApplicationResponse>>(apps);
var paginationResponse = new PagedResponse<ApplicationResponse>(appsResponse, true).GetPaginatedProps(paginationFilter, query);
return Ok(paginationResponse);
}
}
}

View File

@@ -1,53 +0,0 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Roles;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Управление типами приложений
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ApplicationTypeController : BaseApiController
{
private readonly IMapper mapper;
private readonly IApplicationTypeService applicationTypeService;
public ApplicationTypeController(
IMapper mapper,
IApplicationTypeService applicationTypeService
)
{
this.mapper = mapper;
this.applicationTypeService = applicationTypeService;
}
/// <summary>
/// Список типов приложений
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.ApplicationType.GetAll)]
public async Task<IActionResult> GetAll()
{
var appTypes = await applicationTypeService.Get().OrderBy(t => t.Description)
.ToListAsync();
if (!appTypes.Any())
return NoContent();
var response = mapper.Map<List<ApplicationTypeResponse>>(appTypes);
return Ok(new Response<List<ApplicationTypeResponse>>(response, true));
}
}
}

View File

@@ -1,51 +0,0 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Roles;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Статусы ЭК
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class EkStatusController : BaseApiController
{
private readonly IEkStatusService ekStatusService;
private readonly IMapper mapper;
public EkStatusController(
IEkStatusService ekStatusService,
IMapper mapper
)
{
this.ekStatusService = ekStatusService;
this.mapper = mapper;
}
/// <summary>
/// Получить список статусов ЭК
/// </summary>
/// <returns></returns>млни
[HttpGet(ApiRoutes.EkStatus.GetAll)]
public async Task<IActionResult> GetAll()
{
var statuses = await ekStatusService.Get().OrderBy(t => t.Name).ToListAsync();
if (!statuses.Any())
return NoContent();
var response = mapper.Map<List<EkStatusResponse>>(statuses);
return Ok(new Response<List<EkStatusResponse>>(response, true));
}
}
}

View File

@@ -1,71 +0,0 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Roles;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Зоны ответственности
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ResponseAreaController : BaseApiController
{
private readonly IMapper mapper;
private readonly IResponseAreaService responseAreaService;
public ResponseAreaController(
IMapper mapper,
IResponseAreaService responseAreaService
)
{
this.mapper = mapper;
this.responseAreaService = responseAreaService;
}
/// <summary>
/// Список зон ответственности
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.ResponseArea.GetAll)]
public async Task<IActionResult> GetAll()
{
var query = responseAreaService.Get().OrderBy(t => t.Name);
var responseAreas = await query.ToListAsync();
if (!responseAreas.Any())
return NoContent();
var response = mapper.Map<List<ResponseAreaResponse>>(responseAreas);
return Ok(new Response<List<ResponseAreaResponse>>(response, true));
}
/// <summary>
/// Получить зону ответственности по коду
/// </summary>
/// <param name="responseAreaCode"></param>
/// <returns></returns>
[HttpGet(ApiRoutes.ResponseArea.Get)]
public async Task<IActionResult> Get([FromRoute] int responseAreaCode)
{
var responseArea = await responseAreaService.Get().FirstOrDefaultAsync(t => t.Code == responseAreaCode);
if (responseArea == null)
return NotFound();
var response = mapper.Map<ResponseAreaResponse>(responseArea);
return Ok(new Response<ResponseAreaResponse>(response, true));
}
}
}

View File

@@ -22,19 +22,19 @@ namespace PARR.API.Controllers.V1.Statistics
public class StatResponseAreaWorkLoadController : BaseApiController
{
private readonly ITemplateService templateService;
private readonly IResponseAreaService responseAreaService;
//private readonly IResponseAreaService responseAreaService;
private readonly IMapper mapper;
private readonly IWorkLoadService workLoadService;
public StatResponseAreaWorkLoadController(
ITemplateService templateService,
IResponseAreaService responseAreaService,
//IResponseAreaService responseAreaService,
IMapper mapper,
IWorkLoadService workLoadService
)
{
this.templateService = templateService;
this.responseAreaService = responseAreaService;
//this.responseAreaService = responseAreaService;
this.mapper = mapper;
this.workLoadService = workLoadService;
}

View File

@@ -19,20 +19,20 @@ namespace PARR.API.Controllers.V1.Statistics
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class StatUnitFieldValuesController : BaseApiController
{
private readonly IApplicationService applicationService;
//private readonly IApplicationService applicationService;
private readonly IUnitFieldValueService unitFieldValueService;
private readonly INextRunService nextRunService;
//private readonly ICalendarService calendarService;
public StatUnitFieldValuesController(
IApplicationService applicationService,
//IApplicationService applicationService,
IUnitFieldValueService unitFieldValueService,
//ICalendarService calendarService
INextRunService nextRunService
)
{
this.applicationService = applicationService;
//this.applicationService = applicationService;
this.unitFieldValueService = unitFieldValueService;
this.nextRunService = nextRunService;
//this.calendarService = calendarService;

View File

@@ -20,21 +20,21 @@ namespace PARR.API.Controllers.V1.Statistics
{
private readonly ITemplateService templateService;
private readonly IWorkLoadService workLoadService;
private readonly IWorkGroupService workGroupService;
//private readonly IWorkGroupService workGroupService;
private readonly IMapper mapper;
private readonly ILogger<StatWorkGroupWorkLoadController> logger;
public StatWorkGroupWorkLoadController(
ITemplateService templateService,
IWorkLoadService workLoadService,
IWorkGroupService workGroupService,
//IWorkGroupService workGroupService,
IMapper mapper,
ILogger<StatWorkGroupWorkLoadController> logger
)
{
this.templateService = templateService;
this.workLoadService = workLoadService;
this.workGroupService = workGroupService;
//this.workGroupService = workGroupService;
this.mapper = mapper;
this.logger = logger;
}

View File

@@ -23,21 +23,21 @@ namespace PARR.API.Controllers.V1.Statistics
private readonly IWorkLoadService workLoadService;
private readonly IMapper mapper;
private readonly ILogger<StatWorkWorkLoadController> logger;
private readonly IWorkGroupService workGroupService;
//private readonly IWorkGroupService workGroupService;
public StatWorkWorkLoadController(
ITemplateService templateService,
IWorkLoadService workLoadService,
IMapper mapper,
ILogger<StatWorkWorkLoadController> logger,
IWorkGroupService workGroupService
ILogger<StatWorkWorkLoadController> logger
//IWorkGroupService workGroupService
)
{
this.templateService = templateService;
this.workLoadService = workLoadService;
this.mapper = mapper;
this.logger = logger;
this.workGroupService = workGroupService;
//this.workGroupService = workGroupService;
}

View File

@@ -1,95 +0,0 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Requests.Queries;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Common.Pagination;
using PARR.Domain.Common.Roles;
using PARR.Domain.Enums;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Рабочие группы
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class WorkGroupController : BaseApiController
{
private readonly IMapper mapper;
private readonly IWorkGroupService workGroupService;
public WorkGroupController(
IMapper mapper,
IWorkGroupService workGroupService
)
{
this.mapper = mapper;
this.workGroupService = workGroupService;
}
/// <summary>
/// Список рабочих групп постранично
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.WorkGroup.GetAll)]
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WorkGroupQuery filter)
{
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
IQueryable<WorkGroup> query = workGroupService.Get()
.Include(t => t.ResponseArea)
.OrderBy(t => t.Name);
if (!string.IsNullOrEmpty(filter.Name))
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
if (filter.ResponseAreaCode.HasValue)
{
//todo: validate ResponseAreaEnum
if (!Enum.IsDefined(typeof(ResponseAreaEnum), filter.ResponseAreaCode.Value))
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(filter.ResponseAreaCode), Message = "Неверное значение" } }));
query = query.Where(t => t.ResponseAreaCode == filter.ResponseAreaCode.Value);
}
var workGroups = await workGroupService.GetPage(query, paginationFilter).ToListAsync();
if (!workGroups.Any())
return NoContent();
var workGroupResponse = mapper.Map<List<WorkGroupResponse>>(workGroups);
var paginationResponse = new PagedResponse<WorkGroupResponse>(workGroupResponse, true).GetPaginatedProps(paginationFilter, query);
return Ok(paginationResponse);
}
/// <summary>
/// Получить рабочую группу по id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet(ApiRoutes.WorkGroup.Get)]
public async Task<IActionResult> Get([FromRoute] Guid id)
{
var workGroup = await workGroupService.Get().Include(t => t.ResponseArea).FirstOrDefaultAsync(t => t.Id == id);
if (workGroup == null)
return NotFound();
var response = mapper.Map<WorkGroupResponse>(workGroup);
return Ok(new Response<WorkGroupResponse>(response, true));
}
}
}

View File

@@ -106,31 +106,6 @@ namespace PARR.API.MappingProfiles
#endregion
CreateMap<Application, ApplicationResponse>()
.ForMember(t => t.Type, o => o.MapFrom(s => s.ApplicationType));
CreateMap<ApplicationType, ApplicationTypeResponse>();
#region Host
CreateMap<DAL.Models.Host, HostBaseResponse>()
.Include<DAL.Models.Host, HostTemplateResponse>()
.Include<DAL.Models.Host, HostWithApplicationsResponse>()
.ForMember(d => d.Status, o => o.MapFrom(s => s.EkStatus!.Name))
.ForMember(d => d.EkStatus, o => o.MapFrom(s => s.EkStatus))
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.ResponseArea!.Name))
.ForMember(d => d.WorkGroupName, o => o.MapFrom(s => s.WorkGroup!.Name))
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.WorkGroup))
.ForMember(d => d.EkResponseArea, o => o.MapFrom(s => s.ResponseArea));
CreateMap<DAL.Models.Host, HostTemplateResponse>();
CreateMap<DAL.Models.Host, HostWithApplicationsResponse>()
.ForMember(d => d.Applications, o => o.MapFrom(s => s.ApplicationsInHosts.Select(t => t.Application).OrderBy(t => t.Name)));
#endregion
#region Unit
CreateMap<Unit, UnitBaseResponse>();
@@ -181,12 +156,6 @@ namespace PARR.API.MappingProfiles
//));
#endregion
#region WorkGroup
CreateMap<WorkGroup, WorkGroupResponse>();
#endregion
#region Robot
CreateMap<RobotStatus, RobotStatusResponse>();
@@ -423,29 +392,6 @@ namespace PARR.API.MappingProfiles
#endregion
//#region JobAutoControl
//CreateMap<JobAutoControl, JobAutoControlBaseResponse>()
// .Include<JobAutoControl, JobAutoControlResponse>();
//CreateMap<JobAutoControl, JobAutoControlResponse>()
// .ForMember(d => d.EkMasks, o => o.MapFrom(s => s.JobEkMasks.OrderBy(t => t.Name)))
// .ForMember(d => d.EnabledEkStatuses, o => o.MapFrom(s => s.JobAutoControlInEkStatuses.Select(t => t.EkStatus).OrderBy(t => t.Name)))
// .ForMember(d => d.WorkGroups, o => o.MapFrom(s => s.ApplicationsInWork!.WorkGroups.Select(t => t.WorkGroup).OrderBy(t => t.Name)));
//#endregion
#region ResponseArea
CreateMap<ResponseArea, ResponseAreaResponse>();
#endregion
//CreateMap<JobEkMask, JobEkMaskResponse>();
CreateMap<EkStatus, EkStatusResponse>();
CreateMap<WeekendDay, WeekendResponse>();
#region TemplateHistory

View File

@@ -1,54 +0,0 @@
using AutoMapper;
using PARR.API.Contracts.V1.Responses;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Schedule;
namespace PARR.API.MappingProfiles.Resolvers
{
public class ApplicationInWorkScheduleResolver : IValueResolver<ApplicationsInWork, ApplicationInWorkResponse, ApplicationInWorkScheduleResponse?>
{
private readonly IEsppSchTypeConfigService esppConfigService;
private readonly ILogger<ApplicationInWorkScheduleResolver> logger;
private readonly IMapper mapper;
private readonly SettingsFromDb settingsFromDb;
private readonly IScheduleResponseAreaTimeOffsetService scheduleResponseAreaTimeOffsetService;
public ApplicationInWorkScheduleResolver(
IEsppSchTypeConfigService esppConfigService,
ILogger<ApplicationInWorkScheduleResolver> logger,
IMapper mapper,
SettingsFromDb settingsFromDb,
IScheduleResponseAreaTimeOffsetService scheduleResponseAreaTimeOffsetService
)
{
this.esppConfigService = esppConfigService;
this.logger = logger;
this.mapper = mapper;
this.settingsFromDb = settingsFromDb;
this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService;
}
public ApplicationInWorkScheduleResponse? Resolve(ApplicationsInWork source, ApplicationInWorkResponse destination, ApplicationInWorkScheduleResponse? destMember, ResolutionContext context)
{
var schedule = esppConfigService.GetEsppScheduleDto(source.Id);
if (schedule == null)
{
logger.LogError($"ApplicationInWorkScheduleResolver: Не смог замапить расписание, так как оно null. appInWorksId: {source.Id}");
return null;
}
var response = new ApplicationInWorkScheduleResponse
{
//Timezone = settingsFromDb.ScheduleTimezone,
Timezone = scheduleResponseAreaTimeOffsetService.GetDefault.EsppValue,
TypeSchedule = mapper.Map<EsppScheduleTypeScheduleResponse>(schedule.TypeSchedule),
Values = mapper.Map<List<EsppScheduleValResponse>>(schedule.Values).OrderBy(t => t.Order).ToList()
};
return response;
}
}
}

View File

@@ -1,230 +0,0 @@
using FluentValidation;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using PARR.API.Contracts.V1.Requests;
using PARR.DAL.Services.Interfaces;
namespace PARR.API.Validators
{
public class ApplicationInWorkValidator : AbstractValidator<ApplicationInWorkRequest>
{
private readonly IApplicationsInWorkService applicationsInWorkService;
private readonly IEsppSchTypeConfigService esppSchTypeConfigService;
private readonly IWorkGroupService workGroupService;
private readonly IEsppSchTypeValueService esppSchTypeValueService;
public ApplicationInWorkValidator(
IApplicationsInWorkService applicationsInWorkService,
IEsppSchTypeConfigService esppSchTypeConfigService,
IWorkGroupService workGroupService,
IEsppSchTypeValueService esppSchTypeValueService
)
{
this.applicationsInWorkService = applicationsInWorkService;
this.esppSchTypeConfigService = esppSchTypeConfigService;
this.workGroupService = workGroupService;
this.esppSchTypeValueService = esppSchTypeValueService;
RuleFor(t => t.TemplateDuration)
.NotNull().NotEmpty()//.WithMessage("Длительность данного задания на выполнение работ не может быть пустым")
.Matches("^\\d{1,2}\\s\\d{1,2}[:]\\d{1,2}[:]\\d{1,2}$")
//.WithMessage("Длительность данного задания на выполнение работ должна соответствовать шаблону dd hh:mm:ss(7 00:00:00)");
.WithMessage("Значение не соответствует шаблону dd hh:mm:ss(7 00:00:00)");
RuleFor(t => t.ShortDescription)
.NotNull().NotEmpty();//.WithMessage("Краткое описание данного задания на выполнение работ не может быть пустым");
RuleFor(t => t.FullDescription)
.NotNull().NotEmpty();//.WithMessage("Подробное описание данного задания на выполнение работ не может быть пустым");
RuleFor(t => t.Solution)
.NotNull().NotEmpty();//.WithMessage("Решение данного задания на выполнение работ не может быть пустым");
RuleFor(t => t.WorkId)
.MustAsync(async (entity, value, c) => await IsWorkExist(entity))
.WithMessage("Указан несуществующий Id работы");
//.WithMessage("У данного задания на выполнение работ указан несуществующий Id работы");
RuleFor(t => t.ApplicationId)
.MustAsync(async (entity, value, c) => await IsApplicationExist(entity))
.WithMessage("Указан несуществующий Id программного обеспечения");
//.MustAsync(async (entity, value, c) => await AppInWorkIsUnique(entity))
// .WithMessage("Задание на выполнение работ с такими ПО и работой уже существует");
//.WithMessage("У данного задания на выполнение работ указан несуществующий Id программного обеспечения");
#region old schedule
//Проверяем настройки планировщика
//RuleFor(t => t.Schedule).NotNull().NotEmpty()
// .WithMessage("Настройки планировщика задания на выполнение работ не могут быть пустыми");
//RuleFor(t => t.Schedule.EsppSchValues)
// .NotNull().NotEmpty()
// .When(t => t.Schedule != null)
// .WithMessage("Настройки планировщика задания на выполнение работ не могут быть пустыми")
// .Must((entity, value, c) => IsEsppSchValuesExist(entity))
// .WithMessage("Не удалось найти подходящую конфигруцию планировщика задания на выполнение работ");
#endregion
//RuleFor(t => t.Schedule)
// .NotNull().NotEmpty()
// .When(t => t.Schedule.Count() > 0)
// .WithMessage("Настройки планировщика не могут быть пустыми")
// .Must((entity, value, c) => IsEsppSchValuesExist(entity.Schedule))
// .WithMessage("Не удалось найти подходящую конфигруцию планировщика задания");
#region comment
//RuleFor(t => t.Schedule.Values)
// .NotNull().NotEmpty().WithMessage($"Настройки значений планировщика задания на выполнение работ не могут быть пустыми")
// .Must((entity, value, c) => IsScheduleTypeValueIdExist(entity))
// .When(t => t.Schedule != null).WithMessage("Не удалось найти подходящую конфигруцию планировщика задания на выполнение работ");
//RuleFor(t => t.Schedule.TypeScheduleId)
// .NotNull().NotEmpty().WithMessage($"Тип планировщика задания на выполнение работ не может быть пустым")
// .Must((entity, value, c) => IsTypeScheduleIdExist(entity))
// .When(t => t.Schedule != null).WithMessage($"Не удалось найти указанный тип планировщика задания на выполнение работ");
//RuleFor(t => t.Schedule.Values)
// .NotNull().NotEmpty().WithMessage($"Настройки значений планировщика задания на выполнение работ не могут быть пустыми")
// .Must((entity, value, c) => IsScheduleTypeValueIdExist(entity))
// .When(t => t.Schedule != null).WithMessage("Не удалось найти подходящую конфигруцию планировщика задания на выполнение работ");
#endregion
RuleFor(t => t.WorkGroups)
.MustAsync(async (entity, value, c) => await IsWorkGroupsExistAsync(entity))
.WithMessage("Указаные несуществующие Id рабочих групп");
//Автораспределение может быть включено, только если у EsppSchTypeValues не пустое поле DistributionPeriodId
RuleFor(t => t.IsAutoDistributionEnabled)
.MustAsync(async (entity, value, c) => await IsAllowAutoDistributionEnabledAsync(entity, value))
.WithMessage("Нельзя включить автораспределение для этого типа расписания");
}
private async Task<bool> IsAllowAutoDistributionEnabledAsync(ApplicationInWorkRequest entity, bool value)//TODO JobGroupRequest
{
//Автораспределение может быть включено, только если у EsppSchTypeValues не пустое поле DistributionPeriodId
if (value == false)
return true;
//Распределение включено, смотрим, разрешено ли оно в расписании
//по идее, это расписание только с одним значением в EsppSchValues, но мы проверим у всех, но такого быть не может по хорошему
//foreach (var item in entity.Schedule)
//{
// var schVal = await esppSchTypeValueService.GetAsync(item.TypeValueId);
// if (schVal != null)
// if (schVal.DistributionPeriodId == null)
// return false;
//}
return true;
}
private async Task<bool> IsWorkGroupsExistAsync(ApplicationInWorkRequest entity)
{
var result = await workGroupService.Get().Where(t => entity.WorkGroups.Contains(t.Id)).ToListAsync();
return entity.WorkGroups.Count() == result.Count();
}
//private bool IsEsppSchValuesExist(ApplicationInWorkRequest request)
private bool IsEsppSchValuesExist(List<EsppSchValueRequest> listSchedule)
{
var configs = esppSchTypeConfigService.GetWithSchIncludes().ToList();
//Проверяем полученные Id конфигураций и Id конфигураций в базе
var typeConfigIdList = listSchedule.Select(t => t.TypeConfigId);
var foundTypeConfigIdList = configs.Where(t => typeConfigIdList.Contains(t.Id)).Distinct();
if (foundTypeConfigIdList.Count() == 0 //Не найдено совпадений с базой
|| foundTypeConfigIdList.Select(t => t.TypeScheduleId).Distinct().Count() > 1) //или имеют разный тип планировщика
return false;
var typeScheduleId = foundTypeConfigIdList.Select(t => t.TypeScheduleId).FirstOrDefault();
if (foundTypeConfigIdList.Count() != configs.Where(t => t.TypeScheduleId == typeScheduleId).Count()) //не все typeConfig найдены в базе
return false;
//Теперь проверяем значения
foreach (var item in listSchedule)
{
var curTypeConfig = configs.Where(t => t.Id == item.TypeConfigId).Single();
var isCurValueExist = curTypeConfig!.EsppSchType!.EsppSchTypeValues.Where(t => t.Id == item.TypeValueId).Any();
if (!isCurValueExist)
return false;
}
return true;
}
//private async Task<bool> AppInWorkIsUnique(ApplicationInWorkRequest request)
//{
// //уникальная запись по полям ApplicationId, WorkId
// var existSameAiW = await applicationsInWorkService.GetAsync(request.ApplicationId, request.WorkId);
// //TODO: тут спорно, нужна ли эта проверка? Мы же можем создать несколько РР на одно и тоже ПО но с разным расписанием?
// //к тому же, в методе update, такой проверки нет!
// //if (existSameAiW != null)
// // return BadRequest(new Response(false, new List<ErrorModel> {
// // new ErrorModel { Message = $"Уже существует задание на выполнение работ для программного обеспечения id({request.ApplicationId}) и работой id({request.WorkId})." } }
// // ));
// return existSameAiW == null;
//}
private async Task<bool> IsWorkExist(ApplicationInWorkRequest request)
{
//return await workService.GetAsync(request.WorkId) != null;
return true;
}
private async Task<bool> IsApplicationExist(ApplicationInWorkRequest request)
{
//return await workService.GetAsync(request.WorkId) != null;
return true;
}
//private bool IsTypeScheduleIdExist(ApplicationInWorkRequest request)
//{
// var configs = esppSchTypeConfigService.GetWithSchIncludes().ToList();
//var result = configs.Where(t => t.TypeId == request.Schedule.TypeScheduleId).FirstOrDefault() != null;
//return result;
// return false;
//}
//private bool IsScheduleTypeValueIdExist(ApplicationInWorkRequest request)
//{
// var configs = esppSchTypeConfigService.GetWithSchIncludes().ToList();
// var mustValues = configs.Where(t => t.TypeScheduleId == request.Schedule.TypeScheduleId).ToList();
// var values = request.Schedule.Values;
// foreach (var mustValue in mustValues)
// {
// var mlValues = mustValue?.EsppSchType?.EsppSchTypeValues.Select(t => t.Id);
// if (mlValues == null)
// return false;
// if (!mlValues.Intersect(values).Any())
// return false;
// }
// return true;
//}
}
}

View File

@@ -16,14 +16,14 @@ namespace PARR.DAL.Context
{
public DataContext(DbContextOptions<DataContext> options) : base(options) { }
public DbSet<Host> Hosts { get; set; }
public DbSet<WorkGroup> WorkGroups { get; set; }
public DbSet<AppInWorkInWorkGroup> AppInWorkInWorkGroups { get; set; }
public DbSet<EkStatus> EkStatuses { get; set; }
public DbSet<ResponseArea> ResponseAreas { get; set; }
public DbSet<Application> Applications { get; set; }
public DbSet<ApplicationType> ApplicationTypes { get; set; }
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
//public DbSet<Host> Hosts { get; set; }
//public DbSet<WorkGroup> WorkGroups { get; set; }
//public DbSet<AppInWorkInWorkGroup> AppInWorkInWorkGroups { get; set; }
//public DbSet<EkStatus> EkStatuses { get; set; }
//public DbSet<ResponseArea> ResponseAreas { get; set; }
//public DbSet<Application> Applications { get; set; }
//public DbSet<ApplicationType> ApplicationTypes { get; set; }
//public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
public DbSet<Template> Templates { get; set; }
public DbSet<TemplateHistory> TemplateHistories { get; set; }
@@ -35,7 +35,7 @@ namespace PARR.DAL.Context
public DbSet<Subprocess> Subprocesses { get; set; }
public DbSet<Tnk> Tnks { get; set; }
public DbSet<ApplicationsInWork> ApplicationsInWorks { get; set; }
//public DbSet<ApplicationsInWork> ApplicationsInWorks { get; set; }
public DbSet<Models.Setting> Setting { get; set; }
@@ -163,18 +163,18 @@ namespace PARR.DAL.Context
#endregion
#region ApplicationType
modelBuilder.Entity<ApplicationType>(f =>
{
f.HasData(
new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Сервер приложений" },
new() { Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.OS.ToString(), Description = "ОС" },
new() { Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.DB.ToString(), Description = "СУБД" },
new() { Id = new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.CKBS.ToString(), Description = "ЦК БС" },
new() { Id = new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.IB.ToString(), Description = "ИБ" },
new() { Id = new Guid("4466148b-510d-4423-a58f-ce878152ff01"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.SI.ToString(), Description = "Инфраструктура" },
new() { Id = new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.SM.ToString(), Description = "Мониторинг" }
);
});
//modelBuilder.Entity<ApplicationType>(f =>
//{
// f.HasData(
// new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Сервер приложений" },
// new() { Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.OS.ToString(), Description = "ОС" },
// new() { Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.DB.ToString(), Description = "СУБД" },
// new() { Id = new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.CKBS.ToString(), Description = "ЦК БС" },
// new() { Id = new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.IB.ToString(), Description = "ИБ" },
// new() { Id = new Guid("4466148b-510d-4423-a58f-ce878152ff01"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.SI.ToString(), Description = "Инфраструктура" },
// new() { Id = new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.SM.ToString(), Description = "Мониторинг" }
// );
//});
#endregion
#region TaskStatus
@@ -224,47 +224,47 @@ namespace PARR.DAL.Context
#endregion
#region EK
modelBuilder.Entity<EkStatus>(f =>
{
f.HasData(
new { Code = (int)EkStatusEnum.New, Name = "1-Новый" },
new { Code = (int)EkStatusEnum.Preapre, Name = "2-Подготовка к эксплуатации" },
new { Code = (int)EkStatusEnum.Exploitation, Name = "3-В эксплуатации" },
new { Code = (int)EkStatusEnum.Repair, Name = "4-В ремонте" },
new { Code = (int)EkStatusEnum.Reserve, Name = "5-В резерве" },
new { Code = (int)EkStatusEnum.OutOfService, Name = "6-Выведен из эксплуатации" },
new { Code = (int)EkStatusEnum.Test, Name = "7-Тестовый" },
new { Code = (int)EkStatusEnum.Development, Name = "9-В разработке" }
);
});
//modelBuilder.Entity<EkStatus>(f =>
//{
// f.HasData(
// new { Code = (int)EkStatusEnum.New, Name = "1-Новый" },
// new { Code = (int)EkStatusEnum.Preapre, Name = "2-Подготовка к эксплуатации" },
// new { Code = (int)EkStatusEnum.Exploitation, Name = "3-В эксплуатации" },
// new { Code = (int)EkStatusEnum.Repair, Name = "4-В ремонте" },
// new { Code = (int)EkStatusEnum.Reserve, Name = "5-В резерве" },
// new { Code = (int)EkStatusEnum.OutOfService, Name = "6-Выведен из эксплуатации" },
// new { Code = (int)EkStatusEnum.Test, Name = "7-Тестовый" },
// new { Code = (int)EkStatusEnum.Development, Name = "9-В разработке" }
// );
//});
#endregion
#region ResponseArea
modelBuilder.Entity<ResponseArea>(f =>
{
f.HasData(
new { Code = (int)ResponseAreaEnum.dvgd, Name = "96-ДВС" },
new { Code = (int)ResponseAreaEnum.zrw, Name = "94-ЗАБ" },
new { Code = (int)ResponseAreaEnum.esrr, Name = "92-ВСИБ" },
new { Code = (int)ResponseAreaEnum.krw, Name = "88-КРАСН" },
new { Code = (int)ResponseAreaEnum.wsr, Name = "83-ЗСИБ" },
new { Code = (int)ResponseAreaEnum.surw, Name = "80-ЮУР" },
new { Code = (int)ResponseAreaEnum.svrw, Name = "76-СВРД" },
new { Code = (int)ResponseAreaEnum.kbsh, Name = "63-КБШ" },
new { Code = (int)ResponseAreaEnum.pvrr, Name = "61-ПРИВ" },
new { Code = (int)ResponseAreaEnum.serw, Name = "58-ЮВСТ" },
new { Code = (int)ResponseAreaEnum.skzd, Name = "51-СКВ" },
new { Code = (int)ResponseAreaEnum.nrr, Name = "28-СЕВ" },
new { Code = (int)ResponseAreaEnum.grw, Name = "24-ГОР" },
new { Code = (int)ResponseAreaEnum.msk, Name = "17-МСК" },
new { Code = (int)ResponseAreaEnum.klgd, Name = "10-КЛГ" },
new { Code = (int)ResponseAreaEnum.orw, Name = "01-ОКТ" },
new { Code = (int)ResponseAreaEnum.gvc, Name = "00-ГВЦ" },
new { Code = (int)ResponseAreaEnum.general, Name = "ОБЩЕЕ" },
new { Code = (int)ResponseAreaEnum.vp, Name = "ВП" },
new { Code = (int)ResponseAreaEnum.osk, Name = "ОСК" }
);
});
//modelBuilder.Entity<ResponseArea>(f =>
//{
// f.HasData(
// new { Code = (int)ResponseAreaEnum.dvgd, Name = "96-ДВС" },
// new { Code = (int)ResponseAreaEnum.zrw, Name = "94-ЗАБ" },
// new { Code = (int)ResponseAreaEnum.esrr, Name = "92-ВСИБ" },
// new { Code = (int)ResponseAreaEnum.krw, Name = "88-КРАСН" },
// new { Code = (int)ResponseAreaEnum.wsr, Name = "83-ЗСИБ" },
// new { Code = (int)ResponseAreaEnum.surw, Name = "80-ЮУР" },
// new { Code = (int)ResponseAreaEnum.svrw, Name = "76-СВРД" },
// new { Code = (int)ResponseAreaEnum.kbsh, Name = "63-КБШ" },
// new { Code = (int)ResponseAreaEnum.pvrr, Name = "61-ПРИВ" },
// new { Code = (int)ResponseAreaEnum.serw, Name = "58-ЮВСТ" },
// new { Code = (int)ResponseAreaEnum.skzd, Name = "51-СКВ" },
// new { Code = (int)ResponseAreaEnum.nrr, Name = "28-СЕВ" },
// new { Code = (int)ResponseAreaEnum.grw, Name = "24-ГОР" },
// new { Code = (int)ResponseAreaEnum.msk, Name = "17-МСК" },
// new { Code = (int)ResponseAreaEnum.klgd, Name = "10-КЛГ" },
// new { Code = (int)ResponseAreaEnum.orw, Name = "01-ОКТ" },
// new { Code = (int)ResponseAreaEnum.gvc, Name = "00-ГВЦ" },
// new { Code = (int)ResponseAreaEnum.general, Name = "ОБЩЕЕ" },
// new { Code = (int)ResponseAreaEnum.vp, Name = "ВП" },
// new { Code = (int)ResponseAreaEnum.osk, Name = "ОСК" }
// );
//});
#endregion
#region Robots

View File

@@ -1,28 +0,0 @@
namespace PARR.DAL.Context
{
internal static class DataContextSettings
{
/// <summary>
/// Хранение ЭК с компонентным составом, РГ, Типы, С/н, ip, отвтетственные (не пишем шаблоны, расписания)
/// </summary>
public const string Unit = "unit";
/// <summary>
/// Хранение информации о видах работ, критериях выборки подходящих под работы ЭК и т.д.
/// </summary>
public const string Job = "job";
/// <summary>
/// Расписание регламентных работ
/// </summary>
public const string Schedule = "schedule";
/// <summary>
/// Управление очередями
/// </summary>
public const string Task = "task";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,373 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class RemoveOldTables : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AppInWorkInWorkGroups");
migrationBuilder.DropTable(
name: "ApplicationsInHost");
migrationBuilder.DropTable(
name: "ApplicationsInWorks");
migrationBuilder.DropTable(
name: "Hosts");
migrationBuilder.DropTable(
name: "Applications");
migrationBuilder.DropTable(
name: "EkStatuses");
migrationBuilder.DropTable(
name: "WorkGroups");
migrationBuilder.DropTable(
name: "ApplicationTypes");
migrationBuilder.DropTable(
name: "ResponseAreas");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApplicationTypes",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EkStatuses",
columns: table => new
{
Code = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EkStatuses", x => x.Code);
});
migrationBuilder.CreateTable(
name: "ResponseAreas",
columns: table => new
{
Code = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ResponseAreas", x => x.Code);
});
migrationBuilder.CreateTable(
name: "Applications",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationTypeId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Applications", x => x.Id);
table.ForeignKey(
name: "FK_Applications_ApplicationTypes_ApplicationTypeId",
column: x => x.ApplicationTypeId,
principalTable: "ApplicationTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "WorkGroups",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ResponseAreaCode = table.Column<int>(type: "integer", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkGroups", x => x.Id);
table.ForeignKey(
name: "FK_WorkGroups_ResponseAreas_ResponseAreaCode",
column: x => x.ResponseAreaCode,
principalTable: "ResponseAreas",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApplicationsInWorks",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationId = table.Column<Guid>(type: "uuid", nullable: false),
AgentName = table.Column<string>(type: "text", nullable: true),
AgentScript = table.Column<string>(type: "text", nullable: true),
AgentTimeOutSec = table.Column<int>(type: "integer", nullable: true),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
FullDescription = table.Column<string>(type: "text", nullable: false),
IsAgent = table.Column<bool>(type: "boolean", nullable: false),
IsAutoDistributionEnabled = table.Column<bool>(type: "boolean", nullable: false),
ReferenceDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
ShortDescription = table.Column<string>(type: "text", nullable: false),
Solution = table.Column<string>(type: "text", nullable: false),
TemplateDuration = table.Column<string>(type: "text", nullable: false),
WorkId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationsInWorks", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationsInWorks_Applications_ApplicationId",
column: x => x.ApplicationId,
principalTable: "Applications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Hosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
EkStatusCode = table.Column<int>(type: "integer", nullable: false),
ResponseAreaCode = table.Column<int>(type: "integer", nullable: false),
WorkGroupId = table.Column<Guid>(type: "uuid", nullable: true),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Ek = table.Column<string>(type: "text", nullable: false),
IP = table.Column<string>(type: "text", nullable: true),
LastLogon = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Hosts", x => x.Id);
table.ForeignKey(
name: "FK_Hosts_EkStatuses_EkStatusCode",
column: x => x.EkStatusCode,
principalTable: "EkStatuses",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Hosts_ResponseAreas_ResponseAreaCode",
column: x => x.ResponseAreaCode,
principalTable: "ResponseAreas",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Hosts_WorkGroups_WorkGroupId",
column: x => x.WorkGroupId,
principalTable: "WorkGroups",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "AppInWorkInWorkGroups",
columns: table => new
{
ApplicationsInWorkId = table.Column<Guid>(type: "uuid", nullable: false),
WorkGroupId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AppInWorkInWorkGroups", x => new { x.ApplicationsInWorkId, x.WorkGroupId });
table.ForeignKey(
name: "FK_AppInWorkInWorkGroups_ApplicationsInWorks_ApplicationsInWor~",
column: x => x.ApplicationsInWorkId,
principalTable: "ApplicationsInWorks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AppInWorkInWorkGroups_WorkGroups_WorkGroupId",
column: x => x.WorkGroupId,
principalTable: "WorkGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ApplicationsInHost",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ApplicationId = table.Column<Guid>(type: "uuid", nullable: false),
HostId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ApplicationsInHost", x => x.Id);
table.ForeignKey(
name: "FK_ApplicationsInHost_Applications_ApplicationId",
column: x => x.ApplicationId,
principalTable: "Applications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ApplicationsInHost_Hosts_HostId",
column: x => x.HostId,
principalTable: "Hosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "ApplicationTypes",
columns: new[] { "Id", "DateCreated", "DateModified", "Description", "Name" },
values: new object[,]
{
{ new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ИБ", "IB" },
{ new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Сервер приложений", "APP" },
{ new Guid("4466148b-510d-4423-a58f-ce878152ff01"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Инфраструктура", "SI" },
{ new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Мониторинг", "SM" },
{ new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ЦК БС", "CKBS" },
{ new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ОС", "OS" },
{ new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "СУБД", "DB" }
});
migrationBuilder.InsertData(
table: "EkStatuses",
columns: new[] { "Code", "Name" },
values: new object[,]
{
{ 1, "1-Новый" },
{ 2, "2-Подготовка к эксплуатации" },
{ 3, "3-В эксплуатации" },
{ 4, "4-В ремонте" },
{ 5, "5-В резерве" },
{ 6, "6-Выведен из эксплуатации" },
{ 7, "7-Тестовый" },
{ 9, "9-В разработке" }
});
migrationBuilder.InsertData(
table: "ResponseAreas",
columns: new[] { "Code", "Name" },
values: new object[,]
{
{ 1, "01-ОКТ" },
{ 10, "10-КЛГ" },
{ 17, "17-МСК" },
{ 24, "24-ГОР" },
{ 28, "28-СЕВ" },
{ 51, "51-СКВ" },
{ 58, "58-ЮВСТ" },
{ 61, "61-ПРИВ" },
{ 63, "63-КБШ" },
{ 76, "76-СВРД" },
{ 80, "80-ЮУР" },
{ 83, "83-ЗСИБ" },
{ 88, "88-КРАСН" },
{ 92, "92-ВСИБ" },
{ 94, "94-ЗАБ" },
{ 96, "96-ДВС" },
{ 99, "00-ГВЦ" },
{ 100, "ОБЩЕЕ" },
{ 110, "ВП" },
{ 111, "ОСК" }
});
migrationBuilder.CreateIndex(
name: "IX_AppInWorkInWorkGroups_WorkGroupId",
table: "AppInWorkInWorkGroups",
column: "WorkGroupId");
migrationBuilder.CreateIndex(
name: "IX_Applications_ApplicationTypeId",
table: "Applications",
column: "ApplicationTypeId");
migrationBuilder.CreateIndex(
name: "IX_Applications_Name_ApplicationTypeId",
table: "Applications",
columns: new[] { "Name", "ApplicationTypeId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInHost_ApplicationId",
table: "ApplicationsInHost",
column: "ApplicationId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInHost_HostId",
table: "ApplicationsInHost",
column: "HostId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInWorks_ApplicationId",
table: "ApplicationsInWorks",
column: "ApplicationId");
migrationBuilder.CreateIndex(
name: "IX_ApplicationsInWorks_WorkId_ApplicationId",
table: "ApplicationsInWorks",
columns: new[] { "WorkId", "ApplicationId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Hosts_Ek",
table: "Hosts",
column: "Ek",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Hosts_EkStatusCode",
table: "Hosts",
column: "EkStatusCode");
migrationBuilder.CreateIndex(
name: "IX_Hosts_IP",
table: "Hosts",
column: "IP");
migrationBuilder.CreateIndex(
name: "IX_Hosts_ResponseAreaCode",
table: "Hosts",
column: "ResponseAreaCode");
migrationBuilder.CreateIndex(
name: "IX_Hosts_WorkGroupId",
table: "Hosts",
column: "WorkGroupId");
migrationBuilder.CreateIndex(
name: "IX_WorkGroups_ResponseAreaCode",
table: "WorkGroups",
column: "ResponseAreaCode");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("AppInWorkInWorkGroups")]
[PrimaryKey(nameof(ApplicationsInWorkId), nameof(WorkGroupId))]
public class AppInWorkInWorkGroup
{
public Guid ApplicationsInWorkId { get; set; }
public Guid WorkGroupId { get; set; }
public ApplicationsInWork? ApplicationsInWork { get; set; }
public WorkGroup? WorkGroup { get; set; }
}
}

View File

@@ -1,31 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("Applications")]
[Index(nameof(Name), nameof(ApplicationTypeId), IsUnique = true)]
public class Application : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public Guid ApplicationTypeId { get; set; }
[ForeignKey(nameof(ApplicationTypeId))]
public ApplicationType? ApplicationType { get; set; }
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
public ICollection<ApplicationsInWork> ApplicationsInWorks { get; set; } = new HashSet<ApplicationsInWork>();
}
}

View File

@@ -1,23 +0,0 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("ApplicationsInHost")]
public class ApplicationInHost : IBaseEntity
{
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public Guid ApplicationId { get; set; }
[ForeignKey(nameof(ApplicationId))]
public Application? Application { get; set; }
public Guid HostId { get; set; }
[ForeignKey(nameof(HostId))]
public Host? Host { get; set; }
}
}

View File

@@ -1,18 +0,0 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("ApplicationTypes")]
public class ApplicationType : IBaseEntity
{
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public string? Description { get; set; }
public ICollection<Application> Applications { get; set; } = new HashSet<Application>();
}
}

View File

@@ -1,122 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using PARR.Domain.Settings;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("ApplicationsInWorks")]
[Index(nameof(WorkId), nameof(ApplicationId), IsUnique = true)]
public class ApplicationsInWork : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public Guid WorkId { get; set; }
public Guid ApplicationId { get; set; }
/// <summary>
/// TemplateDuration в формате ЕСПП
/// </summary>
public required string TemplateDuration { get; set; }
/// <summary>
/// TemplateDuration в формате TimeSpan
/// </summary>
public TimeSpan? TemplateDurationTimeSpan
{
get
{
try
{
//ЕСПП кривоногие, они почему-то таймспан пишут так "7 00:00:00", а правильно так: "7:00:00:00"
var durationWithTimeSpanFormat = TemplateDuration.Replace(" ", ":");
return TimeSpan.Parse(durationWithTimeSpanFormat);
}
catch
{
return null;
}
}
}
/// <summary>
/// Краткое описание
/// </summary>
public required string ShortDescription { get; set; }
private string _fullDescription = string.Empty;
public required string FullDescription
{
get
{
//В полное описание подставляем префикс, для дальнейшего поиска наряда
return $"{_fullDescription}\r\n{PrefixSettings.PrefixWithoutVariable}";
}
set
{
//удаляем префикс, если он есть
//_fullDescription = value.Replace($"\r\n{PrefixSettings.PrefixWithoutVariable}", string.Empty);
_fullDescription = value.Replace($"{PrefixSettings.PrefixWithoutVariable}", string.Empty).TrimEnd();
}
}
/// <summary>
/// Решение
/// </summary>
public required string Solution { get; set; }
/// <summary>
/// Включить автораспределение
/// </summary>
public bool IsAutoDistributionEnabled { get; set; }
/// <summary>
/// Дата начала работ
/// </summary>
public DateTimeOffset ReferenceDate { get; set; }
/// <summary>
/// Выполняет агент
/// </summary>
public bool IsAgent { get; set; }
/// <summary>
/// Какое-то имя которое мы передаем агенту, пока непонятно что это такое.
/// </summary>
public string? AgentName { get; set; }
/// <summary>
/// Сколько времени ожидать выполнение скрипта агентом (секунд)
/// </summary>
public int? AgentTimeOutSec { get; set; }
/// <summary>
/// Скрипт для автоматического выполнения
/// </summary>
public string? AgentScript { get; set; }
//[ForeignKey(nameof(WorkId))]
//public Work? Work { get; set; }
[ForeignKey(nameof(ApplicationId))]
public Application? Application { get; set; }
// public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
//public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
public ICollection<AppInWorkInWorkGroup> WorkGroups { get; set; } = new HashSet<AppInWorkInWorkGroup>();
//public JobAutoControl? JobAutoControl { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.DAL.Models.Job;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,7 +9,7 @@ namespace PARR.DAL.Models
/// <summary>
/// Период автоматического распеделения РР
/// </summary>
[Table("DistributionPeriods", Schema = DataContextSettings.Schedule)]
[Table("DistributionPeriods", Schema = DatabaseSchemas.Schedule)]
public class DistributionPeriod : IBaseEntity
{
[Key]

View File

@@ -1,10 +1,11 @@
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("DistributionPeriodTypes", Schema = DataContextSettings.Schedule)]
[Table("DistributionPeriodTypes", Schema = DatabaseSchemas.Schedule)]
public class DistributionPeriodType
{
[Key]

View File

@@ -1,19 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("EkStatuses")]
public class EkStatus
{
[Key]
public int Code { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
//public ICollection<JobAutoControlInEkStatus> JobAutoControlInEkStatuses { get; set; } = new HashSet<JobAutoControlInEkStatus>();
}
}

View File

@@ -1,4 +1,5 @@
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +8,7 @@ namespace PARR.DAL.Models
/// <summary>
/// Расписание ЕСПП: типы повторений
/// </summary>
[Table("EsppSchTypes", Schema = DataContextSettings.Schedule)]
[Table("EsppSchTypes", Schema = DatabaseSchemas.Schedule)]
public class EsppSchType
{
[Key]

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,7 +10,7 @@ namespace PARR.DAL.Models
/// <summary>
/// Расписание ЕСПП: Конфигурация типов
/// </summary>
[Table("EsppSchTypeConfigs", Schema = DataContextSettings.Schedule)]
[Table("EsppSchTypeConfigs", Schema = DatabaseSchemas.Schedule)]
[Index(nameof(TypeScheduleId), nameof(TypeId), IsUnique = true)]
public class EsppSchTypeConfig : IBaseEntity
{

View File

@@ -1,4 +1,5 @@
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +8,7 @@ namespace PARR.DAL.Models
/// <summary>
/// Расписание ЕСПП: Повторять задачу
/// </summary>
[Table("EsppSchTypeSchedules", Schema = DataContextSettings.Schedule)]
[Table("EsppSchTypeSchedules", Schema = DatabaseSchemas.Schedule)]
public class EsppSchTypeSchedule
{
[Key]

View File

@@ -1,4 +1,5 @@
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models
/// <summary>
/// Расписание ЕСПП: значения типов повторений
/// </summary>
[Table("EsppSchTypeValues", Schema = DataContextSettings.Schedule)]
[Table("EsppSchTypeValues", Schema = DatabaseSchemas.Schedule)]
public class EsppSchTypeValue : IBaseEntity
{
[Key]

View File

@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models
/// <summary>
/// Расписание ЕСПП: значения заданий для ApplicationsInWorks
/// </summary>
[Table("EsppSchValues", Schema = DataContextSettings.Schedule)]
[Table("EsppSchValues", Schema = DatabaseSchemas.Schedule)]
//[Index(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId), IsUnique = true)]
//[PrimaryKey(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId))]
[PrimaryKey(nameof(JobGroupId), nameof(TypeValueId), nameof(TypeConfigId))]

View File

@@ -1,58 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("Hosts")]
[Index(nameof(IP))]
[Index(nameof(Ek), IsUnique = true)]
public class Host : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Ek { get; set; }
public int EkStatusCode { get; set; }
public string? IP { get; set; }
//public string? RegionalEK { get; set; }
//public string? LinkEK { get; set; }
//TODO: удалить поле Status, вместо него использовать EkStatusCode
//public string? StatusStr { get; set; }
//public string? WorkGroup { get; set; }
public Guid? WorkGroupId { get; set; }
//TODO: удалить поле ResponseAreaStr
//public string? ResponseAreaStr { get; set; }
public int ResponseAreaCode { get; set; }
public DateTimeOffset? LastLogon { get; set; }
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
//public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
[ForeignKey(nameof(EkStatusCode))]
public EkStatus? EkStatus { get; set; }
[ForeignKey(nameof(ResponseAreaCode))]
public ResponseArea? ResponseArea { get; set; }
[ForeignKey(nameof(WorkGroupId))]
public WorkGroup? WorkGroup { get; set; }
}
}

View File

@@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("Jobs", Schema = DataContextSettings.Job)]
[Table("Jobs", Schema = DatabaseSchemas.Job)]
[Comment("Таблица видов работ")]
public class Job : IBaseEntity
{

View File

@@ -1,11 +1,12 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("AutoControls", Schema = DataContextSettings.Job)]
[Table("AutoControls", Schema = DatabaseSchemas.Job)]
[Comment("Таблица управления автоконтролем для работ")]
public class JobAutoControl
{

View File

@@ -1,13 +1,14 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Unit;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("FieldFilters", Schema = DataContextSettings.Job)]
[Table("FieldFilters", Schema = DatabaseSchemas.Job)]
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
public class JobFieldFilter : IBaseEntity
{

View File

@@ -2,6 +2,7 @@
using PARR.DAL.Context;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Models.Unit;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Settings;
using System.ComponentModel.DataAnnotations;
@@ -9,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("Groups", Schema = DataContextSettings.Job)]
[Table("Groups", Schema = DatabaseSchemas.Job)]
[Comment("Таблица описания групп работ, для реализации зонтиков")]
public class JobGroup : IBaseEntity
{

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models.Job
/// <summary>
/// Настройки автораспределения для JobGroup
/// </summary>
[Table("GroupDistributionConfigs", Schema = DataContextSettings.Job)]
[Table("GroupDistributionConfigs", Schema = DatabaseSchemas.Job)]
[Comment("Настройки автораспределения для группы работ")]
public class JobGroupDistributionConfig
{

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
@@ -7,7 +8,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("GroupTypes", Schema = DataContextSettings.Job)]
[Table("GroupTypes", Schema = DatabaseSchemas.Job)]
[Comment("Таблица типов групп работ")]
public class JobGroupType : IBaseEntity
{

View File

@@ -1,11 +1,12 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Unit;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("RelationshipFilters", Schema = DataContextSettings.Job)]
[Table("RelationshipFilters", Schema = DatabaseSchemas.Job)]
[Comment("Таблица фильтров связей ЭК")]
[PrimaryKey(nameof(UnitFilterId), nameof(FieldId))]
public class JobRelationshipFilter //: IBase

View File

@@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Job
{
[Table("UnitFilters", Schema = DataContextSettings.Job)]
[Table("UnitFilters", Schema = DatabaseSchemas.Job)]
[Comment("Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП")]
public class JobUnitFilter : IBaseEntity
{

View File

@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("AppInWorkInWorkGroups")]
//[PrimaryKey(nameof(ApplicationsInWorkId), nameof(WorkGroupId))]
//public class AppInWorkInWorkGroup
//{
// public Guid ApplicationsInWorkId { get; set; }
// public Guid WorkGroupId { get; set; }
// public ApplicationsInWork? ApplicationsInWork { get; set; }
// public WorkGroup? WorkGroup { get; set; }
//}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("Applications")]
//[Index(nameof(Name), nameof(ApplicationTypeId), IsUnique = true)]
//public class Application : IBaseEntity
//{
// [Key]
// public Guid Id { get; set; }
// public DateTimeOffset DateCreated { get; set; }
// public DateTimeOffset? DateModified { get; set; }
// public required string Name { get; set; }
// public Guid ApplicationTypeId { get; set; }
// [ForeignKey(nameof(ApplicationTypeId))]
// public ApplicationType? ApplicationType { get; set; }
// public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
// public ICollection<ApplicationsInWork> ApplicationsInWorks { get; set; } = new HashSet<ApplicationsInWork>();
//}
}

View File

@@ -0,0 +1,23 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("ApplicationsInHost")]
//public class ApplicationInHost : IBaseEntity
//{
// public Guid Id { get; set; }
// public DateTimeOffset DateCreated { get; set; }
// public DateTimeOffset? DateModified { get; set; }
// public Guid ApplicationId { get; set; }
// [ForeignKey(nameof(ApplicationId))]
// public Application? Application { get; set; }
// public Guid HostId { get; set; }
// [ForeignKey(nameof(HostId))]
// public Host? Host { get; set; }
//}
}

View File

@@ -0,0 +1,18 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("ApplicationTypes")]
//public class ApplicationType : IBaseEntity
//{
// public Guid Id { get; set; }
// public DateTimeOffset DateCreated { get; set; }
// public DateTimeOffset? DateModified { get; set; }
// public required string Name { get; set; }
// public string? Description { get; set; }
// public ICollection<Application> Applications { get; set; } = new HashSet<Application>();
//}
}

View File

@@ -0,0 +1,122 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using PARR.Domain.Settings;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("ApplicationsInWorks")]
//[Index(nameof(WorkId), nameof(ApplicationId), IsUnique = true)]
//public class ApplicationsInWork : IBaseEntity
//{
// [Key]
// public Guid Id { get; set; }
// public DateTimeOffset DateCreated { get; set; }
// public DateTimeOffset? DateModified { get; set; }
// public Guid WorkId { get; set; }
// public Guid ApplicationId { get; set; }
// /// <summary>
// /// TemplateDuration в формате ЕСПП
// /// </summary>
// public required string TemplateDuration { get; set; }
// /// <summary>
// /// TemplateDuration в формате TimeSpan
// /// </summary>
// public TimeSpan? TemplateDurationTimeSpan
// {
// get
// {
// try
// {
// //ЕСПП кривоногие, они почему-то таймспан пишут так "7 00:00:00", а правильно так: "7:00:00:00"
// var durationWithTimeSpanFormat = TemplateDuration.Replace(" ", ":");
// return TimeSpan.Parse(durationWithTimeSpanFormat);
// }
// catch
// {
// return null;
// }
// }
// }
// /// <summary>
// /// Краткое описание
// /// </summary>
// public required string ShortDescription { get; set; }
// private string _fullDescription = string.Empty;
// public required string FullDescription
// {
// get
// {
// //В полное описание подставляем префикс, для дальнейшего поиска наряда
// return $"{_fullDescription}\r\n{PrefixSettings.PrefixWithoutVariable}";
// }
// set
// {
// //удаляем префикс, если он есть
// //_fullDescription = value.Replace($"\r\n{PrefixSettings.PrefixWithoutVariable}", string.Empty);
// _fullDescription = value.Replace($"{PrefixSettings.PrefixWithoutVariable}", string.Empty).TrimEnd();
// }
// }
// /// <summary>
// /// Решение
// /// </summary>
// public required string Solution { get; set; }
// /// <summary>
// /// Включить автораспределение
// /// </summary>
// public bool IsAutoDistributionEnabled { get; set; }
// /// <summary>
// /// Дата начала работ
// /// </summary>
// public DateTimeOffset ReferenceDate { get; set; }
// /// <summary>
// /// Выполняет агент
// /// </summary>
// public bool IsAgent { get; set; }
// /// <summary>
// /// Какое-то имя которое мы передаем агенту, пока непонятно что это такое.
// /// </summary>
// public string? AgentName { get; set; }
// /// <summary>
// /// Сколько времени ожидать выполнение скрипта агентом (секунд)
// /// </summary>
// public int? AgentTimeOutSec { get; set; }
// /// <summary>
// /// Скрипт для автоматического выполнения
// /// </summary>
// public string? AgentScript { get; set; }
// //[ForeignKey(nameof(WorkId))]
// //public Work? Work { get; set; }
// [ForeignKey(nameof(ApplicationId))]
// public Application? Application { get; set; }
// // public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
// //public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
// public ICollection<AppInWorkInWorkGroup> WorkGroups { get; set; } = new HashSet<AppInWorkInWorkGroup>();
// //public JobAutoControl? JobAutoControl { get; set; }
//}
}

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("EkStatuses")]
//public class EkStatus
//{
// [Key]
// public int Code { get; set; }
// [Required]
// public string Name { get; set; } = string.Empty;
// public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
// //public ICollection<JobAutoControlInEkStatus> JobAutoControlInEkStatuses { get; set; } = new HashSet<JobAutoControlInEkStatus>();
//}
}

View File

@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("Hosts")]
//[Index(nameof(IP))]
//[Index(nameof(Ek), IsUnique = true)]
//public class Host : IBaseEntity
//{
// [Key]
// public Guid Id { get; set; }
// public DateTimeOffset DateCreated { get; set; }
// public DateTimeOffset? DateModified { get; set; }
// public required string Ek { get; set; }
// public int EkStatusCode { get; set; }
// public string? IP { get; set; }
// //public string? RegionalEK { get; set; }
// //public string? LinkEK { get; set; }
// //TODO: удалить поле Status, вместо него использовать EkStatusCode
// //public string? StatusStr { get; set; }
// //public string? WorkGroup { get; set; }
// public Guid? WorkGroupId { get; set; }
// //TODO: удалить поле ResponseAreaStr
// //public string? ResponseAreaStr { get; set; }
// public int ResponseAreaCode { get; set; }
// public DateTimeOffset? LastLogon { get; set; }
// public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
// //public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
// [ForeignKey(nameof(EkStatusCode))]
// public EkStatus? EkStatus { get; set; }
// [ForeignKey(nameof(ResponseAreaCode))]
// public ResponseArea? ResponseArea { get; set; }
// [ForeignKey(nameof(WorkGroupId))]
// public WorkGroup? WorkGroup { get; set; }
//}
}

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("ResponseAreas")]
//public class ResponseArea
//{
// [Key]
// public int Code { get; set; }
// [Required]
// public string Name { get; set; } = string.Empty;
// public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
// public ICollection<WorkGroup> WorkGroups { get; set; } = new HashSet<WorkGroup>();
//}
}

View File

@@ -0,0 +1,29 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Removed
{
//[Table("WorkGroups")]
//public class WorkGroup : IBaseEntity
//{
// [Key]
// public Guid Id { get; set; }
// public DateTimeOffset DateCreated { get; set; }
// [NotMapped]
// public DateTimeOffset? DateModified { get; set; }
// public required string Name { get; set; }
// public int ResponseAreaCode { get; set; }
// public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
// public ICollection<AppInWorkInWorkGroup> AppInWorks { get; set; } = new HashSet<AppInWorkInWorkGroup>();
// [ForeignKey(nameof(ResponseAreaCode))]
// public ResponseArea? ResponseArea { get; set; }
//}
}

View File

@@ -1,19 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("ResponseAreas")]
public class ResponseArea
{
[Key]
public int Code { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
public ICollection<WorkGroup> WorkGroups { get; set; } = new HashSet<WorkGroup>();
}
}

View File

@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -10,7 +11,7 @@ namespace PARR.DAL.Models.Schedule
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
[Table("ExcludeTypes", Schema = DataContextSettings.Schedule)]
[Table("ExcludeTypes", Schema = DatabaseSchemas.Schedule)]
[Comment("Расписание регламентной работы - Тип исключения")]
public class ScheduleExcludeType : IBaseEntity
{

View File

@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -10,7 +11,7 @@ namespace PARR.DAL.Models.Schedule
/// <summary>
/// Расписание регламентной работы, исключение - Календарь
/// </summary>
[Table("ExcludeTypeCalendars", Schema = DataContextSettings.Schedule)]
[Table("ExcludeTypeCalendars", Schema = DatabaseSchemas.Schedule)]
[Comment("Расписание регламентной работы, исключение - Календарь")]
public class ScheduleExcludeTypeCalendar : IBaseEntity
{

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models.Schedule
/// <summary>
/// Расписание в ЕСПП. Смещение часового пояса относительно МСК для зоны ответственности рабочей группы
/// </summary>
[Table("ResponseAreaTimeOffsets", Schema = DataContextSettings.Schedule)]
[Table("ResponseAreaTimeOffsets", Schema = DatabaseSchemas.Schedule)]
[Comment("Расписание в ЕСПП. Смещение часового пояса относительно МСК для зоны ответственности рабочей группы")]
public class ScheduleResponseAreaTimeOffset
{

View File

@@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("Units", Schema = DataContextSettings.Unit)]
[Table("Units", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица с ЭК")]
[Index(nameof(Name), IsUnique = true)]
public class Unit : IBaseEntity

View File

@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Job;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -10,7 +11,7 @@ namespace PARR.DAL.Models.Unit
/// <summary>
/// Справочник полей ЭК (компонентный состав, ответствтвенные, любые поля)
/// </summary>
[Table("Fields", Schema = DataContextSettings.Unit)]
[Table("Fields", Schema = DatabaseSchemas.Unit)]
[Comment("Справочник полей ЭК")]
[Index(nameof(AihitName))]
[Index(nameof(EsppName))]

View File

@@ -1,11 +1,12 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("FieldInFieldValues", Schema = DataContextSettings.Unit)]
[Table("FieldInFieldValues", Schema = DatabaseSchemas.Unit)]
[Comment("Значения полей ЭК")]
[PrimaryKey(nameof(FieldId), nameof(FieldValueId))]
public class UnitFieldInUnitFieldValue : IBaseEntityDateCreated

View File

@@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("FieldValues", Schema = DataContextSettings.Unit)]
[Table("FieldValues", Schema = DatabaseSchemas.Unit)]
[Comment("Значения полей ЭК")]
[Index(nameof(Value), IsUnique = true)]
public class UnitFieldValue : IBaseEntity

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models.Unit
/// Связь Unit in Field
/// </summary>
///
[Table("UnitInFields", Schema = DataContextSettings.Unit)]
[Table("UnitInFields", Schema = DatabaseSchemas.Unit)]
[Comment("Справочник полей ЭК")]
[PrimaryKey(nameof(UnitId), nameof(FieldId))]
public class UnitInField

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
@@ -7,7 +8,7 @@ namespace PARR.DAL.Models.Unit
/// <summary>
/// Связи иерархии между ЭК
/// </summary>
[Table("UnitInUnits", Schema = DataContextSettings.Unit)]
[Table("UnitInUnits", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица связей иерархии между ЭК")]
[PrimaryKey(nameof(ParentUnitId), nameof(ChildUnitId))]
public class UnitInUnit

View File

@@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("UnitInValues", Schema = DataContextSettings.Unit)]
[Table("UnitInValues", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица связи ЭК с полями и со значениями")]
[PrimaryKey(nameof(UnitId), nameof(FieldId), nameof(ValueId))]
[Index(nameof(FieldId), nameof(ValueId))]

View File

@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +9,7 @@ namespace PARR.DAL.Models.Unit
/// <summary>
/// Список ЭК КИИ, которые учавствуют в групповых работах. Создавалась как временная
/// </summary>
[Table("KiiUnits", Schema = DataContextSettings.Unit)]
[Table("KiiUnits", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица - Список ЭК КИИ, которые учавствуют в групповых работах. Создавалась как временная")]
public class UnitKiiUnit
{

View File

@@ -1,11 +1,12 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
{
[Table("RegionalEkPtkGroups", Schema = DataContextSettings.Unit)]
[Table("RegionalEkPtkGroups", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица - региональные группы ПТК")]
public class UnitRegionalEkPtkGroup
{

View File

@@ -1,10 +1,11 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("UnitsInTemplates", Schema = DataContextSettings.Job)]
[Table("UnitsInTemplates", Schema = DatabaseSchemas.Job)]
[Comment("Таблица связи ЭК в шаблонах")]
public class UnitsInTemplate
{

View File

@@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("WeekendDays", Schema = DataContextSettings.Schedule)]
[Table("WeekendDays", Schema = DatabaseSchemas.Schedule)]
[Index(nameof(Date), IsUnique = true)]
public class WeekendDay : IBaseEntity
{

View File

@@ -1,29 +0,0 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("WorkGroups")]
public class WorkGroup : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public int ResponseAreaCode { get; set; }
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
public ICollection<AppInWorkInWorkGroup> AppInWorks { get; set; } = new HashSet<AppInWorkInWorkGroup>();
[ForeignKey(nameof(ResponseAreaCode))]
public ResponseArea? ResponseArea { get; set; }
}
}

View File

@@ -14,7 +14,6 @@ using PARR.DAL.DomainServices.UnitFilterService.Models;
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;
@@ -84,13 +83,13 @@ namespace PARR.DAL
// Entity services
services.AddTransient<IHostService, HostService>();
services.AddTransient<IWorkGroupService, WorkGroupService>();
services.AddTransient<IApplicationService, ApplicationService>();
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
services.AddTransient<IApplicationsInWorkService, ApplicationsInWorkService>();
services.AddTransient<IApplicationService, ApplicationService>();
//services.AddTransient<IHostService, HostService>();
//services.AddTransient<IWorkGroupService, WorkGroupService>();
//services.AddTransient<IApplicationService, ApplicationService>();
//services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
//services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
//services.AddTransient<IApplicationsInWorkService, ApplicationsInWorkService>();
//services.AddTransient<IApplicationService, ApplicationService>();
services.AddTransient<IProcessService, ProcessService>();
services.AddTransient<ISubprocessService, SubprocessService>();
services.AddTransient<ITnkService, TnkService>();
@@ -108,12 +107,12 @@ namespace PARR.DAL
services.AddTransient<IUserService, UserService>();
services.AddTransient<IRoleService, RoleService>();
services.AddTransient<ITaskStatusService, TaskStatusService>();
services.AddTransient<IEkStatusService, EkStatusService>();
//services.AddTransient<IEkStatusService, EkStatusService>();
services.AddTransient<IEsppSchTypeScheduleService, EsppSchTypeScheduleService>();
services.AddTransient<IWeekendDayService, WeekendDayService>();
services.AddTransient<IDistributionPeriodService, DistributionPeriodService>();
services.AddTransient<IEsppSchTypeValueService, EsppSchTypeValueService>();
services.AddTransient<IResponseAreaService, ResponseAreaService>();
//services.AddTransient<IResponseAreaService, ResponseAreaService>();
services.AddTransient<ITemplateHistoryService, TemplateHistoryService>();
services.AddTransient<IParrComponentService, ParrComponentService>();
services.AddTransient<ITemplateStatusTypeService, TemplateStatusTypeService>();

View File

@@ -1,14 +0,0 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationInHostService : BaseRepository<ApplicationInHost>, IApplicationInHostService
{
public ApplicationInHostService(DataContext dataContext, ILogger<ApplicationInHostService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,19 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationService : BaseRepository<Application>, IApplicationService
{
public ApplicationService(DataContext dataContext, ILogger<ApplicationService> logger) : base(logger, dataContext) { }
public async Task<Application?> GetByNameAsync(string appName, Guid typeId)
{
return await EntitySet.FirstOrDefaultAsync(t => t.Name.ToLower() == appName.Trim().ToLower() && t.ApplicationTypeId == typeId);
}
}
}

View File

@@ -1,14 +0,0 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementation
{
internal class ApplicationTypeService : BaseRepository<ApplicationType>, IApplicationTypeService
{
public ApplicationTypeService(DataContext dataContext, ILogger<ApplicationTypeService> logger) : base(logger, dataContext) { }
}
}

View File

@@ -1,19 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ApplicationsInWorkService : BaseRepository<ApplicationsInWork>, IApplicationsInWorkService
{
public ApplicationsInWorkService(DataContext dataContext, ILogger<ApplicationsInWorkService> logger) : base(logger, dataContext) { }
public async Task<ApplicationsInWork?> GetAsync(Guid applicationId, Guid workId)
{
return await base.Get().FirstOrDefaultAsync(t => t.ApplicationId == applicationId && t.WorkId == workId);
}
}
}

View File

@@ -1,20 +0,0 @@
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class EkStatusService : IEkStatusService
{
private readonly DataContext dataContext;
public EkStatusService(DataContext dataContext)
{
this.dataContext = dataContext;
}
public IQueryable<EkStatus> Get()
{
return dataContext.EkStatuses;
}
}
}

View File

@@ -1,54 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class HostService : BaseRepository<Host>, IHostService
{
public HostService(DataContext dataContext, ILogger<HostService> logger) : base(logger, dataContext) { }
public async Task<Host?> GetHostWithAppsByIpAsync(string ip)
{
return await GetHostWithIncludeApps()
.AsSplitQuery()
.FirstOrDefaultAsync(h => h.IP == ip);
}
public async Task<Host?> GetHostWithAppsByEkAsync(string ek)
{
return await GetHostWithIncludeApps()
.AsSplitQuery()
.FirstOrDefaultAsync(h => h.Ek.ToLower() == ek.ToLower());
}
private IQueryable<Host> GetHostWithIncludeApps()
{
return EntitySet
.Include(t => t.ApplicationsInHosts)
.ThenInclude(a => a.Application)
.ThenInclude(t => t!.ApplicationType)
.Include(t => t.WorkGroup);
}
public async Task<Host?> GetByIpAsync(string ip)
{
return await EntitySet.FirstOrDefaultAsync(t => t.IP == ip);
}
public async Task<Host?> GetByEkAsync(string ek)
{
return await EntitySet.FirstOrDefaultAsync(t => t.Ek.ToLower() == ek.ToLower());
}
}
}

View File

@@ -1,21 +0,0 @@
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class ResponseAreaService : IResponseAreaService
{
private readonly DataContext dataContext;
public ResponseAreaService(DataContext dataContext)
{
this.dataContext = dataContext;
}
public IQueryable<ResponseArea> Get()
{
return dataContext.ResponseAreas;
}
}
}

View File

@@ -1,19 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Repositories.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class WorkGroupService : BaseRepository<WorkGroup>, IWorkGroupService
{
public WorkGroupService(DataContext dataContext, ILogger<WorkGroupService> logger) : base(logger, dataContext) { }
public async Task<WorkGroup?> GetByNameAsync(string name)
{
return await Get().FirstOrDefaultAsync(t => t.Name == name);
}
}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IApplicationInHostService : IBaseService<ApplicationInHost>
{
}
}

View File

@@ -1,10 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IApplicationService : IBaseService<Application>
{
Task<Application?> GetByNameAsync(string appName, Guid typeId);
}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IApplicationTypeService : IBaseService<ApplicationType>
{
}
}

View File

@@ -1,10 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IApplicationsInWorkService : IBaseService<ApplicationsInWork>
{
Task<ApplicationsInWork?> GetAsync(Guid applicationId, Guid workId);
}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Models;
namespace PARR.DAL.Services.Interfaces
{
public interface IEkStatusService
{
IQueryable<EkStatus> Get();
}
}

View File

@@ -1,14 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IHostService : IBaseService<Host>
{
Task<Host?> GetHostWithAppsByIpAsync(string ip);
Task<Host?> GetByIpAsync(string ip);
Task<Host?> GetHostWithAppsByEkAsync(string ek);
Task<Host?> GetByEkAsync(string ek);
}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Models;
namespace PARR.DAL.Services.Interfaces
{
public interface IResponseAreaService
{
IQueryable<ResponseArea> Get();
}
}

View File

@@ -1,10 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IWorkGroupService : IBaseService<WorkGroup>
{
Task<WorkGroup?> GetByNameAsync(string name);
}
}