public BuildStatus AsUnknownBuildStatus(SosDb sosDb)
        {
            var lastKnownBuild = sosDb.ReadAll(this).LastOrDefault();
            var comment = lastKnownBuild == null ? null : lastKnownBuild.Comment;
            var startedTime = lastKnownBuild == null ? null : lastKnownBuild.StartedTime;
            // SosDb doesn't store local start time, so use the server's start time
            var localStartTime = lastKnownBuild == null ? DateTime.MinValue : lastKnownBuild.StartedTime ?? DateTime.MinValue;
            var buildId = lastKnownBuild == null ? null : lastKnownBuild.BuildId;
            var requestedBy = lastKnownBuild == null ? null : lastKnownBuild.RequestedBy;
            var finishedTime = lastKnownBuild == null ? null : lastKnownBuild.FinishedTime;
            var url = lastKnownBuild == null ? null : lastKnownBuild.Url;

            return new BuildStatus
            {
                BuildStatusEnum = BuildStatusEnum.Unknown,
                BuildDefinitionId = Id,
                Name = Name,
                StartedTime = startedTime,
                Comment = comment,
                LocalStartTime = localStartTime,
                BuildId = buildId,
                RequestedBy = requestedBy,
                FinishedTime = finishedTime,
                Url = url
            };
        }
Пример #2
0
 private void InitializeBuildStats()
 {
     if (BuildDefinitionId == null) return;
     var sosDb = new SosDb();
     var allBuilds = sosDb.ReadAll(BuildDefinitionId);
     buildStats1.GraphBuildHistory(allBuilds);
 }
Пример #3
0
        public override void Upgrade(SirenOfShameSettings settings)
        {
            SosDb sosDb = new SosDb();
            List<BuildStatus> allActiveBuildDefinitionsOrderedChronoligically = sosDb
                .ReadAll(settings.GetAllActiveBuildDefinitions())
                .OrderBy(i => i.StartedTime)
                .ToList();

            settings.People.ForEach(i => i.CalculateStats(allActiveBuildDefinitionsOrderedChronoligically));
        }
Пример #4
0
        private void RecalculateAchievements()
        {
            var sosDb = new SosDb();
            var allSettings = sosDb
                .ReadAll(_settings.GetAllActiveBuildDefinitions())
                .OrderBy(i => i.StartedTime)
                .ToList();
            foreach (var person in _settings.People)
            {
                person.TotalBuilds = 0;
                person.FailedBuilds = 0;
                person.Achievements.Clear();
                person.CumulativeBuildTime = 0;
            }
            _status.Visible = true;
            var allActiveBuildDefinitionsOrderedChronoligically = new List<BuildStatus>();
            var buildCount = allSettings.Count;
            progressBar1.Maximum = buildCount;
            foreach (var buildStatus in allSettings)
            {
                _status.Text = string.Format("Processing {0:d}", buildStatus.StartedTime);
                progressBar1.Value++;
                var person = _settings.People.FirstOrDefault(i => i.RawName == buildStatus.RequestedBy);
                if (person == null)
                {
                    _log.Error("Could not find " + buildStatus.RequestedBy);
                    continue;
                }
                person.TotalBuilds++;
                if (buildStatus.BuildStatusEnum == BuildStatusEnum.Broken)
                    person.FailedBuilds++;
                allActiveBuildDefinitionsOrderedChronoligically.Add(buildStatus);
                var newAchievements = person
                    .CalculateNewAchievements(_settings, buildStatus, allActiveBuildDefinitionsOrderedChronoligically)
                    .ToList();

                if (!newAchievements.Any()) continue;

                person.AddAchievements(newAchievements);
                foreach (var achievementLookup in newAchievements)
                {
                    NewAchievement.ShowForm(_settings, achievementLookup, person, this, modal: true);
                }
            }
            _settings.Save();
        }