Ejemplo n.º 1
0
        public void AchievesTwoPercentAt50ThenFails50More_PercentageStaysAtTwo()
        {
            PersonSetting personSetting = new PersonSetting {
                RawName = "currentUser"
            };
            List <BuildStatus> builds = new List <BuildStatus>();

            builds.Add(new BuildStatus {
                RequestedBy = "currentUser", BuildStatusEnum = BuildStatusEnum.Broken
            });
            for (int i = 0; i < 49; i++)
            {
                builds.Add(new BuildStatus {
                    RequestedBy = "currentUser", BuildStatusEnum = BuildStatusEnum.Working
                });
            }
            for (int i = 0; i < 50; i++)
            {
                builds.Add(new BuildStatus {
                    RequestedBy = "currentUser", BuildStatusEnum = BuildStatusEnum.Broken
                });
            }
            Assert.AreEqual(100, builds.Count);
            Assert.AreEqual(0.02, BuildRatio.CalculateLowestBuildRatioAfter50Builds(personSetting, builds));
        }
Ejemplo n.º 2
0
        public static bool ModifyPersonSetting(PersonSetting model)
        {
            string sql = string.Format(@"update {0} set [IsDeleted]=@IsDeleted,[ModifyDate]=getdate(),[WorkGuid]=@WorkGuid,[Price]=@Price,[DepartId]=@DepartId,[DepartName]=@DepartName,[Infos]=@Infos,[Month]=@Month,[TotalPrice]=@TotalPrice,[Discount]=@Discount
            where Id=@Id", TableName);

            return(DBAccess.ExecuteSqlWithEntity(sql, model));
        }
Ejemplo n.º 3
0
        public static int HowManyTimesHasPerformedBackToBackBuildsForABuild(PersonSetting activePerson, IEnumerable <BuildStatus> currentBuildDefinitionOrderedChronoligically)
        {
            BuildStatus lastBuild = null;

            int backToBack = 0;

            foreach (var buildStatus in currentBuildDefinitionOrderedChronoligically)
            {
                bool lastBuildWasByActivePerson   = lastBuild != null && lastBuild.RequestedBy == activePerson.RawName;
                bool currentBuildIsByActivePerson = buildStatus.RequestedBy == activePerson.RawName;
                if (lastBuildWasByActivePerson && currentBuildIsByActivePerson)
                {
                    bool lastBuildPassed    = lastBuild.BuildStatusEnum == BuildStatusEnum.Working;
                    bool currentBuildPassed = buildStatus.BuildStatusEnum == BuildStatusEnum.Working;
                    bool wereBackToBack     = lastBuild.IsBackToBackWithNextBuild(buildStatus);
                    if (lastBuildPassed && currentBuildPassed && wereBackToBack)
                    {
                        backToBack++;
                    }
                }

                lastBuild = buildStatus;
            }

            _log.Debug(activePerson.RawName + " has achieved back to back successful builds " + backToBack + " times");
            return(backToBack);
        }
Ejemplo n.º 4
0
        public void BackToBackThreeTimes()
        {
            var fakePersonSetting = new PersonSetting {
                RawName = "currentUser"
            };
            var builds = new List <BuildStatus>
            {
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser", StartedTime = new DateTime(2010, 2, 2, 2, 2, 2), FinishedTime = new DateTime(2010, 2, 2, 2, 3, 2)
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser", StartedTime = new DateTime(2010, 2, 2, 2, 3, 3), FinishedTime = new DateTime(2010, 2, 2, 2, 4, 3)
                },

                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser", StartedTime = new DateTime(2010, 2, 3, 2, 2, 2), FinishedTime = new DateTime(2010, 2, 3, 2, 3, 2)
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser", StartedTime = new DateTime(2010, 2, 3, 2, 3, 3), FinishedTime = new DateTime(2010, 2, 3, 2, 4, 3)
                },

                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser", StartedTime = new DateTime(2010, 2, 4, 2, 2, 2), FinishedTime = new DateTime(2010, 2, 4, 2, 3, 2)
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser", StartedTime = new DateTime(2010, 2, 4, 2, 3, 3), FinishedTime = new DateTime(2010, 2, 4, 2, 4, 3)
                },
            };

            Assert.AreEqual(3, BackToBackBuilds.HowManyTimesHasPerformedBackToBackBuildsForABuild(fakePersonSetting, builds));
        }
