Method call order when saving
The following virtual methods are defined in ACBSO and related to the saving process:
protected virtual bool OnSave()
protected virtual Msg OnPreSave()
protected virtual void OnPostSave()
You can overwrite these to influence the saving process in your BSO. Don't forget the base call when overwriting!
The saving process is initiated with the OnSave() method. The OnSave () method then makes a series of method calls:
- Aufruf von
protected MsgWithDetails NotifyAllPreSave()
:
"NotifyAllPreSave ()" iterates over all business objects that have the same data context and then calls the OnPreSave () method. If this method has been overwritten in a derivation and a Msg instance is returned instead of a null value, the saving process is aborted and a dialog box opens with the error messages. Otherwise, continue with step 2: - Call of
public bool ACComponent.ACSaveChanges()
:
This method is defined in ACComponent. It calls the ACSaveChanges method on the "IACEntityObjectContext Database" virtual property. If the save process was unsuccessful, a dialog box opens and the error messages are displayed. Otherwise, continue with step 3: - Call to
protected void NotifyAllPostSave()
:
"NotifyAllPostSave ()" iterates over all business objects that have the same data context and then calls the OnPostSave () method to inform all business objects of the successful save
Method call order when undoing
In ACBSO, the following virtual methods are defined that are related to the undo:
protected virtual bool OnPreUndoSave()
protected virtual Msg OnPreUndoSave()
protected virtual void OnPostUndoSave()
You can overwrite this in order to influence the reversal in your BSO. Don't forget the base call when overwriting !
The undo action is initiated with the OnUndoSave () method . The OnUndoSave () method then makes a series of method calls:
- Call to
protected MsgWithDetails NotifyAllPreUndoSave()
:
"NotifyAllPreUndoSave ()" iterates over all business objects that have the same data context and then calls the OnPreUndoSave () method. If this method has been overwritten in a derivation and a Msg instance is returned instead of a null value, the undo process is canceled and a dialog box opens with the error messages. Otherwise, continue with step 2: - Call of
public bool ACComponent.ACUndoChanges()
:
This method is defined in ACComponent. It calls the ACUndoChanges method on the "IACEntityObjectContext Database" virtual property. If the undo process was unsuccessful, a dialog box opens and the error messages are displayed. Otherwise, continue with step 3: - Call to
protected vois NotifyAllPostUndoSave()
:
"NotifyAllPostUndoSave ()" iterates over all business objects that have the same data context and then calls the OnPostUndoSave () method to inform all business objects of the successful rollback .
Preliminary check
In the chapter on synchronous methods you got to know the principle of the IsEnabled methods . IsEnabled methods are used to deactivate UI buttons via CommandBinding . This technique can also be used to deactivate the save and undo buttons in the menu ribbon. This testing logic should be done by overriding the virtual methods
protected virtual bool OnIsEnabledSave()
protected virtual bool OnIsEnabledUndoSave()
implemented. Don't forget the base call when overwriting !
By calling the method and you can query all business objects that work with the same database context at once. During iteration, the OnIsEnabledSave () or OnIsEnabledUndoSave () method is called on each business object. If the return value is incorrect, then a business object does not allow saving or undoing.protected bool NotifyAllIsEnabledSave()
protected bool NotifyAllIsEnabledUndoSave()
Force user query
If a database context has been changed and you want the user to be prompted to confirm whether he wants to accept or undo the changes, call the method public virtual bool ACSaveOrUndoChanges()
. The return value of the method is true if the user has confirmed the save or the undo.