2012-06-20 57 views

回答

4

複製如果您已經安裝就可以使用該命令的TFS電動工具「 tfpt searchcs「從Visual Studio命令提示符處。這將允許您搜索由特定用戶簽入的所有更改集,還可以在其他一些過濾器旁邊設置開始日期和結束日期。這可能會滿足您的需求

4

我認爲通過使用TFS的標準報告功能,不可能在給定的時間範圍內深入查看用戶每個變更集的文件。

下使用TFS-SDK &應該完成的任務:

using System; 
using System.Collections; 
using System.Collections.Generic; 
using System.Linq; 
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.VersionControl.Client; 

namespace GetCheckedInFiles 
{ 
    class Program 
    { 
     static void Main() 
     { 
      TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsURI")); 

      var versionControl = teamProjectCollection.GetService<VersionControlServer>(); 

      //enforcing 3 days as "past few days": 
      var deltaInDays = new TimeSpan(3, 0, 0, 0); 
      DateTime date = DateTime.Now - deltaInDays; 

      VersionSpec versionFrom = GetDateVSpec(date); 
      VersionSpec versionTo = GetDateVSpec(DateTime.Now); 

      IEnumerable results = versionControl.QueryHistory("$/", VersionSpec.Latest, 0, RecursionType.Full, "User" , versionFrom, versionTo, int.MaxValue, true, true); 
      List<Changeset> changesets = results.Cast<Changeset>().ToList(); 

      if (0 < changesets.Count) 
      { 
       foreach (Changeset changeset in changesets) 
       { 
        Change[] changes = changeset.Changes; 
        Console.WriteLine("Files contained in "+changeset.ChangesetId+" at "+changeset.CreationDate+" with comment "+changeset.Comment); 

        foreach (Change change in changes) 
        { 
         string serverItem = change.Item.ServerItem; 
         Console.WriteLine(serverItem + " "+change.ChangeType); 
        } 
        Console.WriteLine(); 
       } 
      } 

     } 

     private static VersionSpec GetDateVSpec(DateTime date) 
     { 
      string dateSpec = string.Format("D{0:yyy}-{0:MM}-{0:dd}T{0:HH}:{0:mm}", date); 
      return VersionSpec.ParseSingleSpec(dateSpec, ""); 
     } 
    } 
} 

GetDateVSpecthis後由Robaticus

相關問題