elsa-core/src/bundles/Elsa.Server.Web/SampleWorkflow.cs
Sipke Schoorstra 2e1ed995da Add synchronous serialization methods and mark async as obsolete
Implemented synchronous methods for serialization and deserialization while marking the asynchronous methods as obsolete across various storage and serialization services. This includes updates to handle serialization within the Save and Load methods, enhancing performance by avoiding unnecessary Task usage.
2024-09-27 12:59:59 +02:00

41 lines
1.2 KiB
C#

using Elsa.Expressions.Models;
using Elsa.Extensions;
using Elsa.Scheduling.Activities;
using Elsa.Workflows;
using Elsa.Workflows.Activities;
using Elsa.Workflows.Contracts;
namespace Elsa.Server.Web;
public class SampleWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
// The WithVariable method ensures that the created variable will be added to the Workflow's Variables collection, which is required for persistent variables.
var variable1 = workflow.WithVariable<string>("Foo").WithWorkflowStorage();
workflow.Variables =
[
variable1
];
workflow.Root = new Sequence
{
Activities =
{
new StartAt(DateTimeOffset.UtcNow + TimeSpan.FromSeconds(5))
{
CanStartWorkflow = true
},
new WriteLine(variable1),
new SetVariable
{
Variable = variable1,
Value = new (Literal.From("Bar"))
},
new Delay(TimeSpan.FromSeconds(1)),
new WriteLine(variable1)
}
};
}
}