Merge
This commit is contained in:
parent
bd50dde6bd
commit
7ba8b1e8d6
151
Samples.sln
Normal file
151
Samples.sln
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28010.2036
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Core", "src\core\Elsa.Core\Elsa.Core.csproj", "{300EE2D5-54C5-46F2-AD03-BB43589EA074}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA71CDAA-8DD3-4D5F-9FBD-8E4B37A2D925}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7165BB9E-F22C-40D2-B7B1-CA3EFA2529A0}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
.gitignore = .gitignore
|
||||
Nuget.Config = Nuget.Config
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Abstractions", "src\core\Elsa.Abstractions\Elsa.Abstractions.csproj", "{3130C574-557C-4DA2-933E-AED7A9EBE48A}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{35F44BE9-13D0-417C-A01A-F0787BEE6DC3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.Console", "src\activities\Elsa.Activities.Console\Elsa.Activities.Console.csproj", "{B98B80CB-D3A3-437C-A61C-ED82C8C77B2F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.Http", "src\activities\Elsa.Activities.Http\Elsa.Activities.Http.csproj", "{1D63E1B4-2386-4BEC-9090-C3F3CBF25703}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Activities", "Activities", "{B43B546E-23F3-46E8-ACB7-D04F05CDA180}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.Email", "src\activities\Elsa.Activities.Email\Elsa.Activities.Email.csproj", "{D20FCB88-9DCA-49EA-9CC2-5B94DD935D30}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.Timers", "src\activities\Elsa.Activities.Timers\Elsa.Activities.Timers.csproj", "{E4B71DC4-3E73-49C3-9B4E-CA13909F222D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Activities.MassTransit", "src\activities\Elsa.Activities.MassTransit\Elsa.Activities.MassTransit.csproj", "{C4939482-9447-47D1-B6AF-E9F8C6323841}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5E5E1E84-DDBC-40D6-B891-0D563A15A44A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample01", "samples\Sample01\Sample01.csproj", "{FD72B97A-60C5-4592-91E5-0ED7A8D34C83}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample02", "samples\Sample02\Sample02.csproj", "{C7F43E7A-B133-41A8-BB9F-B4982CD4A1AA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample03", "samples\Sample03\Sample03.csproj", "{B86540C9-10EC-449C-9FB1-9194D903AF92}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample04", "samples\Sample04\Sample04.csproj", "{DCAB4D92-DF84-4075-8E34-6B09AAC1FC68}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample05", "samples\Sample05\Sample05.csproj", "{A59DA67D-3B50-4128-98E5-D8F1E0484C3C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample06", "samples\Sample06\Sample06.csproj", "{C0F7845C-E844-43E8-A51A-B38751B55B9C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample07", "samples\Sample07\Sample07.csproj", "{FC6628CB-69ED-4ED1-A2F5-B2233CD75C15}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample08", "samples\Sample08\Sample08.csproj", "{9E0C1D8B-7935-42E0-8C10-A31386A9FE9C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample09", "samples\Sample09\Sample09.csproj", "{E8622C16-D80B-46A7-99D4-B939B20FBFD6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{300EE2D5-54C5-46F2-AD03-BB43589EA074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{300EE2D5-54C5-46F2-AD03-BB43589EA074}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{300EE2D5-54C5-46F2-AD03-BB43589EA074}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{300EE2D5-54C5-46F2-AD03-BB43589EA074}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3130C574-557C-4DA2-933E-AED7A9EBE48A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3130C574-557C-4DA2-933E-AED7A9EBE48A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3130C574-557C-4DA2-933E-AED7A9EBE48A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3130C574-557C-4DA2-933E-AED7A9EBE48A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B98B80CB-D3A3-437C-A61C-ED82C8C77B2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B98B80CB-D3A3-437C-A61C-ED82C8C77B2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B98B80CB-D3A3-437C-A61C-ED82C8C77B2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B98B80CB-D3A3-437C-A61C-ED82C8C77B2F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D63E1B4-2386-4BEC-9090-C3F3CBF25703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D63E1B4-2386-4BEC-9090-C3F3CBF25703}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D63E1B4-2386-4BEC-9090-C3F3CBF25703}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D63E1B4-2386-4BEC-9090-C3F3CBF25703}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D20FCB88-9DCA-49EA-9CC2-5B94DD935D30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D20FCB88-9DCA-49EA-9CC2-5B94DD935D30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D20FCB88-9DCA-49EA-9CC2-5B94DD935D30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D20FCB88-9DCA-49EA-9CC2-5B94DD935D30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E4B71DC4-3E73-49C3-9B4E-CA13909F222D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E4B71DC4-3E73-49C3-9B4E-CA13909F222D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E4B71DC4-3E73-49C3-9B4E-CA13909F222D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E4B71DC4-3E73-49C3-9B4E-CA13909F222D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C4939482-9447-47D1-B6AF-E9F8C6323841}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C4939482-9447-47D1-B6AF-E9F8C6323841}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C4939482-9447-47D1-B6AF-E9F8C6323841}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C4939482-9447-47D1-B6AF-E9F8C6323841}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FD72B97A-60C5-4592-91E5-0ED7A8D34C83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FD72B97A-60C5-4592-91E5-0ED7A8D34C83}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FD72B97A-60C5-4592-91E5-0ED7A8D34C83}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FD72B97A-60C5-4592-91E5-0ED7A8D34C83}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7F43E7A-B133-41A8-BB9F-B4982CD4A1AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7F43E7A-B133-41A8-BB9F-B4982CD4A1AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7F43E7A-B133-41A8-BB9F-B4982CD4A1AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7F43E7A-B133-41A8-BB9F-B4982CD4A1AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B86540C9-10EC-449C-9FB1-9194D903AF92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B86540C9-10EC-449C-9FB1-9194D903AF92}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B86540C9-10EC-449C-9FB1-9194D903AF92}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B86540C9-10EC-449C-9FB1-9194D903AF92}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DCAB4D92-DF84-4075-8E34-6B09AAC1FC68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DCAB4D92-DF84-4075-8E34-6B09AAC1FC68}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DCAB4D92-DF84-4075-8E34-6B09AAC1FC68}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DCAB4D92-DF84-4075-8E34-6B09AAC1FC68}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A59DA67D-3B50-4128-98E5-D8F1E0484C3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A59DA67D-3B50-4128-98E5-D8F1E0484C3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A59DA67D-3B50-4128-98E5-D8F1E0484C3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A59DA67D-3B50-4128-98E5-D8F1E0484C3C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C0F7845C-E844-43E8-A51A-B38751B55B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C0F7845C-E844-43E8-A51A-B38751B55B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C0F7845C-E844-43E8-A51A-B38751B55B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C0F7845C-E844-43E8-A51A-B38751B55B9C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FC6628CB-69ED-4ED1-A2F5-B2233CD75C15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FC6628CB-69ED-4ED1-A2F5-B2233CD75C15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FC6628CB-69ED-4ED1-A2F5-B2233CD75C15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FC6628CB-69ED-4ED1-A2F5-B2233CD75C15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9E0C1D8B-7935-42E0-8C10-A31386A9FE9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9E0C1D8B-7935-42E0-8C10-A31386A9FE9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9E0C1D8B-7935-42E0-8C10-A31386A9FE9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9E0C1D8B-7935-42E0-8C10-A31386A9FE9C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E8622C16-D80B-46A7-99D4-B939B20FBFD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E8622C16-D80B-46A7-99D4-B939B20FBFD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E8622C16-D80B-46A7-99D4-B939B20FBFD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E8622C16-D80B-46A7-99D4-B939B20FBFD6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{300EE2D5-54C5-46F2-AD03-BB43589EA074} = {35F44BE9-13D0-417C-A01A-F0787BEE6DC3}
|
||||
{3130C574-557C-4DA2-933E-AED7A9EBE48A} = {35F44BE9-13D0-417C-A01A-F0787BEE6DC3}
|
||||
{35F44BE9-13D0-417C-A01A-F0787BEE6DC3} = {DA71CDAA-8DD3-4D5F-9FBD-8E4B37A2D925}
|
||||
{B43B546E-23F3-46E8-ACB7-D04F05CDA180} = {DA71CDAA-8DD3-4D5F-9FBD-8E4B37A2D925}
|
||||
{B98B80CB-D3A3-437C-A61C-ED82C8C77B2F} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{1D63E1B4-2386-4BEC-9090-C3F3CBF25703} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{D20FCB88-9DCA-49EA-9CC2-5B94DD935D30} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{E4B71DC4-3E73-49C3-9B4E-CA13909F222D} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{C4939482-9447-47D1-B6AF-E9F8C6323841} = {B43B546E-23F3-46E8-ACB7-D04F05CDA180}
|
||||
{FD72B97A-60C5-4592-91E5-0ED7A8D34C83} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{C7F43E7A-B133-41A8-BB9F-B4982CD4A1AA} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{B86540C9-10EC-449C-9FB1-9194D903AF92} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{DCAB4D92-DF84-4075-8E34-6B09AAC1FC68} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{A59DA67D-3B50-4128-98E5-D8F1E0484C3C} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{C0F7845C-E844-43E8-A51A-B38751B55B9C} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{FC6628CB-69ED-4ED1-A2F5-B2233CD75C15} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{9E0C1D8B-7935-42E0-8C10-A31386A9FE9C} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
{E8622C16-D80B-46A7-99D4-B939B20FBFD6} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8B0975FD-7050-48B0-88C5-48C33378E158}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
using System;
|
||||
using Elsa.Services;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample01.Activities
|
||||
{
|
||||
public class GoodByeWorld : Activity
|
||||
{
|
||||
protected override ActivityExecutionResult OnExecute(WorkflowExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Goodbye cruel world...");
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Elsa.Services;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample01.Activities
|
||||
{
|
||||
public class GoodByeWorld : Activity
|
||||
{
|
||||
protected override ActivityExecutionResult OnExecute(WorkflowExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Goodbye cruel world...");
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
using System;
|
||||
using Elsa.Services;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample01.Activities
|
||||
{
|
||||
public class HelloWorld : Activity
|
||||
{
|
||||
protected override ActivityExecutionResult OnExecute(WorkflowExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Hello world!");
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Elsa.Services;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample01.Activities
|
||||
{
|
||||
public class HelloWorld : Activity
|
||||
{
|
||||
protected override ActivityExecutionResult OnExecute(WorkflowExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Hello world!");
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +1,33 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sample01.Activities;
|
||||
|
||||
namespace Sample01
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined in code with a strongly-typed workflow class.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddActivity<HelloWorld>()
|
||||
.AddActivity<GoodByeWorld>()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync<HelloWorldWorkflow>();
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sample01.Activities;
|
||||
|
||||
namespace Sample01
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined in code with a strongly-typed workflow class.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddActivity<HelloWorld>()
|
||||
.AddActivity<GoodByeWorld>()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync<HelloWorldWorkflow>();
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\activities\Elsa.Activities.Console\Elsa.Activities.Console.csproj" />
|
||||
<ProjectReference Include="..\..\src\core\Elsa.Core\Elsa.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\activities\Elsa.Activities.Console\Elsa.Activities.Console.csproj" />
|
||||
<ProjectReference Include="..\..\src\core\Elsa.Core\Elsa.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Activities;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample02
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined in code using fluent workflow builder and Console activities.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddConsoleActivities()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Define a workflow.
|
||||
var workflowBuilder = services.GetRequiredService<IWorkflowBuilder>();
|
||||
var workflowDefinition = workflowBuilder
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new PlainTextExpression("Hello world!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Goodbye cruel world..."))
|
||||
.Build();
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync(workflowDefinition);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Activities;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample02
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined in code using fluent workflow builder and Console activities.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddConsoleActivities()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Define a workflow.
|
||||
var workflowBuilder = services.GetRequiredService<IWorkflowBuilder>();
|
||||
var workflowDefinition = workflowBuilder
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new PlainTextExpression("Hello world!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Goodbye cruel world..."))
|
||||
.Build();
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync(workflowDefinition);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\activities\Elsa.Activities.Console\Elsa.Activities.Console.csproj" />
|
||||
<ProjectReference Include="..\..\src\core\Elsa.Core\Elsa.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\activities\Elsa.Activities.Console\Elsa.Activities.Console.csproj" />
|
||||
<ProjectReference Include="..\..\src\core\Elsa.Core\Elsa.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,49 +1,50 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Activities;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample03
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined as data (workflow definition) and Console activities.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddConsoleActivities()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Define a workflow as data so we can store it somewhere (file, database, etc.).
|
||||
var workflowDefinition = new WorkflowDefinition
|
||||
{
|
||||
Activities = new[]
|
||||
{
|
||||
new ActivityDefinition<WriteLine>("activity-1", new { TextExpression = new PlainTextExpression("Hello world!")}),
|
||||
new ActivityDefinition<WriteLine>("activity-2", new { TextExpression = new PlainTextExpression("Goodbye cruel world...")})
|
||||
},
|
||||
Connections = new []
|
||||
{
|
||||
new ConnectionDefinition("activity-1", "activity-2"),
|
||||
}
|
||||
};
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync(workflowDefinition);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa;
|
||||
using Elsa.Activities.Console.Activities;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample03
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined as data (workflow definition) and Console activities.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddConsoleActivities()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Define a workflow as data so we can store it somewhere (file, database, etc.).
|
||||
var workflowDefinition = new WorkflowDefinition
|
||||
{
|
||||
Activities = new[]
|
||||
{
|
||||
new ActivityDefinition<WriteLine>("activity-1", new { TextExpression = new PlainTextExpression("Hello world!")}),
|
||||
new ActivityDefinition<WriteLine>("activity-2", new { TextExpression = new PlainTextExpression("Goodbye cruel world...")})
|
||||
},
|
||||
Connections = new []
|
||||
{
|
||||
new ConnectionDefinition("activity-1", "activity-2", OutcomeNames.Done),
|
||||
}
|
||||
};
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync(workflowDefinition);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +1,45 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample04.Activities
|
||||
{
|
||||
public abstract class ArithmeticOperation : Activity
|
||||
{
|
||||
private readonly IWorkflowExpressionEvaluator evaluator;
|
||||
|
||||
protected ArithmeticOperation(IWorkflowExpressionEvaluator evaluator)
|
||||
{
|
||||
this.evaluator = evaluator;
|
||||
}
|
||||
|
||||
public WorkflowExpression<double[]> Values
|
||||
{
|
||||
get => GetState<WorkflowExpression<double[]>>();
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
public string ResultVariableName
|
||||
{
|
||||
get => GetState<string>();
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
protected override async Task<ActivityExecutionResult> OnExecuteAsync(WorkflowExecutionContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var values = await evaluator.EvaluateAsync(Values, context, cancellationToken);
|
||||
var sum = Calculate(values);
|
||||
|
||||
context.SetLastResult(sum);
|
||||
context.CurrentScope.SetVariable(ResultVariableName, sum);
|
||||
|
||||
return Done();
|
||||
}
|
||||
|
||||
protected abstract double Calculate(params double[] values);
|
||||
}
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Results;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample04.Activities
|
||||
{
|
||||
public abstract class ArithmeticOperation : Activity
|
||||
{
|
||||
private readonly IWorkflowExpressionEvaluator evaluator;
|
||||
|
||||
protected ArithmeticOperation(IWorkflowExpressionEvaluator evaluator)
|
||||
{
|
||||
this.evaluator = evaluator;
|
||||
}
|
||||
|
||||
public WorkflowExpression<double[]> Values
|
||||
{
|
||||
get => GetState<WorkflowExpression<double[]>>();
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
public string ResultVariableName
|
||||
{
|
||||
get => GetState<string>();
|
||||
set => SetState(value);
|
||||
}
|
||||
|
||||
protected override async Task<ActivityExecutionResult> OnExecuteAsync(WorkflowExecutionContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var values = await evaluator.EvaluateAsync(Values, context, cancellationToken);
|
||||
var sum = Calculate(values);
|
||||
|
||||
context.SetLastResult(sum);
|
||||
context.CurrentScope.SetVariable(ResultVariableName, sum);
|
||||
|
||||
return Done();
|
||||
}
|
||||
|
||||
protected abstract double Calculate(params double[] values);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,11 +16,11 @@ namespace Sample04
|
|||
builder
|
||||
.StartWith<WriteLine>(x => x.TextExpression = new PlainTextExpression("Welcome to Calculator Workflow!"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Enter number 1:"), id: "start")
|
||||
.Then<ReadLine>(x => x.ArgumentName = "number1")
|
||||
.Then<ReadLine>(x => x.VariableName = "number1")
|
||||
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Enter number 2:"))
|
||||
.Then<ReadLine>(x => x.ArgumentName = "number2")
|
||||
.Then<ReadLine>(x => x.VariableName = "number2")
|
||||
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Now enter the operation you wish to apply. Options are: add, subtract, multiply or divide:"))
|
||||
.Then<ReadLine>(x => x.ArgumentName = "operation")
|
||||
.Then<ReadLine>(x => x.VariableName = "operation")
|
||||
.Then<Switch>(@switch =>
|
||||
{
|
||||
@switch.Expression = new JavaScriptExpression<string>("operation");
|
||||
|
|
@ -51,7 +51,7 @@ namespace Sample04
|
|||
)
|
||||
.Add<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`Result: ${result}`"), "showResult")
|
||||
.Then<WriteLine>(x => x.TextExpression = new PlainTextExpression("Try again? (y/n)"))
|
||||
.Then<ReadLine>(x => x.ArgumentName = "retry")
|
||||
.Then<ReadLine>(x => x.VariableName = "retry")
|
||||
.Then<IfElse>(
|
||||
x => x.ConditionExpression = new JavaScriptExpression<bool>("retry.toLowerCase() === 'y'"),
|
||||
ifElse =>
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sample04.Activities;
|
||||
|
||||
namespace Sample04
|
||||
{
|
||||
/// <summary>
|
||||
/// A strongly-typed workflows program demonstrating scripting, and branching.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main()
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddConsoleActivities()
|
||||
.AddActivity<Sum>()
|
||||
.AddActivity<Subtract>()
|
||||
.AddActivity<Multiply>()
|
||||
.AddActivity<Divide>()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Create a workflow.
|
||||
var workflowFactory = services.GetRequiredService<IWorkflowFactory>();
|
||||
var workflow = workflowFactory.CreateWorkflow<CalculatorWorkflow>();
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync(workflow);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sample04.Activities;
|
||||
|
||||
namespace Sample04
|
||||
{
|
||||
/// <summary>
|
||||
/// A strongly-typed workflows program demonstrating scripting, and branching.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main()
|
||||
{
|
||||
// Setup a service collection.
|
||||
var services = new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.AddConsoleActivities()
|
||||
.AddActivity<Sum>()
|
||||
.AddActivity<Subtract>()
|
||||
.AddActivity<Multiply>()
|
||||
.AddActivity<Divide>()
|
||||
.BuildServiceProvider();
|
||||
|
||||
// Create a workflow.
|
||||
var workflowFactory = services.GetRequiredService<IWorkflowFactory>();
|
||||
var workflow = workflowFactory.CreateWorkflow<CalculatorWorkflow>();
|
||||
|
||||
// Invoke the workflow.
|
||||
var invoker = services.GetService<IWorkflowInvoker>();
|
||||
await invoker.InvokeAsync(workflow);
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +1,53 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Activities.Timers.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NodaTime;
|
||||
|
||||
namespace Sample05
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined in code with a strongly-typed workflow class.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main()
|
||||
{
|
||||
var host = new HostBuilder()
|
||||
.ConfigureServices(ConfigureServices)
|
||||
.ConfigureLogging(logging => logging.AddConsole())
|
||||
.UseConsoleLifetime()
|
||||
.Build();
|
||||
|
||||
using (host)
|
||||
{
|
||||
await host.StartAsync();
|
||||
SetupWorkflow(host.Services);
|
||||
await host.WaitForShutdownAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetupWorkflow(IServiceProvider services)
|
||||
{
|
||||
// Register the workflow.
|
||||
var registry = services.GetService<IWorkflowRegistry>();
|
||||
registry.RegisterWorkflow<RecurringWorkflow>();
|
||||
}
|
||||
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddConsoleActivities()
|
||||
.AddTimerActivities(options => options.Configure(x => x.SweepInterval = Period.FromSeconds(10)))
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Activities.Timers.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NodaTime;
|
||||
|
||||
namespace Sample05
|
||||
{
|
||||
/// <summary>
|
||||
/// A minimal workflows program defined in code with a strongly-typed workflow class.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main()
|
||||
{
|
||||
var host = new HostBuilder()
|
||||
.ConfigureServices(ConfigureServices)
|
||||
.ConfigureLogging(logging => logging.AddConsole())
|
||||
.UseConsoleLifetime()
|
||||
.Build();
|
||||
|
||||
using (host)
|
||||
{
|
||||
await host.StartAsync();
|
||||
SetupWorkflow(host.Services);
|
||||
await host.WaitForShutdownAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetupWorkflow(IServiceProvider services)
|
||||
{
|
||||
// Register the workflow.
|
||||
var registry = services.GetService<IWorkflowRegistry>();
|
||||
registry.RegisterWorkflow<RecurringWorkflow>();
|
||||
}
|
||||
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddConsoleActivities()
|
||||
.AddTimerActivities(options => options.Configure(x => x.SweepInterval = Period.FromSeconds(10)))
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
using Elsa.Activities.Console.Activities;
|
||||
using Elsa.Activities.Timers.Activities;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample05
|
||||
{
|
||||
public class RecurringWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.WithId("RecurringWorkflow")
|
||||
.AsSingleton()
|
||||
.StartWith<CronEvent>(x => x.CronExpression = new PlainTextExpression("* * * * *"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`Trigger received. The time is: ${new Date().toISOString()}`"));
|
||||
}
|
||||
}
|
||||
using Elsa.Activities.Console.Activities;
|
||||
using Elsa.Activities.Timers.Activities;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Sample05
|
||||
{
|
||||
public class RecurringWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.WithId("RecurringWorkflow")
|
||||
.AsSingleton()
|
||||
.StartWith<CronEvent>(x => x.CronExpression = new PlainTextExpression("* * * * *"))
|
||||
.Then<WriteLine>(x => x.TextExpression = new JavaScriptExpression<string>("`Trigger received. The time is: ${new Date().toISOString()}`"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +1,43 @@
|
|||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample06
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddHttpActivities()
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IWorkflowRegistry workflowRegistry)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpActivities();
|
||||
app.UseWelcomePage();
|
||||
|
||||
workflowRegistry.RegisterWorkflow<HelloWorldWorkflow>();
|
||||
}
|
||||
}
|
||||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample06
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddHttpActivities()
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IWorkflowRegistry workflowRegistry)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpActivities();
|
||||
app.UseWelcomePage();
|
||||
|
||||
workflowRegistry.RegisterWorkflow<HelloWorldWorkflow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@ using System.Net.Http;
|
|||
using Elsa;
|
||||
using Elsa.Activities.Email.Activities;
|
||||
using Elsa.Activities.Http.Activities;
|
||||
using Elsa.Core.Activities.ControlFlow;
|
||||
using Elsa.Core.Activities.Primitives;
|
||||
using Elsa.Core.Expressions;
|
||||
using Elsa.Activities.ControlFlow;
|
||||
using Elsa.Activities.Primitives;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,45 +1,45 @@
|
|||
using Elsa.Activities.Email.Extensions;
|
||||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Core.Extensions;
|
||||
using Elsa.Core.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample07
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddHttpActivities()
|
||||
.AddEmailActivities(options => options.Bind(Configuration.GetSection("Smtp"))) //Tip: use Smtp4Dev for a local SMTP server that displays sent emails without actually sending them.
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IWorkflowRegistry workflowRegistry)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpActivities();
|
||||
app.UseWelcomePage();
|
||||
|
||||
workflowRegistry.RegisterWorkflow<DocumentApprovalWorkflow>();
|
||||
}
|
||||
}
|
||||
using Elsa.Activities.Email.Extensions;
|
||||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample07
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddHttpActivities()
|
||||
.AddEmailActivities(options => options.Bind(Configuration.GetSection("Smtp"))) //Tip: use Smtp4Dev for a local SMTP server that displays sent emails without actually sending them.
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IWorkflowRegistry workflowRegistry)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpActivities();
|
||||
app.UseWelcomePage();
|
||||
|
||||
workflowRegistry.RegisterWorkflow<DocumentApprovalWorkflow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,56 @@
|
|||
using Elsa.Activities.Email.Extensions;
|
||||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Activities.MassTransit.Extensions;
|
||||
using Elsa.Activities.Timers.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NodaTime;
|
||||
using Sample08.Messages;
|
||||
using Sample08.Workflows;
|
||||
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
|
||||
namespace Sample08
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddHttpActivities()
|
||||
.AddTimerActivities(options => options.Configure(x => x.SweepInterval = Period.FromSeconds(10)))
|
||||
.AddEmailActivities(options => options.Bind(Configuration.GetSection("Smtp")))
|
||||
.AddRabbitMqActivities(
|
||||
options => options.Bind(Configuration.GetSection("MassTransit:RabbitMq")),
|
||||
typeof(CreateOrder),
|
||||
typeof(OrderShipped))
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IWorkflowRegistry workflowRegistry)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpActivities();
|
||||
|
||||
workflowRegistry.RegisterWorkflow<CreateOrderWorkflow>();
|
||||
workflowRegistry.RegisterWorkflow<HandleOrderWorkflow>();
|
||||
}
|
||||
}
|
||||
using Elsa.Activities.Email.Extensions;
|
||||
using Elsa.Activities.Http.Extensions;
|
||||
using Elsa.Activities.MassTransit.Extensions;
|
||||
using Elsa.Activities.Timers.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NodaTime;
|
||||
using Sample08.Messages;
|
||||
using Sample08.Workflows;
|
||||
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
|
||||
namespace Sample08
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWorkflows()
|
||||
.AddHttpActivities()
|
||||
.AddTimerActivities(options => options.Configure(x => x.SweepInterval = Period.FromSeconds(10)))
|
||||
.AddEmailActivities(options => options.Bind(Configuration.GetSection("Smtp")))
|
||||
.AddRabbitMqActivities(
|
||||
options => options.Bind(Configuration.GetSection("MassTransit:RabbitMq")),
|
||||
typeof(CreateOrder),
|
||||
typeof(OrderShipped))
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IWorkflowRegistry workflowRegistry)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpActivities();
|
||||
|
||||
workflowRegistry.RegisterWorkflow<CreateOrderWorkflow>();
|
||||
workflowRegistry.RegisterWorkflow<HandleOrderWorkflow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +1,34 @@
|
|||
using System;
|
||||
using Elsa.Activities.MassTransit.Activities;
|
||||
using Elsa.Activities.Timers.Activities;
|
||||
using Elsa.Activities.Primitives;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Sample08.Messages;
|
||||
|
||||
namespace Sample08.Workflows
|
||||
{
|
||||
public class HandleOrderWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<ReceiveMassTransitMessage>(activity => activity.MessageType = typeof(CreateOrder))
|
||||
.Then<SetVariable>(
|
||||
activity =>
|
||||
{
|
||||
activity.VariableName = "order";
|
||||
activity.ValueExpression = new JavaScriptExpression<object>("lastResult().Order");
|
||||
}
|
||||
)
|
||||
.Then<TimerEvent>(activity => activity.TimeoutExpression = new PlainTextExpression<TimeSpan>("00:00:05"))
|
||||
.Then<SendMassTransitMessage>(activity =>
|
||||
{
|
||||
activity.Message = new JavaScriptExpression<OrderShipped>("return {order: order}");
|
||||
activity.MessageType = typeof(OrderShipped);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Elsa.Activities.MassTransit.Activities;
|
||||
using Elsa.Activities.Timers.Activities;
|
||||
using Elsa.Activities.Primitives;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Sample08.Messages;
|
||||
|
||||
namespace Sample08.Workflows
|
||||
{
|
||||
public class HandleOrderWorkflow : IWorkflow
|
||||
{
|
||||
public void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
builder
|
||||
.StartWith<ReceiveMassTransitMessage>(activity => activity.MessageType = typeof(CreateOrder))
|
||||
.Then<SetVariable>(
|
||||
activity =>
|
||||
{
|
||||
activity.VariableName = "order";
|
||||
activity.ValueExpression = new JavaScriptExpression<object>("lastResult().Order");
|
||||
}
|
||||
)
|
||||
.Then<TimerEvent>(activity => activity.TimeoutExpression = new PlainTextExpression<TimeSpan>("00:00:05"))
|
||||
.Then<SendMassTransitMessage>(activity =>
|
||||
{
|
||||
activity.Message = new JavaScriptExpression<OrderShipped>("return {order: order}");
|
||||
activity.MessageType = typeof(OrderShipped);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
samples/Sample09/Program.cs
Normal file
51
samples/Sample09/Program.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Console.Extensions;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Models;
|
||||
using Elsa.Persistence.Extensions;
|
||||
using Elsa.Serialization;
|
||||
using Elsa.Serialization.Formatters;
|
||||
using Elsa.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Sample09
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple console program that loads & executes a workflow designed with the HTML5 workflow designer.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static async Task Main()
|
||||
{
|
||||
var json = await ReadEmbeddedResourceAsync("Sample09.calculator.json");
|
||||
var services = BuildServices();
|
||||
var serializer = services.GetRequiredService<IWorkflowSerializer>();
|
||||
var workflow = serializer.Deserialize<WorkflowDefinition>(json, JsonTokenFormatter.FormatName);
|
||||
var invoker = services.GetRequiredService<IWorkflowInvoker>();
|
||||
|
||||
await invoker.InvokeAsync(workflow);
|
||||
}
|
||||
|
||||
private static IServiceProvider BuildServices()
|
||||
{
|
||||
return new ServiceCollection()
|
||||
.AddWorkflows()
|
||||
.AddConsoleActivities()
|
||||
.AddMemoryWorkflowDefinitionStore()
|
||||
.AddMemoryWorkflowInstanceStore()
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
|
||||
private static async Task<string> ReadEmbeddedResourceAsync(string resourceName)
|
||||
{
|
||||
var assembly = typeof(Program).GetTypeInfo().Assembly;
|
||||
using (var reader = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
|
||||
{
|
||||
return await reader.ReadToEndAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
samples/Sample09/Sample09.csproj
Normal file
19
samples/Sample09/Sample09.csproj
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\activities\Elsa.Activities.Console\Elsa.Activities.Console.csproj"/>
|
||||
<ProjectReference Include="..\..\src\core\Elsa.Core\Elsa.Core.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="calculator.json"/>
|
||||
<EmbeddedResource Include="calculator.json"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
255
samples/Sample09/calculator.json
Normal file
255
samples/Sample09/calculator.json
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
{
|
||||
"activities": [
|
||||
{
|
||||
"id": "cb5bc5c3-c8a2-4e13-b469-3780af6f1502",
|
||||
"top": 156,
|
||||
"left": 322,
|
||||
"type": "ReadLine",
|
||||
"state": {
|
||||
"variableName": "a"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "caa8b05f-d355-49f5-95b1-9782e7408635",
|
||||
"top": 49,
|
||||
"left": 29,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "Welcome to Calculator!"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "c06feed1-c9f7-407e-820f-68dd045788c0",
|
||||
"top": 295,
|
||||
"left": 46,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "Enter a number:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "b9e1aa68-bb4c-4775-966f-2080b1b21a9e",
|
||||
"top": 23,
|
||||
"left": 613,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "Enter another number:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "b05e7717-39f2-4bf1-a13f-ee30295287c3",
|
||||
"top": 188,
|
||||
"left": 789,
|
||||
"type": "ReadLine",
|
||||
"state": {
|
||||
"variableName": "b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "e5edc24d-59ca-4682-8af0-a464de2b2725",
|
||||
"top": 338,
|
||||
"left": 545,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "Enter an operation. Options: add, subtract, multiply, divide"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "cf9f8965-5765-482e-a280-000c7105e378",
|
||||
"top": 535,
|
||||
"left": 626,
|
||||
"type": "Switch",
|
||||
"state": {
|
||||
"expression": "parseFloat(operation)",
|
||||
"cases": [
|
||||
"Add",
|
||||
"Subtract",
|
||||
"Multiply",
|
||||
"Divide"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "2ef2fc1e-c439-482f-a9a7-9ec0fec7d868",
|
||||
"top": 17,
|
||||
"left": 1258,
|
||||
"type": "SetVariable",
|
||||
"state": {
|
||||
"variableName": "result",
|
||||
"variableExpression": "a + b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "47396ebe-8e62-432b-bd28-4260c07d1ffe",
|
||||
"top": 172,
|
||||
"left": 1259,
|
||||
"type": "SetVariable",
|
||||
"state": {
|
||||
"variableName": "result",
|
||||
"variableExpression": "a - b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "f700f606-6995-4e80-b30e-c6bbfba91c81",
|
||||
"top": 365,
|
||||
"left": 1258,
|
||||
"type": "SetVariable",
|
||||
"state": {
|
||||
"variableName": "result",
|
||||
"variableExpression": "a * b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "80c41881-edc6-4d3f-8f1b-9cc3fc9cbfc1",
|
||||
"top": 526,
|
||||
"left": 1263,
|
||||
"type": "SetVariable",
|
||||
"state": {
|
||||
"variableName": "result",
|
||||
"variableExpression": "a / b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "3343d0cc-eea0-4f28-a370-c182ae74b007",
|
||||
"top": 266,
|
||||
"left": 1607,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "`Result: ${result}`"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "be435fd5-1740-40ee-98e1-7843da139e9a",
|
||||
"top": 465,
|
||||
"left": 1611,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "Try again? (y/n)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "b3f5818e-9a24-4621-9d15-07af7de4da32",
|
||||
"top": 821,
|
||||
"left": 1591,
|
||||
"type": "ReadLine",
|
||||
"state": {
|
||||
"variableName": "retry"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "701a7580-2b6a-42ff-9f18-82ca1910b192",
|
||||
"top": 735,
|
||||
"left": 568,
|
||||
"type": "IfElse",
|
||||
"state": {
|
||||
"expression": "retry === 'y'"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "9e0f75ca-d599-4bf7-8132-ffb305004c2d",
|
||||
"top": 846,
|
||||
"left": 83,
|
||||
"type": "WriteLine",
|
||||
"state": {
|
||||
"textExpression": "Bye!"
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": [
|
||||
{
|
||||
"sourceActivityId": "caa8b05f-d355-49f5-95b1-9782e7408635",
|
||||
"destinationActivityId": "c06feed1-c9f7-407e-820f-68dd045788c0",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "c06feed1-c9f7-407e-820f-68dd045788c0",
|
||||
"destinationActivityId": "cb5bc5c3-c8a2-4e13-b469-3780af6f1502",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "cb5bc5c3-c8a2-4e13-b469-3780af6f1502",
|
||||
"destinationActivityId": "b9e1aa68-bb4c-4775-966f-2080b1b21a9e",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "b9e1aa68-bb4c-4775-966f-2080b1b21a9e",
|
||||
"destinationActivityId": "b05e7717-39f2-4bf1-a13f-ee30295287c3",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "b05e7717-39f2-4bf1-a13f-ee30295287c3",
|
||||
"destinationActivityId": "e5edc24d-59ca-4682-8af0-a464de2b2725",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "e5edc24d-59ca-4682-8af0-a464de2b2725",
|
||||
"destinationActivityId": "cf9f8965-5765-482e-a280-000c7105e378",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "cf9f8965-5765-482e-a280-000c7105e378",
|
||||
"destinationActivityId": "2ef2fc1e-c439-482f-a9a7-9ec0fec7d868",
|
||||
"outcome": "Add"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "cf9f8965-5765-482e-a280-000c7105e378",
|
||||
"destinationActivityId": "47396ebe-8e62-432b-bd28-4260c07d1ffe",
|
||||
"outcome": "Subtract"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "cf9f8965-5765-482e-a280-000c7105e378",
|
||||
"destinationActivityId": "f700f606-6995-4e80-b30e-c6bbfba91c81",
|
||||
"outcome": "Multiply"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "cf9f8965-5765-482e-a280-000c7105e378",
|
||||
"destinationActivityId": "80c41881-edc6-4d3f-8f1b-9cc3fc9cbfc1",
|
||||
"outcome": "Divide"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "2ef2fc1e-c439-482f-a9a7-9ec0fec7d868",
|
||||
"destinationActivityId": "3343d0cc-eea0-4f28-a370-c182ae74b007",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "47396ebe-8e62-432b-bd28-4260c07d1ffe",
|
||||
"destinationActivityId": "3343d0cc-eea0-4f28-a370-c182ae74b007",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "f700f606-6995-4e80-b30e-c6bbfba91c81",
|
||||
"destinationActivityId": "3343d0cc-eea0-4f28-a370-c182ae74b007",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "80c41881-edc6-4d3f-8f1b-9cc3fc9cbfc1",
|
||||
"destinationActivityId": "3343d0cc-eea0-4f28-a370-c182ae74b007",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "3343d0cc-eea0-4f28-a370-c182ae74b007",
|
||||
"destinationActivityId": "be435fd5-1740-40ee-98e1-7843da139e9a",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "be435fd5-1740-40ee-98e1-7843da139e9a",
|
||||
"destinationActivityId": "b3f5818e-9a24-4621-9d15-07af7de4da32",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "b3f5818e-9a24-4621-9d15-07af7de4da32",
|
||||
"destinationActivityId": "701a7580-2b6a-42ff-9f18-82ca1910b192",
|
||||
"outcome": "Done"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "701a7580-2b6a-42ff-9f18-82ca1910b192",
|
||||
"destinationActivityId": "c06feed1-c9f7-407e-820f-68dd045788c0",
|
||||
"outcome": "True"
|
||||
},
|
||||
{
|
||||
"sourceActivityId": "701a7580-2b6a-42ff-9f18-82ca1910b192",
|
||||
"destinationActivityId": "9e0f75ca-d599-4bf7-8132-ffb305004c2d",
|
||||
"outcome": "False"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace Elsa.Activities.Console.Activities
|
|||
this.input = input;
|
||||
}
|
||||
|
||||
public string ArgumentName
|
||||
public string VariableName
|
||||
{
|
||||
get => GetState<string>();
|
||||
set => SetState(value);
|
||||
|
|
@ -40,13 +40,13 @@ namespace Elsa.Activities.Console.Activities
|
|||
|
||||
protected override ActivityExecutionResult OnResume(WorkflowExecutionContext context)
|
||||
{
|
||||
var receivedInput = (string)context.Workflow.Input[ArgumentName];
|
||||
var receivedInput = (string)context.Workflow.Input[VariableName];
|
||||
return Execute(context, receivedInput);
|
||||
}
|
||||
|
||||
private ActivityExecutionResult Execute(WorkflowExecutionContext workflowContext, string receivedInput)
|
||||
{
|
||||
workflowContext.CurrentScope.SetVariable(ArgumentName, receivedInput);
|
||||
workflowContext.CurrentScope.SetVariable(VariableName, receivedInput);
|
||||
workflowContext.SetLastResult(receivedInput);
|
||||
return Outcome(OutcomeNames.Done);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,39 @@
|
|||
using Elsa.Services.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Models
|
||||
{
|
||||
public class ActivityDefinition
|
||||
{
|
||||
public static ActivityDefinition FromActivity(IActivity activity)
|
||||
{
|
||||
return new ActivityDefinition(activity.Id, activity.TypeName, activity.State);
|
||||
}
|
||||
|
||||
public ActivityDefinition(string id, string typeName, JObject state)
|
||||
{
|
||||
Id = id;
|
||||
TypeName = typeName;
|
||||
State = new JObject(state);
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public JObject State { get; set; }
|
||||
}
|
||||
|
||||
public class ActivityDefinition<T> : ActivityDefinition where T : IActivity
|
||||
{
|
||||
public ActivityDefinition(string id, JObject state) : base(id, typeof(T).Name, state)
|
||||
{
|
||||
}
|
||||
|
||||
public ActivityDefinition(string id, object state) : base(id, typeof(T).Name, JObject.FromObject(state))
|
||||
{
|
||||
}
|
||||
}
|
||||
using Elsa.Services.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Models
|
||||
{
|
||||
public class ActivityDefinition
|
||||
{
|
||||
public static ActivityDefinition FromActivity(IActivity activity)
|
||||
{
|
||||
return new ActivityDefinition(activity.Id, activity.TypeName, activity.State);
|
||||
}
|
||||
|
||||
public ActivityDefinition()
|
||||
{
|
||||
}
|
||||
|
||||
public ActivityDefinition(string id, string type, JObject state)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
State = new JObject(state);
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public JObject State { get; set; }
|
||||
}
|
||||
|
||||
public class ActivityDefinition<T> : ActivityDefinition where T : IActivity
|
||||
{
|
||||
public ActivityDefinition(string id, JObject state) : base(id, typeof(T).Name, state)
|
||||
{
|
||||
}
|
||||
|
||||
public ActivityDefinition(string id, object state) : base(id, typeof(T).Name, JObject.FromObject(state))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,20 @@
|
|||
namespace Elsa.Models
|
||||
{
|
||||
public class ConnectionDefinition
|
||||
{
|
||||
public ConnectionDefinition(string sourceActivityId, string targetActivityId, string outcome = null)
|
||||
: this(
|
||||
new SourceEndpointDefinition(sourceActivityId, outcome),
|
||||
new TargetEndpointDefinition(targetActivityId)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public ConnectionDefinition(SourceEndpointDefinition source, TargetEndpointDefinition target)
|
||||
{
|
||||
Source = source;
|
||||
Target = target;
|
||||
}
|
||||
|
||||
public SourceEndpointDefinition Source { get; }
|
||||
public TargetEndpointDefinition Target { get; }
|
||||
}
|
||||
namespace Elsa.Models
|
||||
{
|
||||
public class ConnectionDefinition
|
||||
{
|
||||
public ConnectionDefinition()
|
||||
{
|
||||
}
|
||||
|
||||
public ConnectionDefinition(string sourceActivityId, string destinationActivityId, string outcome)
|
||||
{
|
||||
SourceActivityId = sourceActivityId;
|
||||
DestinationActivityId = destinationActivityId;
|
||||
Outcome = outcome;
|
||||
}
|
||||
|
||||
public string SourceActivityId { get; set; }
|
||||
public string DestinationActivityId { get; set; }
|
||||
public string Outcome { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
namespace Elsa.Models
|
||||
{
|
||||
public abstract class EndpointDefinition
|
||||
{
|
||||
protected EndpointDefinition(string activityId)
|
||||
{
|
||||
ActivityId = activityId;
|
||||
}
|
||||
|
||||
public string ActivityId { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
namespace Elsa.Models
|
||||
{
|
||||
public class SourceEndpointDefinition : EndpointDefinition
|
||||
{
|
||||
public SourceEndpointDefinition(string activityId, string outcome) : base(activityId)
|
||||
{
|
||||
Outcome = outcome;
|
||||
}
|
||||
|
||||
public string Outcome { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
namespace Elsa.Models
|
||||
{
|
||||
public class TargetEndpointDefinition : EndpointDefinition
|
||||
{
|
||||
public TargetEndpointDefinition(string activityId) : base(activityId)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
using Elsa.Serialization.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Serialization
|
||||
{
|
||||
public interface IWorkflowSerializer
|
||||
{
|
||||
string Serialize(WorkflowInstance workflowInstance, string format);
|
||||
string Serialize(JToken token, string format);
|
||||
WorkflowInstance Deserialize(string data, string format);
|
||||
WorkflowInstance Deserialize(JToken token);
|
||||
}
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Serialization
|
||||
{
|
||||
public interface IWorkflowSerializer
|
||||
{
|
||||
string Serialize<T>(T workflowInstance, string format);
|
||||
string Serialize(JToken token, string format);
|
||||
T Deserialize<T>(string data, string format);
|
||||
T Deserialize<T>(JToken token);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,56 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Elsa.Models;
|
||||
|
||||
namespace Elsa.Services.Extensions
|
||||
{
|
||||
public static class WorkflowBlueprintExtensions
|
||||
{
|
||||
public static IEnumerable<ActivityDefinition> GetStartActivities(this WorkflowDefinition workflow)
|
||||
{
|
||||
var targetActivityIds = workflow.Connections.Select(x => x.Target.ActivityId).Distinct().ToLookup(x => x);
|
||||
|
||||
var query =
|
||||
from activity in workflow.Activities
|
||||
where !targetActivityIds.Contains(activity.Id)
|
||||
select activity;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public static ActivityDefinition GetActivity(this WorkflowDefinition workflowDefinition, string id) => workflowDefinition.Activities.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
public static IEnumerable<ConnectionDefinition> GetInboundConnections(this WorkflowDefinition workflowDefinition, string activityId)
|
||||
{
|
||||
return workflowDefinition.Connections.Where(x => x.Target.ActivityId == activityId).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<ConnectionDefinition> GetOutboundConnections(this WorkflowDefinition workflowDefinition, string activityId)
|
||||
{
|
||||
return workflowDefinition.Connections.Where(x => x.Source.ActivityId == activityId).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the full path of incoming activities.
|
||||
/// </summary>
|
||||
public static IEnumerable<string> GetInboundActivityPath(this WorkflowDefinition workflowDefinition, string activityId)
|
||||
{
|
||||
return workflowDefinition.GetInboundActivityPathInternal(activityId, activityId).Distinct().ToList();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetInboundActivityPathInternal(this WorkflowDefinition workflowDefinition, string activityId, string startingPointActivityId)
|
||||
{
|
||||
foreach (var connection in workflowDefinition.GetInboundConnections(activityId))
|
||||
{
|
||||
// Circuit breaker: Detect workflows that implement repeating flows to prevent an infinite loop here.
|
||||
if (connection.Source.ActivityId == startingPointActivityId)
|
||||
yield break;
|
||||
|
||||
yield return connection.Source.ActivityId;
|
||||
|
||||
foreach (var parentActivityId in workflowDefinition.GetInboundActivityPathInternal(connection.Source.ActivityId, startingPointActivityId).Distinct())
|
||||
yield return parentActivityId;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Elsa.Models;
|
||||
|
||||
namespace Elsa.Services.Extensions
|
||||
{
|
||||
public static class WorkflowBlueprintExtensions
|
||||
{
|
||||
public static IEnumerable<ActivityDefinition> GetStartActivities(this WorkflowDefinition workflow)
|
||||
{
|
||||
var destinationActivityIds = workflow.Connections.Select(x => x.DestinationActivityId).Distinct().ToLookup(x => x);
|
||||
|
||||
var query =
|
||||
from activity in workflow.Activities
|
||||
where !destinationActivityIds.Contains(activity.Id)
|
||||
select activity;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
public static ActivityDefinition GetActivity(this WorkflowDefinition workflowDefinition, string id) => workflowDefinition.Activities.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
public static IEnumerable<ConnectionDefinition> GetInboundConnections(this WorkflowDefinition workflowDefinition, string activityId)
|
||||
{
|
||||
return workflowDefinition.Connections.Where(x => x.DestinationActivityId == activityId).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<ConnectionDefinition> GetOutboundConnections(this WorkflowDefinition workflowDefinition, string activityId)
|
||||
{
|
||||
return workflowDefinition.Connections.Where(x => x.SourceActivityId == activityId).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the full path of incoming activities.
|
||||
/// </summary>
|
||||
public static IEnumerable<string> GetInboundActivityPath(this WorkflowDefinition workflowDefinition, string activityId)
|
||||
{
|
||||
return workflowDefinition.GetInboundActivityPathInternal(activityId, activityId).Distinct().ToList();
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetInboundActivityPathInternal(this WorkflowDefinition workflowDefinition, string activityId, string startingPointActivityId)
|
||||
{
|
||||
foreach (var connection in workflowDefinition.GetInboundConnections(activityId))
|
||||
{
|
||||
// Circuit breaker: Detect workflows that implement repeating flows to prevent an infinite loop here.
|
||||
if (connection.SourceActivityId == startingPointActivityId)
|
||||
yield break;
|
||||
|
||||
yield return connection.SourceActivityId;
|
||||
|
||||
foreach (var parentActivityId in workflowDefinition.GetInboundActivityPathInternal(connection.SourceActivityId, startingPointActivityId).Distinct())
|
||||
yield return parentActivityId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,10 +19,10 @@ namespace Elsa.Serialization
|
|||
jsonSerializer = serializerProvider.CreateJsonSerializer();
|
||||
}
|
||||
|
||||
public string Serialize(WorkflowInstance workflowInstance, string format)
|
||||
public string Serialize<T>(T workflowInstance, string format)
|
||||
{
|
||||
var token = JObject.FromObject(workflowInstance, jsonSerializer);
|
||||
return Serialize(token, format);
|
||||
return Serialize((JToken)token, format);
|
||||
}
|
||||
|
||||
public string Serialize(JToken token, string format)
|
||||
|
|
@ -31,16 +31,16 @@ namespace Elsa.Serialization
|
|||
return formatter.ToString(token);
|
||||
}
|
||||
|
||||
public WorkflowInstance Deserialize(string data, string format)
|
||||
public T Deserialize<T>(string data, string format)
|
||||
{
|
||||
var formatter = formatters[format];
|
||||
var token = formatter.FromString(data);
|
||||
return Deserialize(token);
|
||||
return Deserialize<T>(token);
|
||||
}
|
||||
|
||||
public WorkflowInstance Deserialize(JToken token)
|
||||
public T Deserialize<T>(JToken token)
|
||||
{
|
||||
return token.ToObject<WorkflowInstance>(jsonSerializer);
|
||||
return token.ToObject<T>(jsonSerializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ namespace Elsa.Services
|
|||
|
||||
private IActivity CreateActivity(ActivityDefinition definition)
|
||||
{
|
||||
var activity = activityResolver.ResolveActivity(definition.TypeName);
|
||||
var activity = activityResolver.ResolveActivity(definition.Type);
|
||||
|
||||
activity.State = new JObject(definition.State);
|
||||
activity.Id = definition.Id;
|
||||
|
|
@ -59,9 +59,9 @@ namespace Elsa.Services
|
|||
|
||||
private Connection CreateConnection(ConnectionDefinition connectionDefinition, IDictionary<string, IActivity> activityDictionary)
|
||||
{
|
||||
var source = activityDictionary[connectionDefinition.Source.ActivityId];
|
||||
var target = activityDictionary[connectionDefinition.Target.ActivityId];
|
||||
return new Connection(source, target, connectionDefinition.Source.Outcome);
|
||||
var source = activityDictionary[connectionDefinition.SourceActivityId];
|
||||
var target = activityDictionary[connectionDefinition.DestinationActivityId];
|
||||
return new Connection(source, target, connectionDefinition.Outcome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ namespace Elsa.Services
|
|||
var query =
|
||||
from workflow in workflowDefinitions.Values
|
||||
from activity in workflow.GetStartActivities()
|
||||
where activity.TypeName == activityType
|
||||
where activity.Type == activityType
|
||||
select (workflow, activity);
|
||||
|
||||
return query.Distinct();
|
||||
|
|
|
|||
Loading…
Reference in a new issue