Configure primitive activities

This commit is contained in:
Sipke Schoorstra 2021-04-04 15:31:40 +02:00
parent e2118a1135
commit aabf9ff2c2
9 changed files with 67 additions and 20 deletions

View file

@ -1,5 +1,6 @@
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
// ReSharper disable once CheckNamespace
@ -15,7 +16,7 @@ namespace Elsa.Activities.Primitives
)]
public class Correlate : Activity
{
[ActivityProperty(Hint = "An expression that evaluates to the value to store as the correlation ID.")]
[ActivityProperty(Hint = "An expression that evaluates to the value to store as the correlation ID.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string Value { get; set; } = default!;
protected override IActivityExecutionResult OnExecute() => Combine(Done(Value), new CorrelateResult(Value));

View file

@ -1,5 +1,6 @@
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
@ -14,7 +15,7 @@ namespace Elsa.Activities.Primitives
)]
public class SetContextId : Activity
{
[ActivityProperty(Hint = "The context ID to set.")]
[ActivityProperty(Hint = "The context ID to set.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string ContextId { get; set; } = default!;
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)

View file

@ -1,5 +1,6 @@
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
@ -14,7 +15,7 @@ namespace Elsa.Activities.Primitives
)]
public class SetName : Activity
{
[ActivityProperty(Hint = "The value to set as the workflow instance's name.")]
[ActivityProperty(Hint = "The value to set as the workflow instance's name.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string? Value { get; set; }
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)

View file

@ -1,5 +1,6 @@
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
@ -17,7 +18,7 @@ namespace Elsa.Activities.Primitives
[ActivityProperty(Hint = "The name of the transient variable to store the value into.")]
public string VariableName { get; set; } = default!;
[ActivityProperty(Hint = "The value to store in the transient variable.")]
[ActivityProperty(Hint = "The value to store in the transient variable.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public object? Value { get; set; }
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)

View file

@ -1,5 +1,6 @@
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
@ -17,7 +18,7 @@ namespace Elsa.Activities.Primitives
[ActivityProperty(Hint = "The name of the variable to store the value into.")]
public string VariableName { get; set; } = default!;
[ActivityProperty(Hint = "The value to store in the variable.")]
[ActivityProperty(Hint = "The value to store in the variable.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public object? Value { get; set; }
protected override IActivityExecutionResult OnExecute(ActivityExecutionContext context)

View file

@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Persistence;
using Elsa.Services;
using Elsa.Services.Models;
@ -27,13 +28,13 @@ namespace Elsa.Activities.Signaling
_workflowInstanceManager = workflowInstanceStore;
}
[ActivityProperty(Hint = "The ID of the workflow instance to resume.")]
[ActivityProperty(Hint = "The ID of the workflow instance to resume.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string WorkflowInstanceId { get; set; } = default!;
[ActivityProperty(Hint = "The ID of the blocking activity to trigger.")]
[ActivityProperty(Hint = "The ID of the blocking activity to trigger.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string BlockingActivityId { get; set; } = default!;
[ActivityProperty(Hint = "An optional input to pass to the blocking activity.")]
[ActivityProperty(Hint = "An optional input to pass to the blocking activity.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public object? Input { get; set; } = default!;
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)

View file

@ -2,6 +2,7 @@ using System.Threading.Tasks;
using Elsa.Activities.Signaling.Services;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
@ -25,13 +26,13 @@ namespace Elsa.Activities.Signaling
_signaler = signaler;
}
[ActivityProperty(Hint = "An expression that evaluates to the name of the signal to trigger.")]
[ActivityProperty(Hint = "An expression that evaluates to the name of the signal to trigger.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string Signal { get; set; } = default!;
[ActivityProperty(Hint = "An expression that evaluates to the correlation ID to use when signaling.")]
[ActivityProperty(Hint = "An expression that evaluates to the correlation ID to use when signaling.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string? CorrelationId { get; set; }
[ActivityProperty(Hint = "An expression that evaluates to an input value when triggering the signal.")]
[ActivityProperty(Hint = "An expression that evaluates to an input value when triggering the signal.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public object? Input { get; set; }
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)

View file

@ -2,6 +2,7 @@ using System;
using Elsa.Activities.Signaling.Models;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
@ -18,7 +19,7 @@ namespace Elsa.Activities.Signaling
)]
public class SignalReceived : Activity
{
[ActivityProperty(Hint = "The name of the signal to wait for.")]
[ActivityProperty(Hint = "The name of the signal to wait for.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public string Signal { get; set; } = default!;
protected override bool OnCanExecute(ActivityExecutionContext context)

View file

@ -4,6 +4,8 @@ using System.Threading;
using System.Threading.Tasks;
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Design;
using Elsa.Expressions;
using Elsa.Models;
using Elsa.Services;
using Elsa.Services.Models;
@ -27,13 +29,50 @@ namespace Elsa.Activities.Workflows
_workflowRegistry = workflowRegistry;
}
[ActivityProperty] public string? WorkflowDefinitionId { get; set; } = default!;
[ActivityProperty] public string? TenantId { get; set; } = default!;
[ActivityProperty] public object? Input { get; set; }
[ActivityProperty] public string? CorrelationId { get; set; }
[ActivityProperty] public string? ContextId { get; set; }
[ActivityProperty] public Variables? CustomAttributes { get; set; } = default!;
[ActivityProperty] public RunWorkflowMode Mode { get; set; }
[ActivityProperty(
Label = "Workflow Definition",
Hint = "The workflow definition ID to run.",
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid }
)]
public string? WorkflowDefinitionId { get; set; } = default!;
[ActivityProperty(
Label = "Tenant ID",
Hint = "The tenant ID to which the workflow to run belongs.",
Category = PropertyCategories.Advanced,
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid }
)]
public string? TenantId { get; set; } = default!;
[ActivityProperty(Hint = "Optional input to send to the workflow to run.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public object? Input { get; set; }
[ActivityProperty(
Label = "Correlation ID",
Hint = "The correlation ID to associate with the workflow to run.",
Category = PropertyCategories.Advanced,
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid }
)]
public string? CorrelationId { get; set; }
[ActivityProperty(
Label = "Context ID",
Hint = "The context ID to associate with the workflow to run.",
Category = PropertyCategories.Advanced,
SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid }
)]
public string? ContextId { get; set; }
[ActivityProperty(
UIHint = ActivityPropertyUIHints.Json,
Hint = "Optional custom attributes to associate with the workflow to run.",
Category = PropertyCategories.Advanced)]
public Variables? CustomAttributes { get; set; } = default!;
[ActivityProperty(
Hint = "Fire And Forget: run the child workflow and continue the current one. Blocking: Run the child workflow and suspend the current one until the child workflow finishes.",
SupportedSyntaxes = new[] { SyntaxNames.Literal, SyntaxNames.JavaScript, SyntaxNames.Liquid })]
public RunWorkflowMode Mode { get; set; }
public string ChildWorkflowInstanceId
{
@ -47,7 +86,7 @@ namespace Elsa.Activities.Workflows
var workflowBlueprint = await FindWorkflowBlueprintAsync(cancellationToken);
var workflowInstance = await _startsWorkflow.StartWorkflowAsync(workflowBlueprint!, TenantId, Input, CorrelationId, ContextId, cancellationToken);
var workflowStatus = workflowInstance.WorkflowStatus;
ChildWorkflowInstanceId = workflowInstance.Id;
return Mode switch