Пример #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
 /// <summary>
 /// Invoked when the URL has been parsed by the MediaManager.
 /// </summary>
 /// <param name="track">The track representing the audio at the URL</param>
 private void URL_Parsed(TrackData track)
 {
     URLs.Clear();
     URLs.Add(track);
     Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
     {
         ToggleProgressbar(false);
     }));
     if (callCallback && callback != null)
     {
         callback(URLs);
     }
 }
Пример #3
0
        private void URLDelete()
        {
            foreach (var url in URLs.Where(x => x.SelectThis == true))
            {
                FileInfo file = new FileInfo(URL_FILE_PATH + url.Title + URL_FILE_NAME);

                if (file.Exists)
                {
                    file.Delete();
                }
            }
            URLs.Clear();
            URLLoad();
        }
Пример #4
0
        /// <summary>
        /// Invoked after a short delay after the user has changed the URL text.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void inputDelay_Tick(object sender, EventArgs e)
        {
            inputDelay.Stop();

            ToggleProgressbar(true);

            string url = URL.Text;

            if (PlaylistManager.IsSupported(url))
            {
                ThreadStart ParseThread = delegate()
                {
                    HttpWebRequest  req  = (HttpWebRequest)WebRequest.Create(url);
                    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                    Stream          str  = resp.GetResponseStream();
                    Encoding        enc  = Encoding.GetEncoding("utf-8");
                    StreamReader    read = new StreamReader(str, enc);

                    URLs.Clear();
                    foreach (TrackData track in PlaylistManager.ParsePlaylist(read, PlaylistManager.GetType(url)))
                    {
                        track.Icon = "pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/Radio.ico";
                        URLs.Add(track);
                    }

                    resp.Close();
                    read.Close();

                    ToggleProgressbar(false);

                    if (callCallback && callback != null)
                    {
                        callback(URLs);
                    }
                };
                Thread parse_thread = new Thread(ParseThread);
                parse_thread.Name         = "URL Parser";
                parse_thread.IsBackground = true;
                parse_thread.Priority     = ThreadPriority.Lowest;
                parse_thread.Start();
            }
            else
            {
                MediaManager.ParseURLAsync(URL.Text, URL_Parsed, true);
            }
        }
Пример #5
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()));
        }