Chapter 9 introduced the Team Foundation Server Object Model, and
Each Team Foundation Server defines one and only one work item store. This store contains all the work item information for all the different team projects located on that Team Foundation Server.
Using this work item store, you can access work item information by using the work item ID, or by writing a query in the Work Item Query Language (see the
You have already seen, with the Process Template Editor, one great example of what can be built off the Team Foundation Object Model and the work item tracking object model. Another great example is from a company called Devbiz Business Solutions ( devbiz.com ). They have developed an application called TeamPlain ( teamplain.com ), which gives you a Web-based front-end to the work item tracking system. Everything you can do with Team Explorer and work items, including opening new work items, viewing them, and running queries, you can also do with TeamPlain, without having to install any software on a client machine. Again, another great example of the power and flexibility that these object models give you, to make the system work for you, the way you want it to.
So let's explore how to make a (very) poor man's version of TeamPlain. You are going to see how to create an ASP.NET Web page, which will display a list of team projects. You will select a team project, and a list of work items in that project will be displayed. You can then select a work item, and you will see the details of that work item.
Create a new ASP.NET Web site, and
Add the following code to the Page_Load event of the Default.aspx page:
if (!Page.IsPostBack) { TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("mstfs"); WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); ProjectCollection pc = wis.Projects; foreach (Project p in pc) { //al.Add(p.Name); ListItem li = new ListItem(); li.Text = p.Name; li.Value = p.Name; ddlProject.Items.Add(li); li = null; } wis = null; tfs = null; ddlProject.SelectedIndex = -1; }
This code retrieves all the projects from the work item store. This is a list of all the projects that have work items associated with them. For each project, the code creates a list item and populates the ddlProject drop-down list box.
In the SelectedIndexChanged event of the ddlProject drop-down list box, add the following code:
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("mstfs"); WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); WorkItemCollection wic = wis.Query("SELECT System.Id FROM workitems WHERE [Team Project] = ‘" + ddlProject.SelectedValue + "‘"); ddlWorkItem.Items.Clear(); foreach (WorkItem wi in wic) { ListItem li = new ListItem(); li.Text = wi.Id.ToString() + "- "+ wi.Title; li.Value = wi.Id.ToString(); ddlWorkItem.Items.Add(li); li = null; } wic = null; wis = null; tfs = null; ddlWorkItem.SelectedIndex = -1;
This code retrieves all the work items for the selected project and populates the ddlWorkItem drop-down list box with those work items.
Finally, add the following line of code to the SelectedIndexChanged event of the ddlWorkItem drop down list box:
Response.Redirect("http://mstfs:8080//WorkItemTracking/WorkItem.aspx?artifactMonike r=" + ddlWorkItem.SelectedValue.ToString());
This code uses and ASP.NET page provided by Team Foundation Server to return information on the selected work item. The work item ID is passed into the Web page, and is used to retrieve the work item information.
Figures 11-10 and 11-11 show the Web page and the detailed work item information for a selected work item.
Figure 11-10
Figure 11-11

Professional Application Lifecycle Management with Visual Studio 2010 (Wrox Programmer to Programmer)

Professional Team Foundation Server 2010 (Wrox Programmer to Programmer)

Professional Scrum with Team Foundation Server 2010 (Wrox Programmer to Programmer)

Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build