| | | 1 | | using System.ComponentModel; |
| | | 2 | | using System.Runtime.CompilerServices; |
| | | 3 | | using Elsa.Alterations.Core.Contracts; |
| | | 4 | | using Elsa.Workflows; |
| | | 5 | | using Elsa.Workflows.Attributes; |
| | | 6 | | using Elsa.Workflows.Exceptions; |
| | | 7 | | using Elsa.Workflows.Memory; |
| | | 8 | | using Elsa.Workflows.Models; |
| | | 9 | | |
| | | 10 | | namespace Elsa.Alterations.Activities; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Marks an alteration plan as completed. |
| | | 14 | | /// </summary> |
| | | 15 | | [Browsable(false)] |
| | | 16 | | [Activity("Elsa", "Alterations", "Dispatches jobs for the specified Alteration Plan", Kind = ActivityKind.Task)] |
| | | 17 | | public class CompleteAlterationPlan : CodeActivity |
| | | 18 | | { |
| | | 19 | | /// <inheritdoc /> |
| | 19 | 20 | | public CompleteAlterationPlan(Variable<string> planId, [CallerFilePath] string? source = null, [CallerLineNumber] in |
| | | 21 | | { |
| | 19 | 22 | | PlanId = new Input<string>(planId); |
| | 19 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <inheritdoc /> |
| | 0 | 26 | | public CompleteAlterationPlan([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(so |
| | | 27 | | { |
| | 0 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The ID of the alteration plan. |
| | | 32 | | /// </summary> |
| | 67 | 33 | | public Input<string> PlanId { get; set; } = null!; |
| | | 34 | | |
| | | 35 | | /// <inheritdoc /> |
| | | 36 | | protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) |
| | | 37 | | { |
| | 0 | 38 | | var cancellationToken = context.CancellationToken; |
| | 0 | 39 | | var planId = context.Get(PlanId)!; |
| | 0 | 40 | | var manager = context.GetRequiredService<IAlterationPlanManager>(); |
| | 0 | 41 | | var plan = await manager.GetPlanAsync(planId, cancellationToken); |
| | | 42 | | |
| | 0 | 43 | | if (plan == null) |
| | 0 | 44 | | throw new FaultException(AlterationFaultCodes.PlanNotFound, AlterationFaultCategories.Alteration, DefaultFau |
| | | 45 | | |
| | 0 | 46 | | await manager.CompletePlanAsync(plan, cancellationToken); |
| | 0 | 47 | | } |
| | | 48 | | } |