| | | 1 | | using Elsa.Workflows.Memory; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Models; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents a work item that can be scheduled for execution. |
| | | 7 | | /// </summary> |
| | | 8 | | public class ActivityWorkItem |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Creates a new instance of the <see cref="ActivityWorkItem"/> class. |
| | | 12 | | /// </summary> |
| | 3450 | 13 | | public ActivityWorkItem( |
| | 3450 | 14 | | IActivity activity, |
| | 3450 | 15 | | ActivityExecutionContext? owner = null, |
| | 3450 | 16 | | object? tag = null, |
| | 3450 | 17 | | IEnumerable<Variable>? variables = null, |
| | 3450 | 18 | | ActivityExecutionContext? existingActivityExecutionContext = null, |
| | 3450 | 19 | | IDictionary<string, object>? input = null, |
| | 3450 | 20 | | string? schedulingActivityExecutionId = null, |
| | 3450 | 21 | | string? schedulingWorkflowInstanceId = null, |
| | 3450 | 22 | | int? schedulingCallStackDepth = null) |
| | | 23 | | { |
| | 3450 | 24 | | Activity = activity; |
| | 3450 | 25 | | Owner = owner; |
| | 3450 | 26 | | Tag = tag; |
| | 3450 | 27 | | Variables = variables; |
| | 3450 | 28 | | ExistingActivityExecutionContext = existingActivityExecutionContext; |
| | 3450 | 29 | | Input = input ?? new Dictionary<string, object>(); |
| | 3450 | 30 | | SchedulingActivityExecutionId = schedulingActivityExecutionId; |
| | 3450 | 31 | | SchedulingWorkflowInstanceId = schedulingWorkflowInstanceId; |
| | 3450 | 32 | | SchedulingCallStackDepth = schedulingCallStackDepth; |
| | 3450 | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// The activity to be executed. |
| | | 37 | | /// </summary> |
| | 3479 | 38 | | public IActivity Activity { get; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// The activity execution context that owns this work item, if any. |
| | | 42 | | /// </summary> |
| | 7118 | 43 | | public ActivityExecutionContext? Owner { get; set; } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// A tag that can be used to identify the work item. |
| | | 47 | | /// </summary> |
| | 6775 | 48 | | public object? Tag { get; set; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// A set of variables to be created as part of the activity execution context. |
| | | 52 | | /// </summary> |
| | 6814 | 53 | | public IEnumerable<Variable>? Variables { get; set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// An existing activity execution context to schedule, if any. |
| | | 57 | | /// </summary> |
| | 6814 | 58 | | public ActivityExecutionContext? ExistingActivityExecutionContext { get; set; } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Optional input to pass to the activity. |
| | | 62 | | /// </summary> |
| | 6814 | 63 | | public IDictionary<string, object> Input { get; set; } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// The ID of the activity execution context that scheduled this work item. |
| | | 67 | | /// This represents the temporal/execution predecessor that directly triggered execution of this activity, |
| | | 68 | | /// distinct from the structural parent (<see cref="Owner"/>). |
| | | 69 | | /// </summary> |
| | 6775 | 70 | | public string? SchedulingActivityExecutionId { get; set; } |
| | | 71 | | |
| | | 72 | | /// <summary> |
| | | 73 | | /// The workflow instance ID of the workflow that scheduled this work item. |
| | | 74 | | /// This is set when crossing workflow boundaries (e.g., via ExecuteWorkflow or DispatchWorkflow). |
| | | 75 | | /// For activities within the same workflow instance, this will be null. |
| | | 76 | | /// </summary> |
| | 6775 | 77 | | public string? SchedulingWorkflowInstanceId { get; set; } |
| | | 78 | | |
| | | 79 | | /// <summary> |
| | | 80 | | /// The call stack depth of the scheduling activity execution context. |
| | | 81 | | /// This is used to calculate the call stack depth when the scheduling context is not present |
| | | 82 | | /// in ActivityExecutionContexts (e.g., for cross-workflow invocations). |
| | | 83 | | /// Should be set to the depth of the scheduling activity (not depth + 1, as the increment is applied automatically) |
| | | 84 | | /// </summary> |
| | 6775 | 85 | | public int? SchedulingCallStackDepth { get; set; } |
| | | 86 | | } |