feat: создана структура проекта, core, domain, infrastructure. Перенесены enum и task согласно архитектуры

This commit is contained in:
Mikhail Trubnikov
2026-04-13 16:58:30 +10:00
parent 0bbbac09fe
commit da83aff19c
160 changed files with 482 additions and 267 deletions

View File

@@ -6,8 +6,9 @@ using PARR.DAL.Extensions;
using PARR.DAL.Models;
using PARR.DAL.Models.Job;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Models.Unit;
using PARR.Domain.Entities.TaskEntities;
using PARR.Domain.Enums;
namespace PARR.DAL.Context
{
@@ -121,7 +122,7 @@ namespace PARR.DAL.Context
#region Tasks
public DbSet<TaskItem> Tasks { get; set; }
public DbSet<Models.TaskModels.TaskStatus> TaskStatus { get; set; }
public DbSet<Domain.Entities.TaskEntities.TaskStatus> TaskStatus { get; set; }
public DbSet<TaskType> TaskTypes { get; set; }
public DbSet<TaskError> TaskErrors { get; set; }
@@ -581,9 +582,9 @@ namespace PARR.DAL.Context
#region TaskStatus
modelBuilder.Entity<PARR.DAL.Models.TaskModels.TaskStatus>(f =>
modelBuilder.Entity<Domain.Entities.TaskEntities.TaskStatus>(f =>
{
f.HasData(new PARR.DAL.Models.TaskModels.TaskStatus[]
f.HasData(new Domain.Entities.TaskEntities.TaskStatus[]
{
new(){Code=TaskItemStatusEnum.Pending, Name=TaskItemStatusEnum.Pending.ToString(), Description="Ожидание"},
new(){Code=TaskItemStatusEnum.Processing, Name=TaskItemStatusEnum.Processing.ToString(), Description="В работе"},

View File

@@ -1,21 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Уровень истории работы агента
/// </summary>
public enum AgentHistoryLevelEnum
{
// При добавлении новых значений, добавить в валидатор AgentHistoryRequestValidator
/// <summary>
/// Агент начал выполнять задание
/// </summary>
Start = 1,
/// <summary>
/// Агент завершил выполнение задания
/// </summary>
End = 5
}
}

View File

@@ -1,13 +0,0 @@
namespace PARR.DAL.Contracts
{
public enum ApplicationTypesEnum
{
APP,
OS,
DB,
CKBS,
IB,
SI,
SM
}
}

View File

@@ -1,53 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Статусы ЭК
/// </summary>
public enum EkStatusEnum
{
/// <summary>
/// Все записи, используется только внутри проекта
/// </summary>
All = 0,
/// <summary>
/// 1-Новый
/// </summary>
New = 1,
/// <summary>
/// 2-Подготовка к эксплуатации
/// </summary>
Preapre = 2,
/// <summary>
/// 3-В эксплуатации
/// </summary>
Exploitation = 3,
/// <summary>
/// 4-В ремонте
/// </summary>
Repair = 4,
/// <summary>
/// 5-В резерве
/// </summary>
Reserve = 5,
/// <summary>
/// 6-Выведен из эксплуатации
/// </summary>
OutOfService = 6,
/// <summary>
/// 7-Тестовый
/// </summary>
Test = 7,
/// <summary>
/// 9-В разработке
/// </summary>
Development = 9
}
}

View File

@@ -1,43 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Расписание ЕСПП: типы повторений
/// </summary>
public enum EsppSchTypeEnum
{
///// <summary>
///// Повторять задачу: Регулярно, Еженедельно, Ежемесячно...
///// </summary>
//Root = 0,
/// <summary>
/// Через интервал
/// </summary>
Interval = 1,
/// <summary>
/// День недели: пнд, вт...
/// </summary>
DayOfWeek = 2,
/// <summary>
/// Число месяца: 1,2,3,4
/// </summary>
DayOfMonth = 3,
/// <summary>
/// Каждый: первый, второй, третий, четвертый, последний
/// </summary>
Order = 4,
/// <summary>
/// Месяц: январь, февраль...
/// </summary>
Month = 5,
/// <summary>
/// Месяц (родительный падеж): января, февраля,
/// </summary>
MonthGenitive = 6
}
}

View File

@@ -1,39 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Расписание ЕСПП: Повторять задачу
/// </summary>
public enum EsppSchTypeScheduleEnum
{
/// <summary>
/// Регулярно
/// </summary>
Regularly = 1,
/// <summary>
/// Еженежельно
/// </summary>
Weekly = 2,
/// <summary>
/// Ежемесячно
/// </summary>
Monthly = 3,
/// <summary>
/// Ежемесячно-2
/// </summary>
Monthly2 = 4,
/// <summary>
/// Ежегодно
/// </summary>
Annually = 5,
/// <summary>
/// Ежегодно-2
/// </summary>
Annually2 = 6
}
}

View File

@@ -1,20 +0,0 @@
namespace PARR.DAL.Contracts
{
public enum JobGroupTypesEnum
{
/// <summary>
/// Обычный тип без особенностей
/// </summary>
Simple = 0,
/// <summary>
/// Тип зонтик, когда отслеживается количество дочерних или родительских связей
/// </summary>
Umbrella = 1,
/// <summary>
/// Тип группа, когда шаблоны группируются по полю Field
/// </summary>
Group = 2
}
}

View File

@@ -1,109 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Коды дорог
/// </summary>
public enum ResponseAreaEnum
{
/// <summary>
/// ДВЖД
/// </summary>
dvgd = 96,
/// <summary>
/// ЗАБ
/// </summary>
zrw = 94,
/// <summary>
/// ВСИБ
/// </summary>
esrr = 92,
/// <summary>
/// КРАСН
/// </summary>
krw = 88,
/// <summary>
/// ЗСИБ
/// </summary>
wsr = 83,
/// <summary>
/// ЮУР
/// </summary>
surw = 80,
/// <summary>
/// СВРД
/// </summary>
svrw = 76,
/// <summary>
/// КБШ
/// </summary>
kbsh = 63,
/// <summary>
/// ПРИВ
/// </summary>
pvrr = 61,
/// <summary>
/// ЮВСТ
/// </summary>
serw = 58,
/// <summary>
/// СКВ
/// </summary>
skzd = 51,
/// <summary>
/// СЕВ
/// </summary>
nrr = 28,
/// <summary>
/// ГОР
/// </summary>
grw = 24,
/// <summary>
/// МСК
/// </summary>
msk = 17,
/// <summary>
/// КЛГ
/// </summary>
klgd = 10,
/// <summary>
/// ОКТ
/// </summary>
orw = 01,
/// <summary>
/// ГВЦ
/// </summary>
gvc = 99,
/// <summary>
/// ОБЩЕЕ
/// </summary>
general = 100,
/// <summary>
/// ВП
/// </summary>
vp = 110,
/// <summary>
/// ОСК
/// </summary>
osk = 111,
}
}

View File

@@ -1,28 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Уровень логов работы робота
/// </summary>
public enum RobotHistoryLevelEnum
{
/// <summary>
/// Робот начал работу
/// </summary>
Start = 1,
/// <summary>
/// Информация
/// </summary>
Information = 5,
/// <summary>
/// Ошибка
/// </summary>
Error = 10,
/// <summary>
/// Успешно завершил работу
/// </summary>
Complete = 15
}
}

View File

@@ -1,28 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Статусы работы робота PARR.DAL.Models.RobotStatus
/// </summary>
public enum RobotStatusEnum
{
/// <summary>
/// Ожидание, ждет пока робот возьмет в работу
/// </summary>
Wait = 11,
/// <summary>
/// Робот взял в работу
/// </summary>
InProgress = 22,
/// <summary>
/// Ошибка отработки роботом. Требует ручного вмешательства.
/// </summary>
Error = 33,
/// <summary>
/// Робот успешно отработал
/// </summary>
Complete = 44
}
}

