< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.ResumeBulkDispatchWorkflowActivity
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/ResumeBulkDispatchWorkflowActivity.cs
Line coverage
100%
Covered lines: 32
Uncovered lines: 0
Coverable lines: 32
Total lines: 55
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync()100%66100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/ResumeBulkDispatchWorkflowActivity.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Helpers;
 3using Elsa.Workflows.Notifications;
 4using Elsa.Workflows.Runtime.Activities;
 5using Elsa.Workflows.Runtime.Options;
 6using Elsa.Workflows.Runtime.Stimuli;
 7using JetBrains.Annotations;
 8
 9namespace Elsa.Workflows.Runtime.Handlers;
 10
 11/// <summary>
 12/// Resumes any blocking <see cref="BulkDispatchWorkflows"/> activities when its child workflows complete.
 13/// </summary>
 14[PublicAPI]
 46715internal class ResumeBulkDispatchWorkflowActivity(IBookmarkQueue bookmarkQueue, IStimulusHasher stimulusHasher) : INotif
 16{
 17    public async Task HandleAsync(WorkflowExecuted notification, CancellationToken cancellationToken)
 18    {
 46519        var workflowState = notification.WorkflowState;
 20
 46521        if (workflowState.Status != WorkflowStatus.Finished)
 6422            return;
 23
 40124        var waitForCompletion = workflowState.Properties.TryGetValue("WaitForCompletion", out var waitForCompletionValue
 25
 40126        if (!waitForCompletion)
 38227            return;
 28
 1929        var parentInstanceId = (string)workflowState.Properties["ParentInstanceId"];
 1930        var activityTypeName = ActivityTypeNameHelper.GenerateTypeName<BulkDispatchWorkflows>();
 1931        var stimulus = new BulkDispatchWorkflowsStimulus(parentInstanceId);
 1932        var stimulusHash = stimulusHasher.Hash(activityTypeName, stimulus);
 1933        var workflowInstanceId = workflowState.Id;
 1934        var input = new Dictionary<string, object>
 1935        {
 1936            ["WorkflowOutput"] = workflowState.Output,
 1937            ["WorkflowInstanceId"] = workflowInstanceId,
 1938            ["WorkflowStatus"] = workflowState.Status,
 1939            ["WorkflowSubStatus"] = workflowState.SubStatus,
 1940        };
 41
 1942        var resumeBookmarkOptions = new ResumeBookmarkOptions
 1943        {
 1944            Input = input
 1945        };
 1946        var bookmarkQueueItem = new NewBookmarkQueueItem
 1947        {
 1948            WorkflowInstanceId = parentInstanceId,
 1949            ActivityTypeName = activityTypeName,
 1950            StimulusHash = stimulusHash,
 1951            Options = resumeBookmarkOptions
 1952        };
 1953        await bookmarkQueue.EnqueueAsync(bookmarkQueueItem, cancellationToken);
 46554    }
 55}