2

有很多例子展示了如何获取当前 TFS 用户的列表,但是如何获取过去有提交更改但不再属于任何安全组的旧用户的列表?

作为记录,这是我用来查找所有当前用户的代码:

var gss = tfs.GetService<IGroupSecurityService>();
var members = gss.ReadIdentity(SearchFactor.EveryoneApplicationGroup,
                               null,
                               QueryMembership.Expanded).Members;
return gss.ReadIdentities(SearchFactor.Sid, members, QueryMembership.None)
    .Where(identity => identity != null &&
                       identity.Type == IdentityType.WindowsUser)
    .Select(identity => string.Format(@"{0}\{1}",
                                      identity.Domain,
                                      identity.AccountName));
4

2 回答 2

1

我无法提供确切的答案,但希望这会有所帮助...

您可以通过工作区(即 tf.exe 工作区命令和等效 API)列出所有待处理的更改。使用具有未提交更改的每个工作区的所有者,您应该能够交叉引用您已经拥有的活动用户列表。

于 2011-12-04T12:41:00.780 回答
0

下面的代码片段应该揭示曾经在 TeamCollection 存储库中提交过更改的每个人:

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

namespace PeopleWhoHaveCommitedChangesets
{
    class Program
    {
        static void Main()
        {
            TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSServer:8080"));
            VersionControlServer vcs = (VersionControlServer) tpc.GetService(typeof (VersionControlServer));
            IEnumerable results = vcs.QueryHistory(@"$/",
                                                    VersionSpec.Latest, 0, RecursionType.Full, null, null, null, int.MaxValue, true, true);
            List<Changeset> changesets = results.Cast<Changeset>().ToList();

            List<string> Users = new List<string>();
            foreach (var changeset in changesets)
            {
                if(!Users.Contains(changeset.Owner))
                {
                    Users.Add(changeset.Owner);
                }
            }
        }
    }
}

Beware that this is a brute force, and, with a lot of changesets, it would take considerable time to execute.

于 2011-12-05T11:17:41.253 回答