3

我是使用 TFS API 的新手,我正在编写一个删除我的团队项目的应用程序,但在我删除之前我想知道最后一次合并我的意思是出现在 Source Control Explorer > “Sample Project” >查看历史记录,并放入文本框中。

还有用户最后一次进入项目的信息。

4

2 回答 2

3

我不知道如何检查用户上次连接到项目的时间,但这是您可以从代码访问源代码控制历史记录的方式,

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

于 2013-09-17T10:40:40.943 回答
0

(我假设您指的是 TFS 2012)

2013 年 MSDN 杂志中有一篇文章应该给你一个不错的起点 - http://msdn.microsoft.com/en-us/magazine/jj883959.aspx

顺便说一句,如果您想删除团队项目,我强烈建议您使用 TFSDeleteProject ( http://msdn.microsoft.com/en-us/library/ms181482.aspx ),因为您将使用受支持的工具。

于 2013-07-08T02:44:53.250 回答