From 7f5a6228cfb2d9a51d0597ecd5aa182c8d119e9d Mon Sep 17 00:00:00 2001 From: Craig Fowler Date: Tue, 9 Mar 2021 20:09:36 +0000 Subject: [PATCH] Resolve #728 - Fix ActivityExecuted persistence The PersistWorkflow service will now handle ActivityExecuted persistence behaviour, presumably as-intended. --- src/core/Elsa.Core/Handlers/PersistWorkflow.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/Elsa.Core/Handlers/PersistWorkflow.cs b/src/core/Elsa.Core/Handlers/PersistWorkflow.cs index b2470959f..0e53bff60 100644 --- a/src/core/Elsa.Core/Handlers/PersistWorkflow.cs +++ b/src/core/Elsa.Core/Handlers/PersistWorkflow.cs @@ -15,7 +15,8 @@ namespace Elsa.Handlers INotificationHandler, INotificationHandler, INotificationHandler, - INotificationHandler + INotificationHandler, + INotificationHandler { private readonly IWorkflowInstanceStore _workflowInstanceStore; private readonly ILogger _logger; @@ -94,6 +95,16 @@ namespace Elsa.Handlers } } + public async Task Handle(ActivityExecuted notification, CancellationToken cancellationToken) + { + _logger.LogTrace("Received notification {notification}", notification); + + var behavior = notification.WorkflowExecutionContext.WorkflowBlueprint.PersistenceBehavior; + + if (behavior == WorkflowPersistenceBehavior.ActivityExecuted) + await SaveWorkflowAsync(notification.WorkflowExecutionContext, cancellationToken); + } + private async ValueTask SaveWorkflowAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken) { _logger.LogTrace("Persisting workflow instance {instanceId}", workflowExecutionContext.WorkflowInstance.Id);