TFS2015:SQL数据库中存储的完整文件路径

时间:2016-04-12 18:16:59

标签: sql-server visual-studio crystal-reports tfs2015

我正在查看TFS2015背后的SQL数据库(或任何版本的TFS,在本例中为2015或2010)是否存储文件的完整文件路径。我们在项目文件夹中包含了信息(即版本号),虽然我发现有更好的方法来跟踪这些信息,但我们有很多遗留数据,只有该路径中存储的版本。我想将数据拉入Crystal Reports以剥离信息然后使用它。

Screenshot of the information I'm hoping to pull from database

1 个答案:

答案 0 :(得分:1)

您希望获取TFS源代码管理中的文件夹列表,而不是在数据库中查询,我们建议以编程方式实现。下面的博客和与之关联的示例代码将按您的要求执行:

http://blogs.microsoft.co.il/blogs/shair/archive/2009/02/26/tfs-api-part-16-mapping-source-control-using-versioncontrolserver.aspx

另外,请查看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);
                    }
                }
            }