Beispiel #1
0
        public (List <Dictionary <string, string> > games, List <string> headers) GetData(string gameCode, DownloadMode mode)
        {
            var url = $"http://us.patch.battle.net:1119/{gameCode}/{mode.ToString()}?nocache={DateTime.Now.Millisecond}";

            List <string> fileData = bnetWebClient.DownloadString(url).Trim().Lines().ToList();

            List <Dictionary <string, string> > CreatedFileData = new List <Dictionary <string, string> >();

            string[] headers = fileData[0].Split('|');
            fileData.RemoveAt(0);

            for (int i = 0; i < headers.Length; i++)
            {
                headers[i] = headers[i].Split('!')[0].SplitCamelCase();
            }

            for (int i = 0; i < fileData.Count; i++)
            {
                Dictionary <string, string> item = new Dictionary <string, string>();

                string[] line = fileData[i].Split('|');
                for (int h = 0; h < headers.Length; h++)
                {
                    item.Add(headers[h], line[h]);
                }

                CreatedFileData.Add(item);
            }

            return(games : CreatedFileData, headers : headers.ToList());
        }
        private void Execute(DownloadMode mode)
        {
            Console.WriteLine($"===== Execution Mode = {mode.ToString()} =======");
            var websites = this.PrepData();

            var watch = System.Diagnostics.Stopwatch.StartNew();

            switch (mode)
            {
            case DownloadMode.Normal:
                Normal(websites);
                break;

            case DownloadMode.AsyncAndWait:
                AsyncAndWait(websites)
                .Wait();
                break;

            case DownloadMode.AsyncParalel:
                AsyncParalel(websites)
                .Wait();
                break;

            default:
                break;
            }

            watch.Stop();
            var elapseMs = watch.ElapsedMilliseconds;

            Console.WriteLine($"Total execution time = {elapseMs}");
            Console.WriteLine(Environment.NewLine);
        }
Beispiel #3
0
 public DownloadEvent(DownloadMode mode, string url, int num)
   : base(mode.ToString() + ": " + num.ToString() + " - " + url, null, (int)mode, num) {
 }