async Task <List <TeamMemberModel> > GetTeamMembers(string projectId, string teamId, TeamHttpClient teamClient) { List <TeamMemberModel> lst = null; TeamMemberModel teamMemberModel = null; try { var teamMembers = await teamClient.GetTeamMembersWithExtendedPropertiesAsync(projectId, teamId); if (teamMembers != null && teamMembers.Count > 0) { lst = new List <TeamMemberModel>(); foreach (var member in teamMembers) { if (member.Identity != null) { teamMemberModel = new TeamMemberModel() { Email = member.Identity.UniqueName, MemberId = member.Identity.Id, MemberName = member.Identity.DisplayName, MemberUrl = member.Identity.Url }; } lst.Add(teamMemberModel); } } } catch (Exception) { } return(lst); }
/// <summary> /// Get detailed team information /// </summary> /// <param name="TeamProjectName"></param> /// <param name="TeamName"></param> static void GetTeamInfo(string TeamProjectName, string TeamName) { WebApiTeam team = TeamClient.GetTeamAsync(TeamProjectName, TeamName).Result; Console.WriteLine("Team name: " + team.Name); Console.WriteLine("Team description:\n{0}\n", team.Description); List <TeamMember> teamMembers = TeamClient.GetTeamMembersWithExtendedPropertiesAsync(TeamProjectName, TeamName).Result; string teamAdminName = (from tm in teamMembers where tm.IsTeamAdmin == true select tm.Identity.DisplayName).FirstOrDefault(); if (teamAdminName != null) { Console.WriteLine("Team Administrator:" + teamAdminName); } Console.WriteLine("Team members:"); foreach (TeamMember teamMember in teamMembers) { if (!teamMember.IsTeamAdmin) { Console.WriteLine(teamMember.Identity.DisplayName); } } }
/// <summary> /// Get User from the Default Team /// </summary> /// <param name="TeamProjectName"></param> /// <param name="USerDisplayName"></param> /// <returns></returns> static string GetUserId(string TeamProjectName, string UserDisplayName) { List <TeamMember> teamMembers = TeamClient.GetTeamMembersWithExtendedPropertiesAsync(TeamProjectName, TeamProjectName + " Team").Result; var users = from x in teamMembers where x.Identity.DisplayName == UserDisplayName select x.Identity.Id; if (users.Count() == 1) { return(users.First()); } return(""); }
public static IEnumerable <TeamMember> GetAllTeamMembers(this AzureContext context) { List <TeamMember> allMembers = new List <TeamMember>(); TeamHttpClient teamClient = context.GetHttpClientTeam(); string defaultProjectId = context.GetDefaultProject().Id.ToString(); foreach (WebApiTeam team in context.GetTeams()) { allMembers.AddRange(teamClient.GetTeamMembersWithExtendedPropertiesAsync(defaultProjectId, team.Id.ToString()).Result); } return(allMembers.Where(item => !item.Identity.Inactive).GroupBy(item => item.Identity.Id).Select(groupedItem => groupedItem.First())); }
public List <Assignee> GetAssigneesNames(int projectId) { List <Assignee> onlineTeamMembersList = new List <Assignee>(); List <WebApiTeam> teams = _teamClient.GetTeamsAsync(OnlineTfsProjectId).Result; foreach (WebApiTeam team in teams) { List <TeamMember> teamMembers = _teamClient.GetTeamMembersWithExtendedPropertiesAsync(OnlineTfsProjectId, team.Id.ToString()).Result; foreach (TeamMember member in teamMembers) { onlineTeamMembersList.Add(new Assignee { IsActive = 1, ProjectId = projectId, Name = member.Identity.DisplayName }); } } return(onlineTeamMembersList); }
/// <summary> /// Gets the team members for the <paramref name="teamNameOrId" /> in the project corresponding to the <paramref name="projectNameOrId" />. /// </summary> /// <param name="teamHttpClient">The team HTTP client.</param> /// <param name="projectNameOrId">The project name or identifier.</param> /// <param name="teamNameOrId">The team name or identifier.</param> /// <param name="count">The amount of team members to retrieve at most.</param> /// <param name="skip">How many team members to skip.</param> /// <param name="userState">The user state object to pass along to the underlying method.</param> /// <returns> /// The updated team. /// </returns> /// <exception cref="ArgumentNullException">teamHttpClient</exception> /// <exception cref="ArgumentOutOfRangeException">projectNameOrId - projectNameOrId /// or /// teamNameOrId - teamNameOrId</exception> public static IAsyncEnumerable <TeamMember> GetTeamMembers( this TeamHttpClient teamHttpClient, string projectNameOrId, string teamNameOrId, int?count = null, int?skip = null, object userState = null) { if (teamHttpClient == null) { throw new ArgumentNullException(nameof(teamHttpClient)); } if (string.IsNullOrWhiteSpace(projectNameOrId)) { throw new ArgumentOutOfRangeException(nameof(projectNameOrId), $"'{nameof(projectNameOrId)}' may not be null or empty or whitespaces only"); } if (string.IsNullOrWhiteSpace(teamNameOrId)) { throw new ArgumentOutOfRangeException(nameof(teamNameOrId), $"'{nameof(teamNameOrId)}' may not be null or empty or whitespaces only"); } return(AsyncEnumerabletHelper.GetAsyncEnumerableForListProducer( iterationInput => teamHttpClient.GetTeamMembersWithExtendedPropertiesAsync(projectNameOrId, teamNameOrId, iterationInput.Count, iterationInput.Skip, userState, iterationInput.CancellationToken))); }
/// <summary> /// Gets the team members for the <paramref name="teamNameOrId" /> in the project corresponding to the <paramref name="projectNameOrId" />. /// </summary> /// <param name="teamHttpClient">The team HTTP client.</param> /// <param name="projectNameOrId">The project name or identifier.</param> /// <param name="teamNameOrId">The team name or identifier.</param> /// <param name="count">The amount of team members to retrieve at most.</param> /// <param name="skip">How many team members to skip.</param> /// <param name="userState">The user state object to pass along to the underlying method.</param> /// <returns> /// The updated team. /// </returns> /// <exception cref="ArgumentNullException">teamHttpClient</exception> /// <exception cref="ArgumentOutOfRangeException">projectNameOrId - projectNameOrId /// or /// teamNameOrId - teamNameOrId</exception> public static IObservable <TeamMember> GetTeamMembers( this TeamHttpClient teamHttpClient, string projectNameOrId, string teamNameOrId, int?count = null, int?skip = null, object userState = null) { if (teamHttpClient == null) { throw new ArgumentNullException(nameof(teamHttpClient)); } if (string.IsNullOrWhiteSpace(projectNameOrId)) { throw new ArgumentOutOfRangeException(nameof(projectNameOrId), $"'{nameof(projectNameOrId)}' may not be null or empty or whitespaces only"); } if (string.IsNullOrWhiteSpace(teamNameOrId)) { throw new ArgumentOutOfRangeException(nameof(teamNameOrId), $"'{nameof(teamNameOrId)}' may not be null or empty or whitespaces only"); } return(Observable.FromAsync(cancellationToken => teamHttpClient.GetTeamMembersWithExtendedPropertiesAsync(projectNameOrId, teamNameOrId, count, skip, userState, cancellationToken)) .SelectMany(teamMembers => teamMembers)); }
public async Task GetTeamMembers(string teamId, string projectId) { List <TeamMember> teamMembers = await teamClient.GetTeamMembersWithExtendedPropertiesAsync(projectId, teamId); }