Biztalk development tips-. Net calls BizTalk Business Rule Engine
Biztalk Business Rule Engine: Biztalk business rule engine. Its main function and feature are to dynamically configure policy information and modify policy logic without changing the process or re-deploying the project. achieve dynamic business configuration. Similar to WF, the working principle is similar.
This is the application in. Net windows form.ProgramCall BizTalk business rule engine to configure business rules.
Lab scenario:
A simple example of a simulated reimbursement review is provided. If the reimbursement amount is less than or equal to the amount, the application is approved.
Source code
Private
VoidButton#click (ObjectSender,RoutedeventargsE)
{
Biztalkrules. expenses.ExpenseclaimClaim =NewBiztalkrules. expenses.Expenseclaim()
{
Amount =Convert. Toint32 (This. Textamount. Text ),
Category =This. Cobcategory. Text,
Department =This. Cbodepartment. Text,
Description =This. Textdescription. Text,
Name =This. Textname. Text,
Project =This. Textproject. Text
};
If(Claim. Category ="Software"& Claim. Amount <= 500)
{
Claim. Status ="Approved";
}
Else
If(Claim. Category ="Book"& Claim. Amount <= 300)
{
Claim. Status ="Approved";
}
Else
{
Claim. Status ="Require approval";
}
// Microsoft. ruleengine. Policy = new Microsoft. ruleengine. Policy ("expensesapproval ");
// Policy. Execute (claim );
This. Textstatus. Text = claim. status;
}
Using. NET is nothing more than writing a few lines of if else, But if you modify the approval amount, you must recompile the release.
To achieve this, simplifyCodeAs a BizTalk developer. We thought of a similar simple judgment that can be achieved through the BizTalk business rule engine.
How to integrate and call BizTalk Business Rule Engine
1. Create a business entity objectBiztalkrules. expenses.ExpenseclaimIn the BizTalk business rule engineThe basis for facts (fact type) judgment. Because this DLL needs to be configured to GAC, it will be obtained by BizTalk business rule engine. Therefore, a signature is required.
2. Compile biztalkrules. expenses to deploy the DLL to GAC and run gacutil-I biztalkrules. Expenses. dll.
3. Configure BizTalk business rule engine to enable business rule composer and start configuration.
Configure (Conditions) conditions and (Actions) Steps
It indicates that if the value of priority is greater, priority is given to execution.
4.net. Reference Microsoft. ruleengine. dll. The file is in c: \ Program Files (x86) \ common files \ Microsoft BizTalk or c: \ Program Files (x86) \ Microsoft BizTalk Server 2010
The Code is as follows:
Private
VoidButton#click (ObjectSender,RoutedeventargsE)
{
Biztalkrules. expenses.ExpenseclaimClaim =NewBiztalkrules. expenses.Expenseclaim()
{
Amount =Convert. Toint32 (This. Textamount. Text ),
Category =This. Cobcategory. Text,
Department =This. Cbodepartment. Text,
Description =This. Textdescription. Text,
Name =This. Textname. Text,
Project =This. Textproject. Text
};
Microsoft. ruleengine.PolicyPolicy =NewMicrosoft. ruleengine.Policy("Expensesapproval");
Policy. Execute (claim );
This. Textstatus. Text = claim. status;
}
This is the function. If you need to modify the rules, you can directly release and deploy new policies and rules, and the front-end applications do not need to be cheaper.
Extension
You can encapsulate Microsoft. ruleengine and publish WebService or WCF to more applications.