Wiki

Case Status Kiln
Register Log In

Wiki

 
FogBugz Plugin Interfaces (All…»Implementing IPluginProjectJoi…
  • RSS Feed

Last modified on 12/15/2014 5:20 PM by User.

Tags:

Implementing IPluginProjectJoin, IPluginProjectDisplay, and IPluginProjectCommit

Plugin Interfaces > Projects and Areas > IPluginProjectJoin, IPluginProjectDisplay, and IPluginProjectCommit

Introduction

This article will demonstrate a pair of simple FogBugz plugins that implement the IPluginProjectJoin, IPluginProjectDisplay, and IPluginProjectCommit interfaces contained in the FogCreek.FogBugz.Plugins.Interfaces class library.

Functionality

IPluginProjectDisplay and IPluginProjectCommit

In this example, two plugins are created that each add a custom field to a FogBugz "Edit Project" page. One adds a control allowing you assign a "Level of Awesomeness" to a project, and the other adds text box input allowing you to give the project a "Secret Code Name." In addition, each plugin generates a checkbox control allowing the user to force the IPluginProjectCommit function ProjectCommitBefore to return false, thereby causing the commit to fail. To demonstrate how bug commit and rollback occurs (and the order in which they occur across two plugins that each implement IPluginProjectCommit), all of the member functions of IPluginProjectCommit generate a UI notification (using CPluginApi.Notifications) indicating that they were called.

If you upload the plugin and play around with it, you'll notice that:

  • For the ProjectCommitBefore and ProjectCommitAfter methods, FogBugz handles each plugin instance implementing IPluginProjectCommit 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 ProjectCommitRollback method, FogBugz first handles the plugin instance that returned false from ProjectCommitBefore, then calls the ProjectCommitRollback function of all plugin instances that previously called ProjectCommitBefore in reverse order (ie, they're "popped off the stack.").

IPluginProjectJoin

Each of the example plugins use the IPluginProjectJoin method to specify a table containing an integer "ixProject" column, allowing FogBugz to automatically join the columns of that table to the "Project" table. This allows the plugin developer to use CProject.GetPluginField() and CProject.GetPluginFieldOriginal() to easily retrieve column values from the joined table,  and use CProject.SetPluginField() to specify a value to be set upon commit.

 

Compile and Install It On Your Own

Download the source file:   IProjectJoin_Display_Commit_Example_1.cs IProjectJoin_Display_Commit_Example_2.cs

Then follow these instructions to create a functioning plugin assembly: Compiling and Installing a FogBugz Plugin