feat: Из dal перенесены все модели в Domain. Из dal переименованы service в repository, вынесены в Core.

This commit is contained in:
Mikhail Trubnikov
2026-04-30 10:35:31 +10:00
parent f1ea69da1f
commit eb78dfd6a8
356 changed files with 1817 additions and 1985 deletions

View File

@@ -0,0 +1,37 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
/// <summary>
/// История работы агентов
/// </summary>
[Table("AgentHistories")]
public class AgentHistory : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public string? Message { get; set; }
public int HistoryLevelId { get; set; }
public Guid TemplateId { get; set; }
public Guid? OrderId { get; set; }
[ForeignKey(nameof(TemplateId))]
public Template? Template { get; set; }
[ForeignKey(nameof(HistoryLevelId))]
public AgentHistoryLevel? AgentHistoryLevel { get; set; }
public Order? Order { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("AgentHistoryLevels")]
public class AgentHistoryLevel
{
[Key]
public int Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<AgentHistory> AgentHistories { get; set; } = new HashSet<AgentHistory>();
}
}

View File

@@ -0,0 +1,69 @@
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Job;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
/// <summary>
/// Период автоматического распеделения РР
/// </summary>
[Table("DistributionPeriods", Schema = DatabaseSchemas.Schedule)]
public class DistributionPeriod : IBaseEntity
{
[Key]
public Guid Id { get; set; }
[NotMapped]
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public required string Duration { get; set; }
public required string Type { get; set; }
//public DateTimeOffset AddDate
//{
// get
// {
// var typeEnum = Enum.Parse(typeof(DistributionPeriodTypeEnum), Type);
// switch (typeEnum)
// {
// case (DistributionPeriodTypeEnum.Day):
// int.TryParse(Duration, out var intDays);
// return new DateTimeOffset().AddDays(intDays);
// case (DistributionPeriodTypeEnum.Month):
// int.TryParse(Duration, out var intMonth);
// return new DateTimeOffset().AddMonths(intMonth);
// case (DistributionPeriodTypeEnum.Year):
// int.TryParse(Duration, out var intYear);
// return new DateTimeOffset().AddYears(intYear);
// case (DistributionPeriodTypeEnum.TimeSpan):
// TimeSpan.TryParse(Duration, out var timeSpan);
// return new DateTimeOffset().Add(timeSpan);
// }
// return new DateTimeOffset();
// }
//}
[ForeignKey(nameof(Type))]
public DistributionPeriodType? DistributionPeriodType { get; set; }
public ICollection<JobGroupDistributionConfig> GroupDistributionConfig { get; set; } = new HashSet<JobGroupDistributionConfig>();
//public ICollection<EsppSchTypeValue> EsppSchTypeValues { get; set; } = new HashSet<EsppSchTypeValue>();
}
}

View File

@@ -0,0 +1,17 @@
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("DistributionPeriodTypes", Schema = DatabaseSchemas.Schedule)]
public class DistributionPeriodType
{
[Key]
public required string Type { get; set; }
public required string Description { get; set; }
public ICollection<DistributionPeriod> Periods { get; set; } = new HashSet<DistributionPeriod>();
}
}

View File

@@ -0,0 +1,83 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("Jobs", Schema = DatabaseSchemas.Job)]
[Comment("Таблица видов работ")]
public class Job : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Наименование работ для интерфеса в ПАРР
/// </summary>
public required string Name { get; set; }
/// <summary>
/// Наименование работ для поля Работа в шаблоне АСУ ЕСПП, может быть динамическое
/// </summary>
public required string WorkName { get; set; }
/// <summary>
/// Минимальное значение дочерних или родительских связей группового ЭК
/// </summary>
public int? MinValueRelationships { get; set; }
/// <summary>
/// Максимальное значение дочерних или родительских связей группового ЭК
/// </summary>
public int? MaxValueRelationships { get; set; }
/// <summary>
/// Для подсчёта связей групового ЭК использовать родительсике или дочерние связи
/// </summary>
/// <value>
/// true - диапазон связей относится к родительским связям<br/>
/// false, null - диапазон относится к дочерним связям
/// </value>
public bool? IsParentRelationships { get; set; }
/// <summary>
/// Маска для динамического формирования имени шаблона
/// </summary>
public required string TemplateNameMask { get; set; }
/// <summary>
/// Маска для динамического формирования рабочей группы исполнителей шаблона
/// </summary
public required string WorkGroupMask { get; set; }
/// <summary>
/// Зона ответственности
/// </summary>
public required string ResponseAreaMask { get; set; }
public Guid TnkId { get; set; }
public Guid GroupId { get; set; }
[ForeignKey(nameof(GroupId))]
public JobGroup? Group { get; set; }
[ForeignKey(nameof(TnkId))]
public Tnk? Tnk { get; set; }
public ICollection<JobUnitFilter> UnitFilters { get; set; } = new HashSet<JobUnitFilter>();
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
public JobAutoControl? AutoControl { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("AutoControls", Schema = DatabaseSchemas.Job)]
[Comment("Таблица управления автоконтролем для работ")]
public class JobAutoControl
{
[Key]
public Guid JobId { get; set; }
/// <summary>
/// Включен автоконтроль
/// </summary>
public bool IsEnable { get; set; } = false;
/// <summary>
/// Статус шаблона в момент привязки или создания нового шаблона к Job
/// </summary>
public bool InitUsedTemplateState { get; set; } = false;
/// <summary>
/// Статус расписания в момент привязки или создания нового шаблона к Job
/// </summary>
public bool InitUsedScheduleState { get; set; } = false;
[ForeignKey(nameof(JobId))]
public Job? Job { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Unit;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("FieldFilters", Schema = DatabaseSchemas.Job)]
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
public class JobFieldFilter : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public Guid UnitFilterId { get; set; }
public Guid FieldId { get; set; }
public required string ValueMask { get; set; }
/// <summary>
/// Отсутствует
/// </summary>
public bool IsInverse { get; set; } = false;
[ForeignKey(nameof(FieldId))]
public UnitField? UnitField { get; set; }
[ForeignKey(nameof(UnitFilterId))]
public JobUnitFilter? UnitFilter { get; set; }
}
}

