Example #1
0
 private async Task SaveEvent(IDomainEvent @event, long currentSeq)
 {
     var persistedEvent = new Event
     {
         AggregateId   = @event.AggregateId,
         AggregateType = @event.AggregateType?.AssemblyQualifiedName,
         EventData     = @event.ToJson(),
         EventTime     = @event.EventTime,
         Id            = @event.Id,
         Sequence      = (ulong)currentSeq,
         EventType     = @event.GetType().AssemblyQualifiedName
     };
     var response = await EventStoreAzureDbContext.Client.CreateDocumentAsync(EventStoreAzureDbContext.EventsDatabaseLink, persistedEvent)
                    .ConfigureAwait(false);
 }
Example #2
0
        private Event GetEventFromIDomainEvent(IDomainEvent @event, long currentSeq)
        {
            var jsonId = @event.AggregateId != null? @event.AggregateId.ToJson(true) : string.Empty;

            return(new Event
            {
                Id = @event.Id != Guid.Empty ? @event.Id : Guid.NewGuid(),
                EventData = @event.ToJson(),
                HashedAggregateId = !string.IsNullOrWhiteSpace(jsonId) ? jsonId.GetHashCode() : new int?(),
                SerializedAggregateId = !string.IsNullOrWhiteSpace(jsonId) ? Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonId)) : string.Empty,
                AggregateIdType = @event.AggregateId?.GetType()?.AssemblyQualifiedName,
                AggregateType = @event.AggregateType?.AssemblyQualifiedName,
                EventType = @event.GetType().AssemblyQualifiedName,
                EventTime = @event.EventTime,
                Sequence = currentSeq
            });
        }
Example #3
0
 public static void Event(IDomainEvent @event, string message    = null,
                          [CallerFilePath] string sourceFilePath = "", [CallerMemberName] string memberName = "")
 {
     Log.Information("event: {name} {message} {event} {sourceFilePath} {memberName}", @event.EventType.Name,
                     message?.ToLowerInvariant(), @event.ToJson(), sourceFilePath, memberName);
 }