public WorkOrder Handle(CreateWorkOrderItemMessage message) { var workOrderItemEvent = new CreateWorkOrderItemEvent(message.Id, message.Sku, message.StartDate, message.CompleteDate, message.Status, message.Details); var workOrderEvents = _eventStore.AddEvent <WorkOrderEvents>(message.Id, workOrderItemEvent); _eventPublisher.Publish(message); return(new WorkOrder(message.Id, workOrderEvents)); }
private void OnEventRaised(FlowEvent flowEvent) { if (flowEvent == null) { return; } IList <Tuple <string, ICommand> > commands = GetCommands(flowEvent); foreach (var command in commands) { if (!(flowEvent is CommandProcessingEvent)) { eventStore.AddEvent(new OnStartProcessingCommand(flowEvent.ContextOfEvent, command.Item2)); } var observableEvents = command.Item2.Execute(); Action onComplete = () => { if (!(flowEvent is CommandProcessingEvent)) { eventStore.AddEvent(new OnEndProcessingCommand(flowEvent.ContextOfEvent, command.Item2)); } }; observableEvents.IgnoreElements().Subscribe((e) => { }, onComplete); string commandName = command.Item1;// This is needed to capture variable also, we should use command variable in this lambda observableEvents.Subscribe(currentEvent => { if (currentEvent == null) { return; } if (currentEvent.ContextOfEvent == null) { currentEvent.ContextOfEvent = flowEvent.ContextOfEvent; } if (currentEvent.CommandName == DEFAULT_COMMAND_NAME && commandName != DEFAULT_COMMAND_NAME) { currentEvent.CommandName = commandName; } eventStore.AddEvent(currentEvent); }, ex => Console.WriteLine(ex)); } }
public async Task <Guid> Handle(CreateRecipe request, CancellationToken cancellationToken) { var @event = _mapper.Map(request, Guid.NewGuid(), _dateTime.GetCurrentTime(), _currentUser.GetUserId()); await _eventStore.AddEvent(@event); return(@event.EntityId); }
public async Task <Unit> Handle(DeleteRecipe request, CancellationToken cancellationToken) { var @event = _mapper.Map(request, _dateTime.GetCurrentTime(), _currentUser.GetUserId()); await _eventStore.AddEvent(@event); return(Unit.Value); }
public void Should_Not_throw_Error_When_Add_New_Event_With_Non_Already_Used_Version_Value() { // Arrange var evt = new TestEvent(1, 0, "first"); // Act var actionTest = new Action(() => _store.AddEvent(evt)); // Assert actionTest.Should().NotThrow(); }
public Either <string, Unit> Save(T aggregate) => aggregate .NewEvents .Map(x => new Event(x.AggregateInfo, x.Timestamp, x.Owner, x.EventData)) .Map(x => _storage.AddEvent(x)) .Sequence() .Match( Right: _ => _storage.Save(), Left: err => err);
public Task PersistAsync(Event evt) { if (evt == null) { throw new ArgumentNullException(nameof(evt)); } logger.LogInformation("{@event}", evt); if (evt.EventType == EventTypes.Error || evt.EventType == EventTypes.Failure) { eventStore.AddEvent(evt); } return(Task.CompletedTask); }
public void Save(TAggregate aggregate) { try { IEventSourced <TAggregateId> aggregateEventSourcedView = aggregate; var versionFromStore = _eventStore.GetNextExpectedVersion(aggregate.AggregateId); long count = 0; foreach (var evt in aggregateEventSourcedView.UncommittedEvents) { VersionGuard(versionFromStore, evt); versionFromStore = _eventStore.AddEvent(evt); PublishEvent(evt); count++; } aggregateEventSourcedView.ClearUncommittedEvents(); } catch (EventStoreNotReachableException ex) { throw new RepositoryException(CommunicationImpossibleWithPersistenceBackend, ex); } }
public void RaiseEvent(FlowEvent flowEvent) { eventStore.AddEvent(flowEvent); }
internal static Action <string> GetWarningLogger(this IEventStore store) { return((message) => store.AddEvent(EventHelper.CreateWarningEvent(message))); }
public Task DispatchEvent(IEvent <T> ev) { _eventStore.AddEvent(ev); return(Task.CompletedTask); }