StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Saving of Business objectExpand / Collapse
Author
Message
Posted 11/29/2005 7:12:16 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 03/25/2006 6:08:39 PM
Posts: 36, Visits: 65
It is my understanding that a business object has an underlying ADO-DATABLE as the source of record storage.

I would like to understand what happens when you call the Save method of the Business Object when there are multiple records in the DataTable and there are broken rules for some of the records.

I assume only those records that don't have broken rules are saved or do all the records of the datatable have to be valid for the Business object to be saved?

Post #185
Posted 11/29/2005 8:14:34 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 9:17:31 AM
Posts: 4,561, Visits: 4,545
The help documentation has a flow chart that shows the exact save sequence.  I just pulled this image from the help documentation, but for more information read [ Business Layer -> Common Business Object Tasks -> Saving Data ] in the help and this should clear some things up.

When a Save is called, the business rules are checked on each row within the  DataTable.  As the business object checks each row, it raises the CheckRulesOnCurrentRow event (where the business logic resides).  If there is even one broken rule on any row, no data will be saved back to the server until all of the rules have been corrected. 

If the AutoNavigateToFirstBrokenRow property on the business object is set to true, the business object will automatically position itself on the first broken record.

You can access the broken rules one of two ways, first you can use the BrokenRules property:

BrokenRules Example
Dim loRule As MicroFour.StrataFrame.Business.BrokenRule

For Each loRule In Customers.BrokenRules.ToArray()
        '-- Show the rule
        Console.WriteLine(loRule.Description)
Next

The other method is to capture the BusinessRulesChecked event on a business object or a form and use the event arguments passed to that event.

BusinessRulesCheckedEvent Example
Private Sub Customers_BusinessRulesChecked(ByVal e As StrataFrame.Business.BusinessRulesCheckedEventArgs) Handles Customers.BusinessRulesChecked

        '-- Establish Locals
        Dim loBO As MicroFour.StrataFrame.Business.BusinessLayer
        Dim loRule As MicroFour.StrataFrame.Business.BrokenRule

       '-- When captured on a form, there may be more than one business object with broken rules
       '   this is how to cycle through all of the business objects with broken rules

        For Each loBO In e.AllBrokenRules.Keys
            For Each loRule In loBO.BrokenRules.ToArray()
                '-- Show the broken rule
                Console.WriteLine(loRule.Description)
            Next
        Next

    End Sub

You can also determine how many broken rules there are on the current row, all other rows, and an accumulation of all rows using the same event arguments in the BusinessRulesChecked event:

Broken Rules Counters
Private Sub Customers_BusinessRulesChecked(ByVal e As StrataFrame.Business.BusinessRulesCheckedEventArgs) Handles Customers.BusinessRulesChecked

        Console.WriteLine("Broken rules on this row: {0}", e.CountOfBrokenRulesCurrentRow)
        Console.WriteLine("Broken rules on other rows: {0}", e.CountOfBrokenRulesAdditionalRows)
        Console.WriteLine("Broken rules on all rows: {0}", e.CountOfBrokenRulesTotal)

End Sub

You can also force the save and ignore all broken rules.  When this is done, the data will be saved back to the server regardless of the broken rules.

Ignoring Broken Rules
Private Sub Customers_BusinessRulesChecked(ByVal e As StrataFrame.Business.BusinessRulesCheckedEventArgs) Handles Customers.BusinessRulesChecked

        '-- Ignore the broken rules and force the save
        e.IgnoreRulesAndForceSave = True

    End Sub

Post #186
Posted 11/30/2005 8:21:39 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 09/26/2008 8:30:36 AM
Posts: 2,685, Visits: 1,886
No, John, when you save, if there are broken rules on any of the rows, none of the rows will save. (Unless of course, you tell it to ignore the broken rules, then everything will save.)


www.bungie.net
Post #193
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 9:18am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.047. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.