string workItemStore = ConfigurationManager.AppSettings["WorkItemStore"];
store = new WorkItemStore(workItemStore);
to connect to the TFS server and then
WorkItem m_workItem = store.GetWorkItem(int.Parse(this.tbID.Text));
if (m_workItem != null)
{
lblWorkItem.Text = m_workItem.Title;
foreach (Link link in m_workItem.Links)
{
RelatedLink rl = link as RelatedLink;
if (rl != null)
{
WorkItem realtedWorkItem = m_workItem.Store.GetWorkItem(rl.RelatedWorkItemId);
list.Add(realtedWorkItem);
}
}
}
dataGridView1.DataSource = list;
to list the linked work items in a simple grid.
When you want to query for WIs it should be possible to call:
// query retrieves all work items for the specified team project
string wiqlQuery = "SELECT [System.Id], [System.WorkItemType], [System.State], [System.AssignedTo], [System.Title] FROM WorkItems WHERE [System.TeamProject] = '" + teamProjectName + "' ORDER BY [System.WorkItemType], [System.Id]";
// execute the query and retrieve a collection of workitems
WorkItemCollection workitems = store.Projects[0].Store.Query(wiqlQuery);
// loop through work items
if (workitems.Count > 0)
{
// select first Work Item
retWi = workitems[0];
}
Note: To get rid of the assembly load exception just reference the shared assemblies from the disk path and do not use the GAC ones!
No comments:
Post a Comment