Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BO Hook Method, post validate, pre save
Message
De
12/10/2010 08:05:16
 
 
À
11/10/2010 16:24:30
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01484763
Message ID:
01484952
Vues:
27
>>>>Hi,
>>>>
>>>>what method should I use to run some code that should run after all rules have passed but prior to the save occurring on a BO?
>>>
>>>
>>>Hi Frank,
>>>
>>>There isn't a hook method for that, but you can create a custom subclass of the data access class and override the SaveDataSet() method as this method doesn't run until after the business rules have been passed. There is plenty of code in there, so after you do what you need, don't forget to call the base method so the base code would still run.
>>>
>>>Tim
>>
>>
>>Thanks Tim,
>>
>>that doesn't sit properly with how I think. Let me see if I explain in more detail what I want if you might have any other suggestions.
>>
>>I am working on a screen where a Receipt is being created. Depending on the values entered on the receipt I may have to update a field on the Policy that this receipt is being made against.
>>
>>So on my web form I have the Receipt BO, the Receipt Details BO (as a child of the Receipt) and the Policy BO (as a child of the receipt - although the Policy does not have a Receipt Foreign Key, the Receipt has a foreign Key to the Policy, so I'm a bit confused as to what I should set as the ForeignParentKeyField on the Policy in this case).
>>
>>Bear in mind that the Policy is also edited separately elsewhere.
>>
>>So what I want to do is, after the rules for the Receipt and Receipt Details have run, once everything is fine, update a field on the Policy and then let the save occur. It almost fits in as a Rule check on the policy (at least in my mind), but I'll need to check if the Policy is a child of the Receipt, then look at the ReceiptDetails to check some values in there and then change the value on the Policy.
>>
>>I hope this isn't too confusing, as I've pretty much confused myself trying to explain it :)
>
>I think I understand. What is the field on the Policy that you want to update? Is it crucial to the save? You could maybe use the HookPostSave method to update the column as it runs after the save is successfull and only if the save is successfull.
>

The field to be updated is the PaidUpTo Date field and should really be part of the save transaction. If I do not register the Policy as a child, will it still be part of the transaction during the save?

>Another idea might be to add a method to update that column that is called at the end of the CheckRulesHook method after all validation methods have been called. You would have to verify if any of the rules were broken or not.
>

OK, I've done that in the other problem I had in trying to validate the total on the details matched the total entered at the parent level so I think I can get that working.

>Just thinking out loud here, but what is the save order? Receipt, ReceiptDetail, then update the Policy? If you are saving the receipt then the detail is saved as part of the transaction since you have it registered as a child. So the receipt business object Hook Post Save would be OK to then update the policy column.
>Just ideas
>Tim

I'm not sure how MM decides what gets saved first. I'm just calling the web form's Save method.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform