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); }); }
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); }
private void RulesEngineNewNewsItem(object sender, NewNewsItemEventArgs args) { Invoke(() => { args.AvatarImageList = _avatarImageList; _newsFeed1.AddNewsItem(args); }); }
private void WriteProject(NewNewsItemEventArgs args) { _project.Visible = !string.IsNullOrEmpty(args.BuildDefinitionId); if (args.BuildDefinitionId == null) { return; } _project.Text = args.BuildDefinitionId.ToUpperInvariant(); }
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; }
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); }
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); }
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); }
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); }
private void TryToFindAndUpdateOldInProgressNewsItem(NewNewsItemEventArgs args) { var oldBuild = GetNewsItemControls().FirstOrDefault(i => i.BuildId == args.BuildId); if (oldBuild != null) { oldBuild.UpdateState(args); } else { AddNewsItemToPanel(args); } }
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); }
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); }
public void AddNewsItem(NewNewsItemEventArgs args) { if (args == null || args.Person == null) { return; } if (!IncludeInFilter(args)) { return; } if (args.ShouldUpdateOldInProgressNewsItem) { TryToFindAndUpdateOldInProgressNewsItem(args); } else { AddNewsItemToPanel(args); } }
private void InitializeAvatar(NewNewsItemEventArgs args) { avatar1.SetImage(args.Person, args.AvatarImageList); avatar1.Cursor = args.Person.Clickable ? Cursors.Hand : Cursors.Default; }
private void InitializeUserNameLabel(NewNewsItemEventArgs args) { DisplayName = args.Person.DisplayName; }
private bool IncludeInFilter(NewNewsItemEventArgs i) { return(IncludeInFilter(i, _filterPerson, _filterBuildDefinitionId)); }
private void WriteTitle(NewNewsItemEventArgs args) { string title = args.NewsItemType == NewsItemTypeEnum.SosOnlineComment ? "\"" + args.Title + "\"" : args.Title; _title.Text = title; }
public void UpdateState(NewNewsItemEventArgs args) { InitializeReputationChangeLabel(args.ReputationChange); InitializeMetroColors(args); }