View File

@@ -0,0 +1,195 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Schedule;
using PARR.Domain.Entities.Unit;
using PARR.Domain.Settings;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("Groups", Schema = DatabaseSchemas.Job)]
[Comment("Таблица описания групп работ, для реализации зонтиков")]
public class JobGroup : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Наименование работ для интерфеса в ПАРР
/// </summary>
public required string GroupName { get; set; }
///// <summary>
///// Связана ли работа с групповыми ЭК(зонтами)
///// </summary>
//public bool? IsUmbrella { get; set; }
/// <summary>
/// Поле Короткое описания шаблона АСУ ЕСПП
/// </summary>
public required string ShortDescription { get; set; }
/// <summary>
/// Поле Подробное описания шаблона АСУ ЕСПП
/// </summary>
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();
}
}
//public required string FullDescription { get; set; }
/// <summary>
/// Поле Решение описания шаблона АСУ ЕСПП
/// </summary>
public required string Solution { get; set; }
/// <summary>
/// Поле Длительность описания шаблона АСУ ЕСПП
/// </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 DateTimeOffset ReferenceDate { get; set; }
/// <summary>
/// Смещение часового пояса пользователя в минутах относительно UTC на момент ReferenceDate
/// </summary>
[Comment("Смещение часового пояса пользователя в минутах относительно UTC на момент ReferenceDate")]
public int? UserTimeZoneOffsetMinutes { get; set; }
/// <summary>
/// Смещение часового пояса пользователя относительно UTC на момент ReferenceDate, рассчитывается из поля UserTimeZoneOffsetMinutes
/// </summary>
[NotMapped]
public TimeSpan? UserTimeZoneOffset =>
UserTimeZoneOffsetMinutes.HasValue
? TimeSpan.FromMinutes(UserTimeZoneOffsetMinutes.Value)
: null;
/// <summary>
/// Использовать таймзону рабочей группы ответственного за ЭК шаблона
/// </summary>
public bool IsResponseAreaTimezone { get; set; } = false;
/// <summary>
/// Включить автораспределение
/// </summary>
public bool IsAutoDistributionEnabled { 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; }
/// <summary>
/// Тип группы
/// </summary>
public Guid GroupTypeId { get; set; }
/// <summary>
/// Если тип группы - "Сгруппированный", то это поле обязательно, по нему будем группировать
/// TODO: !!!! Связь с иаблице UnitField не создавалась! Нужно это переделать и унести в отдельную таблицу
/// </summary>
public Guid? GroupingUnitFieldId { get; set; }
/// <summary>
/// Группировать по ответственному за ЭК.
/// Если тип группы - "Сгруппированный", то можно менять значение этого поля, в иных случаях - null
/// TODO: По хорошему вынести это в другую таблицу, так как это касается только групповых работ
/// </summary>
public bool? IsGroupByResponsible { get; set; }
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
public Guid ScheduleExcludeTypeId { get; set; }
/// <summary>
/// Расписание регламентной работы, исключение - Календарь
/// </summary>
public Guid? ScheduleExcludeTypeCalendarId { get; set; }
/// <summary>
/// Поле по которому группируется (!!!отключено каскадное удаление!!!)
/// </summary>
[ForeignKey(nameof(GroupingUnitFieldId))]
public UnitField? GroupingUnitField { get; set; }
[ForeignKey(nameof(GroupTypeId))]
public JobGroupType? GroupType { get; set; }
public ICollection<Job> Jobs { get; set; } = new HashSet<Job>();
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
[ForeignKey(nameof(ScheduleExcludeTypeId))]
public ScheduleExcludeType? ScheduleExcludeType { get; set; }
[ForeignKey(nameof(ScheduleExcludeTypeCalendarId))]
public ScheduleExcludeTypeCalendar? ScheduleExcludeTypeCalendar { get; set; }
public JobGroupDistributionConfig? DistributionConfig { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
/// <summary>
/// Настройки автораспределения для JobGroup
/// </summary>
[Table("GroupDistributionConfigs", Schema = DatabaseSchemas.Job)]
[Comment("Настройки автораспределения для группы работ")]
public class JobGroupDistributionConfig
{
[Key]
public Guid GroupId { get; set; }
public Guid DistributionPeriodId { get; set; }
/// <summary>
/// Исключать выходные и праздничные дни
/// </summary>
public bool IsExcludeWeekends { get; set; }
/// <summary>
/// Группировать по рабочей группе
/// </summary>
public bool IsGroupingByWorkGroup { get; set; }
[ForeignKey(nameof(GroupId))]
public JobGroup? Group { get; set; }
[ForeignKey(nameof(DistributionPeriodId))]
public DistributionPeriod? DistributionPeriod { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("GroupTypes", Schema = DatabaseSchemas.Job)]
[Comment("Таблица типов групп работ")]
public class JobGroupType : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required JobGroupTypesEnum Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Unit;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("RelationshipFilters", Schema = DatabaseSchemas.Job)]
[Comment("Таблица фильтров связей ЭК")]
[PrimaryKey(nameof(UnitFilterId), nameof(FieldId))]
public class JobRelationshipFilter //: IBase
{
//[Key]
//public Guid Id { get; set; }
//public DateTimeOffset DateCreated { get; set; }
//public DateTimeOffset? DateModified { get; set; }
public Guid UnitFilterId { get; set; }
/// <summary>
/// Родительская связь - true,
/// Дочерняя связь - false
/// </summary>
public bool IsParent { get; set; }
public Guid FieldId { get; set; }
public required string ValueMask { get; set; }
/// <summary>
/// Полное совпадение или хотябы одно
/// true - list.All()
/// false - list.Any()
/// </summary>
public bool IsFullMatch { get; set; }
/// <summary>
/// Обратный фильтр, что у связи нет таких значений
/// </summary>
public bool IsInverse { get; set; }
[ForeignKey(nameof(UnitFilterId))]
public JobUnitFilter? UnitFilter { get; set; }
[ForeignKey(nameof(FieldId))]
public UnitField? UnitField { get; set; }
}
}

