Work Item Tracking Object Model


Chapter 9 introduced the Team Foundation Server Object Model, and briefly touched on the WorkItemStore service type. This WorkItemStore service type allows you access to the Work Item Tracking Object Model, which is the public interface to the work item tracking Web service on the Team Foundation Server. You use this object model to programmatically interact with the work item tracking system.

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 next section). Once you have retrieved a work item, you can examine its contents or make changes and save them back to the Team Foundation Server. The Visual Studio Software Development Kit has some extensive documentation on the work item tracking object model; we would refer you to there for more information.

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.

  1. Create a new ASP.NET Web site, and name it Chp11WITWebSite.

  2. Open the Default.aspx page, and add two DropDownList controls. Name the first control ddlProject and the second ddlWorkItem, and enable AutoPostBack on each control. The first control is going to contain a list of team projects from the Team Foundation Server. When a project is selected, the second control will be populated with a list of work items from that project. Selecting a work item from the second control will display some detailed information for that work item.

  3. 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.

  4. 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.

  5. 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.

image from book
Figure 11-10

image from book
Figure 11-11



Professional Team Foundation Server
Professional Team Foundation Server
ISBN: 0471919306
EAN: 2147483647
Year: 2004
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net