Saturday, January 8, 2011

Deploying Business Rules Programmatically

static void Main(string[] args)
{
if (args.Length < 1)
Console.WriteLine("Format: DeployPolicies.exe ");
else if (args[0] == "/u")
{
Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver rdd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();

//Undeploy specified policies
for (int i = 1; i < args.Length; i++)
{
string policyName = args[i];
RuleSetInfo rsi = new RuleSetInfo(policyName, 1, 0);
rdd.Undeploy(rsi);
RuleStore rs = rdd.GetRuleStore();
rs.Remove(rsi);
}
}
else
{
//import the BRL file and publish policies in the XML file
Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver rdd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
rdd.ImportAndPublishFileRuleStore(args[0]);

//deploy specified policies
for (int i = 1; i < args.Length; i++)
{
string policyName = args[i];
RuleSetInfo rsi = new RuleSetInfo(policyName, 1, 0);
rdd.Deploy(rsi);
}
System.Threading.Thread.Sleep(60000);
}
}

Ref:http://blogs.msdn.com/b/biztalkbre/archive/2007/02/16/sample-deploying-business-rules-programmatically.aspx

No comments:

Post a Comment