View File

@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Job
{
[Table("UnitFilters", Schema = DatabaseSchemas.Job)]
[Comment("Таблица описания критериев выборки ЭК, описание полей в АСУ ЕСПП")]
public class JobUnitFilter : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string UnitFilter { get; set; }
public Guid JobId { get; set; }
[ForeignKey(nameof(JobId))]
public Job? Job { get; set; }
public ICollection<JobFieldFilter> FieldFilters { get; set; } = new HashSet<JobFieldFilter>();
public ICollection<JobRelationshipFilter> RelationshipFilters { get; set; } = new HashSet<JobRelationshipFilter>();
}
}

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.Domain.Entities
{
/// <summary>
/// Наряды ЕСПП
/// </summary>
[Table("Orders")]
[Index(nameof(Number), IsUnique = true)]
public class Order : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Number { get; set; }
public required string ShortName { get; set; }
public string? WorkGroup { get; set; }
public Guid? TemplateId { get; set; }
/// <summary>
/// Статус в ЕСПП
/// </summary>
public int StatusCode { get; set; }
/// <summary>
/// Статус который должен быть в ЕСПП
/// </summary>
public int? NextStatusCode { get; set; }
/// <summary>
/// Дата генерации наряда в ЕСПП
/// </summary>
public DateTimeOffset? GenerateDate { get; set; }
public DateTimeOffset ExpirationDate { get; set; }
[ForeignKey(nameof(TemplateId))]
public Template? Template { get; set; }
[ForeignKey(nameof(StatusCode))]
public OrderStatus? OrderStatus { get; set; }
[ForeignKey(nameof(NextStatusCode))]
public OrderStatus? NextStatus { get; set; }
public ICollection<AgentHistory> AgentHistories { get; set; } = new HashSet<AgentHistory>();
}
}

