...
This method is invoked when the service is stopping.
Understanding Business Logic Behaviours
When writing plugins to interact with business logic objects, particularly handling events raised by these objects, it is important to understand the behaviours and sequence of events.
The Save
When the Save() of a business logic object is invoked, the following occurs in order:
If no SQL Transaction is already started, one is started
The SaveStart event is raised. It is safe to perform long running actions and UI interactions
SQL commands are issued to INSERT, UPDATE and DELETE
The SaveEnding event is raised. It is unsafe to perform long running actions and UI interactions
The SQL transaction, if started by this business logic object is committed
The SaveEnd event is raised. It is safe to perform long running actions and UI interactions
If any exception is thrown during the save (even by a plugin) then if the business logic object had started a transaction, then it will RollBack that transaction and all SQL commands issued since the transaction started will be undone.
Plugins that wish to use the same SQL transaction to update data to ensure consistency should do this in either the SaveStart or SaveEnding events. If using the SaveEnding event then ensure no user interaction is made.
Common Mistakes
Some of the more common mistakes which can cause significant issues are:
...