BizTalk 101 - Back to Basics

BizTalk & Connected Systems Patterns and Practices from Alan Smith in Stockholm
posts - 54, comments - 32, trackbacks - 121

My Links

News

Article Categories

Archives

Post Categories

Bloggers Guides

Show Me the Code

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!

 

  1. Select your orchestration file in the Solution Explorer.
  2. Create a copy of it (Ctrl+C, Ctrl+V).
  3. Select the copy and change the .odx to .cs, (select Yes in the warning box).
  4. Open the CS file in Visual Studio
  5. 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…

 

Print | posted on Friday, August 20, 2004 9:43 PM |

Feedback

Gravatar

# re: Show Me the Code

Hi Alan,

You could also choose "Open With", then "HTML/XML Editor". This way, you don't have to rename your file, and any CVS bindings will stay intact... :)
8/21/2004 7:14 AM | Martijn

Post Comment

Title  
Name  
Email
Url
Comment   

Powered by: