diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs index 32a5e464166..ac72d43f5d3 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs @@ -131,15 +131,17 @@ public Task CreateActivityExecutionContextAsync(ActivityRecord return Task.FromResult(context); } - public async Task TriggerEventAsync(string name, IDictionary input = null, string correlationId = null, bool isExclusive = false, bool isAlwaysCorrelated = false) + public async Task> TriggerEventAsync(string name, IDictionary input = null, string correlationId = null, bool isExclusive = false, bool isAlwaysCorrelated = false) { var activity = _activityLibrary.GetActivityByName(name); if (activity == null) { _logger.LogError("Activity '{ActivityName}' was not found", name); - return; + return Array.Empty(); } + var triggerdWorkflows = new List(); + // Resume workflow instances halted on this kind of activity for the specified target. var haltedWorkflows = await _workflowStore.ListByActivityNameAsync(name, correlationId, isAlwaysCorrelated); foreach (var workflow in haltedWorkflows) @@ -181,7 +183,8 @@ public async Task TriggerEventAsync(string name, IDictionary inp var blockingActivities = haltedWorkflow.BlockingActivities.Where(x => x.Name == name).ToArray(); foreach (var blockingActivity in blockingActivities) { - await ResumeWorkflowAsync(haltedWorkflow, blockingActivity, input); + var context = await ResumeWorkflowAsync(haltedWorkflow, blockingActivity, input); + triggerdWorkflows.Add(context); } } @@ -230,8 +233,10 @@ public async Task TriggerEventAsync(string name, IDictionary inp } var startActivity = workflowType.Activities.First(x => x.IsStart && x.Name == name); - await StartWorkflowAsync(workflowType, startActivity, input, correlationId); + var context = await StartWorkflowAsync(workflowType, startActivity, input, correlationId); + triggerdWorkflows.Add(context); } + return triggerdWorkflows; } public async Task ResumeWorkflowAsync(Workflow workflow, BlockingActivity awaitingActivity, IDictionary input = null) diff --git a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowManager.cs b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowManager.cs index 98f10cb1bb7..845e101c30f 100644 --- a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowManager.cs +++ b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowManager.cs @@ -38,7 +38,7 @@ public interface IWorkflowManager /// /// If true, to be correlated a workflow instance only needs to be halted on an event activity of the related type, regardless the 'correlationId'. False by default. /// - Task TriggerEventAsync(string name, IDictionary input = null, string correlationId = null, bool isExclusive = false, bool isAlwaysCorrelated = false); + Task> TriggerEventAsync(string name, IDictionary input = null, string correlationId = null, bool isExclusive = false, bool isAlwaysCorrelated = false); /// /// Starts a new workflow using the specified workflow definition. @@ -72,7 +72,7 @@ public interface IWorkflowManager public static class WorkflowManagerExtensions { - public static Task TriggerEventAsync(this IWorkflowManager workflowManager, string name, object input = null, string correlationId = null) + public static Task> TriggerEventAsync(this IWorkflowManager workflowManager, string name, object input = null, string correlationId = null) { return workflowManager.TriggerEventAsync(name, new RouteValueDictionary(input), correlationId); } diff --git a/src/docs/releases/1.9.0.md b/src/docs/releases/1.9.0.md index 789bafa5977..39592394011 100644 --- a/src/docs/releases/1.9.0.md +++ b/src/docs/releases/1.9.0.md @@ -32,6 +32,11 @@ Added new extensions to make registering custom deployment step easier - services.AddDeployment(); - services.AddDeploymentWithoutSource(); +### Workflow Module + + The method `public async Task TriggerEventAsync(string name, IDictionary input = null, string correlationId = null, bool isExclusive = false, bool isAlwaysCorrelated = false)` + was changed to return Task> instead. + ### GraphQL Module When identifying content types for GraphQL exposure, we identify those without a stereotype to provide you with control over the behavior of stereotyped content types. A new option, `DiscoverableSterotypes`, has been introduced in `GraphQLContentOptions`. This allows you to specify stereotypes that should be discoverable by default.