public async Task Project()
        {
            using (var scope = serviceProvider.CreateScope())
            {
                eventStore = scope.ServiceProvider.GetRequiredService <IDomainEventLogService>();
                queryStore = serviceProvider.GetRequiredService <IOrderQueries>();

                var unreadEvent = await eventStore
                                  .GetEventsAsync(0, 10, e => e.State == EventStateEnum.Unread);

                foreach (var @event in unreadEvent)
                {
                    //Must give it assembly name, otherwise returns null
                    Type type = Type.GetType(@event.EventTypeName + ", Ordering.Domain");
                    try
                    {
                        dynamic content = Newtonsoft.Json.JsonConvert.DeserializeObject(@event.Content, type);
                        await When(content);

                        await eventStore.MarkEventAsRead(@event.EventId);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
        }
Beispiel #2
0
 public OrderingContext(DbContextOptions <OrderingContext> options, IMediator mediator, IOrderQueries orderQueries, IDomainEventLogService eventStore) : base(options)
 {
     this.mediator   = mediator;
     this.eventStore = eventStore;
 }