Desty
Desty

Reputation: 2776

How to update TFS work item in own Plugin while ISubscriber.ProcessEvent?

I have written a TFS 2013 Plugin via implementing the Microsoft.TeamFoundation.Framework.Server.ISubscriber interface. In the ProcessEvent method I check if a Work Item was changed with

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

and if true, I want to update this work item. What is the best way to achieve this?

My current solution is to open a Client connection to TFS with the Microsoft.TeamFoundation.Client library, search for the Work Item and update it. The problem here is, that this is a second change after the initial one triggering the event. Can I hook into the updating event instead and change the Work Item in the same workflow?

Upvotes: 3

Views: 799

Answers (1)

No you have to go down the root of creating a Client and loading the work item. However you can either put bypass text in the editing user name. The ui would display "edited by AwesomePlugin4 by TfsService.

Therefore if the edit was made by your plugin you can skip.

In addition you can have a performance degradation as you can hold up processing. A better model would be to put your update logic in a TfsJob and trigger the job in the event on change. Then your job can run and make any changes or bypass as needed. This much more robust.

http://blogs.msdn.com/b/chrisid/archive/2010/02/15/introducing-the-tfs-background-job-agent-and-service.aspx

http://exsertus.wordpress.com/2013/10/10/custom-tfs-jobs-and-job-monitoring/

Upvotes: 2

Related Questions