View File

@@ -1,23 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Расписание регламентной работы - Тип исключения
/// </summary>
public enum ScheduleExcludeTypeEnum
{
/// <summary>
/// Нет исключений
/// </summary>
None = 0,
/// <summary>
/// Выполнить ТОЛЬКО В указанном календаре
/// </summary>
Only = 1,
/// <summary>
/// Выполнить везде, КРОМЕ указанного календаря
/// </summary>
Except = 2
}
}

View File

@@ -1,30 +0,0 @@
namespace PARR.DAL.Contracts
{
// TODO: Сначала надо переименовать TaskStatusEnum -> RobotTaskStatusEnum, а потом TaskTaskStatusEnum -> TaskStatusEnum
/// <summary>
/// Статус задач Task
/// </summary>
public enum TaskItemStatusEnum
{
/// <summary>
/// Ожидание
/// </summary>
Pending=0,
/// <summary>
/// В работе
/// </summary>
Processing = 1,
/// <summary>
/// Выполнено успешно
/// </summary>
Success = 2,
/// <summary>
/// Ошибка
/// </summary>
Failed = 3
}
}

View File

@@ -1,23 +0,0 @@
namespace PARR.DAL.Contracts
{
//TODO: Надо это переименовать в RobotTaskStatusEnum
/// <summary>
/// Статус задания на синхронизацию
/// </summary>
public enum TaskStatusEnum
{
/// <summary>
/// Требуется создание объекта в ЕСПП
/// </summary>
Creating = 10,
/// <summary>
/// Требуется обновление объекта в ЕСПП
/// </summary>
Updating = 20,
/// <summary>
/// Нормальное состояние объекта в ЕСПП и ПАРР. Объект в ПАРР соответствует объекту в ЕСПП
/// </summary>
Ok = 30
}
}

