2016-03-23 5 views

Antwort

0

Ich bin in der Lage Workitem von TFS mit folgendem Code zu lesen:

public static TFSTeamProjectCollection connectToTFS() throws URIException, SQLException 
{ 
    TFSTeamProjectCollection tpc = null; 
    Credentials credentials; 

    credentials = new UsernamePasswordCredentials("username,"password"); 
    tpc = new TFSTeamProjectCollection(URIUtils.newURI("http://0.0.0.127:8080/tfs/DefaultCollection"), credentials); 
    return tpc; 
} 


// get connection using above method 
TFSTeamProjectCollection tpc=connectToTFS(); 
WorkItemClient workItemClient = tpc.getWorkItemClient(); 
// Define the WIQL query.   
String wiqlQuery = "Select ID, Title from WorkItems where (State = 'Active') order by Title"; 

// Run the query and get the results.   
WorkItemCollection workItems = workItemClient.query(wiqlQuery); 
final int maxToPrint = 20; 

for (int i = 0; i < workItems.size(); i++)   
{ 
    if (i >= maxToPrint)    
    { 
     System.out.println("[...]");     
     break; 
    } 
    WorkItem workItem = workItems.getWorkItem(i); 

    System.out.println(workItem.getID()); 
    System.out.println(workItem.getTitle()); 
    System.out.println(workItem.getProject().getName()); 
    System.out.println(workItem.getClient().getUserDisplayName());   
} 
0

Sie mit dem unten Aussagen können wir genau assign_to Feldwert bekommen.

for (int i = 0; i < workItems.size(); i++)   
    { 

     WorkItem workItem = workItems.getWorkItem(i); 

     workItem.syncToLatest(); 
      System.out.println("task assigned to "+ workItem.getFields().getField("Assigned to").getValue()+" Task title is "+workItem.getFields().getField("title").getOriginalValue()); 


    }