示例#1
0
 public virtual SosOnlinePerson CreateSosOnlinePersonFromSosOnlineNotification(NewSosOnlineNotificationArgs args, ImageList avatarImageList)
 {
     var avatarId = GetAvatarId(args, avatarImageList);
     return new SosOnlinePerson
     {
         AvatarId = avatarId,
         DisplayName = args.DisplayName
     };
 }
示例#2
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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;
 }
示例#9
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);
     });
 }
示例#10
0
 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;
 }
示例#11
0
 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;
 }
示例#12
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);
     });
 }