Update samples

This commit is contained in:
Sipke Schoorstra 2022-11-28 21:34:10 +01:00
parent 4fd2066c11
commit 84afa064e1
4 changed files with 74 additions and 2 deletions

View file

@ -0,0 +1,69 @@
using Elsa.Scheduling.Activities;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Activities;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Management.Models;
using Elsa.WorkflowServer.Web.Models;
namespace Elsa.WorkflowServer.Web.Activities;
[Activity("Demo", "Models the entire process of ordering, preparing, and delivering a pizza.")]
public class GetPizza : Composite<Pizza>
{
[Input(
UIHint = InputUIHints.Dropdown,
Options = new[] { "Margaritha", "Funghi", "Veggie", "Carbonara", "Pepperoni", "Hawai" }
)]
public Input<string> Flavor { get; set; } = default!;
[Input(
UIHint = InputUIHints.Dropdown,
Options = new[] { 20, 30, 40, 80 }
)]
public Input<int> Size { get; set; } = default!;
public GetPizza()
{
Root = new Sequence
{
Activities =
{
new WriteLine("Submitting order..."),
Delay.FromSeconds(2),
new WriteLine("Order submitted"),
Delay.FromSeconds(2),
new Fork
{
JoinMode = ForkJoinMode.WaitAll,
Branches =
{
new Sequence
{
Activities =
{
new WriteLine("Heating oven..."),
Delay.FromSeconds(10),
new WriteLine("Oven heated."),
}
},
new Sequence
{
Activities =
{
new WriteLine("Preparing dough and toppings..."),
Delay.FromSeconds(5),
new WriteLine("Pizza ready for heating."),
}
}
}
},
new WriteLine("Heating pizza in oven..."),
Delay.FromSeconds(5),
new WriteLine("Pizza is ready for delivery!"),
Delay.FromSeconds(1),
From(context => context.Set(Result, new Pizza(Size.Get(context), Flavor.Get(context)))),
}
};
}
}

View file

@ -0,0 +1,3 @@
namespace Elsa.WorkflowServer.Web.Models;
public record Pizza(int Size, string Flavor);

View file

@ -31,7 +31,7 @@ public static class ForEachWorkflow
{
// The strategy determines whether the workflow should suspend or wait synchronously.
// For console applications without a host, long-running workflows aren't supported, so we use the Blocking strategy.
Strategy = new Input<DelayBlockingStrategy>(DelayBlockingStrategy.Blocking),
Strategy = DelayBlockingStrategy.Blocking,
TimeSpan = new Input<TimeSpan>(TimeSpan.FromMilliseconds(250))
}
}

View file

@ -31,7 +31,7 @@ public static class ForWorkflow
{
// The strategy determines whether the workflow should suspend or wait synchronously.
// For console applications without a host, long-running workflows aren't supported, so we use the Blocking strategy.
Strategy = new Input<DelayBlockingStrategy>(DelayBlockingStrategy.Blocking),
Strategy = DelayBlockingStrategy.Blocking,
TimeSpan = new Input<TimeSpan>(TimeSpan.FromSeconds(1))
}
}