TFS2010 API - Which server event fires when checkin notes are changed?

Posted by user3708981 on Stack Overflow See other posts from Stack Overflow or by user3708981
Published on 2014-06-12T21:22:16Z Indexed on 2014/06/12 21:24 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

I've written a TFS plugin that impliments the ISubscribe interface, and creates an external ticket base off of the contents of a check-in note. What I would like to do, if when I go back through older TFS check-ins in VS and edit a check-in note, the plugin would process that event and create an external ticket retroactively. What event / SubscribedType do I need to subscribe to in order for ProcessEvents to fire?

My stubbed out code -

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Common;
using Microsoft.TeamFoundation.VersionControl.Client;

// From C:\Program Files\Microsoft Team Foundation Server 2010\Tools\
using Microsoft.TeamFoundation.Framework.Server;
using Microsoft.TeamFoundation.VersionControl.Server;
using Changeset = Microsoft.TeamFoundation.VersionControl.Server.Changeset;

public class EmbeddedWorkItemEventHandler : ISubscriber
  {
    const string EVENT_NAME = "TicketEvent";
    const string APP_LOG = "Application";

    public Type[] SubscribedTypes()
    {
        return new Type[1] { typeof(CheckinNotification) }; // What else do I need here?
    }

    public string Name
    {
        get { return EVENT_NAME; }
    }

    public SubscriberPriority Priority
    {
        get { return SubscriberPriority.Normal; }
    }

    public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs,
                                                out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
    {
        // Create the event source, if it doesn't exist           
        if (!System.Diagnostics.EventLog.SourceExists(EVENT_NAME))
        {
            System.Diagnostics.EventLog.CreateEventSource(EVENT_NAME, APP_LOG);
        }

        statusCode = 0;
        properties = null;
        statusMessage = String.Empty;
        string ErrorLine = "";
        try
        {
            // Here we'll validate the Ticket name
            if (notificationType == NotificationType.DecisionPoint && notificationEventArgs is CheckinNotification)
            {
                //Check-in blocking logic here.
            }
            else if (notificationType == NotificationType.Notification && notificationEventArgs is CheckinNotification)
            {
              // Tickets on check-in here.
            }
        }
        Catch
        {
            // Error checking
        }
   return EventNotificationStatus.ActionPermitted;        
   }

© Stack Overflow or respective owner

Related posts about api

Related posts about plugins