I am trying to write a small Relase Notes program with C#. I need to fetch all changesets and related work items belongs to specified project between specified dates.
I tried to use QueryHistory method but i couldn't find how could i give date filter.
You can set
VersionSpec versionFrom = GetDateVSpec(date);
VersionSpec versionTo = GetDateVSpec(DateTime.Now);
Then with
IEnumerable results = versionServer.QueryHistory(sourceControlPath, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, int.MaxValue, true, true);
List<Changeset> changesets = results.Cast<Changeset>().ToList();
you get the changesets you 're after.
GetDateVSpec
goes as follows:
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, "");
}
I use this in one of my own tools, originally I had found the core for this here (a great post by Robaticus)