Пример #1
0
        /// <summary>
        /// Add existing iteraions to a team
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="TeamName"></param>
        static void AddTeamAreas(string TeamProjectName, string TeamName)
        {
            TeamContext teamContext = new TeamContext(TeamProjectName, TeamName);

            Console.WriteLine("Add areas to the team " + TeamName);

            string[] areas = { @"Application\WinClient", @"Application\WebClient" };

            TeamFieldValues currentTeamAreas = WorkClient.GetTeamFieldValuesAsync(teamContext).Result; // get current areas

            TeamFieldValuesPatch teamAreasPatch = new TeamFieldValuesPatch();

            List <TeamFieldValue> newTeamAreas = new List <TeamFieldValue>(currentTeamAreas.Values); // just copy old areas. Here we may remove unneeded areas

            foreach (string area in areas)
            {
                newTeamAreas.Add(new TeamFieldValue {
                    Value = TeamProjectName + "\\" + area, IncludeChildren = false
                });                                                                                                      // add new areas
            }
            teamAreasPatch.DefaultValue = currentTeamAreas.DefaultValue;
            teamAreasPatch.Values       = newTeamAreas;

            TeamFieldValues updatedTeamAreas = WorkClient.UpdateTeamFieldValuesAsync(teamAreasPatch, teamContext).Result;

            Console.WriteLine("Areas has been added");
        }
Пример #2
0
        /// <summary>
        /// Returns the default area path of the given team project
        /// </summary>
        /// <param name="conn">connection information to query area-path of</param>
        /// <returns>default area path, or null if operation fails or user is not connected to AzureDevOps</returns>
        internal string GetAreaPath(ConnectionInfo conn)
        {
            if (!ConnectedToAzureDevOps)
            {
                return(null);
            }
            WorkHttpClient client = _baseServerConnection.GetClient <WorkHttpClient>();

#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler
            return(client.GetTeamFieldValuesAsync(new TeamContext(conn.Project.Id, conn.Team?.Id)).ContinueWith(task =>
            {
                // Can fail if there is no area path
                return task.IsFaulted ? null : task.Result?.DefaultValue;
            }).Result);

#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler
        }