WorkItemStore: Represents a work item client connection that tracks a server running team Foundation.
A. Adding work items
1. First get the WorkItemStore of a server.
WorkItemStore workstore = server. Getservice<workitemstore> ();
2. Then get Project project from above WorkItemStore.
Project Project = Workstore. projects["Calueng"];
3. Get work Item type WORKITEMTYPE according to project, which can be bugs, tasks, and so on.
WorkItemType itemtype = project. workitemtypes ["Bug"];
4. Create a new work item according to WorkItemType WorkItem
WorkItem bug = new WorkItem (itemtype);
B. Modifying work items and saving work items
1. Can also be modified by WorkItemStore to obtain the WorkItem of the specified ID
WorkItem WorkItem = Workstore. Getworkitem (1);
2.workitem. Fields [Assigned to]. Value = "* * *"; set who the appointment is.
static void Main (string[] args) {uri Tfsuri = new Uri ("Http://pc-20130113jkun:8080/tfs");
Tfsteamprojectcollection Server = new Tfsteamprojectcollection (Tfsuri); WorkItemStore workstore = server.
Getservice<workitemstore> (); Get Calueng this team project projects = Workstore.
projects["Calueng"]; Create a new work item of type "bug", or you can create a new task such as WorkItemType itemtype = project.
Workitemtypes["Bugs"];
WorkItem bug = new WorkItem (itemtype); Make bugs such as the title, description, and status of the bug work item.
Title = "First bug"; Bug. Description = "Two development added first bug!
"; Set the bug's assigned object to be a Zhangyuchun bug. Fields["Assigned to"].
Value = "Zhangyuchun"; Bug.
state = "new"; Bug.
Save (); Console.WriteLine ("The first bug has been saved successfully!")
"); Gets the work item with ID 1, where workitem WorkItem = Workstore is obtained by Getworkitem method.
Getworkitem (1); Get the original assignment, modify the assigned object for ID 1 work Item string oLdassignedto = (string) WorkItem. Fields["Assigned to"].
Value; WorkItem. Fields["Assigned to"].
Value = "Laijingsi"; See if the work item is valid, and save the work item if (WorkItem. IsValid ()) {WorkItem.
Save ();
Console.WriteLine ("The object originally assigned is:" +oldassignedto); Console.WriteLine ("Work item has been saved successfully.)
");
} console.readline (); }