We have many projects with several files inside each. Files can be checked in from the main solution root, from the project level and from the individual level.
Is there a way to find all files checked in by a particular user during the past few days, for all the levels?
If you have the TFS power tools installed you can use the command "tfpt searchcs" from a visual studio command prompt. This will allow you to search for all change sets checked in by a particular user and also set a start and end date along side some other filters. This might meet your needs
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