Ejemplo n.º 5
0
 public static int HowManyTimesHasPerformedBackToBackBuildsAcrossBuilds(PersonSetting activePerson, IEnumerable <BuildStatus> allActiveBuildDefinitionsOrderedChronoligically)
 {
     return(allActiveBuildDefinitionsOrderedChronoligically
            .GroupBy(i => i.BuildDefinitionId)
            .Select(i => HowManyTimesHasPerformedBackToBackBuildsForABuild(activePerson, i))
            .Aggregate(0, (i, j) => i + j));
 }
Ejemplo n.º 6
0
        public void Upgrade_PeopleInSettings_AddedToPeopleInBase()
        {
            var settings = new SirenOfShameSettingsFake();

            settings.CiEntryPointSettings.Add(new CiEntryPointSetting
            {
                BuildDefinitionSettings = new List <BuildDefinitionSetting>
                {
                    new BuildDefinitionSetting
                    {
                        People = new List <string>
                        {
                            "Bob",
                        }
                    }
                }
            });
            settings.DoUpgrade();
            Assert.AreEqual(1, settings.People.Count);
            PersonSetting personSetting = settings.People.First();

            Assert.AreEqual("Bob", personSetting.RawName);
            Assert.AreEqual("Bob", personSetting.DisplayName);
            Assert.AreEqual(0, personSetting.FailedBuilds);
            Assert.AreEqual(0, personSetting.TotalBuilds);
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            lblMessage.Visible = false;

            LoadPerson();

            if (Person != null && Person.PersonID != -1)
            {
                EditEnabled = CurrentModule.Permissions.Allowed(OperationType.Edit, CurrentUser);

                if (ihPersonSettingID.Value.Trim() != string.Empty)
                {
                    try
                    {
                        personSetting = new PersonSetting(Person.PersonID, CurrentOrganization.OrganizationID, ihPersonSettingID.Value.Trim());
                    }
                    catch
                    {
                        throw new ModuleException(CurrentPortalPage, CurrentModule, "Invalid Person Setting Key in hidden field");
                    }
                }

                if (!Page.IsPostBack)
                {
                    ShowList();
                }
            }
        }
Ejemplo n.º 8
0
        public override void SetStats(PersonSetting personSetting, List <BuildStatus> allActiveBuildDefinitionsOrderedChronoligically)
        {
            var buildRatio = CalculateLowestBuildRatioAfter50Builds(personSetting, allActiveBuildDefinitionsOrderedChronoligically);

            personSetting.CurrentBuildRatio             = CalculateCurrentBuildRatio(personSetting, allActiveBuildDefinitionsOrderedChronoligically);
            personSetting.LowestBuildRatioAfter50Builds = buildRatio;
        }
Ejemplo n.º 9
0
        public AvatarPicker(ImageList avatarImageList, PersonSetting personSetting)
        {
            _okToClose       = true;
            _avatarImageList = avatarImageList;
            _personSetting   = personSetting;
            InitializeComponent();
            emailTextbox.Text = personSetting.Email;
            if (personSetting.Email != null)
            {
                _gravatar.SetImage(personSetting, avatarImageList);
                tabControl1.SelectedIndex = 1;
            }
            if (personSetting.AvatarImageName != null)
            {
                _croppedCustom.ImageLocation = Path.Combine(SirenOfShameSettings.GetAvatarsFolder(),
                                                            personSetting.AvatarImageName);
                tabControl1.SelectedIndex = 2;
            }
            int avatarCount = SirenOfShameSettings.AVATAR_COUNT;

            for (int i = 0; i < avatarCount; i++)
            {
                Avatar avatar = new Avatar();
                avatar.SetImage(i, avatarImageList);
                avatar.Click += AvatarOnClick;
                flowLayoutPanel1.Controls.Add(avatar);
            }
        }
Ejemplo n.º 10
0
 public static int CalculateSuccessInARow(PersonSetting personSetting, IEnumerable <BuildStatus> allActiveBuildDefinitionsOrderedChronoligically)
 {
     return(allActiveBuildDefinitionsOrderedChronoligically
            .Reverse()
            .Where(i => i.RequestedBy == personSetting.RawName)
            .TakeWhile(i => i.BuildStatusEnum != BuildStatusEnum.Broken)
            .Count());
 }
