diff --git a/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.Events/IEvent.cs b/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.Events/IEvent.cs index f4273ba..f389391 100644 --- a/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.Events/IEvent.cs +++ b/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.Events/IEvent.cs @@ -5,11 +5,13 @@ namespace Masa.BuildingBlocks.Dispatcher.Events; public interface IEvent { - [JsonIgnore] - Guid Id { get; } + Guid GetEventId(); - [JsonIgnore] - DateTime CreationTime { get; } + void SetEventId(Guid eventId); + + DateTime GetCreationTime(); + + void SetCreationTime(DateTime creationTime); } public interface IEvent : IEvent diff --git a/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.IntegrationEvents/Logs/IntegrationEventLog.cs b/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.IntegrationEvents/Logs/IntegrationEventLog.cs index 1b6eee9..6cc52b0 100644 --- a/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.IntegrationEvents/Logs/IntegrationEventLog.cs +++ b/src/Dispatcher/Masa.BuildingBlocks.Dispatcher.IntegrationEvents/Logs/IntegrationEventLog.cs @@ -29,7 +29,7 @@ public class IntegrationEventLog public Guid TransactionId { get; private set; } = Guid.Empty; - public string RowVersion { get;private set; } + public string RowVersion { get; private set; } private IntegrationEventLog() { @@ -39,9 +39,9 @@ private IntegrationEventLog() public IntegrationEventLog(IIntegrationEvent @event, Guid transactionId) : this() { - EventId = @event.Id; - CreationTime = @event.CreationTime; - ModificationTime = @event.CreationTime; + EventId = @event.GetEventId(); + CreationTime = @event.GetCreationTime(); + ModificationTime = @event.GetCreationTime(); EventTypeName = @event.GetType().FullName!; Content = System.Text.Json.JsonSerializer.Serialize((object)@event); TransactionId = transactionId; @@ -58,6 +58,8 @@ public void Initialize() public IntegrationEventLog DeserializeJsonContent(Type type) { Event = (System.Text.Json.JsonSerializer.Deserialize(Content, type) as IIntegrationEvent)!; + Event?.SetEventId(this.EventId); + Event?.SetCreationTime(this.CreationTime); return this; } }