Beispiel #1
0
        public List <TeamMemberCapacityIdentityRef> ReplaceTeamMemberCapacities()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;

            TeamContext teamContext             = new TeamContext(projectId, teamId);
            List <TeamSettingsIteration> result = workClient.GetTeamIterationsAsync(teamContext, "current").Result;
            Guid iterationId = result[0].Id;

            List <TeamMemberCapacityIdentityRef> capacity = workClient.GetCapacitiesWithIdentityRefAsync(teamContext, iterationId).Result;
            var updatedCapacity = capacity.Select(teamMemberCapacity =>
            {
                return(new TeamMemberCapacityIdentityRef()
                {
                    TeamMember = teamMemberCapacity.TeamMember,
                    Activities = teamMemberCapacity.Activities.Select(a => { return new Activity()
                                                                             {
                                                                                 Name = a.Name, CapacityPerDay = a.CapacityPerDay
                                                                             }; }),
                    DaysOff = teamMemberCapacity.DaysOff
                });
            });

            var updatedCapacityResult = workClient.ReplaceCapacitiesWithIdentityRefAsync(updatedCapacity, teamContext, iterationId).Result;

            return(updatedCapacityResult);
        }
        public NotificationSubscription CreateSubscriptionForTeam()
        {
            NotificationSubscription newSubscription;

            WebApiTeamRef team = ClientSampleHelpers.FindAnyTeam(this.Context, null);

            NotificationHttpClient notificationClient = Context.Connection.GetClient <NotificationHttpClient>();

            // Query the available event types and find the first that can be used in a custom subscription
            List <NotificationEventType> eventTypes = notificationClient.ListEventTypesAsync().Result;
            NotificationEventType        eventType  = eventTypes.Find(e => { return(e.CustomSubscriptionsAllowed); });

            NotificationSubscriptionCreateParameters createParams = new NotificationSubscriptionCreateParameters()
            {
                Description = "A subscription for our team",
                Filter      = new ExpressionFilter(eventType.Id),
                Channel     = new UserSubscriptionChannel(),
                Subscriber  = new IdentityRef()
                {
                    Id = team.Id.ToString()
                }
            };

            newSubscription = notificationClient.CreateSubscriptionAsync(createParams).Result;

            LogSubscription(newSubscription);

            return(newSubscription);
        }
Beispiel #3
0
        public TeamMemberCapacityIdentityRef UpdateTeamMemberCapacity()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;
            Guid userId    = ClientSampleHelpers.GetCurrentUserId(this.Context);

            TeamContext teamContext             = new TeamContext(projectId, teamId);
            List <TeamSettingsIteration> result = workClient.GetTeamIterationsAsync(teamContext, "current").Result;
            Guid iterationId = result[0].Id;

            TeamMemberCapacityIdentityRef capacity = workClient.GetCapacityWithIdentityRefAsync(teamContext, iterationId, userId).Result;
            CapacityPatch capacityPatch            = new CapacityPatch()
            {
                Activities = capacity.Activities.Select(a => { return(new Activity {
                        Name = a.Name, CapacityPerDay = a.CapacityPerDay + 1
                    }); }),
                DaysOff    = capacity.DaysOff
            };

            TeamMemberCapacityIdentityRef updatedCapacity = workClient.UpdateCapacityWithIdentityRefAsync(capacityPatch, teamContext, iterationId, userId).Result;

            return(updatedCapacity);
        }
Beispiel #4
0
        private TeamContext getTeamContext()
        {
            TeamProjectReference project     = ClientSampleHelpers.FindAnyProject(this.Context);
            WebApiTeamRef        team        = ClientSampleHelpers.FindAnyTeam(this.Context, project.Id);
            TeamContext          teamContext = new TeamContext(project.Name, team.Name);

            return(teamContext);
        }
        public IEnumerable <NotificationSubscription> ListSubscriptionsForTeam()
        {
            WebApiTeamRef team = ClientSampleHelpers.FindAnyTeam(this.Context, null);

            VssConnection          connection         = Context.Connection;
            NotificationHttpClient notificationClient = connection.GetClient <NotificationHttpClient>();

            IEnumerable <NotificationSubscription> subscriptions = notificationClient.ListSubscriptionsAsync(targetId: team.Id).Result;

            foreach (var subscription in subscriptions)
            {
                LogSubscription(subscription);
            }

            return(subscriptions);
        }
