Showing posts with label BizTalk. Show all posts
Showing posts with label BizTalk. Show all posts

Sunday, January 2, 2011

UmAlQura Custom Functoid by using Biztalk Server 2010 and Visual Studio 2010

In this article I will create UmAlQura Custom Functoid same as Date functoid which already exists in the Mapping tools.
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


Wednesday, September 29, 2010

BizTalk 1 - Errors to avoid it

BizTalk Server 2009 not compatible with SQL Server 2008 R2 but it will be supported with BizTalk Server 2009 R2 (BizTalk 2010).
-------------------------------------------------------------------

If you want to use “Generate Schemas” with Visual Studio 2005 or 2008 and you got this error:
“DTD to XSD schema generation module is not installed .Execute :\Program File...”

To solve this error just do the following:
Go to this path C:\Program Files (x86)\Microsoft BizTalk Server 2009\SDK\Utilities\Schema Generator\ and copy the Microsoft.BizTalk.DTDToXSDGenerator.dll and Microsoft.BizTalk.WFXToXSDGenerator.dll and then paste it to C:\Program Files (x86)\Microsoft BizTalk Server 2009\Developer Tools\Schema Editor Extensions folder

-------------------------------------------------------------------
If you got Error details like this: The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted.

make sure you have the following :
  • BizTalk Application with Orchestration binding part scenario
  • Or If your BizTalk application does not have Orchestration part so then in send Port >> filter tab You have to determine the Receive Port name for example to determine which message will process by send port as the following :

-------------------------------------------------------------------
If you try to use Call Rule shape from orchestration and you get this error when you want to pass instance of message through the parameter Name (but Parameter  Name is disabled)


Make sure that the Fully Qualified Name of the vocabularies same as Document Type of Schema of instance message.