I want a plug-in to detect when a case is created that falls under a certain custom category. When the case is created, I want to be able to execute some code instantly. How would I go about doing this? I am just starting with FogBugz and can think of potentially referencing the InterfaceEvents assembly or creating a custom workflow, but nothing has seemed right. Any solution? Thanks
Edit: I am trying to implement the IPlugInBugCommit interface, but am getting errors every time I try to build the project:
Error 1 'FogCreek.FogBugz.CBug' is inaccessible due to its protection level *************\Visual Studio 2008\Projects\HelloWorld\HelloWorld\HelloWorld.cs
Error 4 Inconsistent accessibility: parameter type 'FogCreek.FogBugz.CBug' is less accessible than method 'FogCreek.FogBugz.Plugins.Interfaces.HelloWorld.BugCommitAfter(FogCreek.FogBugz.CBug, FogCreek.FogBugz.BugAction, FogCreek.FogBugz.CBugEvent, bool)' C:\Users\mxb\Documents\Visual Studio 2008\Projects\HelloWorld\HelloWorld\HelloWorld.cs 33 21 HelloWorld
Here is my code:
/* FogBugz namespaces-- make sure you add the neccesary assembly references to
* the following DLL files contained in C:\Program Files\FogBugz\Website\bin\ * FogBugz.dll, FogCreek.Plugins.dll, FogCreek.Plugins.InterfaceEvents.dll */
using FogCreek.FogBugz;
using FogCreek.FogBugz.UI;
using FogCreek.FogBugz.Plugins;
using FogCreek.FogBugz.Plugins.Api;
using FogCreek.FogBugz.Plugins.Interfaces;
namespace FogCreek.FogBugz.Plugins.Interfaces
{
/* Class Declaration: Inherit from Plugin, implement interfaces
* IPluginPageDisplay, IPluginExtrasMenu, and IPluginCommit */
public class HelloWorld : Plugin, IPluginPageDisplay, IPluginExtrasMenu, IPluginBugCommit
{
//CODE 1265 GO AND LOG ONTO APPDEV COMPUTER
/* Constructor: We'll just initialize the inherited Plugin class, which
* takes the passed instance of CPluginApi and sets its "api" member variable. */
public string hello;
public HelloWorld(CPluginApi api)
: base(api)
{
hello = "THIS IS A BIG TEST";
}
public string PageDisplay()
{
return "<h1>Hello, world!</h1><p>"+hello+"</p>";
}
#region IPluginBugCommit Members
public void BugCommitAfter(CBug bug, BugAction nBugAction, CBugEvent bugevent, bool fPublic)
{
hello = "A bug was created.";
}
public void BugCommitBefore(CBug bug, BugAction nBugAction, CBugEvent bugevent, bool fPublic)
{
}
public void BugCommitRollback(CBug bug, BugAction nBugAction, bool fPublic)
{
}
#endregion
public PermissionLevel PageVisibility()
{
return PermissionLevel.Normal;
}
public CNavMenuLink[] ExtrasMenuLinks()
{
return new CNavMenuLink[] { new CNavMenuLink("Say Hello", api.Url.PluginPageUrl()) };
}
}
}
Edit2: Everything I have looked at says to add a reference to FogCreek.Plugins.InterfaceEvents.dll, but our local installation of fogbugz has no such file. Is this the reason?
IPluginBugCommit(fogcreek.com/FogBugz/library/70/?topic=/fogbugz/…). This interface lets you run code as soon as a bug is created or changed. – Daniel LeCheminant♦ Jul 14 2010 at 20:40FogCreek.FogBugz.Plugins.Interfacesnamespace. Also, recall that the state ofhelloisn't going to be persisted between calls to the interfaces that you implement. Consider usingapi.Database.GetKeyValueandapi.Database.SetKeyValueif you're trying to persist data. – Daniel LeCheminant♦ Jul 15 2010 at 16:55