我正在查看TFS2015背后的SQL数据库(或任何版本的TFS,在本例中为2015或2010)是否存储文件的完整文件路径。我们在项目文件夹中包含了信息(即版本号),虽然我发现有更好的方法来跟踪这些信息,但我们有很多遗留数据,只有该路径中存储的版本。我想将数据拉入Crystal Reports以剥离信息然后使用它。
答案 0 :(得分:1)
您希望获取TFS源代码管理中的文件夹列表,而不是在数据库中查询,我们建议以编程方式实现。下面的博客和与之关联的示例代码将按您的要求执行:
另外,请查看this case中的代码段,它可以为您提供帮助:
ICommonStructureService structureService = (ICommonStructureService)Tfscollection.GetService(typeof(ICommonStructureService));
ProjectInfo[] projects = structureService.ListAllProjects();
//combo_projects.ItemsSource = projects;
////Create VersionControlServer object from TFS
//sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
RecursionType recursion = RecursionType.OneLevel;
Item[] items = null;
string path = "$/" + projects[0].Name;//"$/TescoPOC/FetchStoryfromTFS";
ItemSet itemSet = versionControl.GetItems(path, recursion);
items = itemSet.Items;
//Dictionary<string, int> FolderListName = new Dictionary<string, int>();
List<string> FolderListName = new List<string>();
foreach (Item keyItem in items)
{
char[] charSeparators = new char[] { '/' };
//Using split to isolated the Project Name and the File Name
string[] ss = keyItem.ServerItem.Split(charSeparators, StringSplitOptions.None);
if (keyItem != items[0])
{
string filename = keyItem.ServerItem.Replace(path + "/", string.Empty);
if (filename != "BuildProcessTemplates")
{
FolderListName.Add(filename);
//if (FolderListName.ContainsKey(filename))
// FolderListName[filename] = FolderListName[filename] + 1;
//else
// FolderListName.Add(filename, 1);
}
}
}