如何获得在TFS API的sourcecontrol的历史?如何获得、历史、API、TFS

2023-09-06 15:33:01 作者:友谊长生不老

我是新使用TFS API,我书面方式一个应用程序,谁删除我的团队项目,但在此之前我删除,我想知道上一次被合并了我的意思是出现在源代码控制浏览器的信息>样本项目>查看历史记录,并付诸文本框。

I'm new using the TFS API, I'm writting an app who delete my team projects, but before I delete I want to know the last time was merged I mean the info that appear in Source Control Explorer > "Sample Project" > view history, and put into a textbox.

此外,最后一次用户输入的项目的信息。

Also the info of the last time a user entered the project.

推荐答案

我不知道如何检查的时候是一个用户连接到该项目中的最后一次,但如何从$ C访问源代码控制历史$ C,

I Don't know how to check when was the last time a user connected to the project, but this how you can access the source control history from code,

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-$c$c.aspx