Solving the "If-Then-Else" problem in a map – part I

Solving the "If-Then-Else" problem in a map – part I

Hi all

I have often wondered why the built-in functoids doesn’t encompass an If-Then-Else
functoid. The Value Mapping functoid only has an If-Then-part and not the Else-part.

This is the first of two blog posts. This post will explore how to solve the issue
with the built-in functionality of BizTalk. The next post will be about creating a
custom functoid to do the job instead and the issues that come with this task.

So, using the built-in functionality:

Imagine this input schema:

IfThenElseInputSchema

And imagine this output schema:

IfThenElseOutputSchema

My goal, now is to create a map that will map the value of the “ifJan” element to
the destination IF the “qualifier” element equals the word “Jan” and otherwise the
value of the “ifNotJan” element should be mapped.

So basically, given this input:

<ns0:IfThenElseInput xmlns:ns0=”http://IfThenElse.IfThenElseInput”>
  <qualifier>Jan</qualifier>
  <ifJan>ifJan</ifJan>
  <ifNotJan>ifNotJan</ifNotJan>
</ns0:IfThenElseInput>

I want this output:

<ns0:IfThenElseOutput xmlns:ns0=”http://IfThenElse.IfThenElseOutput”>
  <field>ifJan</field>
</ns0:IfThenElseOutput>

And given this input:

<ns0:IfThenElseInput xmlns:ns0=”http://IfThenElse.IfThenElseInput”>
  <qualifier>NotJan</qualifier>
  <ifJan>ifJan</ifJan>
  <ifNotJan>ifNotJan</ifNotJan>
</ns0:IfThenElseInput>

I want this output:

<ns0:IfThenElseOutput xmlns:ns0=”http://IfThenElse.IfThenElseOutput”>
  <field>ifNotJan</field>
</ns0:IfThenElseOutput>

Using a map and the built-in functoids, that would look like this:

 IfThenElseMap_Functoids

Basically, you need one value mapping functoid for each possible value to pass on,
and a logical functoid for each value as well, to use in the value mapping functoid.
The “String Concatenate” functoid is just my way of returning the string to use for
the qualifier – in this case: “Jan”.

You can also do it using one scripting functoid like this:

IfThenElseMap_Scripting_XSLT

where the scripting functoid is an “Inline XSLT Call Template” scripting type, and
the script looks likes this:

<xsl:template name=”IfThenElse”>
  <xsl:param name=”qualifier” />
  <xsl:param name=”ifJan” />
  <xsl:param name=”ifNotJan” />
  <xsl:element name=”field”>
    <xsl:choose>
      <xsl:when test=”$qualifier=’Jan'”>
        <xsl:value-of select=”$ifJan” />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select=”$ifNotJan” />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:element>
</xsl:template>

Now… IF my good friend Henrik Badsberg is reading this, then by now he is screaming:
“USE A BLOODY C# SCRIPTING FUNCTOID!!!!!” 🙂

This, naturally is also an option:

IfThenElseMap_Scripting_CSharp

with an “Inline C#” script containing this script:

public string IfThenElse(string qualifier, string ifJan, string ifNotJan)
{
  if (qualifier == “Jan”)
    return ifJan;
  else
    return ifNotJan;
}

Both scripting solutions can be altered to accept the output of a logical functoid
as the first input. Just change the string “Jan” to “true” in the scripts, and change
the name of the parameter if you want.

Now then… I am not a big fan of either of these three options. Generally, I avoid
scripting functoids when I can because it is difficult for a new developer to know
what is happening when he opens the map because he will have to open up all scripting
functoids and find out (and remember) what they do. Also, I am not really a big fan
of the first solution either. First of all, there are too many functoids, and it can
messy if this solution is needed several times in a map. Secondly, you get a warning
every time you compile, because you have two inputs to one element.

You can find my project with the three working maps here.

In my next post, I will look into creating a custom functoid that does the job and
I can tell you right now; That isn’t as easy as I had imagined…

—

eliasen

BizTalk vs Dublin – Do Not Get Confused

I was reading an interesting blog post today called Will Dublin Replace BizTalk?

It got me thinking more about this and I wrote up the response below.  I would love to hear other peoples comments and thoughts on this.  I see a clear separation on when you would use BizTalk vs when you would use Dublin.  I see a great story going forward with both technologies working together.  

I welcome comments and feedback on this. 

