Show all pending changes on the Team Foundation server older than a given age
This came up in the forums and Brian responded with an example showing how to list all pending changes. This is a slightly modified version to print out the changes older than 2 weeks.
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(server);
VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
TimeSpan cutoffAge = TimeSpan.FromDays(14); // 2 weeks
DateTime cutoffPoint = DateTime.Now - cutoffAge;
PendingSet[] sets = vcs.GetPendingSets(new String[] { "$/" }, RecursionType.Full);
Console.WriteLine("{0} total pending set(s)", sets.Length);
foreach (PendingSet set in sets)
{
bool setInfoShown = false;
foreach (PendingChange pc in set.PendingChanges)
{
if (pc.CreationDate < cutoffPoint)
{
if (!setInfoShown)
{
setInfoShown = true;
Console.WriteLine();
Console.WriteLine("Workspace {0};{1} on {2} has {3} total pending change(s)", set.Name, set.OwnerName, set.Computer, set.PendingChanges.Length);
}
Console.WriteLine("{0,-20} {1,-10} {2,-16} {3}", pc.FileName, pc.ChangeTypeName, pc.CreationDate, pc.LocalItem);
}
}
}