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);
        }
        public static bool FindAnyTeam(ClientSampleContext context, Guid?projectId, out WebApiTeamRef team)
        {
            if (!projectId.HasValue)
            {
                TeamProjectReference project;
                if (FindAnyProject(context, out project))
                {
                    projectId = project.Id;
                }
            }

            // Check if we already have a team that has been cached for this project
            if (!context.TryGetValue <WebApiTeamRef>("$" + projectId + "Team", out team))
            {
                TeamHttpClient teamClient = context.Connection.GetClient <TeamHttpClient>();

                using (new ClientSampleHttpLoggerOutputSuppression())
                {
                    team = teamClient.GetTeamsAsync(projectId.ToString(), top: 1).Result.FirstOrDefault();
                }

                if (team != null)
                {
                    context.SetValue <WebApiTeamRef>("$" + projectId + "Team", team);
                }
                else
                {
                    // create a team?
                    throw new Exception("No team available for running this sample.");
                }
            }

            return(team != null);
        }
示例#3
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);
        }
        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);
        }
示例#6
0
        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);
        }