Plugin Interfaces > Projects and Areas > IPluginAreaJoin and IPluginAreaCommit
This article will demonstrate simple code for a FogBugz plugin that implements the IPluginAreaJoin and IPluginAreaCommit interfaces contained in the FogCreek.FogBugz.Plugins.Interfaces class library.
The plugin code presented allows you assign a "Level of Awesomeness" to a project area, and provides a template for performing custom operations when a project area is comitted to the FogBugz database. This occurs whenever an area is created or edited on the "Edit Project" page.
To demonstrate how an area commit and rollback occurs, all of the member functions of IPluginAreaCommit generate a UI notification (using CPluginApi.Notifications) indicating that they were called.
In the event that multiple installed plugins implement the IPluginAreaCommit interface:
- For the AreaCommitBefore and AreaCommitAfter methods, FogBugz handles each plugin instance implementing IPluginAreaCommit in the order that the plugin was installed. (The CPluginApi.PluginPrefix property reveals this; for example it will return "P4" if called from the 4th plugin ever installed on the FogBugz site.)
- For the AreaCommitRollback method, FogBugz first handles the plugin instance that returned false from AreaCommitBefore, then calls the AreaCommitRollback function of all plugin instances that previously called AreaCommitBefore in reverse order (ie, they're "popped off the stack").
The example plugin uses the IPluginAreaJoin method to specify a table containing an integer "ixArea" column, allowing FogBugz to automatically join the columns of that table to the "Area" table. This allows the plugin developer to use CArea.GetPluginField() and CArea.GetPluginFieldOriginal() to easily retrieve column values from the joined table, and use CArea.SetPluginField() to specify a value to be set upon commit.
Compile and Install It On Your Own
Download the source file: IPluginAreaJoin_Commit_Example.cs
Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin