public IEnumerable <SourcedEvent> GetAllEvents()
 {
     return(factory.Create()
            .AllCommits()
            .SelectMany(c => c.Events)
            .ToList());
 }
Beispiel #2
0
        public void Save <TAggregateRoot>(TAggregateRoot aggregateRoot)
            where TAggregateRoot : AggregateRoot
        {
            using (IEventSession eventSession = eventSessionFactory.Create())
            {
                foreach (SourcedEvent @event in aggregateRoot.EventsAdded)
                {
                    EventStreamId eventStreamId = aggregateRoot.GetEventStreamId();

                    eventSession.StoreEvent(@event, eventStreamId);
                    eventSession.StoreHeader(eventStreamId, EventOriginHeader.Key, EventOriginHeader.ForMachine(localMachine));
                }

                eventSession.Commit(Guid.NewGuid());
            }
        }
Beispiel #3
0
 public void SynchroniseCommit(SynchronisableCommit toSynchronise)
 {
     using (var eventSession = eventSessionFactory.Create())
     {
         toSynchronise.Events.ForEach(e => eventSession.StoreEvent(e.ToSourcedEvent(), toSynchronise.StreamId.ToEventStreamId()));
         toSynchronise.Headers.ForEach(h => eventSession.StoreHeader(toSynchronise.StreamId.ToEventStreamId(), h.Key, h.Value.Deserialise()));
         eventSession.CommitWithoutDispatching(toSynchronise.CommitId);
     }
 }
Beispiel #4
0
 public CommitSynchronisation Build(string clientId, DateTime @from, Func <Commit, bool> commitsWhereClause)
 {
     return(new CommitSynchronisation
     {
         Commits = factory.Create()
                   .GetSynchronisableCommits(clientId, @from, commitsWhereClause)
                   .ToList()
     });
 }
        public Task Handle(TCommand command)
        {
            MultiSiteId id = CreateAggregateRootIdFromCommand(command);

            eventSessionFactory
            .Create().StoreEventAndCommit(
                CreateEventFromCommand(command, id),
                id.ToEventStreamId(),
                localMachine);

            return(Task.FromResult(false));
        }