예제 #1
0
        // Весь список друзей, который сохраняется в listFriend
        public int getFriends(string id)
        {
            try
            {
                string jfield = new ClassQueries().loadPage(String.Format("https://api.vk.com/method/friends.get?user_id={0}&order=random", id));
                JToken jtoken = JToken.Parse(jfield);

                listFriend = jtoken["response"].Children().Select(c => c.ToObject <string>()).ToList();
                return(1);
            }
            catch (Exception ex)
            {
                textBox1.AppendText("Error by id: " + id + " ^" + ex.Message + "^ " + Environment.NewLine);
                return(0);
            }
        }
예제 #2
0
        // Имя для создания файла
        public string getNameUser(string id)
        {
            string name = "";

            try
            {
                string      jfield   = new ClassQueries().loadPage(String.Format("https://api.vk.com/method/users.get?user_ids={0}", id));
                JToken      jtoken   = JToken.Parse(jfield);
                List <User> listUser = jtoken["response"].Children().Select(c => c.ToObject <User>()).ToList();
                foreach (User user in listUser)
                {
                    name = user.first_name + " " + user.last_name;
                }
            }
            catch (Exception ex)
            {
                textBox1.AppendText("Error by id: " + id + " ^" + ex.Message + "^ " + Environment.NewLine);
            }
            return(name);
        }
예제 #3
0
        // Загрузка информации о друзьях и фильтрация
        public void checkFiltr(List <string> ids)
        {
            string jfield2 = "";
            JToken jtoken2 = null;

            try
            {
                if (ids.Count != 0 && ids.Count > 1)
                {
                    jfield2 = new ClassQueries().loadPagePOST("https://api.vk.com/method/users.get", "user_ids=" + responseString(ids) + "&fields=country,city,sex&lang=0", ids.Count);
                }
                else
                if (ids.Count == 1)
                {
                    jfield2 = new ClassQueries().loadPage(String.Format("https://api.vk.com/method/users.get?user_ids={0}&fields=country,city,sex&lang=0", ids.First()));
                }
                else
                {
                    return;
                }

                if (jfield2 != "")
                {
                    try
                    {
                        jtoken2 = JToken.Parse(jfield2);
                    }
                    catch (Exception ex) { textBox1.AppendText("Error: " + "ошибка загрузки страницы " + " ^" + ex.Message + "^ " + Environment.NewLine); }
                }

                else
                {
                    textBox1.AppendText("Error: " + "ошибка загрузки страницы" + Environment.NewLine);
                    return;
                }
            }
            catch (Exception ex)
            {
                textBox1.AppendText("Error :" + " ^" + ex.Message + "^ " + Environment.NewLine);
            }

            listInfoFriend.Clear();

            if ((countryComboBox.Text == "") && (cityComboBox.Text == "") && (sexComboBox.Text == ""))
            {
                listInfoFriend = jtoken2["response"].Children().
                                 Select(c => c.ToObject <User>()).ToList();
            }
            else
            {
                if (countryComboBox.Text != "")
                {
                    listInfoFriend = jtoken2["response"].Children().
                                     Select(c => c.ToObject <User>()).
                                     Where(c => c.country == idCountry && countryComboBox.Text != "").ToList();
                }

                if (listInfoFriend.Count != 0 && cityComboBox.Text != "")
                {
                    listInfoFriend = listInfoFriend.Where(c => c.city == idCity && cityComboBox.Text != "").ToList();
                }
                else
                if (cityComboBox.Text != "")
                {
                    listInfoFriend = jtoken2["response"].Children().
                                     Select(c => c.ToObject <User>()).
                                     Where(c => c.city == idCity && cityComboBox.Text != "").ToList();
                }


                if (listInfoFriend.Count != 0 && sexComboBox.Text != "")
                {
                    listInfoFriend = listInfoFriend.Where(c => c.Sex == sexComboBox.Text && sexComboBox.Text != "").ToList();
                }
                else
                if (sexComboBox.Text != "")
                {
                    listInfoFriend = jtoken2["response"].Children().
                                     Select(c => c.ToObject <User>()).
                                     Where(c => c.Sex == sexComboBox.Text && sexComboBox.Text != "").ToList();
                }
            }
        }