Ejemplo n.º 11
0
        public static double CalculateCurrentBuildRatio(PersonSetting personSetting, IEnumerable <BuildStatus> allActiveBuildDefinitionsOrderedChronoligically)
        {
            var currentUserBuilds  = allActiveBuildDefinitionsOrderedChronoligically.Where(i => i.RequestedBy == personSetting.RawName).ToList();
            var totalBuilds        = currentUserBuilds.Count;
            var unsuccessfulBuilds = currentUserBuilds.Count(i => i.BuildStatusEnum == BuildStatusEnum.Broken);

            return(totalBuilds == 0 ? 0 : (double)unsuccessfulBuilds / totalBuilds);
        }
Ejemplo n.º 12
0
 public void RefreshStats(PersonSetting person)
 {
     _reputation.Text             = person.GetReputation().ToString(CultureInfo.InvariantCulture);
     _achievements.Text           = person.Achievements.Count.ToString(CultureInfo.InvariantCulture);
     _failPercent.Text            = string.Format("{0:p1}", person.CurrentBuildRatio).Replace(" ", "");
     _successfulBuildsInARow.Text = string.Format("{0}", person.CurrentSuccessInARow);
     _fixedSomeoneElsesBuild.Text = string.Format("{0}", person.NumberOfTimesFixedSomeoneElsesBuild);
     _totalBuilds.Text            = string.Format("{0}", person.TotalBuilds);
 }
Ejemplo n.º 13
0
        public void IgnoresPassesByOtherPeople()
        {
            PersonSetting personSetting = new PersonSetting {
                RawName = "currentUser"
            };
            List <BuildStatus> buildStatuses = new List <BuildStatus>
            {
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Broken, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Broken, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Broken, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "someoneElse"
                },
            };

            Assert.AreEqual(false, new ReputationRebound(personSetting, buildStatuses).HasJustAchieved());
        }
Ejemplo n.º 14
0
        public void ThreeFailedThenTwelvePass()
        {
            PersonSetting personSetting = new PersonSetting {
                RawName = "currentUser"
            };
            List <BuildStatus> buildStatuses = new List <BuildStatus>
            {
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Broken, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Broken, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Broken, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
                new BuildStatus {
                    BuildStatusEnum = BuildStatusEnum.Working, RequestedBy = "currentUser"
                },
            };

            Assert.AreEqual(true, new ReputationRebound(personSetting, buildStatuses).HasJustAchieved());
        }
Ejemplo n.º 15
0
        public void GetBothDisplayAndRawNames_NullDisplayName_OnlyShowsRawName()
        {
            var personSetting = new PersonSetting
            {
                RawName     = "dev\\lrichard",
                DisplayName = null
            };

            Assert.AreEqual("dev\\lrichard", personSetting.GetBothDisplayAndRawNames());
        }
Ejemplo n.º 16
0
        public UserPanel(PersonSetting person, ImageList avatarImageList)
        {
            RawName = person.RawName;

            InitializeComponent();

            avatar1.SetImage(person, avatarImageList);
            _displayName.Text = person.DisplayName;
            RefreshStats(person);
        }
Ejemplo n.º 17
0
        public void RefreshAvatar(PersonSetting personSetting, ImageList imageList)
        {
            var userPanel = GetUserPanel(personSetting.RawName);

            if (userPanel == null)
            {
                return;
            }
            userPanel.RefreshAvatar(personSetting, imageList);
        }
Ejemplo n.º 18
0
 private void ShowViewUserPage(PersonSetting selectedPerson)
 {
     if (selectedPerson == null)
     {
         return;
     }
     ShowInMainWindow(MainWindowEnum.ViewUser);
     viewUser1.SetUser(selectedPerson, _avatarImageList);
     _newsFeed1.AddUserFilter(_settings, selectedPerson, _avatarImageList);
 }
Ejemplo n.º 19
0
        public void GetBothDisplayAndRawNames_DisplayNameAndRawName_DisplaysBoth()
        {
            var personSetting = new PersonSetting
            {
                RawName     = "dev\\lrichard",
                DisplayName = "Lee Richardson"
            };

            Assert.AreEqual("Lee Richardson (dev\\lrichard)", personSetting.GetBothDisplayAndRawNames());
        }
Ejemplo n.º 20
0
 public void SetUser(PersonSetting personSetting, ImageList avatarImageList)
 {
     this.SuspendDrawing(() =>
     {
         _avatarImageList = avatarImageList;
         avatar1.SetImage(personSetting, avatarImageList);
         _personSetting = personSetting;
         SetUser(personSetting);
     });
 }
