elsa-core/src/samples/console/Elsa.Samples.ConsoleApp.Bookmarks/Program.cs
Sipke Schoorstra 89f94a2261
File Uploads (#4457)
* Initial support for receiving files via HTTP Endpoint activity

* Implement HTTP endpoint request timeout

* Implement request time out handling

* Implement request size validation

* Formatting

* Implement application and system level cancellation tokens

* Create CancellationTokens struct

* Cleanup HttpEndpoint

* Implement file size validation

* Implement file extension validation

* Implement mime type validation

* Update usages of cancellation tokens
2023-09-19 22:42:53 +02:00

43 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));