Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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:

  1. If no SQL Transaction is already started, one is started

  2. The SaveStart event is raised. It is safe to perform long running actions and UI interactions

  3. SQL commands are issued to INSERT, UPDATE and DELETE

  4. The SaveEnding event is raised. It is unsafe to perform long running actions and UI interactions

  5. The SQL transaction, if started by this business logic object is committed

  6. 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:

...