예제 #1
0
        public async Task <SearchIssuesResponse> GetIssuesAsync(SonarRequestGetIssues sonarSettingRequest)
        {
            if (sonarSettingRequest == null || _sonarSettings == null)
            {
                return(null);
            }
            if (sonarSettingRequest.NbIssuesPerRequest == default(int))
            {
                sonarSettingRequest.NbIssuesPerRequest = _sonarSettings.NbIssuesPerRequestDefault;
            }

            SearchIssuesResponse searchIssuesResponse = new SearchIssuesResponse();

            searchIssuesResponse.issues = new List <Issues>();
            bool needToRetrieveNextIssues = true;
            int  pageNumber = 1;

            while (needToRetrieveNextIssues)
            {
                List <KeyValuePair <string, string> > args = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("ps", sonarSettingRequest.NbIssuesPerRequest.ToString()),
                    new KeyValuePair <string, string>("assigned", "true"),
                    new KeyValuePair <string, string>("p", pageNumber.ToString()),
                    new KeyValuePair <string, string>("createdAfter", sonarSettingRequest.DateFrom.ToString("yyyy-MM-dd")),// "2017-10-01"));
                    new KeyValuePair <string, string>("createdBefore", sonarSettingRequest.DateTo.ToString("yyyy-MM-dd")),
                    new KeyValuePair <string, string>("statuses", "OPEN,REOPENED"),
                    new KeyValuePair <string, string>("severities", "CRITICAL, MAJOR"),
                    new KeyValuePair <string, string>("languages", "cs")
                };
                if (sonarSettingRequest.Users != null)
                {
                    args.Add(new KeyValuePair <string, string>("assignees", string.Join(",", sonarSettingRequest.Users)));
                }
                SearchIssuesResponse result = await _httpApiClient.PostAsync <SearchIssuesResponse>(args, _sonarSettings.Uri_GetIssues, _sonarSettings.Token);

                if (result?.issues == null)
                {
                    break;
                }
                searchIssuesResponse.issues.AddRange(result.issues);
                needToRetrieveNextIssues = sonarSettingRequest.NbIssuesPerRequest == result.issues.Count;
                pageNumber++;
            }

            return(searchIssuesResponse);
        }
예제 #2
0
        /// <summary>
        /// Get Sonar issues corresponding to the <see cref="SonarRequestGetIssues"/> parameters.
        /// </summary>
        /// <param name="sonarSettingRequest">The parameters used to get the issues.</param>
        /// <returns>A list of Sonar issues with ActiveDirectory, ChangeSet and CodeProject informations.</returns>
        public IssuesSonarSet GetIssuesSonar(SonarRequestGetIssues sonarSettingRequest)
        {
            if (sonarSettingRequest == null)
            {
                return(null);
            }

            _loggingService.LogInfo(this, "Parameters : DateFrom " + sonarSettingRequest.DateFrom.ToString() + ", DateTo " + sonarSettingRequest.DateFrom.ToString());

            GroupADSet groupADSet = _activeDirectoryService.GetUsersByGroupAd(sonarSettingRequest.GroupAdSet);

            sonarSettingRequest.Users = groupADSet?.GetListOfUser();

            SearchIssuesResponse searchIssuesResponse = _sonarConnector.GetIssuesAsync(sonarSettingRequest).Result;
            List <Issue>         issueSet             = searchIssuesResponse.CreateIssueSet(groupADSet, _mapper, _sonarConnector, _tfsConnector);

            _loggingService.LogInfo(this, issueSet.Count().ToString() + " resultats. Parameters : DateFrom " + sonarSettingRequest.DateFrom.ToString() + ", DateTo " + sonarSettingRequest.DateTo.ToString());

            return(new IssuesSonarSet()
            {
                IssueSet = issueSet
            });
        }
예제 #3
0
 private void InitSonarRequest()
 {
     _sonarRequestGetIssues            = new SonarRequestGetIssues();
     _sonarRequestGetIssues.GroupAdSet = ConfigurationManager.AppSettings["GroupAdSet"].Split(',').ToList();
 }