Ejemplo n.º 21
0
        public void OnlyOnePersonOnProject()
        {
            PersonSetting personSetting = new PersonSetting {
                RawName = "currentUser", TotalBuilds = 110, FailedBuilds = 0
            };
            var people = new List <PersonSetting> {
                personSetting,
            };

            Assert.IsFalse(new Napoleon(personSetting, people).HasJustAchieved());
        }
Ejemplo n.º 22
0
        public void WasJustLikeLightning_ZeroBuilds()
        {
            var fakePersonSetting = new PersonSetting {
                RawName = "currentUser"
            };
            var builds = new List <BuildStatus>
            {
            };

            Assert.AreEqual(false, new LikeLightning(fakePersonSetting, builds).HasJustAchieved());
        }
Ejemplo n.º 23
0
        protected override bool MeetsAchievementCriteria()
        {
            var myReputation       = PersonSetting.GetReputation();
            var everyoneElseOnTeam = _people.Where(i => i.RawName != PersonSetting.RawName).ToList();

            if (everyoneElseOnTeam.Count == 0)
            {
                return(false);
            }
            return(everyoneElseOnTeam.All(i => i.GetReputation() <= (myReputation - 100)));
        }
Ejemplo n.º 24
0
        private void InvokeNewAchievement(PersonSetting person, List <AchievementLookup> achievements)
        {
            var newAchievement = NewAchievement;

            if (newAchievement != null)
            {
                newAchievement(this, new NewAchievementEventArgs {
                    Person = person, Achievements = achievements
                });
            }
            achievements.ForEach(i => InvokeNewNewsItem(i.AsNewNewsItem(person), newsIsBothLocalAndNew: true));
        }
Ejemplo n.º 25
0
        public void SirenNeverBeenConnected()
        {
            PersonSetting personSetting = new PersonSetting {
                RawName = "currentUser"
            };
            SirenOfShameSettings settings = new SirenOfShameSettings(false)
            {
                SirenEverConnected = false,
                MyRawName          = "currentUser"
            };

            Assert.AreEqual(false, new ShamePusher(personSetting, settings).HasJustAchieved());
        }
Ejemplo n.º 26
0
        public void SirenHasBeenConnectedButDifferentUserCheckedIn()
        {
            PersonSetting personSetting = new PersonSetting {
                RawName = "someoneElse"
            };
            SirenOfShameSettings settings = new SirenOfShameSettings(false)
            {
                SirenEverConnected = true,
                MyRawName          = "currentUser"
            };

            Assert.AreEqual(false, new ShamePusher(personSetting, settings).HasJustAchieved());
        }
Ejemplo n.º 27
0
 public InstanceUserDto(PersonSetting personSetting)
 {
     RawName      = personSetting.RawName;
     Reputation   = personSetting.GetReputation();
     DisplayName  = personSetting.DisplayName;
     Achievements = personSetting.Achievements.Select(i => new OfflineUserAchievementDto(i)).ToList();
     AvatarId     = personSetting.AvatarId;
     Hidden       = personSetting.Hidden;
     FailPercent  = (int)(personSetting.CurrentBuildRatio * 100);
     Csb          = personSetting.CurrentSuccessInARow;
     TotalBuilds  = personSetting.TotalBuilds;
     Fseb         = personSetting.NumberOfTimesFixedSomeoneElsesBuild;
 }
Ejemplo n.º 28
0
        private void AddUserPanel(ImageList avatarImageList, PersonSetting person)
        {
            UserPanel userPanel = new UserPanel(person, avatarImageList)
            {
                Cursor  = Cursors.Hand,
                Visible = !person.Hidden
            };

            userPanel.AddMouseUpToAllControls(UserPanelMouseUp);
            userPanel.AddMouseEnterToAllControls(UserPanelMouseEnter);

            _usersPanel.Controls.Add(userPanel);
        }
Ejemplo n.º 29
0
        public void NewAchievements(PersonSetting person)
        {
            if (!Visible)
            {
                return;
            }
            var currentlyDisplayedUserJustGotNewAchievements = _personSetting.RawName == person.RawName;

            if (!currentlyDisplayedUserJustGotNewAchievements)
            {
                return;
            }
            SetUser(person);
        }
Ejemplo n.º 30
0
        private void WithSelectedUser(Action <PersonSetting> action)
        {
            if (string.IsNullOrEmpty(_selectedRawName))
            {
                return;
            }
            PersonSetting selectedPerson = _settings.FindPersonByRawName(_selectedRawName);

            if (selectedPerson == null)
            {
                return;
            }
            action(selectedPerson);
        }