I don’t know about you, but having been working with code most of my life, I seem to think better when looking at code. Working with the orchestration designer is great, but when you have a complex orchestration, with a bunch of loops, decisions, and expression shapes with a few lines of code in them, it’s hard to get a grip on exactly what’s happening in the orchestration. Wouldn’t it be great to get a view of the orchestration, as it would look in code, with all the loop conditions, decision rules, and expression shape code included. It’s pretty easy to do actually!
- Select your orchestration file in the Solution Explorer.
- Create a copy of it (Ctrl+C, Ctrl+V).
- Select the copy and change the .odx to .cs, (select Yes in the warning box).
- Open the CS file in Visual Studio
- There you go!
(You should exclude this rogue C# file from your project before you build!)
Here’s an example of a message re-sequencer I am working on, I chopped out all the DesignerPosition attributes so it’s a bit cleaner, this is the body method:
body ()
{
activate receive (OrderRcvPort.Operation_1, OrderInMsg, initialize SupplierIDCorrSet);
messageStore = new MessageUtils.MessageStore();
sequenceID = 1;
checkStore = true;
sequenceComplete = false;
while (sequenceID < 6)
{
if (OrderInMsg.SequenceID == sequenceID)
{
send (OrderSndPort.Operation_1, OrderInMsg);
sequenceID = sequenceID + 1;
}
else
{
messageStore.AddMessage (OrderInMsg.SequenceID, OrderInMsg);
}
checkStore = true;
while (checkStore)
{
if (messageStore.MessageInStore (sequenceID))
{
construct OrderFromStoreMsg
{
OrderFromStoreMsg = messageStore.GetMessage (sequenceID);
}
send (OrderSndPort.Operation_2, OrderFromStoreMsg);
sequenceID = sequenceID + 1;
}
else
{
checkStore = false;
}
}
if (sequenceID < 6)
{
receive (OrderRcvPort.Operation_1, OrderInMsg, SupplierIDCorrSet);
}
}
}
The temptation to re-name an .odx file to .cs, modify the orchestration using code, then re-name it back could prove too great. It sounds dangerous, (don’t try this at work), I’ll let you know how I get on…