Remove old samples and initiate new samples

This commit is contained in:
Sipke Schoorstra 2022-11-10 14:40:37 +01:00
parent 274a2a0653
commit ecf5ff77cf
48 changed files with 194 additions and 809 deletions

View file

@ -6,8 +6,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{1552
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{C6658DE0-2B2F-47F0-BB61-2CA66D435C09}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Console1", "src\samples\console\Elsa.Samples.Console1\Elsa.Samples.Console1.csproj", "{B44A9DDA-8091-490A-BC0B-2EAE4A601B09}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7D21EB5E-D6B4-48A5-A9BC-A26387A65F0B}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
@ -26,8 +24,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnet", "aspnet", "{56C2FF
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Web1", "src\samples\aspnet\Elsa.Samples.Web1\Elsa.Samples.Web1.csproj", "{A2E6E9A4-4C21-4022-A53E-BDF5ED0D0678}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Console2", "src\samples\console\Elsa.Samples.Console2\Elsa.Samples.Console2.csproj", "{48960E35-903C-4EF0-A8F4-3871B000B12D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Web2", "src\samples\aspnet\Elsa.Samples.Web2\Elsa.Samples.Web2.csproj", "{13A6BAF1-9BAD-4A3A-A61F-5E4F01CDF0BF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}"
@ -64,8 +60,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bundles", "bundles", "{F06B
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa", "src\bundles\Elsa\Elsa.csproj", "{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Formatting", "src\common\Elsa.Formatting\Elsa.Formatting.csproj", "{60CEE728-3187-481B-B6EA-10D5284D8B55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ServiceBus.Abstractions", "src\common\Elsa.ServiceBus.Abstractions\Elsa.ServiceBus.Abstractions.csproj", "{448FCDE6-DE44-4E44-A1CC-B9AA51471121}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Liquid", "src\modules\Elsa.Liquid\Elsa.Liquid.csproj", "{8E5BD3D9-3529-48BC-B741-CFB7A69DB233}"
@ -108,32 +102,28 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Common", "src\modules\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.ProtoActor.Kubernetes", "src\modules\Elsa.ProtoActor.Kubernetes\Elsa.ProtoActor.Kubernetes.csproj", "{26087ED2-9249-4FF3-8869-C11C405E441A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.Console3", "src\samples\console\Elsa.Samples.Console3\Elsa.Samples.Console3.csproj", "{517B703A-7653-4036-AAB5-7B4293D39D0F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "worker", "worker", "{389D40B8-005F-46A1-9493-1FE6065F04FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFrameworkCore", "src\modules\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj", "{7CC95512-7F44-45C3-A669-95B7048D4730}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Persistence.EntityFrameworkCore.Sqlite", "src\modules\Elsa.Persistence.EntityFrameworkCore.Sqlite\Elsa.Persistence.EntityFrameworkCore.Sqlite.csproj", "{CAC22763-4A1C-4FC5-AC0D-6148927596D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.HelloWorld", "src\samples\console\Elsa.Samples.HelloWorld\Elsa.Samples.HelloWorld.csproj", "{D253AFC2-9496-4538-B424-47CC579B7A96}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.SequentialWorkflows", "src\samples\console\Elsa.Samples.SequentialWorkflows\Elsa.Samples.SequentialWorkflows.csproj", "{74B9AFE0-EB4B-4AD2-BF25-90753203EFF8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.ConditionalWorkflows", "src\samples\console\Elsa.Samples.ConditionalWorkflows\Elsa.Samples.ConditionalWorkflows.csproj", "{70D3ACE9-EB41-4B36-949C-08B8C22B99F7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B44A9DDA-8091-490A-BC0B-2EAE4A601B09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B44A9DDA-8091-490A-BC0B-2EAE4A601B09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B44A9DDA-8091-490A-BC0B-2EAE4A601B09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B44A9DDA-8091-490A-BC0B-2EAE4A601B09}.Release|Any CPU.Build.0 = Release|Any CPU
{A2E6E9A4-4C21-4022-A53E-BDF5ED0D0678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2E6E9A4-4C21-4022-A53E-BDF5ED0D0678}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2E6E9A4-4C21-4022-A53E-BDF5ED0D0678}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2E6E9A4-4C21-4022-A53E-BDF5ED0D0678}.Release|Any CPU.Build.0 = Release|Any CPU
{48960E35-903C-4EF0-A8F4-3871B000B12D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48960E35-903C-4EF0-A8F4-3871B000B12D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48960E35-903C-4EF0-A8F4-3871B000B12D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48960E35-903C-4EF0-A8F4-3871B000B12D}.Release|Any CPU.Build.0 = Release|Any CPU
{13A6BAF1-9BAD-4A3A-A61F-5E4F01CDF0BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13A6BAF1-9BAD-4A3A-A61F-5E4F01CDF0BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13A6BAF1-9BAD-4A3A-A61F-5E4F01CDF0BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -194,10 +184,6 @@ Global
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202}.Release|Any CPU.Build.0 = Release|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{60CEE728-3187-481B-B6EA-10D5284D8B55}.Release|Any CPU.Build.0 = Release|Any CPU
{448FCDE6-DE44-4E44-A1CC-B9AA51471121}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{448FCDE6-DE44-4E44-A1CC-B9AA51471121}.Debug|Any CPU.Build.0 = Debug|Any CPU
{448FCDE6-DE44-4E44-A1CC-B9AA51471121}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -282,10 +268,6 @@ Global
{26087ED2-9249-4FF3-8869-C11C405E441A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26087ED2-9249-4FF3-8869-C11C405E441A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26087ED2-9249-4FF3-8869-C11C405E441A}.Release|Any CPU.Build.0 = Release|Any CPU
{517B703A-7653-4036-AAB5-7B4293D39D0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{517B703A-7653-4036-AAB5-7B4293D39D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{517B703A-7653-4036-AAB5-7B4293D39D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{517B703A-7653-4036-AAB5-7B4293D39D0F}.Release|Any CPU.Build.0 = Release|Any CPU
{7CC95512-7F44-45C3-A669-95B7048D4730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CC95512-7F44-45C3-A669-95B7048D4730}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CC95512-7F44-45C3-A669-95B7048D4730}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -294,15 +276,25 @@ Global
{CAC22763-4A1C-4FC5-AC0D-6148927596D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAC22763-4A1C-4FC5-AC0D-6148927596D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAC22763-4A1C-4FC5-AC0D-6148927596D6}.Release|Any CPU.Build.0 = Release|Any CPU
{D253AFC2-9496-4538-B424-47CC579B7A96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D253AFC2-9496-4538-B424-47CC579B7A96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D253AFC2-9496-4538-B424-47CC579B7A96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D253AFC2-9496-4538-B424-47CC579B7A96}.Release|Any CPU.Build.0 = Release|Any CPU
{74B9AFE0-EB4B-4AD2-BF25-90753203EFF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74B9AFE0-EB4B-4AD2-BF25-90753203EFF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74B9AFE0-EB4B-4AD2-BF25-90753203EFF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74B9AFE0-EB4B-4AD2-BF25-90753203EFF8}.Release|Any CPU.Build.0 = Release|Any CPU
{70D3ACE9-EB41-4B36-949C-08B8C22B99F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70D3ACE9-EB41-4B36-949C-08B8C22B99F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70D3ACE9-EB41-4B36-949C-08B8C22B99F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70D3ACE9-EB41-4B36-949C-08B8C22B99F7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
{C6658DE0-2B2F-47F0-BB61-2CA66D435C09} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
{873BFC3E-63C2-4495-A503-5EC05DCD84E4} = {155227F0-A33B-40AA-A4B4-06F813EB921B}
{B44A9DDA-8091-490A-BC0B-2EAE4A601B09} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{56C2FFB8-EA54-45B5-A095-4A78142EB4B5} = {155227F0-A33B-40AA-A4B4-06F813EB921B}
{A2E6E9A4-4C21-4022-A53E-BDF5ED0D0678} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{48960E35-903C-4EF0-A8F4-3871B000B12D} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{13A6BAF1-9BAD-4A3A-A61F-5E4F01CDF0BF} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
{B066ED0A-86E0-4025-85C2-7E8F7139D8A4} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
@ -310,7 +302,6 @@ Global
{6B80C8AC-E9E7-43FD-B514-C0D801D15792} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
{177F4FF3-4618-4CB1-BA93-8B024BC64CD8} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{F06B9573-DF68-4606-866C-A7546A10A05A} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
{60CEE728-3187-481B-B6EA-10D5284D8B55} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{448FCDE6-DE44-4E44-A1CC-B9AA51471121} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
{B2049499-D384-46DF-8837-F1180107DD54} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{FC5D2CE9-FFB0-478D-8D54-E4109D1FD202} = {F06B9573-DF68-4606-866C-A7546A10A05A}
@ -341,10 +332,12 @@ Global
{81A2AE6B-3D0C-4A4A-A80B-7A661FBC8117} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{CF1938A0-BD10-4AA1-9ABC-6D02303A9D53} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{D229105F-6879-4452-9189-75DE060C0F4C} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{517B703A-7653-4036-AAB5-7B4293D39D0F} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{26087ED2-9249-4FF3-8869-C11C405E441A} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{7CC95512-7F44-45C3-A669-95B7048D4730} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{CAC22763-4A1C-4FC5-AC0D-6148927596D6} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{389D40B8-005F-46A1-9493-1FE6065F04FD} = {155227F0-A33B-40AA-A4B4-06F813EB921B}
{D253AFC2-9496-4538-B424-47CC579B7A96} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{74B9AFE0-EB4B-4AD2-BF25-90753203EFF8} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{70D3ACE9-EB41-4B36-949C-08B8C22B99F7} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
EndGlobalSection
EndGlobal

View file

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Description>
A small utility library for formatting objects from and to strings.
</Description>
<PackageTags>elsa, common</PackageTags>
</PropertyGroup>
</Project>

View file

@ -1,3 +0,0 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

View file

@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Elsa.AzureServiceBus.Models;
using Elsa.Common.Services;
using Elsa.Expressions.Models;
using Elsa.Formatting.Services;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Models;

View file

@ -1,6 +1,6 @@
using Azure.Messaging.ServiceBus;
using Elsa.Formatting.Formatters;
using Elsa.Formatting.Services;
using Elsa.Common.Implementations;
using Elsa.Common.Services;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Models;
using Microsoft.Extensions.Logging;

View file

@ -20,7 +20,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Formatting\Elsa.Formatting.csproj" />
<ProjectReference Include="..\Elsa.Mediator\Elsa.Mediator.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />

View file

@ -1,8 +1,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Elsa.Formatting.Services;
using Elsa.Common.Services;
namespace Elsa.Formatting.Formatters;
namespace Elsa.Common.Implementations;
public class JsonFormatter : IFormatter
{

View file

@ -1,7 +1,7 @@
namespace Elsa.Formatting.Services;
namespace Elsa.Common.Services;
/// <summary>
/// Represents a formatter that can serialize an object to a string and deserialize a string into an object.
/// Represents a formatter that can serialize an object to and from a string.
/// </summary>
public interface IFormatter
{

View file

@ -1,3 +1,5 @@
using Elsa.Expressions.Helpers;
namespace Elsa.Expressions.Models;
/// <summary>
@ -14,9 +16,9 @@ public abstract class MemoryBlockReference
public string Id { get; set; } = default!;
public abstract MemoryBlock Declare();
public object? Get(MemoryRegister memoryRegister) => GetBlock(memoryRegister).Value;
public T? Get<T>(MemoryRegister memoryRegister) => (T?)Get(memoryRegister);
public object? Get(ExpressionExecutionContext context) => context.Get(this);
public T? Get<T>(ExpressionExecutionContext context) => (T?)Get(context);
public T? Get<T>(MemoryRegister memoryRegister) => Get(memoryRegister).ConvertTo<T>();
public object Get(ExpressionExecutionContext context) => context.Get(this);
public T? Get<T>(ExpressionExecutionContext context) => Get(context).ConvertTo<T>();
public void Set(MemoryRegister memoryRegister, object? value) => GetBlock(memoryRegister).Value = value;
public void Set(ExpressionExecutionContext context, object? value) => context.Set(this, value);
public MemoryBlock GetBlock(MemoryRegister memoryRegister) => memoryRegister.TryGetBlock(Id, out var location) ? location : memoryRegister.Declare(this);

View file

@ -17,7 +17,7 @@ public class ReadLine : Activity<string>
{
}
public ReadLine(Output? output) : base(output)
public ReadLine(Output<string>? output) : base(output)
{
}

View file

@ -53,7 +53,7 @@ public abstract class Activity<T> : ActivityWithResult
{
}
protected Activity(Output? output) : base(output)
protected Activity(Output<T>? output) : base(output)
{
}
@ -62,10 +62,4 @@ public abstract class Activity<T> : ActivityWithResult
Result = new Output<T>(output);
return this;
}
public new Output<T>? Result
{
get => base.Result as Output<T>;
set => base.Result = value;
}
}

View file

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Elsa.Workflows.Core.Behaviors;
using Elsa.Workflows.Core.Helpers;
using Elsa.Workflows.Core.Services;

View file

@ -5,11 +5,10 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj"/>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,49 @@
using Elsa.Extensions;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
// Setup service container.
var services = new ServiceCollection();
// Add Elsa services.
services.AddElsa();
// Configure logging.
services.AddLogging(logging => logging.AddConsole().SetMinimumLevel(LogLevel.Debug));
// Build service container.
var serviceProvider = services.BuildServiceProvider();
// Declare a workflow variable for use in the workflow.
var ageVariable = new Variable<string>();
// Declare a workflow.
var workflow = new Sequence
{
// Register the variable.
Variables = { ageVariable },
// Setup the sequence of activities to run.
Activities =
{
new WriteLine("Please tell me your age:"),
new ReadLine(ageVariable), // Stores user input into the provided variable.,
new If
{
// If aged 18 or up, beer is provided, soda otherwise.
Condition = new Input<bool>(context => ageVariable.Get<int>(context) < 18),
Then = new WriteLine("Enjoy your soda!"),
Else = new WriteLine("Enjoy your beer!")
},
new WriteLine("Come again!")
}
};
// Resolve a workflow runner to run the workflow.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
// Run the workflow.
await workflowRunner.RunAsync(workflow);

View file

@ -0,0 +1,12 @@
# Conditional Workflows
Many workflows consist of conditional logic to determine which path of execution to take next.
One option to model such a workflow is the use of `If`
## If
The `If` activity provides a `Condition` property that can be set to a flavor of a **workflow expression**.
In addition, the activity provides a `Then` and `Else` property, to which we can assign an activity to execute.
When the condition evaluates to `true`, the `Then` activity is executed, otherwise the `Else` activity is executed.

View file

@ -1,24 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj"/>
<ProjectReference Include="..\..\..\modules\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj"/>
<ProjectReference Include="..\..\..\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj"/>
</ItemGroup>
</Project>

View file

@ -1,94 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Elsa.Extensions;
using Elsa.Samples.Console1.Workflows;
using Elsa.Workflows.Core.Middleware.Activities;
using Elsa.Workflows.Core.Middleware.Workflows;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
using Elsa.Workflows.Runtime.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Elsa.Samples.Console1;
class Program
{
static async Task Main()
{
var serviceProvider = CreateServices();
serviceProvider
// Configure activity execution pipeline.
.ConfigureDefaultActivityExecutionPipeline(pipeline => pipeline
.UseLogging()
.UseDefaultActivityInvoker()
)
// Configure workflow engine execution pipeline.
.ConfigureDefaultWorkflowExecutionPipeline(pipeline => pipeline
.UsePersistentVariables()
.UseDefaultActivityScheduler()
);
var workflow1 = new Func<IActivity>(HelloWorldWorkflow.Create);
var workflow2 = new Func<IActivity>(HelloGoodbyeWorkflow.Create);
var workflow3 = new Func<IActivity>(GreetingWorkflow.Create);
var workflow4 = new Func<IActivity>(ConditionalWorkflow.Create);
var workflow5 = new Func<IActivity>(ForWorkflow.Create);
var workflow6 = new Func<IActivity>(BlockingWorkflow.Create);
var workflow7 = new Func<IActivity>(ForkedWorkflow.Create);
var workflow8 = new Func<IActivity>(CustomizedActivityWorkflow.Create);
var workflow9 = new Func<IActivity>(VariablesWorkflow.Create);
var workflow10 = new Func<IActivity>(WhileWorkflow.Create);
var workflow11 = new Func<IActivity>(ForEachWorkflow.Create);
var workflow12 = new Func<IActivity>(ParallelForEachWorkflow.Create);
var workflow13 = new Func<IActivity>(BlockingParallelForEachWorkflow.Create);
var workflow14 = new Func<IActivity>(FlowchartWorkflow.Create);
var workflow15 = new Func<IActivity>(BreakForWorkflow.Create);
var workflowFactory = workflow1;
var workflowGraph = workflowFactory();
var workflow = Workflow.FromActivity(workflowGraph);
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
var workflowExecutionResult = await workflowRunner.RunAsync(workflow);
var workflowState = workflowExecutionResult.WorkflowState;
var bookmarks = new List<Bookmark>(workflowState.Bookmarks);
while (bookmarks.Any())
{
workflow.Root = workflowFactory();
foreach (var bookmark in bookmarks.ToList())
{
Console.WriteLine("Press enter to resume workflow with bookmark {0}.", new
{
bookmark.Id,
bookmark.Name,
bookmark.Hash,
bookmark.ActivityId,
bookmark.ActivityInstanceId,
bookmark.CallbackMethodName
});
Console.ReadLine();
var resumeResult = await workflowRunner.RunAsync(workflow, workflowState, bookmark.Id);
workflowState = resumeResult.WorkflowState;
bookmarks = workflowState.Bookmarks.ToList();
}
}
}
private static IServiceProvider CreateServices()
{
var services = new ServiceCollection();
services.AddElsa();
services.AddLogging(logging => logging.AddConsole().SetMinimumLevel(LogLevel.Warning));
return services.BuildServiceProvider();
}
}

View file

@ -1,38 +0,0 @@
using System.Collections.Generic;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class BlockingParallelForEachWorkflow
{
public static IActivity Create()
{
var items = new[] { "C#", "Rust", "Go" };
var currentItem = new Variable<string>();
return new Sequence
{
Activities =
{
new WriteLine("Programming languages in parallel:"),
new ParallelForEach<string>()
{
Items = new Input<ICollection<string>>(items),
CurrentValue = currentItem,
Body = new Sequence
{
Activities =
{
new WriteLine(context => $"Begin: {currentItem.Get(context)}"),
new Event(context => currentItem.Get(context)),
new WriteLine(context => $"Completed: {currentItem.Get(context)}")
}
}
},
new WriteLine("Done.")
}
};
}
}

View file

@ -1,16 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class BlockingWorkflow
{
public static IActivity Create()
{
return new Sequence(
new WriteLine("Waiting for event..."),
new Event("SomeEvent"), // Block here.
new WriteLine("Resumed!"),
new WriteLine("Done"));
}
}

View file

@ -1,50 +0,0 @@
using Elsa.Expressions.Models;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class BreakForWorkflow
{
public static IActivity Create()
{
var currentValue = new Variable<int?>();
var start = new Variable<int>(1);
var end = new Variable<int>(3);
return new Sequence
{
Variables = { start, end },
Activities =
{
new WriteLine(context => $"Counting numbers from {start.Get(context)} to {end.Get(context)}:"),
new For
{
Start = new Input<int>(start),
End = new Input<int>(end),
CurrentValue = new Output<MemoryBlockReference?>(currentValue),
Body = new Sequence
{
Activities =
{
new WriteLine(context => $"Current value: {currentValue.Get<int>(context)}"),
new If(context => currentValue.Get<int>(context) == 2)
{
Then = new Sequence
{
Activities =
{
new WriteLine("Breaking out of the loop!"),
new Break()
}
}
}
}
}
},
new WriteLine("End of workflow")
}
};
}
}

View file

@ -1,31 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class ConditionalWorkflow
{
public static IActivity Create()
{
var age = new Variable<int>();
return new Sequence
{
Variables = { age },
Activities =
{
new WriteLine("What's your age?"),
new ReadLine(age),
new If
{
Condition = new Input<bool>(context => age.Get(context) >= 16),
Then = new Sequence(
new WriteLine("Enjoy your driver's license!"),
new WriteLine("But be careful!")),
Else = new WriteLine("Enjoy your bicycle!")
}
}
};
}
}

View file

@ -1,16 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class CustomizedActivityWorkflow
{
public static IActivity Create() => new CustomWriteLine();
}
public class CustomWriteLine : WriteLine
{
public CustomWriteLine() : base("Hello Custom World!")
{
}
}

View file

@ -1,38 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Activities.Flowchart.Activities;
using Elsa.Workflows.Core.Activities.Flowchart.Models;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class FlowchartWorkflow
{
public static IActivity Create()
{
var age = new Variable<int>();
var flowchart = new Flowchart();
var step1 = new WriteLine("Please enter your age.");
var step2 = new ReadLine(age);
var step3 = new If
{
Condition = new Input<bool>(context => age.Get(context) > 16),
Then = new WriteLine("Enjoy your beer!"),
Else = new WriteLine("Enjoy your soda!")
};
var step4 = new WriteLine("Done");
var connection1 = new Connection(step1, step2, default, "Done");
var connection2 = new Connection(step2, step3, default, "Done");
var connection3 = new Connection(step3, step4, default, "Done");
flowchart.Start = step1;
flowchart.Activities.Add(step2);
flowchart.Activities.Add(step3);
flowchart.Activities.Add(step4);
flowchart.Connections.Add(connection1);
flowchart.Connections.Add(connection2);
flowchart.Connections.Add(connection3);
flowchart.Variables.Add(age);
return flowchart;
}
}

View file

@ -1,30 +0,0 @@
using System.Collections.Generic;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class ForEachWorkflow
{
public static IActivity Create()
{
var items = new[] { "C#", "Rust", "Go" };
var currentItem = new Variable<string>();
return new Sequence
{
Activities =
{
new WriteLine("Programming languages:"),
new ForEach<string>
{
Items = new Input<ICollection<string>>(items),
CurrentValue = new Output<string?>(currentItem),
Body = new WriteLine(context => currentItem.Get(context))
},
new WriteLine("Done.")
}
};
}
}

View file

@ -1,35 +0,0 @@
using Elsa.Expressions.Models;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class ForWorkflow
{
public static IActivity Create()
{
var currentValue = new Variable<int?>();
var start = new Variable<int>(1);
var end = new Variable<int>(3);
var for1 = new For
{
Start = new Input<int>(start),
End = new Input<int>(end),
CurrentValue = new Output<MemoryBlockReference?>(currentValue),
Body = new WriteLine(context => $"Current value: {currentValue.Get<int>(context)}")
};
return new Sequence
{
Variables = { start, end },
Activities =
{
new WriteLine(context => $"Counting numbers from {start.Get(context)} to {end.Get(context)}:"),
for1,
new WriteLine("End of workflow")
}
};
}
}

View file

@ -1,27 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class ForkedWorkflow
{
public static IActivity Create()
{
return new Sequence(
new WriteLine("Forking..."),
new Fork
{
JoinMode = JoinMode.WaitAll,
Branches =
{
new Sequence(
new WriteLine("Branch 1 (blocking)"),
new Event("Branch1"),
new WriteLine("Branch 1 (resumed)"),
new WriteLine("Done!")),
new WriteLine("Branch 2"),
new WriteLine("Branch 3")
}
});
}
}

View file

@ -1,24 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class GreetingWorkflow
{
public static IActivity Create()
{
var name = new Variable<string>();
return new Sequence
{
Variables = { name },
Activities =
{
new WriteLine("What's your name?"),
new ReadLine(name),
new WriteLine(context => $"Nice to meet you, {name.Get(context)}!")
}
};
}
}

View file

@ -1,13 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class HelloGoodbyeWorkflow
{
public static IActivity Create() =>
new Sequence(
new WriteLine("Hello World!"),
new WriteLine("Goodbye cruel world...")
);
}

View file

@ -1,9 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class HelloWorldWorkflow
{
public static IActivity Create() => new WriteLine("Hello World!") { Id = "WriteLine1" };
}

View file

@ -1,30 +0,0 @@
using System.Collections.Generic;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class ParallelForEachWorkflow
{
public static IActivity Create()
{
var items = new[] { "C#", "Rust", "Go" };
var currentItem = new Variable<string>();
return new Sequence
{
Activities =
{
new WriteLine("Programming languages in parallel:"),
new ParallelForEach<string>()
{
Items = new Input<ICollection<string>>(items),
CurrentValue = currentItem,
Body = new WriteLine(context => currentItem.Get(context))
},
new WriteLine("Done.")
}
};
}
}

View file

@ -1,26 +0,0 @@
using Elsa.Expressions.Models;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class VariablesWorkflow
{
public static IActivity Create()
{
var greeting = new Variable<string>("Hello! What is your name?");
var name = new Variable<string>();
return new Sequence
{
Variables = { greeting, name },
Activities =
{
new WriteLine(context => greeting.Get(context)),
new ReadLine(name),
new WriteLine(new DelegateBlockReference(context => $"Nice to meet you, {name.Get(context)}!")),
}
};
}
}

View file

@ -1,49 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console1.Workflows;
public static class WhileWorkflow
{
public static IActivity Create()
{
var counter = new Variable<int>();
var localVariable = new Variable<string>("Foo");
return new Sequence
{
Variables = { counter },
Activities =
{
new WriteLine("Looping..."),
new While
{
Condition = new Input<bool>(context => counter.Get(context) < 3),
Body = new Sequence
{
Variables = { localVariable },
Activities =
{
new WriteLine(context => $"Iteration {counter.Get(context) + 1}"),
new WriteLine(context => $"Local variable: {localVariable.Get(context)}"),
new SetVariable<string>
{
Variable = localVariable,
Value = new Input<string>("Bar")
},
new WriteLine(context => $"Updated local variable: {localVariable.Get(context)}"),
new SetVariable<int>
{
Variable = counter,
Value = new Input<int>(context => counter.Get(context) + 1)
},
new Event("Foo")
}
}
},
new WriteLine("Done.")
}
};
}
}

View file

@ -1 +0,0 @@
WriteLine { Text:"Hello World!" };

View file

@ -1 +0,0 @@
print("Hello World");

View file

@ -1,9 +0,0 @@
let readLine1 = ReadLine;
Sequence {
Activities: [
WriteLine { Text: "Please enter your name" },
readLine1,
WriteLine { Text: js => `Hello ${readLine}` } // TODO: Enable workflow variables.
]
};

View file

@ -1,3 +0,0 @@
print("Please enter your name");
variable name = read();
print(js => `Hello ${name}`);

View file

@ -1,16 +0,0 @@
// Print a message.
print("What's your age?");
// Declare a workflow variable and assign the result of the ReadLine activity.
variable age = ReadLine; // Could also use the mapped function called `read()`.
// The `if` keyword is mapped to the If activity. The condition requires a JavaScript expression.
if age >= 18 then
{
print("Enjoy your driver's license!");
print("But be careful!");
}
else
print("Enjoy your bicycle!");
print("Goodbye.");

View file

@ -1,35 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0"/>
</ItemGroup>
<ItemGroup>
<None Remove="Sample1.elsa"/>
<EmbeddedResource Include="Demo1.elsa"/>
<EmbeddedResource Include="Demo3a.elsa"/>
<EmbeddedResource Include="Demo2.elsa"/>
<EmbeddedResource Include="Demo3b.elsa"/>
<EmbeddedResource Include="Demo4.elsa"/>
<EmbeddedResource Include="Sample1.elsa"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj"/>
<ProjectReference Include="..\..\..\modules\Elsa.Dsl\Elsa.Dsl.csproj"/>
<ProjectReference Include="..\..\..\modules\Elsa.Http\Elsa.Http.csproj"/>
<ProjectReference Include="..\..\..\modules\Elsa.Scheduling\Elsa.Scheduling.csproj"/>
</ItemGroup>
</Project>

View file

@ -1,57 +0,0 @@
using System;
using System.IO;
using System.Reflection;
using Elsa.Dsl.Extensions;
using Elsa.Dsl.Services;
using Elsa.Extensions;
using Elsa.Http;
using Elsa.Scheduling.Activities;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
var serviceProvider = CreateServices();
var typeSystem = serviceProvider.GetRequiredService<ITypeSystem>();
var dslEngine = serviceProvider.GetRequiredService<IDslEngine>();
var functionActivityRegistry = serviceProvider.GetRequiredService<IFunctionActivityRegistry>();
// Map .NET types to Elsa DSL. Optionally using an alias.
typeSystem.Register<int>("int");
typeSystem.Register<float>("float");
typeSystem.Register<string>("string");
typeSystem.Register("Variable<>", typeof(Variable<>));
typeSystem.Register<Sequence>();
typeSystem.Register<ReadLine>();
typeSystem.Register<WriteLine>();
typeSystem.Register<HttpEndpoint>();
typeSystem.Register<Timer>();
// Map functions to activities.
functionActivityRegistry.RegisterFunction("print", nameof(WriteLine), new[] { nameof(WriteLine.Text) });
functionActivityRegistry.RegisterFunction("read", nameof(ReadLine), new[] { nameof(ReadLine.Result) });
var assembly = Assembly.GetExecutingAssembly();
// Read text file containing Elsa DSL.
var scriptName = "Demo4";
var resource = assembly.GetManifestResourceStream($"Elsa.Samples.Console2.{scriptName}.elsa");
var script = await new StreamReader(resource!).ReadToEndAsync();
// Evaluate the DSL. The result will be an executable workflow definition.
var workflowDefinition = dslEngine.Parse(script);
// Run the workflow.
var workflowEngine = serviceProvider.GetRequiredService<IWorkflowRunner>();
await workflowEngine.RunAsync(workflowDefinition);
IServiceProvider CreateServices()
{
var services = new ServiceCollection();
services.AddElsa(elsa => elsa.UseDsl());
services.AddLogging(logging => logging.AddConsole().SetMinimumLevel(LogLevel.Warning));
return services.BuildServiceProvider();
}

View file

@ -1,14 +0,0 @@
print("What's your age?");
variable age = ReadLine;
if age > 16 then
{
print("Enjoy your driver's license!");
// delay(5000);
// await signal
print("But be careful!");
}
else
print("Enjoy your bicycle!");
print("Goodbye.");

View file

@ -1,34 +0,0 @@
using Elsa.Extensions;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Core.Services;
using Microsoft.Extensions.DependencyInjection;
// Setup a service container from which we can resolve Elsa services.
var services = new ServiceCollection();
// Add Elsa services to the service collection.
services.AddElsa();
// Build a service provider.
var serviceProvider = services.BuildServiceProvider();
// Resolve a workflow runner.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
// Define a workflow.
//var workflow = new WriteLine("Hello World!");
var workflow = new Workflow
{
Root = new Sequence
{
Activities =
{
new WriteLine("Hello World!"),
new WriteLine("Goodbye cruel world..."),
}
}
};
// Execute the workflow.
workflowRunner.RunAsync(workflow);

View file

@ -1,19 +0,0 @@
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
namespace Elsa.Samples.Console3.Workflows;
public class HelloWorld : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
builder.Root = new Sequence
{
Activities =
{
new WriteLine("Hello World!"),
new WriteLine("Goodbye cruel world...")
}
};
}
}

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,26 @@
using Elsa.Extensions;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
// Setup service container.
var services = new ServiceCollection();
// Add Elsa services.
services.AddElsa();
// Configure logging.
services.AddLogging(logging => logging.AddConsole().SetMinimumLevel(LogLevel.Debug));
// Build service container.
var serviceProvider = services.BuildServiceProvider();
// Create a workflow.
var workflow = new WriteLine("Hello World!");
// Resolve a workflow runner to run the workflow.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
// Run the workflow.
await workflowRunner.RunAsync(workflow);

View file

@ -0,0 +1,3 @@
# Hello World
This console application demonstrates the minimum code necessary to run a workflow, which is represented as a single `WriteLine` activity.

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,33 @@
using Elsa.Extensions;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
// Setup service container.
var services = new ServiceCollection();
// Add Elsa services.
services.AddElsa();
// Configure logging.
services.AddLogging(logging => logging.AddConsole().SetMinimumLevel(LogLevel.Debug));
// Build service container.
var serviceProvider = services.BuildServiceProvider();
// Create a workflow.
var workflow = new Sequence
{
Activities =
{
new WriteLine("Hello World!"),
new WriteLine("Goodbye cruel world...")
}
};
// Resolve a workflow runner to run the workflow.
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
// Run the workflow.
await workflowRunner.RunAsync(workflow);

View file

@ -0,0 +1,7 @@
# Sequential Workflows
A typical workflow consists of two or more steps. One way to model such a workflow is to use `Sequence`.
## Sequence
The `Sequence` activity can contain a collection of child activities to execute one by one.