private void InitializeBuildStats()
 {
     if (BuildDefinitionId == null) return;
     var sosDb = new SosDb();
     var allBuilds = sosDb.ReadAll(BuildDefinitionId);
     buildStats1.GraphBuildHistory(allBuilds);
 }
        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
            };
        }
        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));
        }
Beispiel #4
0
 private void RefreshOfflinePanel()
 {
     _exportedBuilds.Text = "";
     _exportedAchievements.Text = "";
     var sosDb = new SosDb();
     var exportedBuilds = sosDb.ExportNewBuilds(_settings);
     if (exportedBuilds == null)
     {
         return;
     }
     string exportedAchievements = _settings.ExportNewAchievements();
     _exportedBuilds.Text = exportedBuilds;
     _exportedAchievements.Text = exportedAchievements;
 }
        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();
        }
Beispiel #6
0
 public void Write_Writes()
 {
     string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "BuildDefinitionId.txt");
     File.Delete(expectedFileLocation);
     var sosDb = new SosDb();
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = "BuildDefinitionId",
         BuildStatusEnum = BuildStatusEnum.Working,
         Comment = "hi",
         FinishedTime = new DateTime(2010, 1, 1, 1, 1, 1),
         StartedTime = new DateTime(2010, 1, 1, 1, 1, 2),
         LocalStartTime = new DateTime(2010, 1, 1, 1, 1, 3),
         RequestedBy = "Lee",
         Name = "BuildName",
     };
     SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();
     sosDb.Write(buildStatus, fakeSettings);
     Assert.IsTrue(File.Exists(expectedFileLocation));
     string[] linesOutput = File.ReadAllLines(expectedFileLocation);
     Assert.AreEqual(1, linesOutput.Length);
     Assert.AreEqual("633979044620000000,633979044610000000,1,Lee", linesOutput[0]);
     File.Delete(expectedFileLocation);
 }
Beispiel #7
0
 public void Write_InvalidCharacters_Removed()
 {
     const string uglyBuildDefinition = "\"M\"\\(a)/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";
     string expectedFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Automated Architecture", "SirenOfShame", "M(a)ry had a little lamb.txt");
     File.Delete(expectedFileLocation);
     var sosDb = new SosDb();
     BuildStatus buildStatus = new BuildStatus
     {
         BuildDefinitionId = uglyBuildDefinition,
         BuildStatusEnum = BuildStatusEnum.Working,
         Name = "BuildName",
     };
     SirenOfShameSettingsFake fakeSettings = new SirenOfShameSettingsFake();
     sosDb.Write(buildStatus, fakeSettings);
     Assert.IsTrue(File.Exists(expectedFileLocation));
     File.Delete(expectedFileLocation);
 }
Beispiel #8
0
        private void OnVerifyCredentialsSuccess()
        {
            _sosOnlineStatus.Text = "Login success, performing sync";

            var sosDb = new SosDb();
            var exportedBuilds = sosDb.ExportNewBuilds(_settings);
            if (exportedBuilds == null)
            {
                ManualSyncComplete("No new builds to export", authenticatedSuccessfully: true);
                return;
            }
            string exportedAchievements = _settings.ExportNewAchievements();
            var sosOnlineService = new SosOnlineService();
            sosOnlineService.Synchronize(_settings, exportedBuilds, exportedAchievements, OnAddBuildsSuccess, OnSosOnlineFailure);
        }