Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to identify Event handling in TFS 2012 for Bug work item onlt

How to identify Event handling in TFS 2012 for Bug work item onlt

Scheduled Pinned Locked Moved ASP.NET
helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amit sahu20
    wrote on last edited by
    #1

    I have created an event handling class library to handle TFS2012 event lag it is working fine. But i have to handle such event only in case of Bug work Item type change. how i identify work item type in event handling code. Summary of code as

    public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs,
    out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
    {
    string str = requestContext.ServiceHost.Name;
    statusCode = 0;
    properties = null;
    statusMessage = String.Empty;

            if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent)
            {
                WorkItemChangedEvent ev = notificationEventArgs as WorkItemChangedEvent;
                string asw = ev.Title;
                // EventLog.WriteEntry("WorkItemChangedEventHandler", "WorkItem " + ev.WorkItemTitle + " was modified");
               
                System.IO.StreamWriter objWriter = new System.IO.StreamWriter(@"C:\\Amit\\ClassLibrary1\\AssignedToHandler.txt");
                objWriter.WriteLine("Received WorkItemChangedEvent");
                objWriter.Close();
    
            }
    
    
            return EventNotificationStatus.ActionPermitted;
        }
    
    J 1 Reply Last reply
    0
    • A amit sahu20

      I have created an event handling class library to handle TFS2012 event lag it is working fine. But i have to handle such event only in case of Bug work Item type change. how i identify work item type in event handling code. Summary of code as

      public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs,
      out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
      {
      string str = requestContext.ServiceHost.Name;
      statusCode = 0;
      properties = null;
      statusMessage = String.Empty;

              if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent)
              {
                  WorkItemChangedEvent ev = notificationEventArgs as WorkItemChangedEvent;
                  string asw = ev.Title;
                  // EventLog.WriteEntry("WorkItemChangedEventHandler", "WorkItem " + ev.WorkItemTitle + " was modified");
                 
                  System.IO.StreamWriter objWriter = new System.IO.StreamWriter(@"C:\\Amit\\ClassLibrary1\\AssignedToHandler.txt");
                  objWriter.WriteLine("Received WorkItemChangedEvent");
                  objWriter.Close();
      
              }
      
      
              return EventNotificationStatus.ActionPermitted;
          }
      
      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      amit sahu20 wrote:

      how i identify work item type in event handling code.

      Are you sure a == operator is the correct way to compare the values?. What are the actual values? Maybe your comparing the pointers to the objects, and not the value held by the objects.

      if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent)

      Or are you doing a double comparison?

      if (( notificationType == NotificationType.Notification ) && ( notificationEventArgs is WorkItemChangedEvent ))

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups