Update samples
This commit is contained in:
parent
4fd2066c11
commit
84afa064e1
69
src/bundles/Elsa.WorkflowServer.Web/Activities/GetPizza.cs
Normal file
69
src/bundles/Elsa.WorkflowServer.Web/Activities/GetPizza.cs
Normal 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)))),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
3
src/bundles/Elsa.WorkflowServer.Web/Models/Pizza.cs
Normal file
3
src/bundles/Elsa.WorkflowServer.Web/Models/Pizza.cs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
namespace Elsa.WorkflowServer.Web.Models;
|
||||
|
||||
public record Pizza(int Size, string Flavor);
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue