пятница, 20 января 2012 г.

TFS Service Development: Set ChangedBy field for workitem


Case: You are developing service, that should change some WorkItems in Team Foundation Server.
Service should set field ChangedBy properly.


var collection1 = new TfsTeamProjectCollection(new Uri("http://tfs:8080/tfs/collection"));
collection1.EnsureAuthenticated();

var ims = collection1.GetService<IIdentityManagementService>();
var id = ims.ReadIdentity(IdentitySearchFactor.AccountName, "domain\\username"MembershipQuery.None, ReadIdentityOptions.None);

var collection = new TfsTeamProjectCollection(new Uri("http://tfs:8080/tfs/collection"), id.Descriptor);

-- OR --

WorkItem wi;
...
// Change Work Item
...
// Set ChangedBy Field
wi[CoreField.ChangedBy] = userName;
wi.Save();

Комментариев нет:

Отправить комментарий