示例#1
0
        /*
         * Go throught all possible two char combinations and query server
         * Result is DB with all characters from server
         * Filled informations
         *    - Name, Level, ClassId, GenderId, RaceId, FactionId, Guild, LastRefresh
         * Missing informations
         *    - AP, HK
         * ForceUpdate = true
         */
        public async Task MakeCharacterNameListAsync(IProgress <Tuple <int, string> > progres)
        {
            DateTime start           = DateTime.Now;
            Downloader <Character> d = new Downloader <Character>(this._concurrency, Parser.CharacterNameListParser, DBAccess.SaveCharacterNameList);
            List <string>          URLs;
            int safeGuard = DEF_SAVEGUARD;
            int URLCount  = 0;

            Console.WriteLine("CHARACTERS STARTED!");

            URLs = InitNameListURLs(URLBASE1, URLCHARSUFFIX);

            while (URLs.Count > 0 && safeGuard-- > 0)
            {
                URLCount += URLs.Count;

                Task <List <Tuple <string, bool> > > nameListTask = d.StartDownloadAsync(progres, URLs);

                await nameListTask;

                Console.WriteLine("\nPass {0} done!", (DEF_SAVEGUARD - safeGuard).ToString());
                URLs.Clear();
                foreach (Tuple <string, bool> res in nameListTask.Result)
                {
                    if (!res.Item2)
                    {
                        URLs.AddRange(ExpandNameListURL(res.Item1, URLCHARSUFFIX));
                    }
                }
                URLs = URLs.Distinct().ToList();
            }
            Console.WriteLine("CHARACTERS DONE! elapsed time: {0}", DateTime.Now.Subtract(start).ToString());
        }
示例#2
0
        public async Task CharacterListFromArmoryAsync(Progress <Tuple <int, string> > progres)
        {
            DateTime start = DateTime.Now;

            this.characterNames = new SortedSet <string>();
            Downloader <String> d = new Downloader <string>(this._concurrency, Parser.CharacterNameListParserString, AddCharacterNamesToList);
            List <string>       URLs;
            int safeGuard = DEF_SAVEGUARD;
            int URLCount  = 0;

            Program.WriteLineToConsole("Make of Character names list STARTED!");

            URLs = InitNameListURLs(URLBASE1, URLCHARSUFFIX);

            while (URLs.Count > 0 && safeGuard-- > 0)
            {
                URLCount += URLs.Count;

                Task <List <Tuple <string, bool> > > nameListTask = d.StartDownloadAsync(progres, URLs);

                await nameListTask;

                Program.WriteLineToConsole(String.Format("\nPass {0} done!", (DEF_SAVEGUARD - safeGuard).ToString()));
                URLs.Clear();
                foreach (Tuple <string, bool> res in nameListTask.Result)
                {
                    if (!res.Item2)
                    {
                        URLs.AddRange(ExpandNameListURL(res.Item1, URLCHARSUFFIX));
                    }
                }
                URLs = URLs.Distinct().ToList();
            }
            Program.WriteLineToConsole(String.Format("Character name list DONE! elapsed time: {0}", DateTime.Now.Subtract(start).ToString()));

            Downloader <Character> dc = new Downloader <Character>(this._concurrency, Parser.CharacterApKillsParser, DBAccess.SaveCharacterNameList);
            int charsPerReq           = 10;

            start = DateTime.Now;
            URLs.Clear();

            Program.WriteLineToConsole("Update of Character APs and Kills STARTED!");

            List <string> names = characterNames.ToList();

            for (int i = 0; i < names.Count; i += charsPerReq)
            {
                if ((names.Count - i) < charsPerReq)
                {
                    URLs.Add(CreateCharacterAchievURLwoC(names.GetRange(i, names.Count - i)));
                }
                else
                {
                    URLs.Add(CreateCharacterAchievURLwoC(names.GetRange(i, charsPerReq)));
                }
            }

            Task <List <Tuple <string, bool> > > task = d.StartDownloadAsync(progres, URLs);

            await task;

            Program.WriteLineToConsole(String.Format("Update of Character APs and Kills DONE! elapsed time: {0}", DateTime.Now.Subtract(start).ToString()));
        }