View File

@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("OrderStatuses")]
public class OrderStatus
{
[Key]
public int Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
[InverseProperty(nameof(Order.OrderStatus))]
public ICollection<Order> Orders { get; set; } = new HashSet<Order>();
[InverseProperty(nameof(Order.NextStatus))]
public ICollection<Order> OrdersNext { get; set; } = new HashSet<Order>();
}
}

View File

@@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("ParrComponents")]
[Index(nameof(Name), IsUnique = true)]
public class ParrComponent
{
[Key]
public ParrComponentsEnum Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Processes")]
[Index(nameof(EsppId), IsUnique = true)]
public class Process : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public int EsppId { get; set; }
public ICollection<Subprocess> Subprocesses { get; set; } = new HashSet<Subprocess>();
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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.Domain.Entities.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

@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Robots")]
[Index(nameof(Name), IsUnique = true)]
public class Robot
{
[Key]
public int Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
}
}

View File

@@ -0,0 +1,63 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("RobotConfigurations")]
[Index(nameof(TemplateId), nameof(RobotCode), IsUnique = true)]
[Index(nameof(TemplateId), nameof(TaskStatusCode))]
[Index(nameof(TemplateId), nameof(RobotStatusCode))]
public class RobotConfiguration : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public Guid TemplateId { get; set; }
/// <summary>
/// Идентификатор робота
/// </summary>
public int RobotCode { get; set; }
/// <summary>
/// Статус. Что нужно сделать роботу
/// </summary>
public int TaskStatusCode { get; set; }
/// <summary>
/// Статус работы робота
/// </summary>
public int RobotStatusCode { get; set; }
/// <summary>
/// Количество попыток выполнения задания роботом
/// </summary>
public int AttemptsNumber { get; set; }
/// <summary>
/// Последняя дата обновления статуса RobotStatusCode роботом
/// </summary>
public DateTimeOffset? LastRobotStatusUpdated { get; set; }
[ForeignKey(nameof(TemplateId))]
public Template? Template { get; set; }
[ForeignKey(nameof(RobotCode))]
public Robot? Robot { get; set; }
[ForeignKey(nameof(TaskStatusCode))]
public TaskStatus? TaskStatus { get; set; }
[ForeignKey(nameof(RobotStatusCode))]
public RobotStatus? RobotStatus { get; set; }
public ICollection<RobotHistory> RobotHistories { get; set; } = new HashSet<RobotHistory>();
}
}

View File

@@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("RobotHistories")]
[Index(nameof(HistoryLevel), nameof(DateCreated), IsDescending = new[] { false, true })]
[Index(nameof(RobotConfigurationId), nameof(DateCreated))]
[Index(nameof(DateCreated))]
public class RobotHistory : IBaseEntity
{
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public int HistoryLevel { get; set; }
public string? RobotMessage { get; set; }
public string? EsppMessage { get; set; }
/// <summary>
/// Статус. Что нужно было сделать роботу
/// </summary>
public int TaskStatusCode { get; set; }
public Guid RobotConfigurationId { get; set; }
/// <summary>
/// IP адрес робота
/// </summary>
public string? RobotIp { get; set; }
///// <summary>
///// Уникальный идентификатор серии выполнения, нужен для сопоставления истории
///// </summary>
//public Guid IdSeries { get; set; }
[ForeignKey(nameof(HistoryLevel))]
public RobotHistoryLevel? RobotHistoryLevel { get; set; }
[ForeignKey(nameof(RobotConfigurationId))]
public RobotConfiguration? RobotConfiguration { get; set; }
[ForeignKey(nameof(TaskStatusCode))]
public TaskStatus? StatusTask { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
/// <summary>
/// Уровень логов работы робота
/// </summary>
[Table("RobotHistoryLevels")]
public class RobotHistoryLevel
{
[Key]
public int Level { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<RobotHistory> RobotHistories { get; set; } = new HashSet<RobotHistory>();
}
}

View File

@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
/// <summary>
/// Статус работы робота
/// </summary>
[Table("RobotStatuses")]
public class RobotStatus
{
[Key]
public int Code { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Description { get; set; } = string.Empty;
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
}
}

View File

@@ -0,0 +1,25 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Roles")]
public class Role : 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 required string Description { get; set; }
public ICollection<UsersInRole> Users { get; set; } = new HashSet<UsersInRole>();
}
}

View File

@@ -0,0 +1,25 @@
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание ЕСПП: типы повторений
/// </summary>
[Table("EsppSchTypes", Schema = DatabaseSchemas.Schedule)]
public class EsppSchType
{
[Key]
public int Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<EsppSchTypeValue> EsppSchTypeValues { get; set; } = new HashSet<EsppSchTypeValue>();
public ICollection<EsppSchTypeConfig> EsppSchTypeConfigs { get; set; } = new HashSet<EsppSchTypeConfig>();
}
}

