예제 #1
0
        private void SosOnlineServiceOnOnNewSosOnlineNotification(object sender, NewSosOnlineNotificationArgs args)
        {
            NewsItemTypeEnum newItemType = (NewsItemTypeEnum)args.EventTypeId;
            bool             currentUserAuthoredEvent      = args.UserName == _settings.SosOnlineUsername;
            bool             reputationChangeOrAchievement = newItemType == NewsItemTypeEnum.SosOnlineReputationChange ||
                                                             newItemType == NewsItemTypeEnum.SosOnlineNewAchievement;

            if (currentUserAuthoredEvent && reputationChangeOrAchievement)
            {
                return;
            }
            // this may result in a web request to retrieve the person's image, so keep it on some other thread
            SosOnlinePerson sosOnlinePerson = _sosOnlineService.CreateSosOnlinePersonFromSosOnlineNotification(args, _avatarImageList);

            Invoke(() =>
            {
                NewNewsItemEventArgs newNewsItemEventArgs = new NewNewsItemEventArgs
                {
                    EventDate       = DateTime.Now,
                    Person          = sosOnlinePerson,
                    Title           = args.Message,
                    AvatarImageList = _avatarImageList,
                    NewsItemType    = newItemType
                };
                _newsFeed1.AddNewsItem(newNewsItemEventArgs);
            });
        }
예제 #2
0
        public void GetPerson_PersonWithRawNameDoesNotExist_NothingFound()
        {
            var settingsFake = new SirenOfShameSettingsFake();
            var actual       = NewNewsItemEventArgs.GetPerson(settingsFake, "domain\richardsonl");

            Assert.IsNull(actual);
        }
        public void SerializeThenDeserialize()
        {
            SirenOfShameSettingsFake settings = new SirenOfShameSettingsFake();
            var person = settings.FindAddPerson("Bob");
            NewNewsItemEventArgs args = new NewNewsItemEventArgs
            {
                EventDate         = new DateTime(2010, 1, 2, 3, 4, 5, 6),
                Person            = person,
                Title             = "Hello world",
                NewsItemType      = NewsItemTypeEnum.BuildFailed,
                BuildDefinitionId = "Project 1",
                ReputationChange  = -1,
                BuildId           = "5",
            };
            var asCommaSeparated = args.AsCommaSeparated();
            var result           = NewNewsItemEventArgs.FromCommaSeparated(asCommaSeparated, settings);

            Assert.IsNotNull(result);
            Assert.AreEqual("Bob", result.Person.RawName);
            Assert.AreEqual("Hello world", result.Title);
            Assert.AreEqual(new DateTime(2010, 1, 2, 3, 4, 5, 6), result.EventDate);
            Assert.AreEqual(NewsItemTypeEnum.BuildFailed, result.NewsItemType);
            Assert.AreEqual(-1, result.ReputationChange);
            Assert.AreEqual("Project 1", result.BuildDefinitionId);
            Assert.AreEqual("5", result.BuildId);
        }
예제 #4
0
 private void RulesEngineNewNewsItem(object sender, NewNewsItemEventArgs args)
 {
     Invoke(() =>
     {
         args.AvatarImageList = _avatarImageList;
         _newsFeed1.AddNewsItem(args);
     });
 }
예제 #5
0
 private void WriteProject(NewNewsItemEventArgs args)
 {
     _project.Visible = !string.IsNullOrEmpty(args.BuildDefinitionId);
     if (args.BuildDefinitionId == null)
     {
         return;
     }
     _project.Text = args.BuildDefinitionId.ToUpperInvariant();
 }
예제 #6
0
        private void InitializeMetroColors(NewNewsItemEventArgs args)
        {
            Color backColor = GetBackgroundColorForEventType(args.NewsItemType);

            _leftPanel.BackColor        = backColor;
            _project.BackColor          = backColor;
            _userName.BackColor         = backColor;
            _when.BackColor             = backColor;
            _reputationChange.BackColor = backColor;
        }
예제 #7
0
        private void AddNewsItemToPanel(NewNewsItemEventArgs args)
        {
            var newsItem = AddNewsItemToPanel();

            newsItem.Initialize(args);
            _newsItemsPanel.Controls.SetChildIndex(newsItem, 0);
            newsItem.Height = 1;
            _newsItemsToOpen.Add(newsItem);
            _newsItemHeightAnimator.Start();
        }
        public PersonSetting FindPersonByRawName(string rawName)
        {
            if (People == null)
            {
                People = new List <PersonSetting>();
            }
            var person = People.FirstOrDefault(i => NewNewsItemEventArgs.MakeCsvSafe(i.RawName) == NewNewsItemEventArgs.MakeCsvSafe(rawName));

            return(person);
        }
예제 #9
0
        public void GetPerson_NameContainsCommaButIsSearchedForWithoutComma_NameStillFound()
        {
            var settingsFake = new SirenOfShameSettingsFake();

            settingsFake.People.Add(new PersonSetting {
                RawName = "O'Boyle, Robert"
            });
            var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "O'Boyle  Robert");

            Assert.IsNotNull(actual);
        }
