Esempio n. 1
0
        // Token check with direct parsing
        public static int TokenCheckDirectVoid(
            int i,
            string[] tokens,
            RequestParams parameters,
            int bdayDay,
            VkUsers users)
        {
            // First tokens selecting
            if (i < tokens.Length)
            {
                parameters.Token = tokens[i];
                Console.WriteLine("\nToken are blocked. Selected next {0} token\n", i);
                Console.WriteLine("Lets try again parsing {0} day\n", bdayDay);

                return(1);
            }
            // If all tokens in list are lock - check token list again
            else
            {
                i = 0;
                Console.WriteLine("\n.Start again from 0 token\n");

                try
                {
                    while (users.response.Count == 0 && i < tokens.Length)
                    {
                        Console.WriteLine("\n.Try token: {0} \n", i);
                        parameters.Token = tokens[i];
                        var response = VkRequest.VkSearchResponse(parameters);
                        users = VkUsers.VkDeserealiseResponse(response);
                        i++;

                        // No more working tokens -> exit
                        if (i == tokens.Length)
                        {
                            Console.WriteLine("\nTokens are ended. Parsing is finished!\n");
                            return(2);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("\nWhile cycle exception:\n{0}", ex);
                    return(3);
                }

                Console.WriteLine("\nTokens are ended. Try start from {0} token again\n", i);
                Console.WriteLine("Lets try again parsing {0} day\n", bdayDay);

                return(4);
            }
        }
Esempio n. 2
0
        // Get users from Vk (isWriteInFile == false), Get users and write id into file (isWriteInFile == true)
        public static VkUsers GetWriteUsers(RequestParams parameters, int delayFrom, int delayTo, string outputFile,
                                            bool isWriteInFile)
        {
            var randomGen = new Random();

            Thread.Sleep(randomGen.Next(delayFrom, delayTo));
            var response = VkRequest.VkSearchResponse(parameters);
            var users    = VkUsers.VkDeserealiseResponse(response);

            if (isWriteInFile)
            {
                WriteInFile(users, outputFile, parameters.City);
            }

            return(users);
        }
Esempio n. 3
0
        // Token checking for Name parsing :: Find one Ivan in Moscow
        public static bool TokenCheck(RequestParams parameters, int delayFrom)
        {
            Thread.Sleep(delayFrom);

            VkUsers.RequestParamsInit(parameters);
            parameters.Name  = "Иван";
            parameters.City  = 1;
            parameters.Count = 1;

            var response = VkRequest.VkSearchResponse(parameters);
            var users    = VkUsers.VkDeserealiseResponse(response);

            if (users == null || users.response.Count == 0)
            {
                return(false);
            }
            return(users.response.Count > 0);
        }
Esempio n. 4
0
        // Token checking for Random parsing :: Check nearest day
        public static bool TokenCheckRandom(RequestParams parameters, int delayFrom)
        {
            Thread.Sleep(delayFrom);

            // Check for start or end of month:
            if (parameters.BirthDay < Month.DaysInMonth[parameters.BirthMonth])
            {
                ++parameters.BirthDay;
            }
            else
            {
                --parameters.BirthDay;
            }

            var response = VkRequest.VkSearchResponse(parameters);
            var users    = VkUsers.VkDeserealiseResponse(response);

            if (users == null || users.response.Count == 0)
            {
                return(true);
            }
            return(users.response.Count == 0);
        }