From ecf5ff77cf8f1a7704224ccca51db6fc1b058bca Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 10 Nov 2022 14:40:37 +0100 Subject: [PATCH] Remove old samples and initiate new samples --- Elsa.sln | 49 +++++----- .../Elsa.Formatting/Elsa.Formatting.csproj | 14 --- src/common/Elsa.Formatting/FodyWeavers.xml | 3 - .../Activities/MessageReceived.cs | 2 +- .../Activities/SendMessage.cs | 4 +- .../Elsa.AzureServiceBus.csproj | 1 - .../Implementations}/JsonFormatter.cs | 4 +- .../Elsa.Common}/Services/IFormatter.cs | 4 +- .../Models/MemoryBlockReference.cs | 8 +- .../Activities/ReadLine.cs | 2 +- .../Elsa.Workflows.Core/Models/Activity.cs | 8 +- .../Models/ActivityBase.cs | 4 - .../Elsa.Samples.ConditionalWorkflows.csproj} | 3 +- .../Program.cs | 49 ++++++++++ .../Readme.md | 12 +++ .../Elsa.Samples.Console1.csproj | 24 ----- .../console/Elsa.Samples.Console1/Program.cs | 94 ------------------- .../BlockingParallelForEachWorkflow.cs | 38 -------- .../Workflows/BlockingWorkflow.cs | 16 ---- .../Workflows/BreakForWorkflow.cs | 50 ---------- .../Workflows/ConditionalWorkflow.cs | 31 ------ .../Workflows/CustomizedActivityWorkflow.cs | 16 ---- .../Workflows/FlowchartWorkflow.cs | 38 -------- .../Workflows/ForEachWorkflow.cs | 30 ------ .../Workflows/ForWorkflow.cs | 35 ------- .../Workflows/ForkedWorkflow.cs | 27 ------ .../Workflows/GreetingWorkflow.cs | 24 ----- .../Workflows/HelloGoodbyeWorkflow.cs | 13 --- .../Workflows/HelloWorldWorkflow.cs | 9 -- .../Workflows/ParallelForEachWorkflow.cs | 30 ------ .../Workflows/VariablesWorkflow.cs | 26 ----- .../Workflows/WhileWorkflow.cs | 49 ---------- .../console/Elsa.Samples.Console2/Demo1.elsa | 1 - .../console/Elsa.Samples.Console2/Demo2.elsa | 1 - .../console/Elsa.Samples.Console2/Demo3a.elsa | 9 -- .../console/Elsa.Samples.Console2/Demo3b.elsa | 3 - .../console/Elsa.Samples.Console2/Demo4.elsa | 16 ---- .../Elsa.Samples.Console2.csproj | 35 ------- .../console/Elsa.Samples.Console2/Program.cs | 57 ----------- .../Elsa.Samples.Console2/Sample1.elsa | 14 --- .../console/Elsa.Samples.Console3/Program.cs | 34 ------- .../Workflows/HelloWorld.cs | 19 ---- .../Elsa.Samples.HelloWorld.csproj | 14 +++ .../Elsa.Samples.HelloWorld/Program.cs | 26 +++++ .../console/Elsa.Samples.HelloWorld/Readme.md | 3 + .../Elsa.Samples.SequentialWorkflows.csproj | 14 +++ .../Program.cs | 33 +++++++ .../Readme.md | 7 ++ 48 files changed, 194 insertions(+), 809 deletions(-) delete mode 100644 src/common/Elsa.Formatting/Elsa.Formatting.csproj delete mode 100644 src/common/Elsa.Formatting/FodyWeavers.xml rename src/{common/Elsa.Formatting/Formatters => modules/Elsa.Common/Implementations}/JsonFormatter.cs (91%) rename src/{common/Elsa.Formatting => modules/Elsa.Common}/Services/IFormatter.cs (65%) rename src/samples/console/{Elsa.Samples.Console3/Elsa.Samples.Console3.csproj => Elsa.Samples.ConditionalWorkflows/Elsa.Samples.ConditionalWorkflows.csproj} (88%) create mode 100644 src/samples/console/Elsa.Samples.ConditionalWorkflows/Program.cs create mode 100644 src/samples/console/Elsa.Samples.ConditionalWorkflows/Readme.md delete mode 100644 src/samples/console/Elsa.Samples.Console1/Elsa.Samples.Console1.csproj delete mode 100644 src/samples/console/Elsa.Samples.Console1/Program.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/BlockingParallelForEachWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/BlockingWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/BreakForWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/ConditionalWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/CustomizedActivityWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/FlowchartWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/ForEachWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/ForWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/ForkedWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/GreetingWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/HelloGoodbyeWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/HelloWorldWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/ParallelForEachWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/VariablesWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console1/Workflows/WhileWorkflow.cs delete mode 100644 src/samples/console/Elsa.Samples.Console2/Demo1.elsa delete mode 100644 src/samples/console/Elsa.Samples.Console2/Demo2.elsa delete mode 100644 src/samples/console/Elsa.Samples.Console2/Demo3a.elsa delete mode 100644 src/samples/console/Elsa.Samples.Console2/Demo3b.elsa delete mode 100644 src/samples/console/Elsa.Samples.Console2/Demo4.elsa delete mode 100644 src/samples/console/Elsa.Samples.Console2/Elsa.Samples.Console2.csproj delete mode 100644 src/samples/console/Elsa.Samples.Console2/Program.cs delete mode 100644 src/samples/console/Elsa.Samples.Console2/Sample1.elsa delete mode 100644 src/samples/console/Elsa.Samples.Console3/Program.cs delete mode 100644 src/samples/console/Elsa.Samples.Console3/Workflows/HelloWorld.cs create mode 100644 src/samples/console/Elsa.Samples.HelloWorld/Elsa.Samples.HelloWorld.csproj create mode 100644 src/samples/console/Elsa.Samples.HelloWorld/Program.cs create mode 100644 src/samples/console/Elsa.Samples.HelloWorld/Readme.md create mode 100644 src/samples/console/Elsa.Samples.SequentialWorkflows/Elsa.Samples.SequentialWorkflows.csproj create mode 100644 src/samples/console/Elsa.Samples.SequentialWorkflows/Program.cs create mode 100644 src/samples/console/Elsa.Samples.SequentialWorkflows/Readme.md diff --git a/Elsa.sln b/Elsa.sln index bc679f394..d55a3f49e 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -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 diff --git a/src/common/Elsa.Formatting/Elsa.Formatting.csproj b/src/common/Elsa.Formatting/Elsa.Formatting.csproj deleted file mode 100644 index ca6d7ad9c..000000000 --- a/src/common/Elsa.Formatting/Elsa.Formatting.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - net6.0 - - A small utility library for formatting objects from and to strings. - - elsa, common - - - diff --git a/src/common/Elsa.Formatting/FodyWeavers.xml b/src/common/Elsa.Formatting/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c..000000000 --- a/src/common/Elsa.Formatting/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.AzureServiceBus/Activities/MessageReceived.cs b/src/modules/Elsa.AzureServiceBus/Activities/MessageReceived.cs index 21905c0cc..f513a6d5a 100644 --- a/src/modules/Elsa.AzureServiceBus/Activities/MessageReceived.cs +++ b/src/modules/Elsa.AzureServiceBus/Activities/MessageReceived.cs @@ -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; diff --git a/src/modules/Elsa.AzureServiceBus/Activities/SendMessage.cs b/src/modules/Elsa.AzureServiceBus/Activities/SendMessage.cs index 1f89bdb1c..7891a9e50 100644 --- a/src/modules/Elsa.AzureServiceBus/Activities/SendMessage.cs +++ b/src/modules/Elsa.AzureServiceBus/Activities/SendMessage.cs @@ -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; diff --git a/src/modules/Elsa.AzureServiceBus/Elsa.AzureServiceBus.csproj b/src/modules/Elsa.AzureServiceBus/Elsa.AzureServiceBus.csproj index d20e5f516..a9df4ffda 100644 --- a/src/modules/Elsa.AzureServiceBus/Elsa.AzureServiceBus.csproj +++ b/src/modules/Elsa.AzureServiceBus/Elsa.AzureServiceBus.csproj @@ -20,7 +20,6 @@ - diff --git a/src/common/Elsa.Formatting/Formatters/JsonFormatter.cs b/src/modules/Elsa.Common/Implementations/JsonFormatter.cs similarity index 91% rename from src/common/Elsa.Formatting/Formatters/JsonFormatter.cs rename to src/modules/Elsa.Common/Implementations/JsonFormatter.cs index 9770cdb4b..e248540ff 100644 --- a/src/common/Elsa.Formatting/Formatters/JsonFormatter.cs +++ b/src/modules/Elsa.Common/Implementations/JsonFormatter.cs @@ -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 { diff --git a/src/common/Elsa.Formatting/Services/IFormatter.cs b/src/modules/Elsa.Common/Services/IFormatter.cs similarity index 65% rename from src/common/Elsa.Formatting/Services/IFormatter.cs rename to src/modules/Elsa.Common/Services/IFormatter.cs index b9279ad85..e309adfc8 100644 --- a/src/common/Elsa.Formatting/Services/IFormatter.cs +++ b/src/modules/Elsa.Common/Services/IFormatter.cs @@ -1,7 +1,7 @@ -namespace Elsa.Formatting.Services; +namespace Elsa.Common.Services; /// -/// 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. /// public interface IFormatter { diff --git a/src/modules/Elsa.Expressions/Models/MemoryBlockReference.cs b/src/modules/Elsa.Expressions/Models/MemoryBlockReference.cs index aa7eae860..16e665a71 100644 --- a/src/modules/Elsa.Expressions/Models/MemoryBlockReference.cs +++ b/src/modules/Elsa.Expressions/Models/MemoryBlockReference.cs @@ -1,3 +1,5 @@ +using Elsa.Expressions.Helpers; + namespace Elsa.Expressions.Models; /// @@ -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(MemoryRegister memoryRegister) => (T?)Get(memoryRegister); - public object? Get(ExpressionExecutionContext context) => context.Get(this); - public T? Get(ExpressionExecutionContext context) => (T?)Get(context); + public T? Get(MemoryRegister memoryRegister) => Get(memoryRegister).ConvertTo(); + public object Get(ExpressionExecutionContext context) => context.Get(this); + public T? Get(ExpressionExecutionContext context) => Get(context).ConvertTo(); 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); diff --git a/src/modules/Elsa.Workflows.Core/Activities/ReadLine.cs b/src/modules/Elsa.Workflows.Core/Activities/ReadLine.cs index 087dbd0e6..e9ccbf7b9 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/ReadLine.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/ReadLine.cs @@ -17,7 +17,7 @@ public class ReadLine : Activity { } - public ReadLine(Output? output) : base(output) + public ReadLine(Output? output) : base(output) { } diff --git a/src/modules/Elsa.Workflows.Core/Models/Activity.cs b/src/modules/Elsa.Workflows.Core/Models/Activity.cs index b3840b13b..d676ab9fb 100644 --- a/src/modules/Elsa.Workflows.Core/Models/Activity.cs +++ b/src/modules/Elsa.Workflows.Core/Models/Activity.cs @@ -53,7 +53,7 @@ public abstract class Activity : ActivityWithResult { } - protected Activity(Output? output) : base(output) + protected Activity(Output? output) : base(output) { } @@ -62,10 +62,4 @@ public abstract class Activity : ActivityWithResult Result = new Output(output); return this; } - - public new Output? Result - { - get => base.Result as Output; - set => base.Result = value; - } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Models/ActivityBase.cs b/src/modules/Elsa.Workflows.Core/Models/ActivityBase.cs index d470fdc47..ac15bfd58 100644 --- a/src/modules/Elsa.Workflows.Core/Models/ActivityBase.cs +++ b/src/modules/Elsa.Workflows.Core/Models/ActivityBase.cs @@ -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; diff --git a/src/samples/console/Elsa.Samples.Console3/Elsa.Samples.Console3.csproj b/src/samples/console/Elsa.Samples.ConditionalWorkflows/Elsa.Samples.ConditionalWorkflows.csproj similarity index 88% rename from src/samples/console/Elsa.Samples.Console3/Elsa.Samples.Console3.csproj rename to src/samples/console/Elsa.Samples.ConditionalWorkflows/Elsa.Samples.ConditionalWorkflows.csproj index 2e853c40e..5157abaca 100644 --- a/src/samples/console/Elsa.Samples.Console3/Elsa.Samples.Console3.csproj +++ b/src/samples/console/Elsa.Samples.ConditionalWorkflows/Elsa.Samples.ConditionalWorkflows.csproj @@ -5,11 +5,10 @@ net6.0 enable enable - false - + diff --git a/src/samples/console/Elsa.Samples.ConditionalWorkflows/Program.cs b/src/samples/console/Elsa.Samples.ConditionalWorkflows/Program.cs new file mode 100644 index 000000000..656811fb6 --- /dev/null +++ b/src/samples/console/Elsa.Samples.ConditionalWorkflows/Program.cs @@ -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(); + +// 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(context => ageVariable.Get(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(); + +// Run the workflow. +await workflowRunner.RunAsync(workflow); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.ConditionalWorkflows/Readme.md b/src/samples/console/Elsa.Samples.ConditionalWorkflows/Readme.md new file mode 100644 index 000000000..7f092fdbc --- /dev/null +++ b/src/samples/console/Elsa.Samples.ConditionalWorkflows/Readme.md @@ -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. + diff --git a/src/samples/console/Elsa.Samples.Console1/Elsa.Samples.Console1.csproj b/src/samples/console/Elsa.Samples.Console1/Elsa.Samples.Console1.csproj deleted file mode 100644 index e7c4a2f82..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Elsa.Samples.Console1.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net6.0 - enable - false - - - - - - - - - - - - - - - - - diff --git a/src/samples/console/Elsa.Samples.Console1/Program.cs b/src/samples/console/Elsa.Samples.Console1/Program.cs deleted file mode 100644 index 250664b3a..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Program.cs +++ /dev/null @@ -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(HelloWorldWorkflow.Create); - var workflow2 = new Func(HelloGoodbyeWorkflow.Create); - var workflow3 = new Func(GreetingWorkflow.Create); - var workflow4 = new Func(ConditionalWorkflow.Create); - var workflow5 = new Func(ForWorkflow.Create); - var workflow6 = new Func(BlockingWorkflow.Create); - var workflow7 = new Func(ForkedWorkflow.Create); - var workflow8 = new Func(CustomizedActivityWorkflow.Create); - var workflow9 = new Func(VariablesWorkflow.Create); - var workflow10 = new Func(WhileWorkflow.Create); - var workflow11 = new Func(ForEachWorkflow.Create); - var workflow12 = new Func(ParallelForEachWorkflow.Create); - var workflow13 = new Func(BlockingParallelForEachWorkflow.Create); - var workflow14 = new Func(FlowchartWorkflow.Create); - var workflow15 = new Func(BreakForWorkflow.Create); - - var workflowFactory = workflow1; - var workflowGraph = workflowFactory(); - var workflow = Workflow.FromActivity(workflowGraph); - - var workflowRunner = serviceProvider.GetRequiredService(); - var workflowExecutionResult = await workflowRunner.RunAsync(workflow); - var workflowState = workflowExecutionResult.WorkflowState; - var bookmarks = new List(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(); - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/BlockingParallelForEachWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/BlockingParallelForEachWorkflow.cs deleted file mode 100644 index 19c1e6133..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/BlockingParallelForEachWorkflow.cs +++ /dev/null @@ -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(); - - return new Sequence - { - Activities = - { - new WriteLine("Programming languages in parallel:"), - new ParallelForEach() - { - Items = new Input>(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.") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/BlockingWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/BlockingWorkflow.cs deleted file mode 100644 index 8fdc81380..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/BlockingWorkflow.cs +++ /dev/null @@ -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")); - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/BreakForWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/BreakForWorkflow.cs deleted file mode 100644 index 14cb4e5ed..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/BreakForWorkflow.cs +++ /dev/null @@ -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(); - var start = new Variable(1); - var end = new Variable(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(start), - End = new Input(end), - CurrentValue = new Output(currentValue), - Body = new Sequence - { - Activities = - { - new WriteLine(context => $"Current value: {currentValue.Get(context)}"), - new If(context => currentValue.Get(context) == 2) - { - Then = new Sequence - { - Activities = - { - new WriteLine("Breaking out of the loop!"), - new Break() - } - } - } - } - } - }, - new WriteLine("End of workflow") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/ConditionalWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/ConditionalWorkflow.cs deleted file mode 100644 index 580ae7276..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/ConditionalWorkflow.cs +++ /dev/null @@ -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(); - - return new Sequence - { - Variables = { age }, - Activities = - { - new WriteLine("What's your age?"), - new ReadLine(age), - new If - { - Condition = new Input(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!") - } - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/CustomizedActivityWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/CustomizedActivityWorkflow.cs deleted file mode 100644 index f83ce7d28..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/CustomizedActivityWorkflow.cs +++ /dev/null @@ -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!") - { - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/FlowchartWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/FlowchartWorkflow.cs deleted file mode 100644 index eb989fb0b..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/FlowchartWorkflow.cs +++ /dev/null @@ -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(); - var flowchart = new Flowchart(); - var step1 = new WriteLine("Please enter your age."); - var step2 = new ReadLine(age); - var step3 = new If - { - Condition = new Input(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; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/ForEachWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/ForEachWorkflow.cs deleted file mode 100644 index 05e037189..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/ForEachWorkflow.cs +++ /dev/null @@ -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(); - - return new Sequence - { - Activities = - { - new WriteLine("Programming languages:"), - new ForEach - { - Items = new Input>(items), - CurrentValue = new Output(currentItem), - Body = new WriteLine(context => currentItem.Get(context)) - }, - new WriteLine("Done.") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/ForWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/ForWorkflow.cs deleted file mode 100644 index d738f09eb..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/ForWorkflow.cs +++ /dev/null @@ -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(); - var start = new Variable(1); - var end = new Variable(3); - - var for1 = new For - { - Start = new Input(start), - End = new Input(end), - CurrentValue = new Output(currentValue), - Body = new WriteLine(context => $"Current value: {currentValue.Get(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") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/ForkedWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/ForkedWorkflow.cs deleted file mode 100644 index 6b365b2c3..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/ForkedWorkflow.cs +++ /dev/null @@ -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") - } - }); - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/GreetingWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/GreetingWorkflow.cs deleted file mode 100644 index 6b15b7c7a..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/GreetingWorkflow.cs +++ /dev/null @@ -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(); - - 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)}!") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/HelloGoodbyeWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/HelloGoodbyeWorkflow.cs deleted file mode 100644 index 0c4a5873f..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/HelloGoodbyeWorkflow.cs +++ /dev/null @@ -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...") - ); -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/HelloWorldWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/HelloWorldWorkflow.cs deleted file mode 100644 index f4ae95cda..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/HelloWorldWorkflow.cs +++ /dev/null @@ -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" }; -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/ParallelForEachWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/ParallelForEachWorkflow.cs deleted file mode 100644 index 011cb1fb6..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/ParallelForEachWorkflow.cs +++ /dev/null @@ -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(); - - return new Sequence - { - Activities = - { - new WriteLine("Programming languages in parallel:"), - new ParallelForEach() - { - Items = new Input>(items), - CurrentValue = currentItem, - Body = new WriteLine(context => currentItem.Get(context)) - }, - new WriteLine("Done.") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/VariablesWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/VariablesWorkflow.cs deleted file mode 100644 index a9fc5b042..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/VariablesWorkflow.cs +++ /dev/null @@ -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("Hello! What is your name?"); - var name = new Variable(); - - 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)}!")), - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console1/Workflows/WhileWorkflow.cs b/src/samples/console/Elsa.Samples.Console1/Workflows/WhileWorkflow.cs deleted file mode 100644 index c702d5524..000000000 --- a/src/samples/console/Elsa.Samples.Console1/Workflows/WhileWorkflow.cs +++ /dev/null @@ -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(); - var localVariable = new Variable("Foo"); - - return new Sequence - { - Variables = { counter }, - Activities = - { - new WriteLine("Looping..."), - new While - { - Condition = new Input(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 - { - Variable = localVariable, - Value = new Input("Bar") - }, - new WriteLine(context => $"Updated local variable: {localVariable.Get(context)}"), - new SetVariable - { - Variable = counter, - Value = new Input(context => counter.Get(context) + 1) - }, - new Event("Foo") - } - } - }, - new WriteLine("Done.") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console2/Demo1.elsa b/src/samples/console/Elsa.Samples.Console2/Demo1.elsa deleted file mode 100644 index f5199fa85..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Demo1.elsa +++ /dev/null @@ -1 +0,0 @@ -WriteLine { Text:"Hello World!" }; \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console2/Demo2.elsa b/src/samples/console/Elsa.Samples.Console2/Demo2.elsa deleted file mode 100644 index dfe80e8de..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Demo2.elsa +++ /dev/null @@ -1 +0,0 @@ -print("Hello World"); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console2/Demo3a.elsa b/src/samples/console/Elsa.Samples.Console2/Demo3a.elsa deleted file mode 100644 index feb6762f4..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Demo3a.elsa +++ /dev/null @@ -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. - ] -}; \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console2/Demo3b.elsa b/src/samples/console/Elsa.Samples.Console2/Demo3b.elsa deleted file mode 100644 index 89c94dbf4..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Demo3b.elsa +++ /dev/null @@ -1,3 +0,0 @@ -print("Please enter your name"); -variable name = read(); -print(js => `Hello ${name}`); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console2/Demo4.elsa b/src/samples/console/Elsa.Samples.Console2/Demo4.elsa deleted file mode 100644 index 906ab524e..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Demo4.elsa +++ /dev/null @@ -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."); diff --git a/src/samples/console/Elsa.Samples.Console2/Elsa.Samples.Console2.csproj b/src/samples/console/Elsa.Samples.Console2/Elsa.Samples.Console2.csproj deleted file mode 100644 index 43b80c130..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Elsa.Samples.Console2.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - Exe - net6.0 - enable - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/samples/console/Elsa.Samples.Console2/Program.cs b/src/samples/console/Elsa.Samples.Console2/Program.cs deleted file mode 100644 index fbd03ad35..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Program.cs +++ /dev/null @@ -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(); -var dslEngine = serviceProvider.GetRequiredService(); -var functionActivityRegistry = serviceProvider.GetRequiredService(); - -// Map .NET types to Elsa DSL. Optionally using an alias. -typeSystem.Register("int"); -typeSystem.Register("float"); -typeSystem.Register("string"); -typeSystem.Register("Variable<>", typeof(Variable<>)); -typeSystem.Register(); -typeSystem.Register(); -typeSystem.Register(); -typeSystem.Register(); -typeSystem.Register(); - -// 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(); -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(); -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console2/Sample1.elsa b/src/samples/console/Elsa.Samples.Console2/Sample1.elsa deleted file mode 100644 index 81b12c0b9..000000000 --- a/src/samples/console/Elsa.Samples.Console2/Sample1.elsa +++ /dev/null @@ -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."); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console3/Program.cs b/src/samples/console/Elsa.Samples.Console3/Program.cs deleted file mode 100644 index cdb25674a..000000000 --- a/src/samples/console/Elsa.Samples.Console3/Program.cs +++ /dev/null @@ -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(); - -// 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); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.Console3/Workflows/HelloWorld.cs b/src/samples/console/Elsa.Samples.Console3/Workflows/HelloWorld.cs deleted file mode 100644 index cebdb7903..000000000 --- a/src/samples/console/Elsa.Samples.Console3/Workflows/HelloWorld.cs +++ /dev/null @@ -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...") - } - }; - } -} \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.HelloWorld/Elsa.Samples.HelloWorld.csproj b/src/samples/console/Elsa.Samples.HelloWorld/Elsa.Samples.HelloWorld.csproj new file mode 100644 index 000000000..339111a54 --- /dev/null +++ b/src/samples/console/Elsa.Samples.HelloWorld/Elsa.Samples.HelloWorld.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/src/samples/console/Elsa.Samples.HelloWorld/Program.cs b/src/samples/console/Elsa.Samples.HelloWorld/Program.cs new file mode 100644 index 000000000..70299da10 --- /dev/null +++ b/src/samples/console/Elsa.Samples.HelloWorld/Program.cs @@ -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(); + +// Run the workflow. +await workflowRunner.RunAsync(workflow); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.HelloWorld/Readme.md b/src/samples/console/Elsa.Samples.HelloWorld/Readme.md new file mode 100644 index 000000000..06f451aa7 --- /dev/null +++ b/src/samples/console/Elsa.Samples.HelloWorld/Readme.md @@ -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. \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.SequentialWorkflows/Elsa.Samples.SequentialWorkflows.csproj b/src/samples/console/Elsa.Samples.SequentialWorkflows/Elsa.Samples.SequentialWorkflows.csproj new file mode 100644 index 000000000..5157abaca --- /dev/null +++ b/src/samples/console/Elsa.Samples.SequentialWorkflows/Elsa.Samples.SequentialWorkflows.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/src/samples/console/Elsa.Samples.SequentialWorkflows/Program.cs b/src/samples/console/Elsa.Samples.SequentialWorkflows/Program.cs new file mode 100644 index 000000000..60bfa3b53 --- /dev/null +++ b/src/samples/console/Elsa.Samples.SequentialWorkflows/Program.cs @@ -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(); + +// Run the workflow. +await workflowRunner.RunAsync(workflow); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.SequentialWorkflows/Readme.md b/src/samples/console/Elsa.Samples.SequentialWorkflows/Readme.md new file mode 100644 index 000000000..f11ccb27b --- /dev/null +++ b/src/samples/console/Elsa.Samples.SequentialWorkflows/Readme.md @@ -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.