2014-09-18 3 views
8

저는 WPF/C#에서 프로젝트보고 도구를 작성하려고합니다. TFS (Team Foundation Server)의 모든 프로젝트 이름에 액세스 한 다음 주어진 프로젝트의 각 작업 항목에 대한 통계를 표시하려고합니다.C#의 TFS에서 workitem 목록을 검색하려면 어떻게해야합니까?

프로젝트 이름을 얻었지만 실제 작업 항목을 얻는 것이 어렵습니다. 여기가 내가 지금까지있어 무엇 :

public const string tfsLocation = "http://whatever"; 

// get the top list of project names from the team foundation server 
public List<string> LoadProjectList() 
{ 
    var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsLocation)); 
    var workItemStore = new WorkItemStore(tpc); 
    var projects = (from Project project in workItemStore.Projects select project.Name).ToList(); 

    return projects; 
} 

public string GetProjectInfo(string targetProject) 
{ 
    string info = String.Empty; 

    var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsLocation)); 
    var workItemStore = new WorkItemStore(tpc); 

    foreach (Project project in workItemStore.Projects) 
    { 
     if (project.Name == targetProject) 
     { 
      info += String.Format("Project: {0}\n\n", project.Name); 

      info += "Work Item Types:\n"; 
      foreach (WorkItemType item in project.WorkItemTypes) 
      { 
       info += String.Format("- {0}\n", item.Name); 
       info += String.Format(" - Description: {0}\n", item.Description); 
       info +=    " - Field Definitions:\n"; 

       foreach (FieldDefinition field in item.FieldDefinitions) 
       { 
        info += String.Format("  - {0}\n", field.Name); 
       } 
       info += "\n"; 
      } 
     } 
    } 

    return info; 
} 

GetProjectInfo 각 프로젝트 기능에 대한 몇 가지 유용한 정보를 다시 보내지 만, 나는 단지 정의 작업 항목이 구성 무엇을 보는 것 같은 지금까지 보이는, 실제 WorkItem 자체는 아닙니다. 필자가 작성한 프로그래밍이 잘못된 위치에서 찾고 있다고 생각합니다.

WorkItem에서의 마이크로 소프트의 정의, ( http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.workitem.aspx)는 WorkItemTracking.Client 내부의 아닌 WorkItemStore 내부, 나는 그것을 액세스하기 위해 갈 곳 모르겠어요 것 같습니다 에서.

최종 버전 :

여기 아래의 대답을 참조 후, 내 기능의 업데이트 버전입니다. 이 작업은 작업 항목 이름의 긴 문자열을 새로운 줄 사이에 인쇄합니다. 인쇄 할 때는 작업중인 모든 항목을 (지금 당장) 가져옵니다.

+0

나는 흥미롭게 들린다. 누군가가이 일을하도록 도와주세요. – mybirthname

답변

10

관심있는 실제 작업 항목을 얻으려면 WIQL 쿼리를 사용해야합니다. 특정 프로젝트의 모든 작업 항목을 가져 오는 것 :

using Microsoft.TeamFoundation.WorkItemTracking.Client; 

Query query = new Query(
    workItemStore, 
    "select * from issue where System.TeamProject = @project", 
    new Dictionary<string, string>() { { "project", project.Name } } 
); 

var workItemCollection = query.RunQuery(); 
foreach(var workItem in workItemCollection) 
{ 
    /*Get work item properties you are interested in*/ 
    foreach(var field in workItem.Fields) 
    { 
     /*Get field value*/ 
     info += String.Format("Field name: {0} Value: {1}\n", field.name, field.Value); 
    } 
} 
+0

및 플랫 쿼리 및 계층 구조에 대한 여러 가지 방법이 있음을 염두에 두십시오 –

+0

나는 이것을 조사하여 작동시킬 수 있는지 알아 봅니다. 감사. –

+0

"from issue"를 사용했지만 "WorkItems"가 아니어야합니까? "문제"참조 란 무엇입니까? –

관련 문제