How to identify Event handling in TFS 2012 for Bug work item onlt
-
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; }
-
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; }
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 ))