private async Task Save(IProcessManagerState state, string streamName, string correlationId, string causationId) { var commitHeaders = new Dictionary <string, object>(); var metaData = _environment.GetMetaData().MetaData; foreach (var item in metaData) { commitHeaders[item.Key] = item.Value; } if (!string.IsNullOrEmpty(correlationId)) { commitHeaders[CorrelationIdKey] = correlationId; } if (!string.IsNullOrEmpty(causationId)) { commitHeaders[CausationIdKey] = causationId; } commitHeaders[AggregateClrTypeHeader] = state.GetType().AssemblyQualifiedName; commitHeaders[AggregateIdHeader] = state.Id; _environment.GetSettings <EventStoreSettings>().ModifyHeaders(commitHeaders); var eventStream = state.GetUncommittedChanges(); var newEvents = eventStream.Events.ToList(); var originalVersion = state.Version - newEvents.Count; var versionToExpect = originalVersion == 0 ? ExpectedVersion.Any : originalVersion - 1; await SaveEventsToStream(streamName, versionToExpect, newEvents, commitHeaders).ConfigureAwait(false); state.ClearUncommittedChanges(); }
public LoadedProcessState(IProcessManagerState state, string correlationId, string causationId) { State = state; CorrelationId = correlationId; CausationId = causationId; }
protected void OnProcessStateLoaded(IProcessManagerState state, string stream) { _loadedProcessStates[stream] = new LoadedProcessState(state, _environment.GetCorrelationId(), _environment.GetCausationId()); }