10

我们有很多项目,每个项目里面都有几个文件。可以从主解决方案根目录、项目级别和个人级别签入文件。

有没有办法找到过去几天特定用户签入的所有文件,适用于所有级别?

4

2 回答 2

4

I think it's not possible to drill down to the files of each changeset of a user within a given timeframe by using the standard reporting facilities of TFS.

The following uses the TFS-SDK & should accomplish the task:

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, "");
        }
    }
}

The GetDateVSpec was copied from this post by Robaticus

于 2012-06-20T12:36:36.660 回答
4

如果您安装了 TFS 电动工具,则可以从 Visual Studio 命令提示符使用命令“tfpt searchcs”。这将允许您搜索由特定用户签入的所有更改集,并与其他一些过滤器一起设置开始和结束日期。这可能会满足您的需求

于 2012-06-21T00:45:59.083 回答