コード例 #1
0
        public async Task <TeamCityProject> LoadProjectAsync(string projectName, CancellationToken token)
        {
            // Builds
            // Changes
            // Change Details

            using (CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(token))
            {
                // Get Project Data that includes Build Types
                _logger?.LogInformation("Starting Load of {0}.", projectName);
                try
                {
                    var pData = await _tMgr.GetProjectData(projectName);

                    _logger?.LogInformation("Finished High Level Project data load for {0}.", projectName);

                    pData.ParallelBuildTypes = LoadBuildTypesCollection(pData, QueueBoundedCapacity);

                    _logger?.LogInformation("{0} has {1} build types.", projectName, pData.ParallelBuildTypes.Count);
                    // Load Builds for each Build Type
                    var p1 = Parallel.ForEach <BuildType>(pData.ParallelBuildTypes, bt =>
                    {
                        _logger?.LogInformation("Starting to get builds for Build Type {0}.", bt.Name);
                        bt.Builds = _tMgr.GetBuilds(bt.Id).GetAwaiter().GetResult()?.Build;

                        if (token.IsCancellationRequested)
                        {
                            throw new OperationCanceledException();
                        }

                        if (bt.Builds != null)
                        {
                            _logger?.LogInformation("Retrieved {0} builds for BuildType {1}.", bt.Builds.Count(), bt.Name);
                            foreach (var b in bt.Builds)
                            {
                                b.Changes = _tMgr.GetChanges(b.Id).GetAwaiter().GetResult()?.Change;

                                if (token.IsCancellationRequested)
                                {
                                    throw new OperationCanceledException();
                                }
                            }
                        }
                        else
                        {
                            _logger.LogInformation("There were zero builds for BuildType {0}.", bt.Name);
                            bt.Builds = new List <Build>();
                        }
                    });

                    return(pData);
                }
                catch (Exception ex)
                {
                    cts.Cancel();
                    if (!(ex is OperationCanceledException))
                    {
                        _logger?.LogError("Error building project.", ex);
                        throw;
                    }
                    return(null);
                }
            }
        }
コード例 #2
0
 public TeamCityProject GetFullProjectReleaseNotes(string ProjectName)
 {
     return(_mgr.GetProjectData(ProjectName).GetAwaiter().GetResult());
 }