elsa-core
elsa-core copied to clipboard
[BUG] Context.SetVariable not stored in WorkflowInstance
Description
When using the Context.SetVariable
the variable is not stored after the workflow was suspended. The storage provider is the WorkflowStorageDriver
.
Steps to Reproduce
Using the following snippet to reproduce
public class CreateVariableActivity : CodeActivity
{
protected override void Execute(ActivityExecutionContext context)
{
var variable = context.SetVariable("Foo", "Bar");
Console.Write(variable.StorageDriverType);
}
}
public class ReadVariableActivity : CodeActivity<string>
{
protected override void Execute(ActivityExecutionContext context)
{
var foo = context.GetVariable<string>("Foo");
Result.Set(context, foo);
}
}
class SampleWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
var variable1 = new Variable<string>();
workflow.Root = new Sequence
{
Variables =
{
variable1
},
Activities =
{
new CreateVariableActivity(),
new Delay(TimeSpan.FromSeconds(5)),
new ReadVariableActivity
{
Result = new(variable1)
},
new WriteLine(variable1)
}
};
}
}
Expected Behavior
For the variable to return "Bar"
Actual Behavior
The variable is null