irc-netcore-api/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs

48 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using IRaCIS.Core.Domain.Models;
using MassTransit;
using System.ComponentModel;
using System.Globalization;
namespace IRaCIS.Core.Domain.BaseModel;
/// <summary>
/// 事件 不影响数据库提交事务的,不会记录稽查
///
/// 比如 添加subject 自动添加访视不适合作为事件否则自动添加访视后记录稽查当前请求url 都不知道
/// </summary>
[Description("领域实体事件基类")]
public abstract class DomainEvent
{
public Guid EventId { get; set; } = NewId.NextSequentialGuid();
//是不是延迟消费的事件,需要用定时任务调度
public bool IsDelayScheduleEvent => DelaySeconds!=null && DelaySeconds > 0;
/// <summary>
/// 在事件产生多少s后开始消费该事件
/// </summary>
public int? DelaySeconds{ get; set; }
public string CultureInfoName { get; set; } = CultureInfo.CurrentCulture.Name;
}
/// <summary>
/// 命令,触发一些操作,在当前事务一起提交
/// </summary>
[Description("领域实体命令基类")]
public abstract class DomainCommand
{
}
public class FailedDomainEvent
{
public Guid Id { get; set; }
public string EventType { get; set; } = string.Empty;
public string EventData { get; set; } = string.Empty;
public DateTime FailedAt { get; set; }
}