Beispiel #6
0
        public List <TeamMemberCapacityIdentityRef> GetTeamCapacity()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;

            TeamContext teamContext             = new TeamContext(projectId, teamId);
            List <TeamSettingsIteration> result = workClient.GetTeamIterationsAsync(teamContext, "current").Result;
            Guid iterationId = result[0].Id;

            List <TeamMemberCapacityIdentityRef> capacity = workClient.GetCapacitiesWithIdentityRefAsync(teamContext, iterationId).Result;

            return(capacity);
        }
        public TeamSetting GetTeamSettings()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;

            var         context = new TeamContext(projectId, teamId);
            TeamSetting result  = workClient.GetTeamSettingsAsync(context).Result;

            Console.WriteLine("Backlog iteration: {0}", result.BacklogIteration.Name);
            Console.WriteLine("Bugs behavior: {0}", result.BugsBehavior);
            Console.WriteLine("Default iteration : {0}", result.DefaultIterationMacro);

            return(result);
        }
        public IEnumerable <IdentityRef> GetTeamMembers()
        {
            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;

            VssConnection  connection = Context.Connection;
            TeamHttpClient teamClient = connection.GetClient <TeamHttpClient>();

            IEnumerable <IdentityRef> teamMembers = teamClient.GetTeamMembersAsync(projectId.ToString(), teamId.ToString()).Result;

            Console.WriteLine("Members of {0}:", teamId);
            foreach (var member in teamMembers)
            {
                Console.WriteLine("  " + member.DisplayName);
            }

            return(teamMembers);
        }
        public WebApiTeam GetTeam()
        {
            // Get any project then get any team from it
            TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);

            string teamName = ClientSampleHelpers.FindAnyTeam(this.Context, project.Id).Name;

            // Get a client
            VssConnection  connection = Context.Connection;
            TeamHttpClient teamClient = connection.GetClient <TeamHttpClient>();

            WebApiTeam team = teamClient.GetTeamAsync(project.Id.ToString(), teamName).Result;

            Console.WriteLine("ID         : {0}", team.Id);
            Console.WriteLine("Name       : {0}", team.Name);
            Console.WriteLine("Description: {0}", team.Description);

            return(team);
        }
        public Board GetTeamStoriesBoard()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
            WebApiTeamRef        team    = ClientSampleHelpers.FindAnyTeam(this.Context, project.Id);

            TeamContext context = new TeamContext(project.Id, team.Id);

            context.Team    = team.Name;
            context.Project = project.Name;

            Board board = workClient.GetBoardAsync(context, "Stories").Result;

            Context.Log("Columns for 'Stories' Board for Project '{0}' and Team '{1}'", context.Project, context.Team);
            Context.Log("");

            return(board);
        }
        public List <TeamSettingsIteration> GetTeamSettingsCurrentIteration()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            Guid projectId = ClientSampleHelpers.FindAnyProject(this.Context).Id;
            Guid teamId    = ClientSampleHelpers.FindAnyTeam(this.Context, projectId).Id;

            var context = new TeamContext(projectId, teamId);
            List <TeamSettingsIteration> result = workClient.GetTeamIterationsAsync(context, "current").Result;

            foreach (var item in result)
            {
                Console.WriteLine("Current Iteration: {0}", item.Name);
                Console.WriteLine("Start Date: {0}", item.Attributes.StartDate.ToString());
                Console.WriteLine("Finish Date: {0}", item.Attributes.FinishDate.ToString());
            }

            return(result);
        }
        public List <BacklogLevelConfiguration> GetBacklogs()
        {
            VssConnection  connection = Context.Connection;
            WorkHttpClient workClient = connection.GetClient <WorkHttpClient>();

            TeamProjectReference project = ClientSampleHelpers.FindAnyProject(this.Context);
            WebApiTeamRef        team    = ClientSampleHelpers.FindAnyTeam(this.Context, project.Id);

            TeamContext teamContext = new TeamContext(project.Id, team.Id)
            {
                Team    = team.Name,
                Project = project.Name
            };

            List <BacklogLevelConfiguration> backlogs = workClient.GetBacklogsAsync(teamContext).Result;

            foreach (var backlog in backlogs)
            {
                Context.Log("Backlog: '{0}' Type: '{1}'", backlog.Name, backlog.Type);
            }

            return(backlogs);
        }