Comment on “Will Dublin Replace BizTalk?” blog post:

“I like your article on Dublin and BizTalk but wanted to comment on a few parts.

As someone who makes a living working with BizTalk Server my ears perk up when I hear “it is going away”. I heard this same kind of talk three years ago when Microsoft introduced Workflow in .Net 3.0. I for one was confused about how Workflow would fit in with BizTalk. And now, BizTalk is bigger and stronger than ever.

Why? Because it does a great job inside the enterprise for the scenarios it is designed to address such as system and application integration, connectivity, transformation, and monitoring, just to name a few.

What I see Dublin (and .Net 4.0) doing is taking some of the best features of BizTalk and making them accessible to other parts of the enterprise that might not have requirements that call for a full and robust Integration Server. With Dublin specifically, it is the management and monitory concepts from BizTalk that we can see inside the Dublin code from PDC.

Will there be scenarios that now make more sense in a Dublin environment than BizTalk? Of course. Will all scenarios fit into Dublin – not a chance.

Even today I hear the question, “Why would we pay for BizTalk?” And for some customers BizTalk is not the right answer. For those customers they will now have Dublin to look at rather than having to custom build a solution.

It often comes down to a cost to buy vs. cost to build analysis. On an individual project basis this sometimes becomes a difficult decision. When you think enterprise wide, typically the cost to buy a supportable product with a core set of features is the better answer. With BizTalk, you get adapters, high availability, robust development tools, EDI, RFID, flat file parsing, administration, BAM, etc. While some of these items are being moved further down into the stack, not all of them will be.

The buy vs. build analysis will become more difficult. I think that is a good thing. The end goal is to do more with less and to lower the cost for consistently delivering supportable and maintainable code that meets the requirements. I think Dublin (and .Net 4.0) helps us down that road. In my mind, I’ll always see a need for BizTalk and will continue to recommend it to my clients as a core component in the enterprise when it makes sense.

I do not foresee a world without BizTalk, but I am excited about the world with options that include BizTalk and Dublin.

