So if you want to query all WorkItems assigned the current user you first have to reference
- Microsoft.TeamFoundation.Client
- Microsoft.TeamFoundation.Common
- Microsoft.TeamFoundation.WorkItemTracking.Client
Then use the following code:
var collection = new TfsTeamProjectCollection(new Uri("http://nb-tri:8080/tfs/defaultcollection"));
collection.EnsureAuthenticated();
var query =
"SELECT * " +
"FROM WorkItems " +
"WHERE [System.TeamProject] = @project and " +
" [System.WorkItemType] <> '' and " +
" [System.State] <> '' and " +
" [System.AssignedTo] = @user " +
"ORDER BY [System.Id] ";
var wiStore = collection.GetService<WorkItemStore>();
var parameter = new Dictionary<string, string>
{
{"project", "ScrumTest"},
{"user", collection.AuthorizedIdentity.DisplayName}
};
var result = wiStore.Query(query, parameter);
That's it... easy, isn't it?
Keine Kommentare:
Kommentar veröffentlichen