elsa-core/src/common/Elsa.Testing.Shared.Integration/RunWorkflowExtensions.cs

92 lines
4 KiB
C#
Raw Normal View History

using Elsa.Common.Models;
using Elsa.Workflows;
using Elsa.Workflows.Management;
using Elsa.Workflows.Models;
using Elsa.Workflows.Options;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Messages;
using Elsa.Workflows.State;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Testing.Shared;
/// <summary>
/// Provides extension methods for <see cref="IServiceProvider"/>.
/// </summary>
[PublicAPI]
public static class RunWorkflowExtensions
{
/// <param name="services">The services.</param>
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
extension(IServiceProvider services)
{
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
/// <summary>
/// Runs a workflow until its end, automatically resuming any bookmark it encounters.
/// </summary>
/// <param name="workflowDefinitionId">The ID of the workflow definition.</param>
/// <param name="input">An optional dictionary of input values.</param>
/// <param name="correlationId">An optional correlation id of the workflow.</param>
/// <param name="versionOptions">An optional set of options to specify the version of the workflow definition to retrieve.</param>
/// <param name="runWorkflowOptions">Optional workflow execution options.</param>
/// <returns>The workflow state.</returns>
public async Task<WorkflowState> RunWorkflowUntilEndAsync(string workflowDefinitionId,
IDictionary<string, object>? input = null,
string? correlationId = null,
VersionOptions? versionOptions = null,
RunWorkflowOptions? runWorkflowOptions = null)
{
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
var workflowDefinitionService = services.GetRequiredService<IWorkflowDefinitionService>();
var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(workflowDefinitionId, versionOptions ?? VersionOptions.Published);
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
if (workflowGraph == null)
throw new InvalidOperationException($"Workflow definition with ID '{workflowDefinitionId}' not found.");
var workflowRuntime = services.GetRequiredService<IWorkflowRuntime>();
var workflowClient = await workflowRuntime.CreateClientAsync();
var response = await workflowClient.CreateAndRunInstanceAsync(new()
{
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(workflowGraph.Workflow.Identity.Id),
Input = input,
CorrelationId = correlationId,
Properties = runWorkflowOptions?.Properties
});
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
var bookmarkStore = services.GetRequiredService<IBookmarkStore>();
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
// Continue resuming the workflow for as long as there are bookmarks to resume and the workflow is not Finished.
while (response.Status != WorkflowStatus.Finished)
{
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
var bookmarks = (await bookmarkStore.FindManyAsync(new()
{
WorkflowInstanceId = response.WorkflowInstanceId
})).ToList();
if (!bookmarks.Any())
break;
foreach (var bookmark in bookmarks)
{
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
var runRequest = new RunWorkflowInstanceRequest
{
BookmarkId = bookmark.Id,
Input = input,
Properties = runWorkflowOptions?.Properties
};
response = await workflowClient.RunInstanceAsync(runRequest);
}
}
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
// Return the workflow state.
return await workflowClient.ExportStateAsync();
}
Configures Flowchart Execution via DI (#7141) * Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-15 09:15:39 +00:00
/// <summary>
/// Runs a workflow until its end, automatically resuming any bookmark it encounters.
/// </summary>
public async Task<WorkflowState> RunWorkflowUntilEndAsync<TWorkflow>(IDictionary<string, object>? input = null) where TWorkflow : IWorkflow
{
var workflowDefinitionId = typeof(TWorkflow).Name;
return await services.RunWorkflowUntilEndAsync(workflowDefinitionId, input);
}
}
}