Update activity execution mapping in workflow runtime (#5253)

The code changes involve updating the activity execution mapper in Elsa.Workflows.Runtime. The updated logic now consider the closest ancestor in the workflow hierarchy when determining the workflow persistence property. This provides a more accurate representation of the workflow's state, rather than relying solely on the workflow execution context.

Fixes #5252
This commit is contained in:
Sipke Schoorstra 2024-04-19 21:57:55 +02:00 committed by GitHub
parent eb0ab1539d
commit 85ba3fc646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
using Elsa.Extensions;
using Elsa.Workflows.Activities;
using Elsa.Workflows.Enums;
using Elsa.Workflows.Management.Options;
using Elsa.Workflows.Models;
@ -28,7 +29,8 @@ public class DefaultActivityExecutionMapper(IOptions<ManagementOptions> options)
* }
*/
var workflowPersistenceProperty = GetDefaultPersistenceMode(source.WorkflowExecutionContext.Workflow.CustomProperties, () => options.Value.LogPersistenceMode);
var workflow = (Workflow?)source.GetAncestors().FirstOrDefault(x => x.Activity is Workflow)?.Activity ?? source.WorkflowExecutionContext.Workflow;
var workflowPersistenceProperty = GetDefaultPersistenceMode(workflow.CustomProperties, () => options.Value.LogPersistenceMode);
var activityPersistenceProperties = source.Activity.CustomProperties.GetValueOrDefault<IDictionary<string, object?>>(LogPersistenceModeKey, () => new Dictionary<string, object?>());
var activityPersistencePropertyDefault = GetDefaultPersistenceMode(source.Activity.CustomProperties, () => workflowPersistenceProperty);