Listening to TFS Work item state change using C# window service

偶尔善良 提交于 2021-02-08 10:21:04

问题


I am working on a project where i need to sync data (tickets) from help desk department to TFS and vice-a-versa. i am able to add item in TFS using windows service and its running fine. but, Whenever a work item's status is change in TFS, i want to update the same in Help desk system. so for that i need an event listener kind of things which can listen to TFS work item status change. I am using TFS2010 API and i also looked into ISubscriber. but it look like i need to develop plug-in and put it in somewhere in plug-in folder of TFS installation. I don't want to do it that way, neither using web service directly.

I used following method to subscribe to event.

public static int RegisterWithTFS(TfsTeamProjectCollection server, string eventType, string filter, int port, string receiveMethod)
{
string serviceEndPointURL = String.Format("http://{0}:{1}/{2}", Environment.MachineName, port, receiveMethod);
var preferences = new DeliveryPreference { Schedule = DeliverySchedule.Immediate, Type = DeliveryType.Soap, Address = serviceEndPointURL };

IEventService eventService = (IEventService)server.GetService(typeof(IEventService));
string username = @"mytfsuser";
return eventService.SubscribeEvent(username, eventType, filter, preferences);

}

I want to know a mechanism to trigger my window service (C#) as soon as the work item status change in TFS. so i can able to update it back to my helpdesk system. so can anyone help me for this problem ? Thanks in advance.


回答1:


You could write a web-service and then subscribe it to TFS Event Service. Reference:

  • http://msdn.microsoft.com/en-us/library/bb130154(v=vs.90).aspx
  • http://msdn.microsoft.com/en-us/library/bb130324(v=vs.90).aspx



回答2:


Finally, i found the solution:

I developed a Tfs server Plugin (instead of Window service) and subscribe to TFS WorkItemChanged event. it Inherits ISubscriber interface and override the ProcessEvent method. I need to deploy this plugin on the TFS Server in plugin folders of Tfs installation. This approach works extremely well!!



来源:https://stackoverflow.com/questions/17531239/listening-to-tfs-work-item-state-change-using-c-sharp-window-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!