What I am trying to do is find all .sql scripts pushed into my Test TFS Team Project during a specific timeframe AND then get either a link to view the file or download that copy OUTSIDE of my workspace. So I don't necessary want to get latest. This will be for an application to review all specifically .sql changes executed during a specific timeframe and then I will be comparing those files with a branched environment to determine which .sql where copied and ran against the database.
I am stuck on getting either a link to view the file or downloading the files. The problem I foresee with downloading the files is that I am going to download hundreds of files and what I really will end up doing to viewing each file to determine if I can re-run the .sql script against a different environment outside of Test.
public void GetChangesets(DataTable files,
bool excludeManualDatabaseFiles,
bool containsExcludedDerictoriesAndFiles)
{
// this gets collection-lvl services, in contrast to TfsConfigurationServer (server-lvl)
Uri serverUri = new Uri("<insert serverUri>");
var tpc = new TfsTeamProjectCollection(serverUri);
var vcs = tpc.GetService<VersionControlServer>();
DateTime testDate;
DateTime.TryParse("2017-07-01", out testDate);
VersionSpec fromDateVersion = new DateVersionSpec(testDate);
VersionSpec toDateVersion = new DateVersionSpec(DateTime.Now);
vcs.QueryRootBranchObjects(RecursionType.Full);
string teamProjectName = "<insert team project name>";
TeamProject[] tps = new TeamProject[]
{
vcs.GetTeamProject(teamProjectName)
};
DataTable returnedChangesetDetail = new DataTable();
// Step 1: THIS WORKS
returnedChangesetDetail.Columns.Add("FileName");
// Step 2: THIS DOES NOT WORK, this is currently empty !!!!!!
returnedChangesetDetail.Columns.Add("Uri");
foreach(TeamProject tp in tps)
{
IEnumerable changesets = vcs.QueryHistory(string.Concat("$/", tp.Name, "/Test/SQL"),
VersionSpec.Latest,
deletionId: 0,
recursion: RecursionType.Full,
user: null,
versionFrom: fromDateVersion,
versionTo: toDateVersion,
maxCount: int.MaxValue,
includeChanges: true,
slotMode: true);
foreach(Changeset changeset in changesets)
{
foreach(Change change in changeset.Changes)
{
string fileName = change.Item.ServerItem;
// I think this would be it but its not an accessible link, do I add/remove
// something to make this a Uri?
//var artifactUrui = change.Item.ArtifactUri;
// Step 1: WORKING
lstbxFileNames.Items.Add(fileName);
}
}
}
}
I hope that the comments explain what I am looking for. This will be an app for a non-dev but tech user to be able to review the changes needed in their environment. They will need to review approx 100 files and I was thinking a Uri would be an easy way for them to see the changes and then later select the files they need while disregarding changes found in Step 1 but determined not needed.