View File

@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание ЕСПП: Конфигурация типов
/// </summary>
[Table("EsppSchTypeConfigs", Schema = DatabaseSchemas.Schedule)]
[Index(nameof(TypeScheduleId), nameof(TypeId), IsUnique = true)]
public class EsppSchTypeConfig : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public int TypeScheduleId { get; set; }
public int TypeId { get; set; }
public int Order { get; set; }
[ForeignKey(nameof(TypeId))]
public EsppSchType? EsppSchType { get; set; }
[ForeignKey(nameof(TypeScheduleId))]
public EsppSchTypeSchedule? EsppSchTypeSchedule { get; set; }
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
}
}

View File

@@ -0,0 +1,22 @@
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание ЕСПП: Повторять задачу
/// </summary>
[Table("EsppSchTypeSchedules", Schema = DatabaseSchemas.Schedule)]
public class EsppSchTypeSchedule
{
[Key]
public int Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<EsppSchTypeConfig> EsppSchTypeConfigs { get; set; } = new HashSet<EsppSchTypeConfig>();
}
}

View File

@@ -0,0 +1,55 @@
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание ЕСПП: значения типов повторений
/// </summary>
[Table("EsppSchTypeValues", Schema = DatabaseSchemas.Schedule)]
public class EsppSchTypeValue : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Значение в ЕСПП, при создании/изменении расписания
/// </summary>
public required string Value { get; set; }
public int TypeId { get; set; }
/// <summary>
/// Значение ЕСПП при отображении представления, используется при экспорте
/// </summary>
public required string EsppExportValue { get; set; }
/// <summary>
/// Сортировка в интерфейсе ПАРР (для удобста должна совпадать с ЕСПП)
/// </summary>
public int Order { get; set; }
///// <summary>
///// Если есть связь с периодом, то есть функция автораспределения
///// </summary>
//public Guid? DistributionPeriodId { get; set; }
//[ForeignKey(nameof(DistributionPeriodId))]
//public DistributionPeriod? DistributionPeriod { get; set; }
[ForeignKey(nameof(TypeId))]
public EsppSchType? EsppSchType { get; set; }
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
}
}

View File

