Exemple #1
0
        private static void Main(string[] args)
        {
            Test();
            ParsedRequester parsedRequester = new ParsedRequester(API_KEY);

            using (StreamReader streamReader = new StreamReader(WORDS_PATH))
            {
                File.Delete(NAMES_PATH);
                string[] wordBounds = Console.ReadLine().Split(new char[] { ',' });
                string firstWord = wordBounds.First();
                string lastWord = wordBounds.Last();
                log.InfoFormat("first word: {0}, last word: {1}", firstWord, lastWord);
                IOrderedEnumerable<string> words = WordsFormatter.Format(firstWord, lastWord, streamReader.ReadToEnd());
                int wordsCount = words.Count();
                StringBuilder strBuilder = new StringBuilder();

                for (int i = 0; i < wordsCount; i++)
                {
                    string word = words.ElementAt(i);

                    if ((i % (wordsCount / CHECK_POINTS)) == 0)
                    {
                        Console.Clear();
                        string logMsg = String.Format(
                            "checkpoint: {0}/{1}, word: {2}",
                            Convert.ToInt32(i * Convert.ToDouble(CHECK_POINTS) / wordsCount),
                            CHECK_POINTS,
                            word);
                        Console.WriteLine(logMsg);
                        log.Info(logMsg);
                        File.AppendAllText(NAMES_PATH, strBuilder.ToString());
                        strBuilder = new StringBuilder();
                    }

                    try
                    {
                        if (!parsedRequester.CheckSummonerExists(word, REGION))
                        {
                            strBuilder.Append(String.Format("{0}{1}", word, Environment.NewLine));
                        }
                    }
                    catch (ServerUnavailableException)
                    {
                        log.InfoFormat("failed on {0} because the server was unavailable", word);
                        i--;
                    }
                }

                File.AppendAllText(NAMES_PATH, strBuilder.ToString());
                Process.Start(NAMES_PATH);
            }
        }
Exemple #2
0
        private static void Main(string[] args)
        {
            Test();
            ParsedRequester parsedRequester = new ParsedRequester(API_KEY);

            using (StreamReader streamReader = new StreamReader(WORDS_PATH))
            {
                File.Delete(NAMES_PATH);
                string[] wordBounds = Console.ReadLine().Split(new char[] { ',' });
                string   firstWord  = wordBounds.First();
                string   lastWord   = wordBounds.Last();
                log.InfoFormat("first word: {0}, last word: {1}", firstWord, lastWord);
                IOrderedEnumerable <string> words = WordsFormatter.Format(firstWord, lastWord, streamReader.ReadToEnd());
                int           wordsCount          = words.Count();
                StringBuilder strBuilder          = new StringBuilder();

                for (int i = 0; i < wordsCount; i++)
                {
                    string word = words.ElementAt(i);

                    if ((i % (wordsCount / CHECK_POINTS)) == 0)
                    {
                        Console.Clear();
                        string logMsg = String.Format(
                            "checkpoint: {0}/{1}, word: {2}",
                            Convert.ToInt32(i * Convert.ToDouble(CHECK_POINTS) / wordsCount),
                            CHECK_POINTS,
                            word);
                        Console.WriteLine(logMsg);
                        log.Info(logMsg);
                        File.AppendAllText(NAMES_PATH, strBuilder.ToString());
                        strBuilder = new StringBuilder();
                    }

                    try
                    {
                        if (!parsedRequester.CheckSummonerExists(word, REGION))
                        {
                            strBuilder.Append(String.Format("{0}{1}", word, Environment.NewLine));
                        }
                    }
                    catch (ServerUnavailableException)
                    {
                        log.InfoFormat("failed on {0} because the server was unavailable", word);
                        i--;
                    }
                }

                File.AppendAllText(NAMES_PATH, strBuilder.ToString());
                Process.Start(NAMES_PATH);
            }
        }
Exemple #3
0
        private static void Test()
        {
            if (!TEST)
            {
                return;
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ParsedRequester requester = new ParsedRequester(API_KEY);

            Console.WriteLine("god exists: {0}", requester.CheckSummonerExists("god", REGION));
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
            Console.WriteLine("done");
            Console.ReadLine();
            Environment.Exit(SAFE_EXIT);
        }
Exemple #4
0
 private static void Test()
 {
     if (!TEST) return;
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////
     ParsedRequester requester = new ParsedRequester(API_KEY);
     Console.WriteLine("god exists: {0}", requester.CheckSummonerExists("god", REGION));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Console.WriteLine("done");
     Console.ReadLine();
     Environment.Exit(SAFE_EXIT);
 }