From 09a0cfe5fe06557658bc5822eed5819325d94c88 Mon Sep 17 00:00:00 2001 From: MariusVuscanNx <96233009+MariusVuscanNx@users.noreply.github.com> Date: Wed, 24 May 2023 16:18:51 +0300 Subject: [PATCH] Allow the user to select the start activty when calling through the api (#4064) --- .../Endpoints/WorkflowDefinitions/Dispatch/Endpoint.cs | 4 +++- .../Endpoints/WorkflowDefinitions/Dispatch/Models.cs | 1 + .../Endpoints/WorkflowDefinitions/Execute/Endpoint.cs | 2 +- .../Endpoints/WorkflowDefinitions/Execute/Models.cs | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Endpoint.cs index f220a07c5..453be1760 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Endpoint.cs @@ -41,6 +41,7 @@ internal class Endpoint : ElsaEndpoint var instanceId = request.InstanceId ?? _identityGenerator.GenerateId(); var correlationId = request.CorrelationId; + var triggerActivityId = request.TriggerActivityId; var input = (IDictionary?)request.Input; var dispatchRequest = new DispatchWorkflowDefinitionRequest { @@ -48,7 +49,8 @@ internal class Endpoint : ElsaEndpoint VersionOptions = VersionOptions.Published, Input = input, InstanceId = instanceId, - CorrelationId = correlationId + CorrelationId = correlationId, + TriggerActivityId = triggerActivityId }; await _workflowDispatcher.DispatchAsync(dispatchRequest, cancellationToken); diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Models.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Models.cs index a1bc1897e..db3a3bb92 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Models.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Dispatch/Models.cs @@ -8,6 +8,7 @@ internal class Request public string DefinitionId { get; set; } = default!; public string? InstanceId { get; set; } public string? CorrelationId { get; set; } + public string? TriggerActivityId { get; set; } [JsonConverter(typeof(ExpandoObjectConverterFactory))] public object? Input { get; set; } diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Endpoint.cs index 2ecd926ee..846ec39c8 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Endpoint.cs @@ -54,7 +54,7 @@ internal class Execute : ElsaEndpoint var correlationId = request.CorrelationId; var input = (IDictionary?)request.Input; - var startWorkflowOptions = new StartWorkflowRuntimeOptions(correlationId, input, VersionOptions.Published); + var startWorkflowOptions = new StartWorkflowRuntimeOptions(correlationId, input, VersionOptions.Published, request.TriggerActivityId); var result = await _workflowRuntime.StartWorkflowAsync(definitionId, startWorkflowOptions, cancellationToken); // If a workflow fault occurred, respond appropriately with a 500 internal server error. diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Models.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Models.cs index 9ed3cc609..392babddd 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Models.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Models.cs @@ -8,7 +8,8 @@ internal class Request { public string DefinitionId { get; set; } = default!; public string? CorrelationId { get; set; } - + public string? TriggerActivityId { get; set; } + [JsonConverter(typeof(ExpandoObjectConverterFactory))] public object? Input { get; set; } }