Ejemplo n.º 1
0
        private void SendNewCustomImages(SirenOfShameSettings settings, List <InstanceUserDto> changedUsers)
        {
            var changedPeople = changedUsers
                                .Select(changedUser => settings.FindPersonByRawName(changedUser.RawName))
                                .Where(person => person != null);

            var changedPeopleWithUnUploadedCustomImages = changedPeople
                                                          .Where(i => !string.IsNullOrEmpty(i.AvatarImageName) && !i.AvatarImageUploaded);

            foreach (var person in changedPeopleWithUnUploadedCustomImages)
            {
                var webClientXml = new WebClientXml();
                AddSosOnlineCredentials(settings, webClientXml);
                webClientXml.Add("AvatarImageName", person.AvatarImageName);
                var avatarImagePath = SirenOfShameSettings.GetAvatarImagePath(person.AvatarImageName);
                var imageAsBytes    = File.ReadAllBytes(avatarImagePath);
                var imageAsString   = Convert.ToBase64String(imageAsBytes);
                webClientXml.Add("AvatarImage", imageAsString);
                string url     = SOS_URL + "/ApiV1/AddImage";
                var    person1 = person;
                webClientXml.UploadValuesAndReturnStringAsync(url, s => _log.Debug("Uploaded " + person1.AvatarImageName), ex => _log.Error("Error uploading image for " + person1.AvatarImageName), settings.GetSosOnlineProxy());
                person.AvatarImageUploaded = true;
                settings.Save();
            }
        }
Ejemplo n.º 2
0
        public static PersonSetting GetPerson(SirenOfShameSettings settings, string element)
        {
            var rawName = element;
            var person  = settings.FindPersonByRawName(rawName);

            if (person == null)
            {
                _log.Error("Unable to find person from news item: " + rawName);
                return(null);
            }
            return(person);
        }
Ejemplo n.º 3
0
        private void UserPanelMouseUp(object sender, MouseEventArgs e)
        {
            UserPanel userPanel = TraverseParentsUntilUserPanel((Control)sender);

            if (userPanel == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                _selectedRawName = userPanel.RawName;
                _userMenu.Show((Control)sender, e.Location);
                var person = _settings.FindPersonByRawName(_selectedRawName);
                _hiddenButton.Checked = person.Hidden;
            }

            if (e.Button == MouseButtons.Left)
            {
                InvokeOnUserSelected(userPanel.RawName);
            }
        }
Ejemplo n.º 4
0
        private void AddClick(object sender, System.EventArgs e)
        {
            var pretendItsActually = (string)_pretendItsActually.SelectedItem;
            var whenISee           = (string)_whenISee.SelectedItem;

            if (!string.IsNullOrEmpty(whenISee) && !string.IsNullOrEmpty(pretendItsActually) && whenISee != pretendItsActually)
            {
                var whenISeePerson = _settings.FindPersonByRawName(whenISee);
                whenISeePerson.Hidden = true;
                _settings.UserMappings.Add(new UserMapping
                {
                    WhenISee           = whenISee,
                    PretendItsActually = pretendItsActually
                });
                _settings.Save();
            }
            Close();
            Dispose();
        }