I am trying to access saved TFS requests in their full path (deeper than My Requests / General Requests) and the name of the request.
The scenario is that users can add the path to their command directory, and the request names of their work items can be added to the xml configuration file. I read xml and get data.
XML example
<Teams> <Team name ="MyTeam"> <Query project="MyProj" queryfolder="Shared Queries/blah/blah2/MyTeamFolder" queryName="MyTeams WorkItems - All Workitems"/> </Team> </Teams>
I am looking to use "queryfolder" and "queryName" to find a query in TFS. What I still have is that it works for root directories ("My queries" / "General queries"), but I can’t figure out how getting something works on deeper paths.
This does not work:
QueryHierarchy queryRoot = workItemStore.Projects["MyProj"].QueryHierarchy; QueryFolder folder = (QueryFolder)queryRoot["Shared Queries/blah/blah2/MyTeamFolder"]; QueryDefinition query = (QueryDefinition)folder["MyTeams WorkItems - All Workitems"]; string queryResults = query.QueryText;
This will result in an error when searching for the folder QueryFolder folder = (QueryFolder) queryRoot [".."]
with KeyNotFoundException
changing a folder using "general queries" or "My queries", which can find this folder, but then would get the same exception when trying to find a query by its "name". And, as expected, if the request is in the root folder (general / my requests), it works fine.
So, how do I search deeper than just the root folder?
(all internet searches so far have cited only examples that use the root folder)
source share