private void AddBuildWarnings(IBuildDetail tfsBuild, Build build)
        {
            List <IBuildWarning> associatedBuildWarnings = InformationNodeConverters.GetBuildWarnings(tfsBuild);

            var groupedWarnings = associatedBuildWarnings.GroupBy(this.ParseWarningType);

            build.Warnings =
                groupedWarnings.Select(
                    x => new Domain.Model.Warning {
                Type = x.Key, Total = x.Count()
            }).ToList();
        }
        private void GetBuildInformation(TfsDashboardSummary summary)
        {
            var watch = Stopwatch.StartNew();

            _projectCollection.EnsureAuthenticated();

            var buildServer     = _projectCollection.GetService <IBuildServer>();
            var buildDetailSpec = buildServer.CreateBuildDetailSpec(_settings.Project, _settings.BuildDefinition);

            buildDetailSpec.MaxBuildsPerDefinition = 150;
            buildDetailSpec.QueryOptions           = QueryOptions.All;
            buildDetailSpec.QueryOrder             = BuildQueryOrder.FinishTimeDescending;
            buildDetailSpec.InformationTypes       = null;

            var results = buildServer.QueryBuilds(buildDetailSpec);

            if (!results.Failures.Any())
            {
                var builds = results.Builds.Select(buildDetail => new TfsBuildSummary
                {
                    Uri               = buildDetail.Uri,
                    Duration          = (int)(buildDetail.FinishTime - buildDetail.StartTime).TotalSeconds,
                    Who               = buildDetail.Requests[0].RequestedFor,
                    Username          = buildDetail.Requests[0].RequestedForDisplayName,
                    BuildNumber       = buildDetail.BuildNumber,
                    DropLocation      = buildDetail.DropLocation,
                    StartTime         = buildDetail.StartTime,
                    TestStatus        = buildDetail.TestStatus,
                    CompilationStatus = buildDetail.CompilationStatus.ToString(),
                    Status            = buildDetail.Status.ToString(),
                    SourceGetVersion  = buildDetail.SourceGetVersion,
                }).ToList();
                summary.LastBuilds = builds.OrderBy(x => x.StartTime);

                var lastBuild = builds.OrderByDescending(x => x.StartTime).FirstOrDefault();
                if (lastBuild != null)
                {
                    lastBuild.TestCoverage   = GetTestcoverage(_projectCollection, lastBuild.Uri);
                    summary.LastBuild        = lastBuild;
                    summary.LastWarningCount = InformationNodeConverters.GetBuildWarnings(results.Builds.OrderByDescending(x => x.StartTime).FirstOrDefault()).Count;
                }
            }
            Trace.WriteLine("GetBuildInformation: " + watch.Elapsed);
        }