Passing an Array of Facts into the Rules Engine

Passing an Array of Facts into the Rules Engine (BizTalk 2004)

The last piece of the puzzle for me in working with generic messages to do away with a TON of duplication is to dynamically call a rules policy to validate outbound EDI messages.

This is some sample code I found on the blog mentioned above:

//System.Collections.ArrayList List;
sCon = “Initial Catalog=Northwind;Data Source=(local);Integrated Security=SSPI;”;
con = new System.Data.SqlClient.SqlConnection(sCon);
dcNorthwind = new Microsoft.RuleEngine.DataConnection(“Northwind”, “ShipperCountry”, con);
List.Add(dcNorthwind);

xmlDocument = msgShippingRequest;
typedXmlDocument = new Microsoft.RuleEngine.TypedXmlDocument(“RoleLinkSample.ShippingRequest”,xmlDocument);
policy = new Microsoft.RuleEngine.Policy(“ShippingPolicy”);
List.Add(typedXmlDocument);

policy.Execute(List.ToArray());
msgOutgoingShippingRequest = typedXmlDocument.Document;
policy.Dispose();
typedXmlDocument = null;
dcNorthwind = null;

This sample is based on Biztalk 2004, but should not differ in this instance for Biztalk 2006.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s