elsa-workflows / elsa-workflows/elsa-core
[BUG]Context.SetVariable not stored in Console application running WorkflowInstance
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
I dev a console application , call json workflow, but the ported WriteLine activity cannot get value of variable "CurrentIndex" from custom activity :
But run in ElsaServer is OK, the value of variable is right .
`if (iterateNode != null)
{
var currentValue = _pdfProcessor?.ExtractPageAsBytes((int)currentIndex, step);
var variable1 = new Variable("CurrentIndex", currentIndex).WithWorkflowStorage();
var variable2 = new Variable("CurrentValue", currentValue).WithWorkflowStorage();
var variables = new[]
{
variable1,
variable2
};
await context.ScheduleActivityAsync(iterateNode, OnChildCompleted, variables: variables);
}`
json workflow:
`{
"id": "59dabb480ee4c5b0",
"definitionId": "5b71a718ed245a04",
"name": "Workflow 1",
"createdAt": "2024-10-02T10:52:13.6914379+00:00",
"version": 1,
"toolVersion": "3.3.0.0",
"variables": [],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {},
"isReadonly": false,
"isSystem": false,
"isLatest": true,
"isPublished": false,
"options": { "autoUpdateConsumingWorkflows": false },
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "ff1084d568b1ff10",
"nodeId": "Workflow1:ff1084d568b1ff10",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"pdfFilePath": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "D:\\code\\doc-connector\\sample\\6.pdf"
}
},
"start": {
"typeName": "Int32",
"expression": {
"type": "Literal",
"value": "1"
}
},
"end": {
"typeName": "Int32",
"expression": {
"type": "Literal",
"value": "6"
}
},
"outerBoundInclusive": {
"typeName": "Boolean",
"expression": {
"type": "Literal",
"value": true
}
},
"step": {
"typeName": "Int32",
"expression": {
"type": "Literal",
"value": "1"
}
},
"body": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "1c1c84e22b833e86",
"nodeId": "Workflow1:ff1084d568b1ff10:ec5ba70d008eff4d:1c1c84e22b833e86",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"path": {
"typeName": "String",
"expression": {
"type": "CSharp",
"value": "$\u0022D:\\\\code\\\\doc-connector\\\\sample\\\\output\\\\{Variables.Get(\u0022CurrentIndex\u0022)}.pdf\u0022"
}
},
"pdfContent": {
"typeName": "ByteArray",
"expression": {
"type": "CSharp",
"value": "Variables.Get(\u0022CurrentValue\u0022)"
}
},
"id": "bd14720311c156e0",
"nodeId": "Workflow1:ff1084d568b1ff10:ec5ba70d008eff4d:1c1c84e22b833e86:bd14720311c156e0",
"name": "WriteToPDFFileActivity1",
"type": "e5d.doc.activities.WriteToPDFFileActivity",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -220,
"y": -540
},
"size": {
"width": 204.828125,
"height": 50
}
}
}
}
],
"connections": []
},
"currentValue": null,
"currentIndex": {
"typeName": "Object",
"memoryReference": { "id": "ec5ba70d008eff4d:output-current-index" }
},
"id": "ec5ba70d008eff4d",
"nodeId": "Workflow1:ff1084d568b1ff10:ec5ba70d008eff4d",
"name": "PDFForEachActivity1",
"type": "e5d.doc.activities.PDFForEachActivity",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -420,
"y": -660
},
"size": {
"width": 183.46875,
"height": 120
}
}
}
}
],
"connections": []
}
}`
Contributor guide
Assessment
This issue has not been assessed yet.