@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Job;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание ЕСПП: значения заданий для ApplicationsInWorks
/// </summary>
[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))]
public class EsppSchValue
{
//public Guid ApplicationsInWorkId { get; set; }
public Guid TypeValueId { get; set; }
public Guid TypeConfigId { get; set; }
public Guid JobGroupId { get; set; }
//[ForeignKey(nameof(ApplicationsInWorkId))]
//public ApplicationsInWork? ApplicationsInWork { get; set; }
[ForeignKey(nameof(TypeValueId))]
public EsppSchTypeValue? EsppSchTypeValue { get; set; }
[ForeignKey(nameof(TypeConfigId))]
public EsppSchTypeConfig? EsppSchTypeConfig { get; set; }
[ForeignKey(nameof(JobGroupId))]
public JobGroup? JobGroup { get; set; }
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Job;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
[Table("ExcludeTypes", Schema = DatabaseSchemas.Schedule)]
[Comment("Расписание регламентной работы - Тип исключения")]
public class ScheduleExcludeType : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Название в ПАРР
/// </summary>
public required string Title { get; set; }
public required string EsppName { get; set; }
public required string EsppValue { get; set; }
public required string Code { get; set; }
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Job;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание регламентной работы, исключение - Календарь
/// </summary>
[Table("ExcludeTypeCalendars", Schema = DatabaseSchemas.Schedule)]
[Comment("Расписание регламентной работы, исключение - Календарь")]
public class ScheduleExcludeTypeCalendar : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Название в ПАРР
/// </summary>
public required string Title { get; set; }
public required string EsppName { get; set; }
public required string EsppValue { get; set; }
public required string Code { get; set; }
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Schedule
{
/// <summary>
/// Расписание в ЕСПП. Смещение часового пояса относительно МСК для зоны ответственности рабочей группы
/// </summary>
[Table("ResponseAreaTimeOffsets", Schema = DatabaseSchemas.Schedule)]
[Comment("Расписание в ЕСПП. Смещение часового пояса относительно МСК для зоны ответственности рабочей группы")]
public class ScheduleResponseAreaTimeOffset
{
[Key]
public required string ResponseArea { get; set; }
/// <summary>
/// ЕСПП значение
/// </summary>
public required string EsppValue { get; set; }
/// <summary>
/// Смещение относительно UTC
/// </summary>
public required TimeSpan UtcTimeOffset { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Settings")]
public class Setting
{
[Key]
public required string Name { get; set; }
public required string Value { get; set; }
public required string Description { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Subprocesses")]
[Index(nameof(EsppId), IsUnique = true)]
public class Subprocess : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public int EsppId { get; set; }
public Guid ProcessId { get; set; }
[ForeignKey(nameof(ProcessId))]
public Process? Process { get; set; }
public ICollection<Tnk> Tnks { get; set; } = new HashSet<Tnk>();
}
}

View File

@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
/// <summary>
/// Статус шаблона. Что нужно сделать роботу в ЕСПП
/// </summary>
[Table("TaskStatuses")]
public class TaskStatus
{
[Key]
public int Code { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Description { get; set; } = string.Empty;
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
public ICollection<RobotHistory> RobotHistories { get; set; } = new HashSet<RobotHistory>();
}
}

View File

@@ -0,0 +1,97 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.Base.History.Base;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Templates")]
[Index(nameof(Name), nameof(Index), IsUnique = true)]
public class Template : IBaseEntity, ITemplateGeneralProps, IHistoryInitiator, IMyHistory<TemplateHistory>
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
/// <summary>
/// Индекс, используется в групповых шаблонах
/// </summary>
public int? Index { get; set; }
public bool IsActiveTemplate { get; set; }
public bool IsActiveSchedule { get; set; }
/// <summary>
/// Номер расписания еспп
/// </summary>
public string? ScheduleEsppId { get; set; }
///// <summary>
///// Следующая дата срабатываения генерации наряда
///// </summary>
//public DateTimeOffset NextScheduleStart { get; set; }
///// <summary>
///// Следующа дата выполнения скрипта агентом. Может быть нулл если шаблон не автоматический (не выполняется скриптом)
///// </summary>
//public DateTimeOffset? NextScriptStart { get; set; }
public DateTimeOffset? LastRun { get; set; }
public DateTimeOffset NextRun { get; set; }
//public Guid ApplicationInWorkId { get; set; }
public Guid JobId { get; set; }
public Guid UnitId { get; set; }
public TemplateStatusTypeEnum StatusTypeId { get; set; } = TemplateStatusTypeEnum.Used;
//public Guid HostId { get; set; }
#region Initiator
public string? InitiatorIp { get; set; }
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
public string? InitiatorComment { get; set; }
#endregion
//[ForeignKey(nameof(ApplicationInWorkId))]
//public ApplicationsInWork? ApplicationsInWork { get; set; }
//[ForeignKey(nameof(HostId))]
//public Host? Host { get; set; }
[ForeignKey(nameof(JobId))]
public Job.Job? Job { get; set; }
[ForeignKey(nameof(UnitId))]
public Unit.Unit? Unit { get; set; }
public ICollection<RobotConfiguration> RobotConfigurations { get; set; } = new HashSet<RobotConfiguration>();
public ICollection<AgentHistory> AgentHistories { get; set; } = new HashSet<AgentHistory>();
public ICollection<Order> Orders { get; set; } = new HashSet<Order>();
public ICollection<TemplateHistory> TemplateHistories { get; set; } = new HashSet<TemplateHistory>();
public ICollection<UnitsInTemplate> UnitsInTemplate { get; set; } = new HashSet<UnitsInTemplate>();
public TemplateStatusType? StatusType { get; set; }
}
}

View File

@@ -0,0 +1,53 @@
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.Base.History.Base;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("TemplateHistories")]
public class TemplateHistory : IBaseEntity, ITemplateGeneralProps, IHistoryInitiator, IHistoryTable
{
[Key]
public Guid Id { get; set; }
public Guid ParentId { get; set; }
public DateTimeOffset DateAddedToHistory { get; set; }
public string? InitiatorIp { get; set; }
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
public string? InitiatorComment { get; set; }
[NotMapped]
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
public bool IsActiveTemplate { get; set; }
public bool IsActiveSchedule { get; set; }
public DateTimeOffset? LastRun { get; set; }
public DateTimeOffset NextRun { get; set; }
public TemplateStatusTypeEnum StatusTypeId { get; set; } = TemplateStatusTypeEnum.Used;
public string? ScheduleEsppId { get; set; }
[ForeignKey(nameof(ParentId))]
public Template? Template { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("TemplateStatusTypes")]
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
public class TemplateStatusType
{
[Key]
public TemplateStatusTypeEnum Id { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
}
}

View File

@@ -0,0 +1,35 @@
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("Tnks")]
//[Index(nameof(EsppId), IsUnique = true)]
public class Tnk : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
/// <summary>
/// Краткое наименование, применяется в шорткоде "%ТНК-КРАТКО%"
/// </summary>
public string? ShortName { get; set; }
public int? EsppId { get; set; }
public Guid SubprocessId { get; set; }
[ForeignKey(nameof(SubprocessId))]
public Subprocess? Subprocess { get; set; }
public ICollection<Job.Job> Jobs { get; set; } = new HashSet<Job.Job>();
}
}

