WIQL查询以获取项目中的所有团队和用户? [英] WIQL query to get all the team and the users in a Project?

查看:175
本文介绍了WIQL查询以获取项目中的所有团队和用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有一个项目名称"Scrum",并且该项目有一些用户并且获得了sprint,所以**我希望该项目的目标用户使用Scrum中的Sprint **.图片已附上.

let's say i have a project name ="Scrum" and that has some users the project and got sprints so **i want dstinct users of the Project that the Sprints in Scrum **. image attached.

推荐答案

您还可以将以下代码用于团队:

You can use also this code for teams:

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.ProcessConfiguration.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.Collections.Generic;
using System.Linq;

namespace QueryLinkedWIQL
{
    class Program
    {

        static List<TeamFoundationTeam> ListTeams(TfsTeamProjectCollection pTpc, Project pProject)
        {
            TfsTeamService _teamService = pTpc.GetService<TfsTeamService>();
            var _teams = _teamService.QueryTeams(pProject.Uri.ToString());

            return (from t in _teams select t).ToList();
        }

        static bool GetTeamsSettings(TfsTeamProjectCollection pTpc, TeamFoundationTeam pTeam)
        {
            try
            {
                var _teamConfig = pTpc.GetService<TeamSettingsConfigurationService>();

                var _configs = _teamConfig.GetTeamConfigurations(new Guid[] { pTeam.Identity.TeamFoundationId  });

                Console.WriteLine("============={0}==================", pTeam.Name);

                Console.WriteLine("Team Members: ");

                foreach (var _member in pTeam.GetMembers(pTpc, MembershipQuery.Expanded))
                    Console.WriteLine("Display Name: " + _member.DisplayName + " || Is active: " + _member.IsActive);

                foreach( var _config in _configs)
                {
                    Console.WriteLine("Team current iteration: " + _config.TeamSettings.CurrentIterationPath);
                    Console.WriteLine("Team selected iterations:");
                    foreach (var _iteration in _config.TeamSettings.IterationPaths)
                        Console.WriteLine(_iteration);
                    Console.WriteLine("Team selected areas:");
                    foreach (var _area in _config.TeamSettings.TeamFieldValues)
                        Console.WriteLine("Area path: " + _area.Value + " || Include children: " + _area.IncludeChildren.ToString());
                }

                Console.WriteLine("===============================");


            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }

        static void Main(string[] args)
        {

            string _teamProject = "YourProjectName";

            try
            {
                TfsTeamProjectCollection _tpc = new TfsTeamProjectCollection(new Uri("http://yourserver/DefaultCollection"));

                WorkItemStore _wistore = _tpc.GetService<WorkItemStore>();

                var _teams = ListTeams(_tpc, _wistore.Projects[_teamProject]);
                foreach (var _team in _teams) GetTeamsSettings(_tpc, _team);

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
    }
}

这篇关于WIQL查询以获取项目中的所有团队和用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