View File

@@ -1,13 +0,0 @@
namespace PARR.DAL.Contracts
{
/// <summary>
/// Типы заданий
/// </summary>
public enum TaskTypeEnum
{
/// <summary>
/// Загруженность
/// </summary>
Workload = 0,
}
}

View File

@@ -11,6 +11,7 @@ using PARR.DAL.Models.Job;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.Domain.Enums;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

View File

@@ -9,6 +9,7 @@ using PARR.DAL.Models.Job;
using PARR.DAL.Models.Unit;
using PARR.DAL.Services.Interfaces.Job;
using PARR.DAL.Services.Interfaces.Unit;
using PARR.Domain.Enums;
using System.Diagnostics;
namespace PARR.DAL.DomainServices.UnitFilterService;

View File

@@ -1,4 +1,4 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models
/// История работы агентов
/// </summary>
[Table("AgentHistories")]
public class AgentHistory : IBase
public class AgentHistory : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +7,7 @@ namespace PARR.DAL.Models
{
[Table("Applications")]
[Index(nameof(Name), nameof(ApplicationTypeId), IsUnique = true)]
public class Application : IBase
public class Application : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,10 +1,10 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("ApplicationsInHost")]
public class ApplicationInHost : IBase
public class ApplicationInHost : IBaseEntity
{
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }

View File

