2013-06-12 37 views
0

我正在嘗試對TFS2010中的工作項目進行大量驗證。我明白可以使用微軟給出的開箱即用的規則來完成驗證,但我期待進行更高級的驗證。例如,TFS工作項目交叉驗證是可能的嗎?

1)如果前一個Sprint正在進行,則不應發生Sprint Planning。

2)我也在尋找工作項目類型之間的驗證。例如,除了當前Sprint中計劃的狀態更改外,所有用戶故事都不應允許進行狀態更改。

是有可能通過API,如果是指導我上面兩個是我的要求....

另一個查詢,或者是有可能寫驗證錯誤,這scenario..say當我們試圖保存任何無標題它拋出TF20012工作項...

同樣,我們可以處理這種情況?如果是的話引導我...

但我想這樣,啓動我試圖這樣下面的代碼以前的衝刺說我包括開始和結束日期跟蹤,如果是的話,那麼我必須寫出所有n次衝刺,結束了...哪種方式最好去ahea d

Uri tfsUri = (args.Length < 1) ? 
       new Uri("http://cscdbche646:8080/tfs") : new Uri(args[0]); 

      TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); 

      // Get the catalog of team project collections 
      ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
       new[] { CatalogResourceTypes.ProjectCollection }, 
       false, CatalogQueryOptions.None); 

      // List the team project collections 
      foreach (CatalogNode collectionNode in collectionNodes) 
      { 
       // Use the InstanceId property to get the team project collection 
       Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); 
       TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); 

       // Print the name of the team project collection 
       Console.WriteLine("Collection: " + teamProjectCollection.Name); 

       // Get a catalog of team projects for the collection 
       ReadOnlyCollection<CatalogNode> projectNodes = collectionNode.QueryChildren(
        new[] { CatalogResourceTypes.TeamProject }, 
        false, CatalogQueryOptions.None); 

       // List the team projects in the collection 
       foreach (CatalogNode projectNode in projectNodes) 
       { 
        Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName); 

        // Get the work item store 
        WorkItemStore workItemStore = teamProjectCollection.GetService<WorkItemStore>(); 
        // WorkItemCollection queryResults = workItemStore.Query(" Select [State], [Title] From WorkItems Where [Work Item Type] = 'Bug'"); 
        WorkItemCollection queryResults = workItemStore.Query("Select [Work Item Type] = 'User Story' From WorkItems Where [State] = 'Closed' And ([System.StartDate.SDate] = '10/05/13') And ([System.EndDate.EDate] = '20/05/13')"); 

        foreach (WorkItem wi in queryResults) 
        { 
         Console.WriteLine("State = " + wi.State.ToString()); 
         Console.WriteLine("Title = " + wi.Title.ToString()); 
         //string oldAssignedTo = (string)wi.Fields["State"].Value; 
         //wi.Fields["State"].Value = "In-Progress"; 
         if (wi.IsDirty) 
          Console.WriteLine("The work item state cannot be changed."); 
         string oldAssignedTo = (string)wi.State; 
         wi.Fields["State"].Value = oldAssignedTo; 
         wi.Save(); 


        } 

       } 
      } 

回答

0

我想你可以通過結合API和工作項目類型模板來實現它。您可以修改TFS工作項定義類型並在字段上設置一些規則,或者您可以定義自己的自定義字段並在其上設置條件/值。恩。您可以創建一個自定義字段來跟蹤衝刺狀態並使用工作項類型的When, AllowedValues, ProhibitedValues

您還可以將標題設置爲NotEmptyWhen條件。您可以參考this瞭解如何定義現場規則,定製工作項目類型等。

我希望這會對您有所幫助。