Using Business Rules Table

S

sck10

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 = (e-mail address removed)


Second row
-------------
RuleNameID = Rule02
Constraint01 = TravelType
ConstraintValue01 = Domestic
Constraint02 = VisitType
ContactEmail = Internal Meeting
ContactEmail = (e-mail address removed)


Second row
-------------
RuleNameID = Rule03
Constraint01 = TravelType
ConstraintValue01 = International
Constraint02 = TravelCost
ContactEmail = $3000
ContactEmail = (e-mail address removed)
 
S

Steven Cheng[MSFT]

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.
 
S

sck10

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 =
"(e-mail address removed)";

row 02: if (this.hdnTravelType.value == "Domestic" ||
this.hdnTravelReason.value != "Customer Visit") this.hdnApproverEmail =
"(e-mail address removed)";

row 03: if (this.hdnTravelType.value == "International")
this.hdnApproverEmail = "(e-mail address removed)";

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
 
S

Steven Cheng[MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top