feat: создана структура проекта, core, domain, infrastructure. Перенесены enum и task согласно архитектуры
This commit is contained in:
18
PARR.Domain/Entities/Base/History/Base/IHistoryTable.cs
Normal file
18
PARR.Domain/Entities/Base/History/Base/IHistoryTable.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace PARR.Domain.Entities.Base.History.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Таблица отслеживания изменений основной таблицы (таблица истории)
|
||||
/// </summary>
|
||||
public interface IHistoryTable : IBaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Id записи в родительской таблице
|
||||
/// </summary>
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата добавления в историю
|
||||
/// </summary>
|
||||
public DateTimeOffset DateAddedToHistory { get; set; }
|
||||
}
|
||||
}
|
||||
9
PARR.Domain/Entities/Base/History/Base/IMyHistory.cs
Normal file
9
PARR.Domain/Entities/Base/History/Base/IMyHistory.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace PARR.Domain.Entities.Base.History.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// По этому интерфейсу определям, что хотим вести историю.
|
||||
/// В родительской таблице, по которой ведется история, указываются настройки истории.
|
||||
/// </summary>
|
||||
/// <typeparam name="HistoryTable">Таблица истории</typeparam>
|
||||
public interface IMyHistory<HistoryTable> where HistoryTable : class { }
|
||||
}
|
||||
14
PARR.Domain/Entities/Base/History/HistoryInitiator.cs
Normal file
14
PARR.Domain/Entities/Base/History/HistoryInitiator.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.Domain.Entities.Base.History
|
||||
{
|
||||
/// <summary>
|
||||
/// Инициатор изменений, ведение истории
|
||||
/// </summary>
|
||||
public class HistoryInitiator : IHistoryInitiator
|
||||
{
|
||||
public string? InitiatorIp { get; set; }
|
||||
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
|
||||
public string? InitiatorComment { get; set; }
|
||||
}
|
||||
}
|
||||
25
PARR.Domain/Entities/Base/History/IHistoryInitiator.cs
Normal file
25
PARR.Domain/Entities/Base/History/IHistoryInitiator.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.Domain.Entities.Base.History
|
||||
{
|
||||
/// <summary>
|
||||
/// Инициатор изменений, ведение истории
|
||||
/// </summary>
|
||||
public interface IHistoryInitiator
|
||||
{
|
||||
/// <summary>
|
||||
/// IP инициатора изменений (пользователь)
|
||||
/// </summary>
|
||||
public string? InitiatorIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id инициатора компонента ПАРР
|
||||
/// </summary>
|
||||
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Комментарий от инициатора
|
||||
/// </summary>
|
||||
public string? InitiatorComment { get; set; }
|
||||
}
|
||||
}
|
||||
15
PARR.Domain/Entities/Base/History/ITemplateGeneralProps.cs
Normal file
15
PARR.Domain/Entities/Base/History/ITemplateGeneralProps.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace PARR.Domain.Entities.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; }
|
||||
}
|
||||
}
|
||||
12
PARR.Domain/Entities/Base/IBaseEntity.cs
Normal file
12
PARR.Domain/Entities/Base/IBaseEntity.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace PARR.Domain.Entities.Base
|
||||
{
|
||||
public interface IBaseEntity : IBaseEntityDateCreated, IBaseEntityDateModified
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
//DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
//DateTimeOffset? DateModified { get; set; }
|
||||
}
|
||||
}
|
||||
7
PARR.Domain/Entities/Base/IBaseEntityDateCreated.cs
Normal file
7
PARR.Domain/Entities/Base/IBaseEntityDateCreated.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PARR.Domain.Entities.Base
|
||||
{
|
||||
public interface IBaseEntityDateCreated
|
||||
{
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
}
|
||||
}
|
||||
7
PARR.Domain/Entities/Base/IBaseEntityDateModified.cs
Normal file
7
PARR.Domain/Entities/Base/IBaseEntityDateModified.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PARR.Domain.Entities.Base
|
||||
{
|
||||
public interface IBaseEntityDateModified
|
||||
{
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
}
|
||||
}
|
||||
32
PARR.Domain/Entities/TaskEntities/TaskError.cs
Normal file
32
PARR.Domain/Entities/TaskEntities/TaskError.cs
Normal 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.TaskEntities
|
||||
{
|
||||
[Table("Errors", Schema = DatabaseSchemas.Task)]
|
||||
[Comment("Таблица ошибок заданий")]
|
||||
public class TaskError : IBaseEntity
|
||||
{
|
||||
[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; }
|
||||
}
|
||||
}
|
||||
52
PARR.Domain/Entities/TaskEntities/TaskItem.cs
Normal file
52
PARR.Domain/Entities/TaskEntities/TaskItem.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
using PARR.Domain.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.TaskEntities
|
||||
{
|
||||
[Table("Tasks", Schema = DatabaseSchemas.Task)]
|
||||
[Comment("Таблица заданий")]
|
||||
public class TaskItem : IBaseEntity, 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>();
|
||||
}
|
||||
}
|
||||
23
PARR.Domain/Entities/TaskEntities/TaskStatus.cs
Normal file
23
PARR.Domain/Entities/TaskEntities/TaskStatus.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.TaskEntities
|
||||
{
|
||||
[Table("Statuses", Schema = DatabaseSchemas.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>();
|
||||
}
|
||||
}
|
||||
43
PARR.Domain/Entities/TaskEntities/TaskType.cs
Normal file
43
PARR.Domain/Entities/TaskEntities/TaskType.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Constants;
|
||||
using PARR.Domain.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.Domain.Entities.TaskEntities
|
||||
{
|
||||
[Table("Types", Schema = DatabaseSchemas.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>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user