| | | 1 | | using Elsa.Workflows.Management; |
| | | 2 | | using Elsa.Workflows.Runtime.Entities; |
| | | 3 | | using Microsoft.Extensions.Logging; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Runtime; |
| | | 6 | | |
| | | 7 | | /// <inheritdoc /> |
| | 57 | 8 | | public class TriggerBoundWorkflowService(IWorkflowMatcher workflowMatcher, IWorkflowDefinitionService workflowDefinition |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | | 11 | | public async Task<IEnumerable<TriggerBoundWorkflow>> FindManyAsync(string activityTypeName, object stimulus, Cancell |
| | | 12 | | { |
| | 0 | 13 | | var triggers = await workflowMatcher.FindTriggersAsync(activityTypeName, stimulus, cancellationToken); |
| | 0 | 14 | | return await FindManyAsync(triggers, cancellationToken); |
| | 0 | 15 | | } |
| | | 16 | | |
| | | 17 | | /// <inheritdoc /> |
| | | 18 | | public async Task<IEnumerable<TriggerBoundWorkflow>> FindManyAsync(string stimulusHash, CancellationToken cancellati |
| | | 19 | | { |
| | 5 | 20 | | var triggers = await workflowMatcher.FindTriggersAsync(stimulusHash, cancellationToken); |
| | 5 | 21 | | return await FindManyAsync(triggers, cancellationToken); |
| | 5 | 22 | | } |
| | | 23 | | |
| | | 24 | | private async Task<IEnumerable<TriggerBoundWorkflow>> FindManyAsync(IEnumerable<StoredTrigger> triggers, Cancellatio |
| | | 25 | | { |
| | 10 | 26 | | var groupedTriggers = triggers.GroupBy(x => x.WorkflowDefinitionVersionId); |
| | 5 | 27 | | var triggerBoundWorkflows = new List<TriggerBoundWorkflow>(); |
| | | 28 | | |
| | 20 | 29 | | foreach (var triggerGroup in groupedTriggers) |
| | | 30 | | { |
| | 5 | 31 | | var workflowDefinitionVersionId = triggerGroup.Key; |
| | 5 | 32 | | var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(workflowDefinitionVersionId, canc |
| | | 33 | | |
| | 5 | 34 | | if (workflowGraph == null) |
| | | 35 | | { |
| | 0 | 36 | | logger.LogWarning("Workflow definition with ID {WorkflowDefinitionVersionId} not found", workflowDefinit |
| | 0 | 37 | | continue; |
| | | 38 | | } |
| | | 39 | | |
| | 5 | 40 | | var triggerBoundWorkflow = new TriggerBoundWorkflow(workflowGraph, triggerGroup.ToList()); |
| | 5 | 41 | | triggerBoundWorkflows.Add(triggerBoundWorkflow); |
| | 5 | 42 | | } |
| | | 43 | | |
| | 5 | 44 | | return triggerBoundWorkflows; |
| | 5 | 45 | | } |
| | | 46 | | } |