| | | 1 | | using System.ComponentModel; |
| | | 2 | | using System.Runtime.CompilerServices; |
| | | 3 | | using Elsa.Alterations.Bookmarks; |
| | | 4 | | using Elsa.Extensions; |
| | | 5 | | using Elsa.Workflows; |
| | | 6 | | using Elsa.Workflows.Attributes; |
| | | 7 | | using Elsa.Workflows.Memory; |
| | | 8 | | using Elsa.Workflows.Models; |
| | | 9 | | |
| | | 10 | | namespace Elsa.Alterations.Activities; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Submits an alteration plan for execution. |
| | | 14 | | /// </summary> |
| | | 15 | | [Browsable(false)] |
| | | 16 | | [Activity("Elsa", "Alterations", "Triggered when an Alteration Plan completed")] |
| | | 17 | | public class AlterationPlanCompleted : Trigger |
| | | 18 | | { |
| | | 19 | | /// <inheritdoc /> |
| | 19 | 20 | | public AlterationPlanCompleted(Variable<string> planId, [CallerFilePath] string? source = null, [CallerLineNumber] i |
| | | 21 | | { |
| | 19 | 22 | | PlanId = new Input<string>(planId); |
| | 19 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <inheritdoc /> |
| | 0 | 26 | | public AlterationPlanCompleted([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(s |
| | | 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 | | if (context.IsTriggerOfWorkflow()) |
| | | 39 | | { |
| | 0 | 40 | | await context.CompleteActivityAsync(); |
| | 0 | 41 | | return; |
| | | 42 | | } |
| | | 43 | | |
| | 0 | 44 | | var planId = context.Get(PlanId)!; |
| | 0 | 45 | | var bookmarkPayload = new AlterationPlanCompletedPayload(planId); |
| | 0 | 46 | | context.CreateBookmark(bookmarkPayload, false); |
| | 0 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <inheritdoc /> |
| | | 50 | | protected override object GetTriggerPayload(TriggerIndexingContext context) |
| | | 51 | | { |
| | 0 | 52 | | var planId = context.Get(PlanId)!; |
| | 0 | 53 | | return new AlterationPlanCompletedPayload(planId); |
| | | 54 | | } |
| | | 55 | | } |