public virtual SosOnlinePerson CreateSosOnlinePersonFromSosOnlineNotification(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { var avatarId = GetAvatarId(args, avatarImageList); return new SosOnlinePerson { AvatarId = avatarId, DisplayName = args.DisplayName }; }
public SosOnlinePerson CreateSosOnlinePersonFromSosOnlineNotification(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { var avatarId = GetAvatarId(args, avatarImageList); return(new SosOnlinePerson { AvatarId = avatarId, DisplayName = args.DisplayName }); }
private void InvokeOnOnNewSosOnlineNotification(string message, string displayName, string imageUrl, string userName) { var args = new NewSosOnlineNotificationArgs { Message = message, DisplayName = displayName, ImageUrl = imageUrl, UserName = userName, }; NewSosOnlineNotification handler = OnNewSosOnlineNotification; if (handler != null) handler(this, args); }
private static int GetGravatarFromWebAndAddToImageList(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { int avatarId; var webClient = new WebClient(); byte[] imageRaw = webClient.DownloadData(args.ImageUrl); using (MemoryStream gravatarMs = new MemoryStream(imageRaw)) { Image gravatarImage = Image.FromStream(gravatarMs); avatarId = avatarImageList.Images.Add(gravatarImage, Color.Transparent); } return(avatarId); }
private int GetAvatarId(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { var gravatarService = new GravatarService(); int avatarId; try { avatarId = gravatarService.DownloadImageFromWebAndAddToImageList(args.ImageUrl, avatarImageList); } catch (Exception ex) { _log.Error("Error retrieving gravatar for " + args.DisplayName, ex); avatarId = SirenOfShameSettings.GenericSosOnlineAvatarId; } return(avatarId); }
private void InvokeOnOnNewSosOnlineNotification(string message, string displayName, string imageUrl, string userName) { var args = new NewSosOnlineNotificationArgs { Message = message, DisplayName = displayName, ImageUrl = imageUrl, UserName = userName, }; NewSosOnlineNotification handler = OnNewSosOnlineNotification; if (handler != null) { handler(this, args); } }
private int GetAvatarId(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { int avatarId; try { if (!_cachedAvatarIds.TryGetValue(args.ImageUrl, out avatarId)) { avatarId = GetGravatarFromWebAndAddToImageList(args, avatarImageList); _cachedAvatarIds[args.ImageUrl] = avatarId; } } catch (Exception ex) { _log.Error("Error retrieving gravatar for " + args.DisplayName, ex); avatarId = SirenOfShameSettings.GenericSosOnlineAvatarId; } return(avatarId); }
private int GetAvatarId(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { var gravatarService = new GravatarService(); int avatarId; try { avatarId = gravatarService.DownloadImageFromWebAndAddToImageList(args.ImageUrl, avatarImageList); } catch (Exception ex) { _log.Error("Error retrieving gravatar for " + args.DisplayName, ex); avatarId = SirenOfShameSettings.GenericSosOnlineAvatarId; } return avatarId; }
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); }); }
private int GetAvatarId(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { int avatarId; try { if (!_cachedAvatarIds.TryGetValue(args.ImageUrl, out avatarId)) { avatarId = GetGravatarFromWebAndAddToImageList(args, avatarImageList); _cachedAvatarIds[args.ImageUrl] = avatarId; } } catch (Exception ex) { _log.Error("Error retrieving gravatar for " + args.DisplayName, ex); avatarId = SirenOfShameSettings.GenericSosOnlineAvatarId; } return avatarId; }
private static int GetGravatarFromWebAndAddToImageList(NewSosOnlineNotificationArgs args, ImageList avatarImageList) { int avatarId; var webClient = new WebClient(); byte[] imageRaw = webClient.DownloadData(args.ImageUrl); using (MemoryStream gravatarMs = new MemoryStream(imageRaw)) { Image gravatarImage = Image.FromStream(gravatarMs); avatarId = avatarImageList.Images.Add(gravatarImage, Color.Transparent); } return avatarId; }
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); }); }