@@ -1,10 +1,10 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("ApplicationTypes")]
public class ApplicationType : IBase
public class ApplicationType : IBaseEntity
{
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.DAL.Settings;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models
{
[Table("ApplicationsInWorks")]
[Index(nameof(WorkId), nameof(ApplicationId), IsUnique = true)]
public class ApplicationsInWork : IBase
public class ApplicationsInWork : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,18 +0,0 @@
namespace PARR.DAL.Models.Base.History.Base
{
/// <summary>
/// Таблица отслеживания изменений основной таблицы (таблица истории)
/// </summary>
public interface IHistoryTable : IBase
{
/// <summary>
/// Id записи в родительской таблице
/// </summary>
public Guid ParentId { get; set; }
/// <summary>
/// Дата добавления в историю
/// </summary>
public DateTimeOffset DateAddedToHistory { get; set; }
}
}

View File

@@ -1,9 +0,0 @@
namespace PARR.DAL.Models.Base.History.Base
{
/// <summary>
/// По этому интерфейсу определям, что хотим вести историю.
/// В родительской таблице, по которой ведется история, указываются настройки истории.
/// </summary>
/// <typeparam name="HistoryTable">Таблица истории</typeparam>
public interface IMyHistory<HistoryTable> where HistoryTable : class { }
}

View File

@@ -1,15 +0,0 @@
namespace PARR.DAL.Models.Base.History
{
public interface ITemplateGeneralProps
{
public string Name { get; set; }
public bool IsActiveTemplate { get; set; }
public bool IsActiveSchedule { get; set; }
public DateTimeOffset? LastRun { get; set; }
public DateTimeOffset NextRun { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
namespace PARR.DAL.Models.Base
{
public interface IBase: IBaseDateCreated, IBaseDateModified
{
Guid Id { get; set; }
//DateTimeOffset DateCreated { get; set; }
//DateTimeOffset? DateModified { get; set; }
}
}

View File

@@ -1,7 +0,0 @@
namespace PARR.DAL.Models.Base
{
public interface IBaseDateCreated
{
DateTimeOffset DateCreated { get; set; }
}
}

View File

@@ -1,7 +0,0 @@
namespace PARR.DAL.Models.Base
{
public interface IBaseDateModified
{
DateTimeOffset? DateModified { get; set; }
}
}

View File

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

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -11,7 +11,7 @@ namespace PARR.DAL.Models
/// </summary>
[Table("EsppSchTypeConfigs", Schema = DataContextSettings.Schedule)]
[Index(nameof(TypeScheduleId), nameof(TypeId), IsUnique = true)]
public class EsppSchTypeConfig : IBase
public class EsppSchTypeConfig : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

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

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models
[Table("Hosts")]
[Index(nameof(IP))]
[Index(nameof(Ek), IsUnique = true)]
public class Host : IBase
public class Host : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models.Job
{
[Table("Jobs", Schema = DataContextSettings.Job)]
[Comment("Таблица видов работ")]
public class Job : IBase
public class Job : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

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

View File

@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Schedule;
using PARR.DAL.Models.Unit;
using PARR.DAL.Settings;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -11,7 +11,7 @@ namespace PARR.DAL.Models.Job
{
[Table("Groups", Schema = DataContextSettings.Job)]
[Comment("Таблица описания групп работ, для реализации зонтиков")]
public class JobGroup : IBase
public class JobGroup : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,7 +9,7 @@ namespace PARR.DAL.Models.Job
{
[Table("GroupTypes", Schema = DataContextSettings.Job)]
[Comment("Таблица типов групп работ")]
public class JobGroupType : IBase
public class JobGroupType : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

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

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -10,7 +10,7 @@ namespace PARR.DAL.Models
/// </summary>
[Table("Orders")]
[Index(nameof(Number), IsUnique = true)]
public class Order : IBase
public class Order : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.Constants;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +7,7 @@ namespace PARR.DAL.Models
{
[Table("Processes")]
[Index(nameof(EsppId), IsUnique = true)]
public class Process : IBase
public class Process : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,7 +9,7 @@ namespace PARR.DAL.Models
[Index(nameof(TemplateId), nameof(RobotCode), IsUnique = true)]
[Index(nameof(TemplateId), nameof(TaskStatusCode))]
[Index(nameof(TemplateId), nameof(RobotStatusCode))]
public class RobotConfiguration : IBase
public class RobotConfiguration : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,10 +1,10 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("RobotHistories")]
public class RobotHistory : IBase
public class RobotHistory : IBaseEntity
{
public Guid Id { get; set; }

View File

@@ -1,11 +1,11 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("Roles")]
public class Role : IBase
public class Role : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +7,7 @@ namespace PARR.DAL.Models
{
[Table("Subprocesses")]
[Index(nameof(EsppId), IsUnique = true)]
public class Subprocess : IBase
public class Subprocess : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,32 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.TaskModels
{
[Table("Errors", Schema = DataContextSettings.Task)]
[Comment("Таблица ошибок заданий")]
public class TaskError : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public Guid TaskId { get; set; }
public int AttemptNumber { get; set; }
public required string ErrorMessage { get; set; }
public string? StackTrace { get; set; }
[ForeignKey(nameof(TaskId))]
public TaskItem? TaskItem { get; set; }
}
}

View File

@@ -1,53 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.TaskModels
{
[Table("Tasks", Schema = DataContextSettings.Task)]
[Comment("Таблица заданий")]
public class TaskItem : IBase, IHistoryInitiator
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public TaskTypeEnum TypeCode { get; set; }
public TaskItemStatusEnum StatusCode { get; set; }
public string? Payload { get; set; }
/// <summary>
/// Кол-во попыток
/// </summary>
public int RetryCount { get; set; }
/// <summary>
/// Дата завершения (устанавливается или когда Успех или когда Ошибка)
/// </summary>
public DateTimeOffset? ProcessedAt { get; set; }
public string? InitiatorIp { get; set; }
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
public string? InitiatorComment { get; set; }
[ForeignKey(nameof(TypeCode))]
public TaskType? TaskType { get; set; }
[ForeignKey(nameof(StatusCode))]
public TaskStatus? TaskStatus { get; set; }
public ICollection<TaskError> TaskErrors { get; set; } = new HashSet<TaskError>();
}
}

View File

@@ -1,23 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.TaskModels
{
[Table("Statuses", Schema = DataContextSettings.Task)]
[Comment("Таблица статусов заданий")]
public class TaskStatus
{
[Key]
public TaskItemStatusEnum Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<TaskItem> Tasks { get; set; } = new HashSet<TaskItem>();
}
}

View File

@@ -1,43 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.TaskModels
{
[Table("Types", Schema = DataContextSettings.Task)]
[Comment("Таблица типов заданий")]
public class TaskType
{
[Key]
public TaskTypeEnum Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
/// <summary>
/// Максимальное кол-во попыток
/// </summary>
public int MaxRetries { get; set; }
/// <summary>
/// Максимальное время выполнения
/// </summary>
public int MaxExecutionTimeMinutes { get; set; }
/// <summary>
/// Одновременно может быть только одна задача или несколько
/// </summary>
public bool IsSingleton { get; set; }
/// <summary>
/// Сколько дней хранить в БД
/// </summary>
public int RetentionDays { get; set; }
public ICollection<TaskItem> Tasks { get; set; } = new HashSet<TaskItem>();
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore;
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Base.History;
using PARR.DAL.Models.Base.History.Base;
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;
@@ -11,7 +11,7 @@ namespace PARR.DAL.Models
{
[Table("Templates")]
[Index(nameof(Name), nameof(Index), IsUnique = true)]
public class Template : IBase, ITemplateGeneralProps, IHistoryInitiator, IMyHistory<TemplateHistory>
public class Template : IBaseEntity, ITemplateGeneralProps, IHistoryInitiator, IMyHistory<TemplateHistory>
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,15 +1,15 @@
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Base.History;
using PARR.DAL.Models.Base.History.Base;
using PARR.Constants;
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.DAL.Models
{
[Table("TemplateHistories")]
public class TemplateHistory : IBase, ITemplateGeneralProps, IHistoryInitiator, IHistoryTable
public class TemplateHistory : IBaseEntity, ITemplateGeneralProps, IHistoryInitiator, IHistoryTable
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,4 +1,4 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -6,7 +6,7 @@ namespace PARR.DAL.Models
{
[Table("Tnks")]
//[Index(nameof(EsppId), IsUnique = true)]
public class Tnk : IBase
public class Tnk : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,7 +9,7 @@ namespace PARR.DAL.Models.Unit
[Table("Units", Schema = DataContextSettings.Unit)]
[Comment("Таблица с ЭК")]
[Index(nameof(Name), IsUnique = true)]
public class Unit : IBase
public class Unit : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Job;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -14,7 +14,7 @@ namespace PARR.DAL.Models.Unit
[Comment("Справочник полей ЭК")]
[Index(nameof(AihitName))]
[Index(nameof(EsppName))]
public class UnitField : IBase
public class UnitField : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models.Unit
@@ -12,7 +12,7 @@ namespace PARR.DAL.Models.Unit
[Index(nameof(FieldId), nameof(ValueId))]
[Index(nameof(UnitId), nameof(FieldId))]
[Index(nameof(FieldId), nameof(UnitId))]
public class UnitInValue : IBaseDateModified, IBaseDateCreated
public class UnitInValue : IBaseEntityDateModified, IBaseEntityDateCreated
{
public Guid UnitId { get; set; }

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -7,7 +7,7 @@ namespace PARR.DAL.Models
{
[Table("Users")]
[Index(nameof(Ip), IsUnique = true)]
public class User : IBase
public class User : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Context;
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models
{
[Table("WeekendDays", Schema = DataContextSettings.Schedule)]
[Index(nameof(Date), IsUnique = true)]
public class WeekendDay : IBase
public class WeekendDay : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,11 +1,11 @@
using PARR.DAL.Models.Base;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("WorkGroups")]
public class WorkGroup : IBase
public class WorkGroup : IBaseEntity
{
[Key]
public Guid Id { get; set; }

View File

@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Enums;
using System.Text.Json;
namespace PARR.DAL.NextRunServices.Subservices

View File

@@ -23,5 +23,11 @@
<ProjectReference Include="..\PARR.BLL\PARR.BLL.csproj" />
<ProjectReference Include="..\PARR.Common\PARR.Common.csproj" />
<ProjectReference Include="..\PARR.Constants\PARR.Constants.csproj" />
<ProjectReference Include="..\PARR.Core\PARR.Core.csproj" />
<ProjectReference Include="..\PARR.Domain\PARR.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Repositories\Base\" />
</ItemGroup>
</Project>

View File

@@ -33,6 +33,11 @@ namespace PARR.DAL
{
public static class ParrDalInstaller
{
// TODO: Переименовать InstallDalServices -> DependencyInjection
// TODO: Переименовать InstallDalServices -> AddDalServices
// TODO: Избавиться от лишнего
/// <summary>
/// Устанавливает Dal сервисы (1)
/// </summary>

View File

@@ -1,17 +1,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.Extensions.Logging;
using PARR.Common.Domain;
using PARR.DAL.Context;
using PARR.DAL.DomainModels;
using PARR.DAL.Models.Base;
using PARR.DAL.Models.Base.History.Base;
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.Base.History.Base;
using System.Reflection;
namespace PARR.DAL.Services.Abstracts
{
internal abstract class BaseService<T> : IBaseService<T> where T : class, IBase
internal abstract class BaseService<T> : IBaseService<T> where T : class, IBaseEntity
{
private readonly ILogger<BaseService<T>> logger;
@@ -118,10 +118,10 @@ namespace PARR.DAL.Services.Abstracts
/// <param name="obj"></param>
private void DateModifiedResolver(EntityEntry obj)
{
if (obj.Entity is IBaseDateModified)
if (obj.Entity is IBaseEntityDateModified)
{
logger.LogDebug("Обновляю DateModified для сущности типа {EntityType}", obj.Entity.GetType().Name);
(obj.Entity as IBaseDateModified)!.DateModified = DateTimeOffset.UtcNow;
(obj.Entity as IBaseEntityDateModified)!.DateModified = DateTimeOffset.UtcNow;
}
}
@@ -168,7 +168,7 @@ namespace PARR.DAL.Services.Abstracts
FillHistoryProp(ref historyInstance, nameof(IHistoryTable.DateAddedToHistory), DateTimeOffset.UtcNow);
// Заполняем Id
FillHistoryProp(ref historyInstance, nameof(IBase.Id), Guid.NewGuid());
FillHistoryProp(ref historyInstance, nameof(IBaseEntity.Id), Guid.NewGuid());
try
{
@@ -202,7 +202,7 @@ namespace PARR.DAL.Services.Abstracts
return;
//Смотрим, если это Id, записываем его в ParentId
var histPropName = prop.Name == nameof(IBase.Id) ? nameof(IHistoryTable.ParentId) : prop.Name;
var histPropName = prop.Name == nameof(IBaseEntity.Id) ? nameof(IHistoryTable.ParentId) : prop.Name;
var histProp = historyInstance.GetType().GetProperty(histPropName);
if (histProp == null) continue;

View File

@@ -2,10 +2,10 @@
using Microsoft.Extensions.Logging;
using PARR.Constants;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Enums;
namespace PARR.DAL.Services.Implementations
{

View File

@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
{

View File

@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
{

View File

@@ -1,6 +1,6 @@
using PARR.DAL.Context;
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Implementations.TaskServices
{

View File

@@ -1,13 +1,13 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Npgsql;
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Context;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;
namespace PARR.DAL.Services.Implementations
{

View File

@@ -1,10 +1,10 @@
using PARR.Common.Domain;
using PARR.DAL.DomainModels;
using PARR.DAL.Models.Base;
using PARR.DAL.DomainModels;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
namespace PARR.DAL.Services.Interfaces.Base
{
public interface IBaseService<T> where T : class, IBase
public interface IBaseService<T> where T : class, IBaseEntity
{
Task<T?> GetAsync(Guid id);
IQueryable<T> Get();

View File

@@ -1,7 +1,7 @@
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Enums;
namespace PARR.DAL.Services.Interfaces
{

View File

@@ -1,6 +1,6 @@
using PARR.Common.Domain;
using PARR.DAL.Models;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Entities.Base.History;
namespace PARR.DAL.Services.Interfaces
{

View File

@@ -1,5 +1,5 @@
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Services.Interfaces.Base;
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Interfaces.TaskServices
{

View File

@@ -1,5 +1,5 @@
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Services.Interfaces.Base;
using PARR.DAL.Services.Interfaces.Base;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Interfaces.TaskServices
{

View File

@@ -1,4 +1,4 @@
using PARR.DAL.Models.TaskModels;
using PARR.Domain.Entities.TaskEntities;
namespace PARR.DAL.Services.Interfaces.TaskServices
{

View File

@@ -1,6 +1,6 @@
using PARR.BLL.Contracts.Interfaces;
using PARR.Common.Domain;
using PARR.DAL.Contracts;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;
namespace PARR.DAL.TaskServices
{

View File

@@ -1,10 +1,10 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.BLL.Contracts.Interfaces;
using PARR.Common.Domain;
using PARR.DAL.Contracts;
using PARR.DAL.Models.TaskModels;
using PARR.DAL.Services.Interfaces.TaskServices;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Entities.TaskEntities;
using PARR.Domain.Enums;
using System.Text.Encodings.Web;
using System.Text.Json;