예제 #10
0
        public void GetPerson_PersonWithRawNameExists_PersonIsFound()
        {
            var settingsFake = new SirenOfShameSettingsFake();

            settingsFake.People.Add(new PersonSetting {
                RawName = "domain\richardsonl"
            });
            var actual = NewNewsItemEventArgs.GetPerson(settingsFake, "domain\richardsonl");

            Assert.IsNotNull(actual);
        }
예제 #11
0
 public static bool IncludeInFilter(NewNewsItemEventArgs newsItem, string filterPerson, string filterBuildDefinitionId)
 {
     if (filterPerson == null && filterBuildDefinitionId == null)
     {
         return(true);
     }
     if (filterPerson != null)
     {
         return(newsItem.Person.RawName == filterPerson);
     }
     return(newsItem.IsSosOnlineEvent || newsItem.BuildDefinitionId == filterBuildDefinitionId);
 }
예제 #12
0
        private void TryToFindAndUpdateOldInProgressNewsItem(NewNewsItemEventArgs args)
        {
            var oldBuild = GetNewsItemControls().FirstOrDefault(i => i.BuildId == args.BuildId);

            if (oldBuild != null)
            {
                oldBuild.UpdateState(args);
            }
            else
            {
                AddNewsItemToPanel(args);
            }
        }
예제 #13
0
        public void Initialize(NewNewsItemEventArgs args)
        {
            _rawUserName = args.Person.RawName;
            BuildId      = args.BuildId;
            EventDate    = args.EventDate;

            InitializeUserNameLabel(args);
            InitializeReputationChangeLabel(args.ReputationChange);
            WriteProject(args);
            WriteTitle(args);
            WriteDate(args.EventDate);
            InitializeAvatar(args);
            InitializeMetroColors(args);
        }
예제 #14
0
        private void SosOnlineServiceOnNewSosOnlineNotification(object sender, NewSosOnlineNotificationArgs args)
        {
            // this may result in a web request to retrieve the person's image, so keep it on some other thread
            SosOnlinePerson sosOnlinePerson = _sosOnlineService.CreateSosOnlinePersonFromSosOnlineNotification(args, _avatarImageList);

            Invoke(() =>
            {
                NewNewsItemEventArgs newNewsItemEventArgs = new NewNewsItemEventArgs
                {
                    EventDate       = DateTime.Now,
                    Person          = sosOnlinePerson,
                    Title           = args.Message,
                    AvatarImageList = _avatarImageList,
                    NewsItemType    = NewsItemTypeEnum.SosOnlineComment
                };
                _newsFeed1.AddNewsItem(newNewsItemEventArgs);
            });
        }
        public void SerializeThenDeserialize_CommaSeparatedTitle()
        {
            SirenOfShameSettingsFake settings = new SirenOfShameSettingsFake();
            var person = settings.FindAddPerson("Bob");
            NewNewsItemEventArgs args = new NewNewsItemEventArgs
            {
                EventDate         = new DateTime(2010, 1, 2, 3, 4, 5, 6),
                Person            = person,
                NewsItemType      = NewsItemTypeEnum.BuildFailed,
                Title             = ",Hello, world,",
                BuildDefinitionId = "Project 1"
            };
            var asCommaSeparated = args.AsCommaSeparated();
            var result           = NewNewsItemEventArgs.FromCommaSeparated(asCommaSeparated, settings);

            Assert.IsNotNull(result);
            Assert.AreEqual(",Hello, world,", result.Title);
        }
예제 #16
0
 public void AddNewsItem(NewNewsItemEventArgs args)
 {
     if (args == null || args.Person == null)
     {
         return;
     }
     if (!IncludeInFilter(args))
     {
         return;
     }
     if (args.ShouldUpdateOldInProgressNewsItem)
     {
         TryToFindAndUpdateOldInProgressNewsItem(args);
     }
     else
     {
         AddNewsItemToPanel(args);
     }
 }
예제 #17
0
 private void InitializeAvatar(NewNewsItemEventArgs args)
 {
     avatar1.SetImage(args.Person, args.AvatarImageList);
     avatar1.Cursor = args.Person.Clickable ? Cursors.Hand : Cursors.Default;
 }
예제 #18
0
 private void InitializeUserNameLabel(NewNewsItemEventArgs args)
 {
     DisplayName = args.Person.DisplayName;
 }
예제 #19
0
 private bool IncludeInFilter(NewNewsItemEventArgs i)
 {
     return(IncludeInFilter(i, _filterPerson, _filterBuildDefinitionId));
 }
예제 #20
0
        private void WriteTitle(NewNewsItemEventArgs args)
        {
            string title = args.NewsItemType == NewsItemTypeEnum.SosOnlineComment ? "\"" + args.Title + "\"" : args.Title;

            _title.Text = title;
        }
예제 #21
0
 public void UpdateState(NewNewsItemEventArgs args)
 {
     InitializeReputationChangeLabel(args.ReputationChange);
     InitializeMetroColors(args);
 }