View File

@@ -0,0 +1,98 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
[Table("Units", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица с ЭК")]
[Index(nameof(Name), IsUnique = true)]
public class Unit : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// ЭК
/// </summary>
public required string Name { get; set; }
public DateTimeOffset? LastLogon { get; set; }
[NotMapped]
public BaseFields? BaseFields
{
get
{
if (UnitValues.Any())
{
var result = new BaseFields();
result.IP = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "IP_АДРЕС")?.Value?.Value;
result.ResponseArea = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "ЗО_РГ")?.Value?.Value;
result.WorkGroup = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "РАБОЧАЯ_ГР_ОТВ_ЗАК")?.Value?.Value;
result.Status = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "СТАТУС")?.Value?.Value;
result.NotUnique = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "НЕУНИКАЛЬНЫЙ_ЭК")?.Value?.Value;
return result;
}
return null;
}
}
public ICollection<UnitInField> UnitFields { get; set; } = new HashSet<UnitInField>();
public ICollection<UnitInValue> UnitValues { get; set; } = new HashSet<UnitInValue>();
/// <summary>
/// Получить всех родителей
/// </summary>
[InverseProperty(nameof(UnitInUnit.ChildUnit))]
public ICollection<UnitInUnit> ParentUnits { get; set; } = new HashSet<UnitInUnit>();
/// <summary>
/// Получить детей
/// </summary>
[InverseProperty(nameof(UnitInUnit.ParentUnit))]
public ICollection<UnitInUnit> ChildUnits { get; set; } = new HashSet<UnitInUnit>();
/// <summary>
/// Связь с шаблонами. Один ко многим
/// </summary>
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
/// <summary>
/// К одному шаблону привязано несколько ЭК(Груповой тип работы). Многие ко многим
/// </summary>
public ICollection<UnitsInTemplate> TemplatesInUnit { get; set; } = new HashSet<UnitsInTemplate>();
public UnitKiiUnit? UnitKii { get; set; }
}
public class BaseFields
{
public string? IP { get; set; }
public string? ResponseArea { get; set; }
public string? WorkGroup { get; set; }
public string? Status { get; set; }
public string? NotUnique { get; set; }
}
}

View File

