如何获取引用特定迭代路径查询名路径、迭代

2023-09-04 03:33:45 作者:某个路人。

通过选择项目名称,我就装循环路径。现在我需要引用选定迭代路径查询名称。

code加载循环路径传递项目名称:

 私人无效LoadIterationPaths(字符串项目名)
        {
            VAR TFS = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_tfs.Uri);
            变种wiStore = tfs.GetService&其中; WorkItemStore>();
            VAR projCollections = wiStore.Projects;

            VAR detailsOfTheSelectedProject = projCollections.Cast<项目>()式(项目=>!String.IsNullOrEmpty(_selectedTeamProject.Name))。
                                                                        .FirstOrDefault(项目=> project.Name.Contains(_selectedTeamProject.Name));
            VAR iterationPathsList = GetIterationPaths(detailsOfTheSelectedProject);

            的foreach(在iterationPathsList.Where VAR iterationPath(iterationPath => iterationPath.Contains(项目名称)))
            {
                cmbIterationPath.Items.Add(iterationPath);
            }
            cmbIterationPath.Enabled = cmbIterationPath.Items.Count> 0;
        }
 

现在,我需要查询的名字引用选定迭代路径列表。谢谢你。

TiDB进阶篇 TiKV架构

注意:我能够得到所有的查询名字中的一个项目,但是,我不需要。 对于我用下面的code

 的foreach(在detailsOfTheSelectedProject.StoredQueries StoredQuery齐)
        {
            cmbQueries.Items.Add(qi.Name);
        }
 

解决方案

您code应该看起来像这样

字符串selectedIterationPath = ... 的foreach(在detailsOfTheSelectedProject.StoredQueries StoredQuery气){   如果(qi.QueryText.Contains(selectedIterationPath){             cmbQueries.Items.Add(qi.Name);   } }

这是我和Beytan库尔特的意见建议。 取而代之的是哑巴包含,你应该使用的正防爆pression 来考虑误报和漏报。

With selected project name, I had loaded iteration paths. Now I need to get the query names that references the selected iteration path.

Code to load iteration paths passing project name:

        private void LoadIterationPaths(string projectName)
        {
            var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_tfs.Uri);
            var wiStore = tfs.GetService<WorkItemStore>();
            var projCollections = wiStore.Projects;

            var detailsOfTheSelectedProject = projCollections.Cast<Project>().Where(project => !String.IsNullOrEmpty(_selectedTeamProject.Name))
                                                                        .FirstOrDefault(project => project.Name.Contains(_selectedTeamProject.Name));
            var iterationPathsList = GetIterationPaths(detailsOfTheSelectedProject);

            foreach (var iterationPath in iterationPathsList.Where(iterationPath => iterationPath.Contains(projectName)))
            {
                cmbIterationPath.Items.Add(iterationPath);
            }
            cmbIterationPath.Enabled = cmbIterationPath.Items.Count > 0;
        }

Now, I need to get the list of Query names that references the selected iteration Path. Thanks.

Note: I am able to get all the query names in a project but that i don't need. For that I used the below code

foreach (StoredQuery qi in detailsOfTheSelectedProject.StoredQueries)
        {
            cmbQueries.Items.Add(qi.Name);
        }

解决方案

Your code should looks like this

string selectedIterationPath = ... foreach (StoredQuery qi in detailsOfTheSelectedProject.StoredQueries) { if (qi.QueryText.Contains(selectedIterationPath) { cmbQueries.Items.Add(qi.Name); } }

This is what me and Beytan Kurt suggested in the comments. Instead of a dumb Contains, you should use a Regular Expression to account for false positives and negatives.

 
精彩推荐
图片推荐