diff --git a/src/bundles/Elsa.WorkflowServer.Web/Activities/GetPizza.cs b/src/bundles/Elsa.WorkflowServer.Web/Activities/GetPizza.cs new file mode 100644 index 000000000..ea3d6ca6e --- /dev/null +++ b/src/bundles/Elsa.WorkflowServer.Web/Activities/GetPizza.cs @@ -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 +{ + [Input( + UIHint = InputUIHints.Dropdown, + Options = new[] { "Margaritha", "Funghi", "Veggie", "Carbonara", "Pepperoni", "Hawai" } + )] + public Input Flavor { get; set; } = default!; + + [Input( + UIHint = InputUIHints.Dropdown, + Options = new[] { 20, 30, 40, 80 } + )] + public Input 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)))), + } + }; + } +} \ No newline at end of file diff --git a/src/bundles/Elsa.WorkflowServer.Web/Models/Pizza.cs b/src/bundles/Elsa.WorkflowServer.Web/Models/Pizza.cs new file mode 100644 index 000000000..c4ec7d760 --- /dev/null +++ b/src/bundles/Elsa.WorkflowServer.Web/Models/Pizza.cs @@ -0,0 +1,3 @@ +namespace Elsa.WorkflowServer.Web.Models; + +public record Pizza(int Size, string Flavor); \ No newline at end of file diff --git a/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForEachWorkflow.cs b/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForEachWorkflow.cs index 2f8c0f5c1..79d80c3ff 100644 --- a/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForEachWorkflow.cs +++ b/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForEachWorkflow.cs @@ -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.Blocking), + Strategy = DelayBlockingStrategy.Blocking, TimeSpan = new Input(TimeSpan.FromMilliseconds(250)) } } diff --git a/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForWorkflow.cs b/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForWorkflow.cs index c1ee6f513..81ab7a12b 100644 --- a/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForWorkflow.cs +++ b/src/samples/console/Elsa.Samples.LoopingWorkflows/Workflows/ForWorkflow.cs @@ -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.Blocking), + Strategy = DelayBlockingStrategy.Blocking, TimeSpan = new Input(TimeSpan.FromSeconds(1)) } }