|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using Business Rules TableI need to create a Business Rules table that can be pulled into the web page and use it as criteria for who should receive the approval email. For example, I have created a travel request form that ask a series of questions: TravelType: Domestic or International VisitType: (Customer, Internal Meeting, Seminar) TravelCost In my table I have the following: TravelRules ------------ RuleNameID Constraint01 ConstraintValue01 Constraint02 ConstraintValue02 ContactEmail Below is an example of the rules that I would like to use. My question is as follows: 1. Does my table structure seem feasible? 2. How do I add the rules to the web page and then use them with my data? Also, the two constraints are used as an "AND" statement where the different rows constitute an "OR" statement. So I would have to account for multiple rules. Any help with this would be appreciated, sck10 First row --------- RuleNameID = Rule01 Constraint01 = TravelType ConstraintValue01 = Domestic Constraint02 = VisitType ContactEmail = Customer ContactEmail = fi***@my.com Second row ------------- RuleNameID = Rule02 Constraint01 = TravelType ConstraintValue01 = Domestic Constraint02 = VisitType ContactEmail = Internal Meeting ContactEmail = v*@my.com Second row ------------- RuleNameID = Rule03 Constraint01 = TravelType ConstraintValue01 = International Constraint02 = TravelCost ContactEmail = $3000 ContactEmail = s**@my.com Hi,
1) Table design seems perfect (i guess, you will be normalizing it). 2) I didn't get your second question. Regards, Augustin http://augustinprasanna.blogspot.com Show quote "sck10" wrote: > Hello, > > I need to create a Business Rules table that can be pulled into the web page > and use it as criteria for who should receive the approval email. For > example, I have created a travel request form that ask a series of > questions: > > TravelType: Domestic or International > VisitType: (Customer, Internal Meeting, Seminar) > TravelCost > > In my table I have the following: > > TravelRules > ------------ > RuleNameID > Constraint01 > ConstraintValue01 > Constraint02 > ConstraintValue02 > ContactEmail > > Below is an example of the rules that I would like to use. My question is > as follows: > 1. Does my table structure seem feasible? > 2. How do I add the rules to the web page and then use them with my data? > > Also, the two constraints are used as an "AND" statement where the different > rows constitute an "OR" statement. So I would have to account for multiple > rules. > > Any help with this would be appreciated, sck10 > > > First row > --------- > RuleNameID = Rule01 > Constraint01 = TravelType > ConstraintValue01 = Domestic > Constraint02 = VisitType > ContactEmail = Customer > ContactEmail = fi***@my.com > > > Second row > ------------- > RuleNameID = Rule02 > Constraint01 = TravelType > ConstraintValue01 = Domestic > Constraint02 = VisitType > ContactEmail = Internal Meeting > ContactEmail = v*@my.com > > > Second row > ------------- > RuleNameID = Rule03 > Constraint01 = TravelType > ConstraintValue01 = International > Constraint02 = TravelCost > ContactEmail = $3000 > ContactEmail = s**@my.com > > > > > > > Hi Steve,
Based on the table structure, I can get your business rules as below: 1. each rule record will define a travel request type and the final contact (email) 2. each record row contains multiple constraint which will work together as "AND" to detailedly define the rule Currently, for your second question: ========= 2. How do I add the rules to the web page and then use them with my data? =========== I'm wondering whether you're wantting to create a page for admin and manage these rules or will create a page which create concrete travel requests but will refer to this table? If convenient, would you provide some further information such as what will be presented on the page UI and how will the user interact with the page to finish a task. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights. Hi Steven,
After sleeping on it, I was wondering if the best way to handle this would be to have the actual code in the table? For example, on my webpage, I have the hidden variables: hdnTravelType hdnTravelReason hdnApproverEmail (Please forgive my c# I'm still more comfortable with vb) So, in the database I would store the following: TravelRules ------------ RuleNameID Constraint row 01: if (this.hdnTravelType.value == "Domestic" || this.hdnTravelReason.value == "Customer Visit") this.hdnApproverEmail = "d**@mysite.com"; row 02: if (this.hdnTravelType.value == "Domestic" || this.hdnTravelReason.value != "Customer Visit") this.hdnApproverEmail = "v*@mysite.com"; row 03: if (this.hdnTravelType.value == "International") this.hdnApproverEmail = "s**@mysite.com"; In my CodeBehind, I would call the stored procedure and read each record (below). So my question is, as the DataReader reads each record, how can it execute each "if statement"? Thanks again, sck10 .... using (OleDbDataReader spRules = cmdSearch.ExecuteReader()) { if (spRules.HasRows) { while (spRules.Read()) { if (spRules["Constraint"].ToString() != null) Execute the if statements from the database; } //Loop } //End if } //End Using Show quote "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:3d83m9CyGHA.400@TK2MSFTNGXA01.phx.gbl... > Hi Steve, > > Based on the table structure, I can get your business rules as below: > > 1. each rule record will define a travel request type and the final > contact > (email) > > 2. each record row contains multiple constraint which will work together > as > "AND" to detailedly define the rule > > Currently, for your second question: > > ========= > 2. How do I add the rules to the web page and then use them with my data? > =========== > > I'm wondering whether you're wantting to create a page for admin and > manage > these rules or will create a page which create concrete travel requests > but will refer to this table? > > If convenient, would you provide some further information such as what > will > be presented on the page UI and how will the user interact with the page > to > finish a task. > > Sincerely, > > Steven Cheng > > Microsoft MSDN Online Support Lead > > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > > > Thanks for your reply Steve,
I'm afraid the idea of "storing the complete rule detection and processing code in database and execute it dynamically after reading them from database" is not supported due to the net framework exeution model. We can not dynamically compile and execute a discretionary code fragment. IMO, a more proper approach is defing a component/helper class which provide some helper methods to parse the text based rules(read from database) and execute the proper code to maniplate controls and values in page. for example: public class HelperClass { public void ProcessByRules(string rule, control ctrl1, control ctrl2 ....) { if( ....) if (....) or switch(...) { case... case... } } } How do you think of this? Anyway, we need to let our program code accept some more understandable identity or values (to represent the rules) so that it is easier to process the page in code. Please let me know if you have any other consideration or ideas. Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights. Thanks Steven,
I'll follow your example... Show quote "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:RQdO5RnyGHA.4220@TK2MSFTNGXA01.phx.gbl... > Thanks for your reply Steve, > > I'm afraid the idea of "storing the complete rule detection and processing > code in database and execute it dynamically after reading them from > database" is not supported due to the net framework exeution model. We can > not dynamically compile and execute a discretionary code fragment. IMO, a > more proper approach is defing a component/helper class which provide some > helper methods to parse the text based rules(read from database) and > execute the proper code to maniplate controls and values in page. for > example: > > public class HelperClass > { > > public void ProcessByRules(string rule, control ctrl1, control ctrl2 > ....) > { > if( ....) > > if (....) > > or > > switch(...) > { > case... > > case... > > } > } > > } > > > How do you think of this? Anyway, we need to let our program code accept > some more understandable identity or values (to represent the rules) so > that it is easier to process the page in code. Please let me know if you > have any other consideration or ideas. > > Sincerely, > > Steven Cheng > > Microsoft MSDN Online Support Lead > > > > This posting is provided "AS IS" with no warranties, and confers no > rights. > |
|||||||||||||||||||||||