Project connection and work item query for TFs Secondary Development

Source: Internet
Author: User
  • ClassProgram
  • {
  • // This example shows how to access the project list, query the work items of each project, and edit the work items.
  • Static
    VoidMain (String[] ARGs)
  • {
  • Networkcredential Re =NewNetworkcredential (user, password); // initialize the user
  • Tfsteamprojectcollection TPC =NewTfsteamprojectcollection (
  • NewUri ("http: // ip: 8080/defaultcollection"), CRES );
  • TPC. Authenticate ();
  • Workitemstore = (workitemstore) TPC. getservice (Typeof(Workitemstore); // getservice obtains various services, including work items and version control.
  • // Print all projects
  • Foreach(Project itemInWorkitemstore. Projects)
  • {
  • Console. writeline (item. Name );
  • }
  • // Unique wilq query, which is different from 2008 and 2010
  • Workitemcollection queryresults = workitemstore. Query (
  • "Select [system. Title] From workitems where [system. teamproject] = 'work management'" +
  • "And [system. workitemtype] = 'task' and [system. State] = 'active'" +
  • "Order by [system. State] ASC, [system. changeddate] DESC ");
  • Workitem ad = queryresults [22];
  • Ad. Fields ["assigned to"]. value = "XX ";
  • // Verify whether the fields of the work item are valid. If a save error occurs, you can verify the error in this way.
  • Arraylist AR = AD. Validate ();
  • Foreach(VAR itemInAR)
  • {
  • Console. writeline (item. tostring ());
  • }
  • Ad. Save ();
  • // Work item Field Information
  • Fieldcollection FL = AD. fields;
  • Foreach(Field itemInFL)
  • {
  • Console. writeline (item. Name );
  • }
  • Console. writeline (Ad. Title );
  • Console. writeline (queryresults. Count );
  • Console. readkey ();
  • }
  • }

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.