| | | 1 | | using Elsa.Mediator.Contracts; |
| | | 2 | | using Elsa.Workflows.CommitStates; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using Elsa.Workflows.Runtime.Entities; |
| | | 5 | | using Elsa.Workflows.Runtime.Notifications; |
| | | 6 | | using Elsa.Workflows.Runtime.Requests; |
| | | 7 | | using Elsa.Workflows.State; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Workflows.Runtime; |
| | | 10 | | |
| | 437 | 11 | | public class DefaultCommitStateHandler( |
| | 437 | 12 | | IWorkflowInstanceManager workflowInstanceManager, |
| | 437 | 13 | | IBookmarksPersister bookmarkPersister, |
| | 437 | 14 | | IVariablePersistenceManager variablePersistenceManager, |
| | 437 | 15 | | IMediator mediator, |
| | 437 | 16 | | ILogRecordSink<ActivityExecutionRecord> activityExecutionLogRecordSink, |
| | 437 | 17 | | ILogRecordSink<WorkflowExecutionLogRecord> workflowExecutionLogRecordSink) : ICommitStateHandler |
| | | 18 | | { |
| | | 19 | | public async Task CommitAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken |
| | | 20 | | { |
| | 0 | 21 | | var workflowState = workflowInstanceManager.ExtractWorkflowState(workflowExecutionContext); |
| | 0 | 22 | | await CommitAsync(workflowExecutionContext, workflowState, cancellationToken); |
| | 0 | 23 | | } |
| | | 24 | | |
| | | 25 | | public async Task CommitAsync(WorkflowExecutionContext workflowExecutionContext, WorkflowState workflowState, Cancel |
| | | 26 | | { |
| | 466 | 27 | | var updateBookmarksRequest = new UpdateBookmarksRequest(workflowExecutionContext, workflowExecutionContext.Bookm |
| | 466 | 28 | | await bookmarkPersister.PersistBookmarksAsync(updateBookmarksRequest); |
| | 466 | 29 | | await activityExecutionLogRecordSink.PersistExecutionLogsAsync(workflowExecutionContext, cancellationToken); |
| | 466 | 30 | | await workflowExecutionLogRecordSink.PersistExecutionLogsAsync(workflowExecutionContext, cancellationToken); |
| | 466 | 31 | | await variablePersistenceManager.SaveVariablesAsync(workflowExecutionContext); |
| | 466 | 32 | | var workflowInstance = await workflowInstanceManager.SaveAsync(workflowState, cancellationToken); |
| | 466 | 33 | | workflowExecutionContext.ExecutionLog.Clear(); |
| | 466 | 34 | | workflowExecutionContext.ClearCompletedActivityExecutionContexts(); |
| | 466 | 35 | | await workflowExecutionContext.ExecuteDeferredTasksAsync(); |
| | 466 | 36 | | await mediator.SendAsync(new WorkflowStateCommitted(workflowExecutionContext, workflowState, workflowInstance), |
| | 466 | 37 | | } |
| | | 38 | | } |