As an admin of a TFS server I wanted to be able to send an email to people reminding them of any pending changes they may have.
I knocked up a quick application and have now configured it to run once a week with a scheduled task.
The main logic to get pending change sets is (where _vcs is a VersionControlServer from the Microsoft.TeamFoundation.VersionControl.Client namespace):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
var itemSpecs = new[] { new ItemSpec("$/", RecursionType.Full) }; var pendingSets = _vcs.QueryPendingSets(itemSpecs, null, null); var pendingChanges = (from pendingSet in pendingSets from pendingChange in pendingSet.PendingChanges orderby pendingSet.OwnerDisplayName, pendingChange.ServerItem select new PendingChange { OwnerDisplayName = pendingSet.OwnerDisplayName, OwnerName = pendingSet.OwnerName, LocalItem = pendingChange.LocalItem, ServerItem = pendingChange.ServerItem, PendingSetName = pendingChange.PendingSetName + " [" + pendingSet.Computer + "]" }).ToList(); |
The PendingChange class is a simple POCO:
1 2 3 4 5 6 7 8 |
public class PendingChange { public string OwnerDisplayName { get; set; } public string OwnerName { get; set; } public string LocalItem { get; set; } public string ServerItem { get; set; } public string PendingSetName { get; set; } } |
After that it was a simple case of looping through the PendingChanges List<> building up emails and sending them.