Using Business Rules Table

Discussion in 'ASP .Net' started by sck10, Aug 24, 2006.

  1. sck10

    sck10 Guest

    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 =


    Second row
    -------------
    RuleNameID = Rule02
    Constraint01 = TravelType
    ConstraintValue01 = Domestic
    Constraint02 = VisitType
    ContactEmail = Internal Meeting
    ContactEmail =


    Second row
    -------------
    RuleNameID = Rule03
    Constraint01 = TravelType
    ConstraintValue01 = International
    Constraint02 = TravelCost
    ContactEmail = $3000
    ContactEmail =
    sck10, Aug 24, 2006
    #1
    1. Advertising

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

    "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 =
    >
    >
    > Second row
    > -------------
    > RuleNameID = Rule02
    > Constraint01 = TravelType
    > ConstraintValue01 = Domestic
    > Constraint02 = VisitType
    > ContactEmail = Internal Meeting
    > ContactEmail =
    >
    >
    > Second row
    > -------------
    > RuleNameID = Rule03
    > Constraint01 = TravelType
    > ConstraintValue01 = International
    > Constraint02 = TravelCost
    > ContactEmail = $3000
    > ContactEmail =
    >
    >
    >
    >
    >
    >
    >
    =?Utf-8?B?QXVndXN0aW4gUHJhc2FubmE=?=, Aug 25, 2006
    #2
    1. Advertising

  3. 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.
    Steven Cheng[MSFT], Aug 25, 2006
    #3
  4. sck10

    sck10 Guest

    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 =
    "";

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

    row 03: if (this.hdnTravelType.value == "International")
    this.hdnApproverEmail = "";

    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






    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > 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.
    >
    >
    >
    >
    sck10, Aug 25, 2006
    #4
  5. 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.
    Steven Cheng[MSFT], Aug 28, 2006
    #5
  6. sck10

    sck10 Guest

    Thanks Steven,

    I'll follow your example...


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > 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.
    >
    sck10, Aug 28, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Johnson

    Business Rules & Referential Integrity

    Paul Johnson, Nov 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    539
    Paul Johnson
    Nov 20, 2004
  2. hab
    Replies:
    3
    Views:
    1,752
    Tom Dyess
    Mar 18, 2005
  3. Mike
    Replies:
    1
    Views:
    1,142
    Patrick TJ McPhee
    Nov 21, 2003
  4. Waleed Abdulla
    Replies:
    0
    Views:
    360
    Waleed Abdulla
    Jun 1, 2005
  5. Nathan

    Business rules engine

    Nathan, Dec 4, 2006, in forum: Java
    Replies:
    0
    Views:
    331
    Nathan
    Dec 4, 2006
Loading...

Share This Page