Пример #1
0
        private Task <IReadOnlyList <MergeRequestInfo> > GetMergeRequests(string username)
        {
            var getMergeRequestsOptions = new GetMergeRequestsOptionsBuilder()
                                          .ExcludingProjects(gitLabOptions.ExcludingProjects)
                                          .NotAuthoredBy(username)
                                          .NotUpvotedBy(username)
                                          .OnlyNotWorkInProgress()
                                          .OnlyOpened()
                                          .Build();

            return(mergeRequestsProvider.GetOpenedMergeRequestAsync(gitLabOptions.ProjectGroupId, getMergeRequestsOptions));
        }
Пример #2
0
        private async Task NotifyAllUsersAsync()
        {
            while (true)
            {
                var getMergeRequestsOptions = new GetMergeRequestsOptionsBuilder()
                                              .ExcludingProjects(gitLabOptions.ExcludingProjects)
                                              .OnlyOpened()
                                              .OnlyNotWorkInProgress()
                                              .Build();

                var mergeRequests = await mergeRequestsProvider.GetOpenedMergeRequestAsync(
                    gitLabOptions.ProjectGroupId,
                    getMergeRequestsOptions);

                var users       = usersRepository.GetAllUsers();
                var notifyTasks = users.Select(async user => await NotifyUserAsync(user, mergeRequests));
                await Task.WhenAll(notifyTasks);

                await Task.Delay(TimeSpan.FromMinutes(2)); // TODO: вынести в настройки
            }
        }