@@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Job;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
/// <summary>
/// Справочник полей ЭК (компонентный состав, ответствтвенные, любые поля)
/// </summary>
[Table("Fields", Schema = DatabaseSchemas.Unit)]
[Comment("Справочник полей ЭК")]
[Index(nameof(AihitName))]
[Index(nameof(EsppName))]
public class UnitField : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
/// <summary>
/// Имя поля в АИХ ИТ, заполняется при синхронизации
/// </summary>
public required string AihitName { get; set; }
/// <summary>
/// Название поля в ЕСПП, возможно в дальнейшем для синхронизации
/// </summary>
public string? EsppName { get; set; }
/// <summary>
/// Название поля для отображения в ГУИ
/// </summary>
public string? DisplayName { get; set; }
/// <summary>
/// Код поля, используется в GUI
/// </summary>
public string? Code { get; set; }
/// <summary>
/// Могут ли принимать несколько значений. Из АИХ ИТ приходят значения разделённые запятой
/// </summary>
public bool? IsMultipleValue { get; set; }
public ICollection<UnitInField> Units { get; set; } = new HashSet<UnitInField>();
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
public ICollection<UnitFieldInUnitFieldValue> UnitFieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
public ICollection<JobRelationshipFilter> RelationshipFilters { get; set; } = new HashSet<JobRelationshipFilter>();
/// <summary>
/// JobGroup которые группируются по этому полю (!!!отключено каскадное удаление!!!)
/// </summary>
public ICollection<JobGroup> JobGroupWithGrouping { get; set; } = new HashSet<JobGroup>();
}
}

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
[Table("FieldInFieldValues", Schema = DatabaseSchemas.Unit)]
[Comment("Значения полей ЭК")]
[PrimaryKey(nameof(FieldId), nameof(FieldValueId))]
public class UnitFieldInUnitFieldValue : IBaseEntityDateCreated
{
public Guid FieldId { get; set; }
public Guid FieldValueId { get; set; }
public DateTimeOffset DateCreated { get; set; }
[ForeignKey(nameof(FieldId))]
public UnitField? Field { get; set; }
[ForeignKey(nameof(FieldValueId))]
public UnitFieldValue? FieldValue { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
[Table("FieldValues", Schema = DatabaseSchemas.Unit)]
[Comment("Значения полей ЭК")]
[Index(nameof(Value), IsUnique = true)]
public class UnitFieldValue : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public string? Value { get; set; }
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
public ICollection<UnitFieldInUnitFieldValue> FieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
public UnitRegionalEkPtkGroup? RegionalEkPtkGroup { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
/// <summary>
/// Связь Unit in Field
/// </summary>
///
[Table("UnitInFields", Schema = DatabaseSchemas.Unit)]
[Comment("Справочник полей ЭК")]
[PrimaryKey(nameof(UnitId), nameof(FieldId))]
public class UnitInField
{
public Guid UnitId { get; set; }
public Guid FieldId { get; set; }
public DateTimeOffset DateCreated { get; set; }
[ForeignKey(nameof(UnitId))]
public Unit? Unit { get; set; }
[ForeignKey(nameof(FieldId))]
public UnitField? UnitField { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
/// <summary>
/// Связи иерархии между ЭК
/// </summary>
[Table("UnitInUnits", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица связей иерархии между ЭК")]
[PrimaryKey(nameof(ParentUnitId), nameof(ChildUnitId))]
public class UnitInUnit
{
public Guid ParentUnitId { get; set; }
public Guid ChildUnitId { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateSynced { get; set; }
[ForeignKey(nameof(ParentUnitId))]
public Unit? ParentUnit { get; set; }
[ForeignKey(nameof(ChildUnitId))]
public Unit? ChildUnit { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
[Table("UnitInValues", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица связи ЭК с полями и со значениями")]
[PrimaryKey(nameof(UnitId), nameof(FieldId), nameof(ValueId))]
[Index(nameof(FieldId), nameof(ValueId))]
[Index(nameof(UnitId), nameof(FieldId))]
[Index(nameof(FieldId), nameof(UnitId))]
public class UnitInValue : IBaseEntityDateModified, IBaseEntityDateCreated
{
public Guid UnitId { get; set; }
public Guid FieldId { get; set; }
public Guid ValueId { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
[ForeignKey(nameof(UnitId))]
public Unit? Unit { get; set; }
[ForeignKey(nameof(FieldId))]
public UnitField? Field { get; set; }
[ForeignKey(nameof(ValueId))]
public UnitFieldValue? Value { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
/// <summary>
/// Список ЭК КИИ, которые учавствуют в групповых работах. Создавалась как временная
/// </summary>
[Table("KiiUnits", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица - Список ЭК КИИ, которые учавствуют в групповых работах. Создавалась как временная")]
public class UnitKiiUnit
{
//TODO: создавалась как временная таблица
[Key]
public Guid UnitId { get; set; }
[ForeignKey(nameof(UnitId))]
public Unit? Unit { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.Unit
{
[Table("RegionalEkPtkGroups", Schema = DatabaseSchemas.Unit)]
[Comment("Таблица - региональные группы ПТК")]
public class UnitRegionalEkPtkGroup
{
[Key]
public Guid FieldValueId { get; set; }
[ForeignKey(nameof(FieldValueId))]
public UnitFieldValue? FieldValue { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("UnitsInTemplates", Schema = DatabaseSchemas.Job)]
[Comment("Таблица связи ЭК в шаблонах")]
public class UnitsInTemplate
{
public Guid TemplateId { get; set; }
public Guid UnitId { get; set; }
public DateTimeOffset DateCreated { get; set; }
[ForeignKey(nameof(TemplateId))]
public Template? Template { get; set; }
[ForeignKey(nameof(UnitId))]
public Unit.Unit? Unit { 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.Domain.Entities
{
[Table("Users")]
[Index(nameof(Ip), IsUnique = true)]
public class User : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public required string Ip { get; set; }
public required string Name { get; set; }
public string? Description { get; set; }
public DateTimeOffset? LastLogon { get; set; }
public ICollection<UsersInRole> Roles { get; set; } = new HashSet<UsersInRole>();
}
}

View File

@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("UsersInRoles")]
[PrimaryKey(nameof(RoleId), nameof(UserId))]
public class UsersInRole
{
public Guid RoleId { get; set; }
public Guid UserId { get; set; }
[ForeignKey(nameof(RoleId))]
public Role? Role { get; set; }
[ForeignKey(nameof(UserId))]
public User? User { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities
{
[Table("WeekendDays", Schema = DatabaseSchemas.Schedule)]
[Index(nameof(Date), IsUnique = true)]
public class WeekendDay : IBaseEntity
{
[Key]
public Guid Id { get; set; }
[NotMapped]
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public DateOnly Date { get; set; }
}
}