Пример #1
0
        /* Метод для сбора данных друзей по списку пользователей
         * Возвращает массив json */
        // TODO Долго работает, много мусора
        public JArray VkUsersFriendsSearch(List <string> users)
        {
            Console.WriteLine("FriendsGet");
            timer.Restart();
            /* ???? | ???? */
            HashSet <string> unique_ids = new HashSet <string>(users);

            foreach (string user_id in users)
            {
                HashSet <string> friends_ids = new HashSet <string>(VkApi.FriendsGet(user_id));
//                int trusted_friends = 0;

                /*
                 * foreach (string check_friend_id in friends_ids)
                 * {
                 *  if (users.Contains(check_friend_id))
                 *  {
                 *      trusted_friends++;
                 *
                 *  }
                 * }*/
                if (users.Count(friends_ids.Contains) > friends_ids.Count() * (50.0 / 100.0))
                {
                    foreach (string friend_id in friends_ids)
                    {
                        unique_ids.Add(friend_id);
                    }
                }
            }
            timer.Stop();
            Console.WriteLine("Найдено " + unique_ids.Count() + " друзей " + timer.Elapsed);

            Console.WriteLine("UsersGet");
            timer.Restart();
            /* ???? | ???? */
            JArray users_friends_data = VkApiMulti.UsersGet(unique_ids.ToList(), VkApiUtils.fields, "search");

            timer.Stop();
            Console.WriteLine("Получена информация о " + users_friends_data.Count() + " пользователях и друзьях " + timer.Elapsed);

            return(users_friends_data);
        }