If you are looking for more information on Dublin, I have a screen cast available (http://www.biztalkgurus.com/media/p/21919.aspx) and a high level visual review of Dublin (http://www.biztalkgurus.com/blogs/biztalk/archive/2008/11/10/first-look-screen-shots-of-windows-application-server-dublin.aspx) available on my web site.

Stephen W. Thomas
www.BizTalkGurus.com“

Two Workflow Foundation 4.0 Webcasts

I’ve just published a couple of webcasts looking at Workflow Foundation 4.0.
WF 4.0 Sequential Workflow Designer
This webcast takes a look at the new designer in WF 4.0 and features simple workflows to input and output data. It also focuses on the new DbUpdate activity and shows how it can be used to insert data to a SQL database (modelled in “M” of course 🙂 from a workflow.
Building Custom Activities in WF 4.0

This webcasts focuses on developing custom activities for WF 4.0 and also at using the new WPF activity designer. We start off with a simple WriteLine activity, then add aWPF based designer to allow properties to be edited in the workflow designer. We then look at creating a custom While activity that can be used to create a loop in a workflow (actually quite useful as there is no while activity in the toolbox at present.

BizTalk presentation for the Aalborg .NET User Group

Hi all

On October 29’th I did a BizTalk presentation for the Aalborg
.NET User Group. It was the first in AANUG, so it makes sense that the topic should
be the best topic ever 🙂

Those who were present will remember that I completely broke the time frame I was
bound by, and didn’t even make it all the way through my presentation.

Weird, how I always get side tracked when I talk about something I am good at and/or
like 🙂

Anyway, this blog post has two purposes:

  1. Just a little more advertising for Aalborg
    .NET User Group. If you live close by, sign up and come to our meetings
  2. To make the slides available.

    They can be found here.

    Only in Danish, I am afraid.

—

eliasen

Moving Directories in a SVN Repository using Tortoise SVN

Moving a directory that is already under SVN using Tortoise SVN isn’t as straightforward as this question and answer on Stackoverflow.com appears to suggest – the SVN Move versioned files here option isn’t always available…
So how do you move versioned directories to another location in the repository?

Create the new directory and add that directory to […]

Teach Yourself DSL-Tools

Finally!! We now have an end-to-end walk-through published on Code Gallery. According to Jean-Marc Prieur, the author of the lab,
“The idea is that, if you complete this Lab until the end, you’ll be able to create your own modeling graphical designers using the DSL Tools technology, and the code generator that will generate code, documentation, […]

StringReplace functoid added to collection

Hi all

So, I have just added one more functoid to the collection of functoids. This time,
I have added a string replace functoid, as I think that is really missing from the
standard functoids that BizTalk supplies.

You can get version 3 of my functoid collection here: http://www.eliasen.eu/DownloadSoftware.aspx

And for those of you that are not bothered to read further on the download page than
the download section, let me just repeat some text from the download page:

— BEGIN QUOTE

As you can probably see from my extremely lousy icons, layouts, and so on, graphics
really isn’t one of my strong sides. So if you are good at creating icons and so on,
and would like to help me with this part, please contact me.

— END QUOTE

—

eliasen

Styling a Silverlight Twitter Application with Expression Blend 2

Styling a Silverlight Twitter Application with Expression Blend 2

Silverlight 2 provides a rich platform for building cross-browser/cross-platform RIA applications. 

One of the things that makes Silverlight so powerful is the ease with which developers and designers can collaborate together on projects.  Developers can use Visual Studio to open and edit Silverlight 2 projects and get a powerful code-focused .NET development environment, and designers can use Expression Blend 2 SP1 to open and edit the exact same project and use a creative tool to sculpt and create optimal user experience designs.

The WPF UI framework shipped in Silverlight further enables a great designer/developer workflow by supporting concepts like layout management, controls, styles, templates, and resources – which help avoid scenarios where designers and developers end up tripping over each other when integrating functionality, behavior and expressive design.

Silverlight 2 Twitter Sample

Last month I posted an in-depth blog tutorial on how to build a Silverlight 2 Digg application which you can read here.  This tutorial was aimed primarily at developers, and focused on introducing the fundamental programming concepts involved when building a Silverlight 2 application. 

Today Celso Gomes and Peter Blois posted a cool 10 minute video tutorial that shows off using Expression Blend to stylize a Silverlight 2 Twitter Messenger application.  You can watch the video here.  You can download the source code for the completed Silverlight Twitter application here.

The video does a nice job demonstrating how designers can re-style a Silverlight application without having to mess with the code behind it.  In the process it shows some of the power and capability that Expression Blend 2 provides to build really rich user experiences.  Celso starts with a developer version of the application, and then customizes and sculpts the UI to have a fun twitter character theme:

The Application Model

The Silverlight Twitter client is hosted within an ASP.NET server application that exposes a web service that enables the Silverlight Twitter application to communicate to the Twitter service (since Twitter does not allow direct access from client applications). Communication between the Silverlight client and the ASP.NET web server is done using Windows Communication Foundation (WCF).

The client application uses a Model-View-Presenter (MVP) pattern (also known as the Model-View-ViewModel pattern) which is commonly used in large WPF applications. Even though this is a fairly simple application they wanted to take advantage of the flexibility that MVP allows and allow room for future growth. 

Maintaining the separation between the visuals and the application logic also enables designers to make fairly complex visual changes without impacting the basic application flow.  The video goes through some examples of the styling flexibility this architecture facilitates.

The Styling Process

In the video, Celso highlights how Resources can help designers quickly change colors.  A common Brush Resource, for example, can be used to change the color of all the text elements in the application:

Celso shows how easy is to create new User Controls from graphics using Expression Blend 2 SP1 (just select multiple elements in the designer, right-click, and choose the "Make Control" menu option):

And also how to create new states inside this new User Control (using the Visual State Manager feature – which is also now supported with WPF), to animate the bird (fly, blink, etc…)

Celso also shows how to create animations for each state, changing advanced properties like Key Spline curves, and Repeat Behavior:

He also shows how to create custom buttons from drawings (which can come from XAML or any other design tool like Photoshop or Illustrator). All the states of a Button Control are available out of the box.

Expression Blend also enables you to easily change complex controls like List Boxes. Designers have access to all Styles, Templates, and states – and can completely customize all the parts of a List Box without having to write any code:

You can watch the video and download the code to check out the above Twitter application.

To learn more about Expression Blend, I also recommend watching the Expression Blend: Tips and Tricks presentation from the PDC conference two weeks ago.

Update: Also check out Shawn Wildermuth’s Deep Control Skinning with Styles webcast.

Hope this helps,

Scott