TFS Two-time development workitem Add and modify, save

Source: Internet
Author: User

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 (); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.