Beispiel #1
0
        private async Task DownloadNewestPipelinesNotInBrancNameList(ICiDataProvider dataProvider, Project project, int howMany, IEnumerable <string> branchNames, PipelinesMerger merger)
        {
            var branchNamesSet    = new HashSet <string>(branchNames);
            var pageCounter       = 0;
            var maxPagesToLookFor = int.Parse(_configuration["DataProviders:NewestPipelinesMaxPages"]);

            while (merger.NewestPipelinesCount < howMany && pageCounter++ <= maxPagesToLookFor)
            {
                var pagedNewest = await dataProvider.FetchNewestPipelines(project.ApiHostUrl, project.ApiAuthenticationToken, project.ApiProjectId, pageCounter, perPage : howMany);

                var pagePipelinesNotInLocalStatic = pagedNewest.pipelines.Where(p => !branchNamesSet.Contains(p.Ref));

                merger.AddPipelinesPageAtEnd(pagePipelinesNotInLocalStatic);

                if (pageCounter >= pagedNewest.totalPages) //If last page
                {
                    break;
                }
            }
        }
Beispiel #2
0
        private async Task UpdatePipeline(DataProviderPipelineInfo info, ICiDataProvider dataProvider)
        {
            var found = await _projectRepository.FindProjectByDataProviderInfoAsync(info);

            if (found.Item1 == null)
            {
                return;
            }
            var project  = found.Item1;
            var pipeline = found.Item2;

            if (pipeline != null)
            {
                var updatetedPipeline = await dataProvider.FetchPipelineById(project.ApiHostUrl, project.ApiAuthenticationToken, project.ApiProjectId, pipeline.DataProviderPipelineId);

                pipeline.Status = updatetedPipeline.Status;
                //pipeline.Stages = updatetedPipeline.Stages;
                await UpdatePipelineStages(pipeline, updatetedPipeline.Stages);

                pipeline.LastUpdate = DateTime.Now;
                //await _pipelineRepository.UpdateAsync(pipeline, pipeline.Id);
                await _pipelineRepository.SaveAsync();

                //pipeline.Status = info.Status;
                //await _pipelineRepository.SaveAsync();
            }
            else
            {
                int pipeIdINT = 0;
                if (!int.TryParse(info.PipelineId, out pipeIdINT))
                {
                    return;
                }
                var updatetedPipeline = await dataProvider.FetchPipelineById(project.ApiHostUrl, project.ApiAuthenticationToken, project.ApiProjectId, pipeIdINT);

                updatetedPipeline.LastUpdate = DateTime.Now;
                await InsertPipelineToDB(updatetedPipeline, project);
            }
        }