2013-07-05 94 views
2

我是新的使用TFS API,我正在寫一個應用程序誰刪除我的團隊項目,但在我刪除之前我想知道上次合併我的意思是出現在源代碼管理資源管理器>「示例項目「>查看歷史記錄,並放入一個文本框。如何獲取TFS API中sourcecontrol的歷史記錄?

同樣是用戶最後一次輸入項目的信息。

回答

2

我不知道如何檢查的時候是最後一次用戶連接到該項目,但該如何從代碼訪問源控制歷史,

using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.VersionControl.Client; 
using System.Collections; 
using System.Windows.Forms; 

//The example function is very simple: It gets a change and shows message boxes of all the changesets that have a change for the specified file up to the change transferred to the method. 

//Note: Change the [Server Name] with your TFS name. 

    public void GetChangesetsOfFile(Change theChange) 
    { 
     //Query History parameters 

     TeamFoundationServer tfs = new TeamFoundationServer 
        ("[Server Name]"); 

     VersionControlServer VCServer = 
        (VersionControlServer)tfs.GetService 
        (typeof(VersionControlServer)); 

     int changeId = (theChange.Item.DeletionId != 0) ? 
        theChange.Item.ChangesetId - 1 : 
        theChange.Item.ChangesetId; 

     ChangesetVersionSpec version = new 
          ChangesetVersionSpec(changeId); 
     ChangesetVersionSpec versionFrom = new 
          ChangesetVersionSpec(1); 
     string path = theChange.Item.ServerItem; 

     //Query History Command 
     IEnumerable changesets = VCServer.QueryHistory(path, 
       version, 0, RecursionType.None, null, 
       versionFrom, LatestVersionSpec.Latest, 
       int.MaxValue, true, false); 


     foreach (Changeset cSet in changesets) 
     { 
     MessageBox.Show(cSet.Changes 
      [0].Item.ChangesetId.ToString()); 
     } 
    } 

參考

http://blogs.microsoft.co.il/blogs/srlteam/archive/2009/06/14/how-to-get-a-file-history-in-tfs-source-control-using-code.aspx