Spotlight on BizTalk 2006 Custom Functoid

A very important topic I will talk about which is how to develop a custom functoid. Especially Developing a Custom Referenced Functoid.

A Custom Referenced Functoid!!! You mean there are other types of custom functoid.
Yes, there are three types. Let us define them

A Custom Referenced Functoid: Custom referenced functoids do not copy implementation code inline into the map. Instead, a reference to the assembly, class, and method is placed in the extension object file associated with the generated style sheet and called at run time.


A Custom Inline Functoid: Custom inline functoids provide functionality by copying implementation code directly into a map and not by referencing an assembly, class, and method name like a custom referenced functoid.

A Custom Cumulative Functoid: Use a custom cumulative functoid to perform accumulation operations for values that occur multiple times within an instance message.
Now after you knowing what the types of Custom Functoids are, let us develop our custom referenced functoid.


Note #1: all custom functoids must derive from the BaseFunctoid class. You must first override the constructor and make a set of calls that tell BizTalk Mapper about your custom functoid. Then you need to write the functoid logic
Fine, our custom functoid name Percentage, which will calculate the percentage where it takes two input parameters.

1) Fine, create a new project its type is class library and name it CustomFunctoid


2) Add a reference of Microsoft.BizTalk.BaseFunctoids you can find it here :
X:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Microsoft.BizTalk.BaseFunctoids.dll (where X the drive that holds the installation of BizTalk server 2006)


3) let you class implement from BaseFunctoid
public class Percentage : BaseFunctoid


4) let the constructor override the base
public Percentage(): base()


5) write the following line of code in the construction :

this.ID = 3003;
SetupResourceAssembl("CustomFunctoid.CustomFunctoidResource",
System.Reflection.Assembly.GetExecutingAssembly());
SetName("PERCENTAGE_NAME");
SetTooltip("PERCENTAGE_TOOLTIP");
SetDescription("PERCENTAGE_DESCRIPTION");
SetBitmap("PERCENTAGE_BITMAP");
this.SetMinParams(2);
this.SetMaxParams(2);
SetExternalFunctionName(GetType().Assembly.FullName, "CustomFunctoid.Percentage", "CalculatePercentage");
this.Category = FunctoidCategory.Math;
AddInputConnectionType(ConnectionType.AllExceptRecord);
AddInputConnectionType(ConnectionType.AllExceptRecord);
this.OutputConnectionType = ConnectionType.AllExceptRecord;

Where:


· ID: Assign a unique ID to the functoid


· SetupResourceAssembly: Point to the resource assembly
NOTE #2: Include a resource file with your project. If building with Visual Studio, the resource assembly must be ProjectName.ResourceName. Example: Our resource file named CustomFunctoidResource which includes the value of name, tooltip , description, and the Icon of our custom Functoid , and our project named CustomFunctoid


· SetName , SetTooltip , SetDescription, SetBitmap: set the name , tooltip , description and the icon of our custom functoid

· SetMinParams, SetMaxParams: Specify the number of parameters accepted , where SetMinParams is used to set the number of required parameters and the SetMaxParams is used to method to set the number of optional parameters

· SetExternalFunctionName: Tell BizTalk Server which methods to invoke for your functoid

· Category: Assign the functoid to one or more categories, for example Math, String, MassCopy…etc.
· AddInputConnectionType : Declare what can connect to your functoid

· OutputConnectionType : Declare what your functoid can connect to


6)Now create the function that will calculate the percentage which is :


public float CalculatePercentage(float x, float y)
{
float c = float.MinValue;
c = (x / y) * 100;
return c;
}

7) Create a Strong key , and Assign it to your class library


8) Build the Class Library and copy the DLL to : X:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Mapper Extensions (where X is the drive that holds the installation of BizTalk Server 2006)

9) Add this dll it to the GAC ( open the Visual Studio 2005 Command Prompt and type GACUTIL –i X:\CustomFunctoid.dll)


10) Add it to the ToolBox in Visual Studio 2005 (right click on the ToolBox, choose Add/Remove items, click the Functoids tab and browse to the Customfunctoid.dll file and make sure it’s checked.


you can download the whole project from here

0 Response to "Spotlight on BizTalk 2006 Custom Functoid"