Update sample workflows to mark startable activities

This commit is contained in:
Sipke Schoorstra 2022-03-07 15:06:31 +01:00
parent 217f632379
commit 03da168caa
2 changed files with 36 additions and 34 deletions

View file

@ -14,41 +14,44 @@ using HttpMethods = Microsoft.AspNetCore.Http.HttpMethods;
public class HttpWorkflow : IWorkflow
{
public string Id => nameof(HttpWorkflow);
public int Version => 1;
public void Build(IWorkflowDefinitionBuilder workflow)
{
// Setup workflow graph.
workflow.WithRoot(new Sequence
{
Activities =
// Setup the workflow.
workflow
.WithDefinitionId(nameof(HttpWorkflow))
.WithVersion(1)
// Workflows have one starting node, aka its "root".
.WithRoot(new Sequence
{
new HttpEndpoint
Activities =
{
Path = new Input<string>("/hello-world"),
SupportedMethods = new Input<ICollection<string>>(new[] { HttpMethods.Get })
},
new If
{
Condition = new Input<bool>(true),
Then = new Sequence(
new WriteLine("It's true!"),
new HttpEndpoint
{
Path = new Input<string>("/hello-world/true"),
SupportedMethods = new Input<ICollection<string>>(new[] { HttpMethods.Post })
},
new WriteLine("Let's continue")
),
Else = new WriteLine("It's not true!")
},
new WriteHttpResponse
{
StatusCode = new Input<HttpStatusCode>(HttpStatusCode.OK),
Content = new Input<string?>("Hello World!")
new HttpEndpoint
{
CanStartWorkflow = true,
Path = new Input<string>("/hello-world"),
SupportedMethods = new Input<ICollection<string>>(new[] { HttpMethods.Get })
},
new If
{
Condition = new Input<bool>(true),
Then = new Sequence(
new WriteLine("It's true!"),
new HttpEndpoint
{
Path = new Input<string>("/hello-world/true"),
SupportedMethods = new Input<ICollection<string>>(new[] { HttpMethods.Post })
},
new WriteLine("Let's continue")
),
Else = new WriteLine("It's not true!")
},
new WriteHttpResponse
{
StatusCode = new Input<HttpStatusCode>(HttpStatusCode.OK),
Content = new Input<string?>("Hello World!")
}
}
}
});
});
}
}

View file

@ -1,12 +1,10 @@
using System;
using Elsa.Activities.Console;
using Elsa.Activities.Workflows;
using Elsa.Contracts;
using Elsa.Models;
using Elsa.Modules.AzureServiceBus.Activities;
using Elsa.Modules.AzureServiceBus.Models;
using Elsa.Runtime.Contracts;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SQLitePCL;
namespace Elsa.Samples.Web1.Workflows;
@ -23,6 +21,7 @@ public class ReceiveMessageWorkflow : IWorkflow
{
new MessageReceived
{
CanStartWorkflow = true,
QueueOrTopic = new Input<string>("inbox"),
ReceivedMessageBody = new Output<object>(receivedMessage)
},