Skip to content
Snippets Groups Projects
Commit 51ac5c40 authored by Recolic K's avatar Recolic K
Browse files

bug fix: wrap one-activity workflow with a SEQ

parent dac6d5ae
No related branches found
No related tags found
No related merge requests found
Pipeline #893 passed with stage
...@@ -160,9 +160,10 @@ namespace CIS { ...@@ -160,9 +160,10 @@ namespace CIS {
bool prevOperationIsSequential = true; bool prevOperationIsSequential = true;
rlib::string xamlCode; rlib::string xamlCode;
// For a long expression A >> B >> C >> D, A is in xamlCode, and [B,C,D] are cached in queuedOnRight to wait for merge. // If representing a long expression A >> B >> C >> D, A is in xamlCode, and [B,C,D] are cached in queuedOnRight to wait for merge.
std::list<rlib::string> queuedOnRight; std::list<rlib::string> queuedOnRight;
// Consumes this and seqNext, and create a new Flow representing the merged Flow.
Flow binaryOperation(Flow seqNext, bool thisOperationIsSequential) const { Flow binaryOperation(Flow seqNext, bool thisOperationIsSequential) const {
Flow result = *this; Flow result = *this;
result.reduceQueuedIfNecessary(thisOperationIsSequential); result.reduceQueuedIfNecessary(thisOperationIsSequential);
...@@ -176,6 +177,8 @@ namespace CIS { ...@@ -176,6 +177,8 @@ namespace CIS {
return result; return result;
} }
// If we are going to perform a different binary operation, we need to merge xamlCode and queuedOnRight into this.xamlCode, to keep the queue clear.
// If we are going to perform the previous binary operation again, we don't need to reduce the queue, and this function does nothing.
void reduceQueuedIfNecessary(bool thisOperationIsSequential) { void reduceQueuedIfNecessary(bool thisOperationIsSequential) {
if(thisOperationIsSequential == prevOperationIsSequential || queuedOnRight.empty()) return; if(thisOperationIsSequential == prevOperationIsSequential || queuedOnRight.empty()) return;
rlib::string resultXaml = prevOperationIsSequential ? templates::SEQ_BEGIN : templates::PAR_BEGIN; rlib::string resultXaml = prevOperationIsSequential ? templates::SEQ_BEGIN : templates::PAR_BEGIN;
...@@ -231,7 +234,14 @@ namespace CIS { ...@@ -231,7 +234,14 @@ namespace CIS {
inline auto Flow::generateXaml(Metadata metadata) const { inline auto Flow::generateXaml(Metadata metadata) const {
Flow finalized(*this); Flow finalized(*this);
finalized.reduceQueuedIfNecessary(!finalized.prevOperationIsSequential); // Always necessary if queue is not empty. if(finalized.queuedOnRight.empty()) {
// If the queue is empty, it means there is only one activity in the workflow.
// We must wrap it with a SEQuence, or CIS will fail with internal error.
finalized.xamlCode = templates::SEQ_BEGIN + finalized.xamlCode + templates::SEQ_END;
} else {
// Merge all pending elements into one.
finalized.reduceQueuedIfNecessary(!finalized.prevOperationIsSequential);
}
return metadata.generateXamlHead() + dirty_plugins::patchGS(finalized.xamlCode) + metadata.generateXamlTail(); return metadata.generateXamlHead() + dirty_plugins::patchGS(finalized.xamlCode) + metadata.generateXamlTail();
} }
inline auto Flow::generateXaml(std::string className) const { inline auto Flow::generateXaml(std::string className) const {
......
...@@ -6,6 +6,6 @@ int main() { ...@@ -6,6 +6,6 @@ int main() {
.addInputSetting("RunAsDaemon", "true") .addInputSetting("RunAsDaemon", "true")
; ;
println(to_file("AlarmingDaemonWorkflow.xaml"), flow.generateXaml("Microsoft.Office.FleetAGC.Workflows.AlarmingDaemonWorkflow")); println(to_file("AlarmingDaemonWorkflow.xaml"), flow.generateXaml("FleetAGC.Workflows.AlarmingDaemonWorkflow"));
} }
#include <cis-workflow-gen/quick-include.hpp>
int main() {
Flow flow =
Activity("SendEmail", "FleetAGC.Activities.SendEmailActivity")
.addInputSetting("to", CS(GlobalSettings["to"]))
.addInputSetting("title", CS(GlobalSettings["title"]))
.addInputSetting("content_b64", CS(GlobalSettings["content_b64"])) >> Noop("Noop")
;
println(to_file("SendEmailActivityWorkflow.xaml"), flow.generateXaml("M365AGCBuildout.Workflows.SendEmailActivityWorkflow"));
}
...@@ -89,7 +89,7 @@ __TEMPLATE_ARG_XtraNamespaces </sco:Collection> ...@@ -89,7 +89,7 @@ __TEMPLATE_ARG_XtraNamespaces </sco:Collection>
<AssemblyReference>System.Xml</AssemblyReference> <AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference> <AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference> <AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>Microsoft.Office.FleetAGC.Activities</AssemblyReference> <AssemblyReference>FleetAGC.Activities</AssemblyReference>
__TEMPLATE_ARG_XtraAssemblies </sco:Collection> __TEMPLATE_ARG_XtraAssemblies </sco:Collection>
</TextExpression.ReferencesForImplementation> </TextExpression.ReferencesForImplementation>
)XAML"; )XAML";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment