BizTalk Server General - Business Rules Quickie... I hope

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > September 2005 > Business Rules Quickie... I hope





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Business Rules Quickie... I hope
Matthew Berkland

2005-09-08, 5:52 pm

Hello again,

I am working on a business rule set for my company and am scratching my
head. Keep in mind that I am new to BRE and perhaps I am trying to make it
do something it wasn't meant for, but it sure seems like it would be.

We are currently designing our Purchase Order creation business process and
I want to use the BRE whenever I can if it makes sense. So far I have rule
set that checks to see if the total is over a certain amount, if it is it
sets a flag in the XML message that is later used in the orchestration to
route the message to an "Approval needed" branch.

What I need to accomplish next is take all of the line items on our PO and
compare their part numbers to what are Valid part numbers in our database.
If it finds an invalid part number it needs to halt the rule processing, and
set a flag in the message that the entire PO is screwed and return to the
orchestration for it to handle it.

I have no idea where to start on this one. I have played with using the "is
equal to" predicate and checking a column value against my POLineItem nodes
but that doesn't exactly do what I am expecting. It generates the SQL code
of 'select * from [ItemMaster] where [ItemNo] = myXmlValue' which is great,
so if it gets a hit on the database the condition returns true and my action
can take place, except there is no action! It is when it doesn't get a match
out of the database that I want my action to execute. The only way I
thought to try was to change the predicate to "is not equal to" which then
generates the SQL of 'select * from [ItemMaster] where [ItemNo] <>
myXmlValue' which would then assert into memory every part number in the
table except the current lineItem!! There are over 20,000 rows in the table
and this absolutley kills the business rules composer and of course this is
not the way to do this.

Would I be better off using a .NET class to do the checking? If so how would
I structure it? If anyone out there could point me in the right direction or
perhaps have a code sample they wouyld be willing to share I sure would
appreciate it. I have the Sams book Biztalk 2004 Unleashed but it didn't
provide enough information to get me started.

Thanks in advance,

Matt


Matt Milner

2005-09-08, 5:52 pm

I can think of a couple of options.

1) My first response is that testing for negative values in SQL does not
work well in the BRE so you have to write a component that does the check
and returns true/false. This can then be used as your predicate in the
rule. Basically, you'd pass in the part number to the method and it would
do the quickest SQL lookup to verify that the part exists or not.

2) Do a simple lookup with the part number against the database and for each
one you find add it to an collection in a .Net class. Have a single rule
that sets a property on the .Net class for the number of parts (use
true=true for the predicate). Have a bool property on the class that tells
you if it is valid. This would only return true when the two values are the
same. Now, use this class in your orchestration to make the decision about
how to proceed or raise an error.

3) Do something like #2, but you could keep all of your state in the xml
document if that is easier.

HTH,
Matt


"Matthew Berkland" <matt@austinhardware.com> wrote in message
news:utjWefItFHA.3316@TK2MSFTNGP12.phx.gbl...
> Hello again,
>
> I am working on a business rule set for my company and am scratching my
> head. Keep in mind that I am new to BRE and perhaps I am trying to make it
> do something it wasn't meant for, but it sure seems like it would be.
>
> We are currently designing our Purchase Order creation business process
> and
> I want to use the BRE whenever I can if it makes sense. So far I have
> rule
> set that checks to see if the total is over a certain amount, if it is it
> sets a flag in the XML message that is later used in the orchestration to
> route the message to an "Approval needed" branch.
>
> What I need to accomplish next is take all of the line items on our PO and
> compare their part numbers to what are Valid part numbers in our database.
> If it finds an invalid part number it needs to halt the rule processing,
> and
> set a flag in the message that the entire PO is screwed and return to the
> orchestration for it to handle it.
>
> I have no idea where to start on this one. I have played with using the
> "is
> equal to" predicate and checking a column value against my POLineItem
> nodes
> but that doesn't exactly do what I am expecting. It generates the SQL code
> of 'select * from [ItemMaster] where [ItemNo] = myXmlValue' which is
> great,
> so if it gets a hit on the database the condition returns true and my
> action
> can take place, except there is no action! It is when it doesn't get a
> match
> out of the database that I want my action to execute. The only way I
> thought to try was to change the predicate to "is not equal to" which then
> generates the SQL of 'select * from [ItemMaster] where [ItemNo] <>
> myXmlValue' which would then assert into memory every part number in the
> table except the current lineItem!! There are over 20,000 rows in the
> table
> and this absolutley kills the business rules composer and of course this
> is
> not the way to do this.
>
> Would I be better off using a .NET class to do the checking? If so how
> would
> I structure it? If anyone out there could point me in the right direction
> or
> perhaps have a code sample they wouyld be willing to share I sure would
> appreciate it. I have the Sams book Biztalk 2004 Unleashed but it didn't
> provide enough information to get me started.
>
> Thanks in advance,
>
> Matt
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com