elsa-core/src/samples/console/Elsa.Samples.ConsoleApp.Bookmarks/Program.cs
Sipke Schoorstra 683f0ee6d8
Add Bulk Dispatch Workflow activity (#4683)
* Initial version of BulkDispatchWorkflow

* Update comments

* Refactor options models for running workflows and add Properties

* Fix resumption

* Add ability to provide arguments when evaluating expressions

* Update args syntax for JS

* Fix ProtoActor Runtime Properties mapping

* Use default constructor

* Provide completed workflow instance ID as input to BulkDispatchWorkflows

* Implement ChildFaulted port

* Switch to Publish to make Memory service bus work

* Update input evaluation and activity output retrieval

Refined the input evaluation process to only consider inputs with AutoEvaluate set to true. Added a comment to clarify the purpose of the GetActivitiesWithOutputs method. Removed the unnecessary check for AutoEvaluate from the EvaluateInputPropertyAsync method.
2023-12-06 22:32:08 +01:00

41 lines
1.2 KiB
C#

using Elsa.Extensions;
using Elsa.Samples.ConsoleApp.Bookmarks.Activities;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Core.Options;
using Microsoft.Extensions.DependencyInjection;
// Setup service container.
var services = new ServiceCollection();
// Add Elsa services.
services.AddElsa();
// Build service container.
var serviceProvider = services.BuildServiceProvider();
// Resolve a workflow runner to run the workflow.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
// Create a workflow.
var workflow = new Workflow
{
Root = new Sequence
{
Activities =
{
new WriteLine("Hello World!"),
new MyEvent(), // Blocks until the event bookmark is resumed.
new WriteLine("Event received!")
}
}
};
// Run the workflow.
var result = await workflowRunner.RunAsync(workflow);
// Resume the workflow using te created bookmark.
var bookmark = result.WorkflowState.Bookmarks.Single();
var workflowState = result.WorkflowState;
await workflowRunner.RunAsync(workflow, workflowState, new RunWorkflowOptions { BookmarkId = bookmark.Id });