Versions Compared

Key

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

...

The Added event is raised when an item is added to the JiwaCollection.

Changed

The Changed even is raised when a property if the item changes. The PropertyChangedEventArgs argument has a PropertyName property which contains the name of the property which changed.

Removing

The Removing event is raised when an item is being removed from the JiwaCollection.

Removed

The Removed event is raised when an item is removed from the JiwaCollection.

Common Mistakes

Some of the more common mistakes which can cause significant issues are:

Blocking a SQL Transaction with a UI prompt

An entire organisation can be ground to a halt by displaying a messagebox or dialog at the wrong time.

If a plugin is awaiting user interaction and there are un-committed transactions pending, then other users will be blocked from reading or writing to the same tables or pages of the database.

The SaveEnding event of all business logic objects is raised when the business logic has created a SQL Transaction, issued SQL inserts, updates or deletes and not yet committed the transaction.

Awaiting user interaction, or any long running operation - such as I/O or external API’s should not be done in handlers of the SaveEnding eventThe item argument is the item which was added.

The code below shows a handler for a sales order lines, displaying a message box of the PartNo property of the sales order line when added to the collection.

Code Block
languagec#
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{
	public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    }
	
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
		JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;
		salesOrderForm.SalesOrder.SalesOrderLines.Added += delegate(JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine salesOrderLine)
			{
				System.Windows.Forms.MessageBox.Show(String.Format("Added '{0}'", salesOrderLine.PartNo));
			};
    }
}

Changed

The Changed even is raised when a property if the item changes. The PropertyChangedEventArgs argument has a PropertyName property which contains the name of the property which changed.

Removing

The Removing event is raised when an item is being removed from the JiwaCollection.

Removed

The Removed event is raised when an item is removed from the JiwaCollection.

Common Mistakes

Some of the more common mistakes which can cause significant issues are:

Blocking a SQL Transaction with a UI prompt

An entire organisation can be ground to a halt by displaying a messagebox or dialog at the wrong time.

If a plugin is awaiting user interaction and there are un-committed transactions pending, then other users will be blocked from reading or writing to the same tables or pages of the database.

The SaveEnding event of all business logic objects is raised when the business logic has created a SQL Transaction, issued SQL inserts, updates or deletes and not yet committed the transaction.

Awaiting user interaction, or any long running operation - such as I/O or external API’s should not be done in handlers of the SaveEnding event.

DRY (Don’t Repeat Yourself)

If there is code that is going to be needed by multiple plugins don’t repeat the code in multiple places, instead create a plugin and create a public class within this plugin to hold the code and then add a plugin reference to each of the plugins that need to access this code and call this new class. By doing this you don’t have to maintain multiple copies of the same code.