feat: создана структура проекта, core, domain, infrastructure. Перенесены enum и task согласно архитектуры
This commit is contained in:
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