My environment includes the following tools:
Windows 7 64 bit
Visual Studio 2010
SQL Server 2008 R2
BizTalk Server 2010
So let's start by the following steps:
First Step:
- Create Class Library called "UmAlQura_CF" with class named " UmAlQuraConverter.cs"
- Add a strong –named key "key.snk"
- Add Resource file called "UmAlQura_FC_Resource.resx" which include these properteies:
- Name (string)
- Description(stirng)
- Tooltip(string)
- UmAlQura(Image)
- Add this Assembly as Reference
- Microsoft.BizTalk.BaseFunctoids.dll" from this path C:\Program Files (x86)\Microsoft BizTalk Server 2010\Developer Tools
So the Project structured as following:
Second Step:
Write this code to UmAlQuraConverter.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.BizTalk.BaseFunctoids;
using System.Reflection;
using System.Globalization;
namespace UmAlQura_CF
{
/// <summary>
/// Inherit from BaseFunctoid Abstract class
/// </summary>
public class UmAlQuraConverter : BaseFunctoid
{
public UmAlQuraConverter()
{
//ID of the functoid
this.ID = 20000;
//Resource file for the functoid
SetupResourceAssembly("UmAlQura_CF.UmAlQura_FC_Resource", Assembly.GetExecutingAssembly());
//Set Resource's Properties of the functoid
//Name of functoid
SetName("Name");
//Tooltip of functoid
SetTooltip("Tooltip");
//Description of functoid
SetDescription("Description");
//Image of functoid
SetBitmap("UmAlQura");
//Set Max Params
this.SetMaxParams(1);
//Set the name of function to call when the functoid used.
SetExternalFunctionName(GetType().Assembly.FullName, "UmAlQura_CF.UmAlQuraConverter", "UmAlQuraConverterFunction");
//Determine in which Category the functoid will appear
this.Category = FunctoidCategory.DateTime;
//Determine the type of node to which the output and input can be connected
this.OutputConnectionType = ConnectionType.AllExceptRecord;
AddInputConnectionType(ConnectionType.All);
}
//Function of convert the current date to UmAlQura Date
public string UmAlQuraConverterFunction(string dateFormat)
{
DateTime date = DateTime.Now;
UmAlQuraCalendar umAlQuraCal = new UmAlQuraCalendar();
CultureInfo umAlQuraCulture = new CultureInfo("ar-SA");
umAlQuraCulture.DateTimeFormat.Calendar = umAlQuraCal;
//return the current UmAlQura date wiht User inserted format
return date.ToString(dateFormat, umAlQuraCulture);
}
}
}
Then build the project.
Third Step:
- Add UmAlQura_CF.dll to GAC
- Copy UmAlQura_CF.dll to this path C:\Program Files (x86)\Microsoft BizTalk Server 2010\Developer Tools\Mapper Extensions
Forth Step:
- Create new BizTalk Server Project from Visual studio 2010
- Create new Schema called " TestSchema.xsd " with Date element
- Create new Map called " TestMap.btm" and then add " TestSchema.xsd" as source and destination file for purpose of testing
- Then open the map file and go to Toolbox and Right click and Choose items…
- Go to BizTalk Mapper Functoids and browse to this path C:\Program Files (x86)\Microsoft BizTalk Server 2010\Developer Tools\Mapper Extensions and select the UmAlQura_CF.dll
- Add UmAlQura Converter control to the grid preview and set the params
Right click on the map file and then test it.
done
1 comment:
Hi
Great post, I was wondering if there is a way to name the parameters so that they are more descriptive instead of input[x].
Mr T
Post a Comment