Example #1
2
        public List<BookData> FindBooksByOLIDs(List<string> oLIDs)
        {
            if (oLIDs == null)
            {
                throw new ArgumentNullException("oLIDs");
            }

            List<BookData> books = new List<BookData>();

            var bibkeys = new StringBuilder();
            foreach (var oLID in oLIDs)
            {
                bibkeys.Append(oLID);
                bibkeys.Append(",");
            }
            if (bibkeys.Length != 0)
            {
                var getUri = baseUrl + "books?bibkeys=OLID:" + bibkeys.ToString().TrimEnd(new char[] { ',' }) + "&format=json&jscmd=data";

                using (var webClient = new WebClient())
                {
                    var response = JsonConvert.DeserializeObject<Dictionary<string, BookData>>(webClient.DownloadString(getUri));
                    if (response.Count() > 0)
                    {
                        books = new List<BookData>();
                        foreach (var value in response.Values)
                        {
                            books.Add(value);
                        }
                    }
                }
            }
            return books;
        }
        /// <summary>
        /// loads a xml from the web server
        /// </summary>
        /// <param name="_url">URL of the XML file</param>
        /// <returns>A XmlDocument object of the XML file</returns>
        public static XmlDocument LoadXml(string _url)
        {
            var xmlDoc = new XmlDocument();
            
            try
            {
                while (Helper.pingForum("forum.mods.de", 10000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                xmlDoc.Load(_url);
            }
            catch (XmlException)
            {
                while (Helper.pingForum("forum.mods.de", 100000) == false)
                {
                    Console.WriteLine("Can't reach forum.mods.de right now, try again in 15 seconds...");
                    System.Threading.Thread.Sleep(15000);
                }

                WebClient client = new WebClient(); ;
                Stream stream = client.OpenRead(_url);
                StreamReader reader = new StreamReader(stream);
                string content = reader.ReadToEnd();

                content = RemoveTroublesomeCharacters(content);
                xmlDoc.LoadXml(content);
            }

            return xmlDoc;
        }
Example #3
1
        public async override Task<IEnumerable<string>> GetVersion(string packageName)
        {
            if (string.IsNullOrEmpty(packageName))
                return Enumerable.Empty<string>();

            string url = $"http://registry.npmjs.org/{packageName}";
            string json = "{}";

            using (var client = new WebClient())
            {
                json = await client.DownloadStringTaskAsync(url);
            }

            var array = JObject.Parse(json);
            var time = array["time"];

            if (time == null)
                return Enumerable.Empty<string>();

            var props = time.Children<JProperty>();

            return from version in props
                   where char.IsNumber(version.Name[0])
                   orderby version.Name descending
                   select version.Name;
        }
Example #4
1
        public List<SearchResult> Search(string searchQuery)
        {
            string url = "http://www.imdb.com/find?q={0}&s=all".Fmt(searchQuery);

            string html = new WebClient().DownloadString(url);

            CQ dom = html;

            var searchResults = new List<SearchResult>();

            foreach (var fragment in dom.Select("table.findList tr.findResult"))
            {
                var searchResult = new SearchResult();
                searchResult.ImageUrl = fragment.Cq().Find(".primary_photo > a > img").Attr("src");
                searchResult.Text = fragment.Cq().Find(".result_text").Html();
                searchResult.Text = StringEx.RemoveHtmlTags(searchResult.Text);

                string filmUrl = fragment.Cq().Find(".result_text > a").Attr("href");
                filmUrl = filmUrl.Replace("/title/", "");
                searchResult.FilmId = filmUrl.Substring(0, filmUrl.IndexOf("/"));

                searchResults.Add(searchResult);
            }

            return searchResults;
        }
Example #5
1
 public ItemCrawler(Uri url)
 {
     _htmlDocument = new HtmlDocument();
     var html = new WebClient().DownloadString(url.OriginalString);
     _htmlDocument.LoadHtml(html);
     _document = _htmlDocument.DocumentNode;
 }
Example #6
1
		public async Task<Queue> DownloadQueue()
		{
			using (WebClient w = new WebClient())
			{
				return this.ConvertApiResultToQueue(await w.DownloadStringTaskAsync("http://localhost:8080/sabnzbd/api?mode=queue&output=xml"));
			}
		}
Example #7
1
        public static List<CoinInformation> GetCoinInformation(string userAgent = "",
            BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new WebClient();
            if (!string.IsNullOrEmpty(userAgent))
                client.Headers.Add("user-agent", userAgent);

            string apiUrl = GetApiUrl(profitabilityBasis);

            string jsonString = client.DownloadString(apiUrl);
            JArray jsonArray = JArray.Parse(jsonString);

            List<CoinInformation> result = new List<CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                if (coinInformation.Difficulty > 0)
                    //only add coins with valid info since the user may be basing
                    //strategies on Difficulty
                    result.Add(coinInformation);
            }

            return result;
        }
Example #8
1
		public HttpClient (Uri baseUrl)
		{
//			this.baseUrl = baseUrl;
			visualizeUrl = new Uri (baseUrl, "visualize");
			stopVisualizingUrl = new Uri (baseUrl, "stopVisualizing");
			client = new WebClient ();
		}
        /// <summary>
        /// Used to perform the actual conversion of the input string
        /// </summary>
        /// <param name="InputString"></param>
        /// <returns></returns>
        public override string TranslateString(string InputString)
        {
            Console.WriteLine("Processing: " + InputString);
            string result = "";

            using (WebClient client = new WebClient())
            {
                using (Stream data = client.OpenRead(this.BuildRequestString(InputString)))
                {

                    using (StreamReader reader = new StreamReader(data))
                    {
                        string s = reader.ReadToEnd();

                        result = ExtractTranslatedString(s);

                        reader.Close();
                    }

                    data.Close();
                }
            }

            return result;
        }
Example #10
1
        public void UpdateFiles()
        {
            try
            {
                WriteLine("Local version: " + Start.m_Version);

                WebClient wc = new WebClient();
                string versionstr;
                using(System.IO.StreamReader sr = new System.IO.StreamReader(wc.OpenRead(baseurl + "version.txt")))
                {
                    versionstr = sr.ReadLine();
                }
                Version remoteversion = new Version(versionstr);
                WriteLine("Remote version: " + remoteversion);

                if(Start.m_Version < remoteversion)
                {
                    foreach(string str in m_Files)
                    {
                        WriteLine("Updating: " + str);
                        wc.DownloadFile(baseurl + str, str);
                    }
                }
                wc.Dispose();
                WriteLine("Update complete");
            }
            catch(Exception e)
            {
                WriteLine("Update failed:");
                WriteLine(e);
            }
            this.Button_Ok.Enabled = true;
        }
        public GamePlayHistory AddNewGameHistory(GamePlayHistory gamePlayHistory)
        {
            if (string.IsNullOrEmpty(ToSavourToken))
            {
                throw new InvalidOperationException("No ToSavour Token is set");
            }

            RequestClient = new WebClient();
            RequestClient.Headers.Add("Authorization", ToSavourToken);
            RequestClient.Headers.Add("Content-Type", "application/json");

            var memoryStream = new MemoryStream();
            GetSerializer(typeof(GamePlayHistory)).WriteObject(memoryStream, gamePlayHistory);

            memoryStream.Position = 0;
            var sr = new StreamReader(memoryStream);
            var json = sr.ReadToEnd();

            var userJsonString = RequestClient.UploadString(_host + @"gamehistories", json);

            var byteArray = Encoding.ASCII.GetBytes(userJsonString);
            var stream = new MemoryStream(byteArray);

            var returnedGamePlayHistory = GetSerializer(typeof(GamePlayHistory)).ReadObject(stream) as GamePlayHistory;

            return returnedGamePlayHistory;
        }
        private void CreateIncident()
        {
            WebClient client = new WebClient();
            client.Headers[HttpRequestHeader.Accept] = "application/json";
            client.Headers[HttpRequestHeader.ContentType] = "application/json";

            client.UploadStringCompleted += (object source, UploadStringCompletedEventArgs e) =>
            {
                if (e.Error != null || e.Cancelled)
                {
                    Console.WriteLine("Error" + e.Error);
                    Console.ReadKey();
                }
            };

            JavaScriptSerializer js = new JavaScriptSerializer();
            TriggerDetails triggerDetails = new TriggerDetails(Component, Details);
            var detailJson = js.Serialize(triggerDetails);

            //Alert name should be unique for each alert - as alert name is used as incident key in pagerduty.
            string key = ConfigurationManager.AppSettings["PagerDutyServiceKey"];
            if (!string.IsNullOrEmpty(EscPolicy))
            {
                key = ConfigurationManager.AppSettings["PagerDutySev1ServiceKey"];
            }
            if (string.IsNullOrEmpty(key))
            {
                key = ConfigurationManager.AppSettings["PagerDutyServiceKey"];
            }
            
            Trigger trigger = new Trigger(key,AlertName,AlertSubject,detailJson);           
            var triggerJson = js.Serialize(trigger);
            client.UploadString(new Uri("https://events.pagerduty.com/generic/2010-04-15/create_event.json"), triggerJson); 
            
        }
Example #13
1
        protected void UserAuthenticate(object sender, AuthenticateEventArgs e)
        {
            if (Membership.ValidateUser(this.LoginForm.UserName, this.LoginForm.Password))
            {
                e.Authenticated = true;
                return;
            }

            string url = string.Format(
                this.ForumAuthUrl,
                HttpUtility.UrlEncode(this.LoginForm.UserName),
                HttpUtility.UrlEncode(this.LoginForm.Password)
                );

            WebClient web = new WebClient();
            string response = web.DownloadString(url);

            if (response.Contains(groupId))
            {
                e.Authenticated = Membership.ValidateUser("Premier Subscriber", "danu2HEt");
                this.LoginForm.UserName = "Premier Subscriber";

                HttpCookie cookie = new HttpCookie("ForumUsername", this.LoginForm.UserName);
                cookie.Expires = DateTime.Now.AddMonths(2);

                Response.Cookies.Add(cookie);
            }
        }
Example #14
1
        public List<string> FindOLIDsByTitle(string title)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentNullException("title");
            }

            // OpenLibrary is friendly with the book title whose first character is captial. 
            title = title[0].ToString().ToUpper() + title.Substring(1);

            var uri = baseUrl + "things?query={\"type\":\"\\/type\\/edition\",\"title~\":\"" + title + "*\"}&prettyprint=true&text=true";

            List<string> oLIDs = new List<string>();
            using (var webClient = new WebClient())
            {
                var response = JsonConvert.DeserializeObject<Thing>(webClient.DownloadString(uri));
                if (response.Status.Equals("ok", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var oLID in response.Result)
                    {
                        string strToRemove = "/books/";
                        if (oLID.StartsWith(strToRemove))
                        {
                            oLIDs.Add(oLID.Replace(strToRemove, ""));
                        }
                    }
                }
            }
            return oLIDs;
        }
        public static string DELETE(string uri, IDictionary<string, string> args)
        {
            try {
                WebClient client = new WebClient();

                client.Encoding = Encoding.UTF8;

                client.Headers["Connection"] = "Keep-Alive";
                StringBuilder formattedParams = new StringBuilder();

                IDictionary<string, string> parameters = new Dictionary<string, string>();

                foreach (var arg in args)
                {
                    parameters.Add(arg.Key, arg.Value);
                    formattedParams.AppendFormat("{0}={{{1}}}", arg.Key, arg.Key);
                }

                //Formatted URI
                Uri baseUri = new Uri(uri);

                client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompletedDelete);

                client.UploadStringAsync(baseUri, "DELETE", string.Empty);
                allDone.Reset();
                allDone.WaitOne();

                return requestResult;
            }
            catch (WebException ex) {
                return ReadResponse(ex.Response.GetResponseStream());
            }
        }
Example #16
1
        public List<Thread> GetFilmThreads(string filmId, int? page = null)
        {
            string url = "http://www.imdb.com/title/{0}/board".Fmt(filmId);

            if (page.HasValue)
                url += "?p=" + page.Value;

            string html = new WebClient().DownloadString(url);
            CQ dom = html;
            var threadHtmlFragments = dom.Select("div.threads > div.thread");
            var threads = new List<Thread>();

            foreach (var fragment in threadHtmlFragments)
            {
                if (fragment["class"] == "thread header")
                    continue;

                var cq = fragment.Cq();

                var thread = new Thread();

                thread.Title = cq.Find(">.title a").Html();
                thread.Url = cq.Find(">.title a").Attr("href");
                thread.Id = thread.Url.Substring(thread.Url.LastIndexOf("/") + 1);
                thread.UserUrl = cq.Find(".author .user a.nickname").Attr("href");
                thread.UserImage = cq.Find(".author .user .avatar > img").Attr("src");
                thread.UserName = cq.Find(".author .user a.nickname").Html();
                thread.RepliesCount = int.Parse(cq.Find(".replies a").Html().Trim());
                thread.Timestamp = ParseDate(cq.Find(".timestamp > a > span").Attr("title"), hasSeconds: false);

                threads.Add(thread);
            }

            return threads;
        }
Example #17
0
        public YouTubeDownloader(string youTubeVideoUrl)
        {
            _internalDownloader = new WebClient();
            _youTubeVideoUrl = youTubeVideoUrl;

            RegisterDownloadEventHandlers();
        }
Example #18
0
 static WebClient SetupClient()
 {
     var webClient = new WebClient();
     webClient.Headers.Add("user-agent", DefaultUserAgent);
     webClient.DownloadProgressChanged += OnDownloadProgressChanged;
     return webClient;
 }
Example #19
0
        public string downloadBinaryFile_Action(string urlOfFileToFetch, string targetFileOrFolder)
        {
            if (urlOfFileToFetch.is_Null() || targetFileOrFolder.is_Null())
                return null;
            var targetFile = targetFileOrFolder;
            if (Directory.Exists(targetFileOrFolder))
                targetFile = targetFileOrFolder.pathCombine(urlOfFileToFetch.fileName());

            PublicDI.log.debug("Downloading Binary File {0}", urlOfFileToFetch);
            lock (this)
            {
                using (var webClient = new WebClient())
                {
                    try
                    {
                        byte[] pageData = webClient.DownloadData(urlOfFileToFetch);
                        O2Kernel_Files.WriteFileContent(targetFile, pageData);
                        PublicDI.log.debug("Downloaded File saved to: {0}", targetFile);

                        webClient.Dispose();

                        GC.Collect();       // because of WebClient().GetRequestStream prob
                        return targetFile;
                    }
                    catch (Exception ex)
                    {
                        PublicDI.log.ex(ex);
                    }
                }
            }
            GC.Collect();       // because of WebClient().GetRequestStream prob
            return null;
        }
Example #20
0
        public static void GetStationCollectionAsync(IQueryBuilder url, RealTimeDataDelegate callback)
        {
            try
            {
                if (url == null) throw new Exception("Cannot work with null-objects");
                if (String.IsNullOrEmpty(url.Url)) throw new Exception("Url cannot be empty");

                var client = new WebClient();

                client.DownloadStringCompleted += (s, e) =>
                {
                    if (e.Error != null) throw e.Error;
                    if (e.Result == null) return;

                    var collection = JsonHelper.Deserialize<
                        IList<Station>>(e.Result);

                    callback(new ObservableCollection<Station>(collection));
                };

                client.DownloadStringAsync(new Uri(url.Url));
            }
            catch (Exception)
            {
                throw;
            }
        }
        // internet connection test method
        public static EnvironmentCheckResult ConnectedToInternetTest()
        {
            EnvironmentCheckResult result = new EnvironmentCheckResult();
            result.Message = "You are connected to the Internet.";
            result.DidPass = true;

            WebClient client = new WebClient();

            try
            {
                string results = client.DownloadString( "https://rockrms.blob.core.windows.net/install/html-alive.txt" );

                if ( !results.Contains( "success" ) )
                {
                    result.DidPass = false;
                    result.Message = "It does not appear you are connected to the Internet. Rock requires a connection to download the installer.";
                }
            }
            catch ( Exception ex )
            {
                result.DidPass = false;
                result.Message = "Could not connect to the Internet.  Error: " + ex.Message;
                return result;
            }
            finally
            {
                client = null;
            }

            return result;
        }
Example #22
0
        public override void Use(Player p, string message)
        {
            if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; }
            if (!Directory.Exists("extra/copy"))
                Directory.CreateDirectory("extra/copy");

            if (!File.Exists("extra/copy/christmastree.copy"))
            {
                Player.SendMessage(p, "ChrismasTree copy doesn't exist. Downloading...");
                try
                {
                    using (WebClient WEB = new WebClient())
                        WEB.DownloadFile("http://dekemaserv.com/xmas.copy", "extra/copy/christmastree.copy");
                }
                catch
                {
                    Player.SendMessage(p, "Sorry, downloading failed. Please try again later.");
                    return;
                }
            }
            Command.all.Find("retrieve").Use(p, "christmastree");
            Command.all.Find("paste").Use(p, "");
            ushort[] loc = p.getLoc(false);
            Command.all.Find("click").Use(p, loc[0] + " " + loc[1] + " " + loc[2]);
        }
        private int DownloadTranslations(int translationId, int chapterNo)
        {
            int status = 0;

            Dispatcher.BeginInvoke(() =>
            {
                busyIndicator.IsRunning = true;

                try
                {
                    String xmlUrl = "http://web.quran360.com/services/Verse.php?translationId=" + translationId + "&chapterId=" + chapterNo + "&format=xml";

                    WebClient client = new WebClient();
                    client.OpenReadCompleted += (sender, e) =>
                    {
                        if (e.Error != null)
                            return;

                        Stream str = e.Result;
                        XDocument xdoc = XDocument.Load(str);

                        // take results
                        List<Verse> verses = (from verse in xdoc.Descendants("verse")
                                              select new Verse()
                                              {
                                                  id = (int)verse.Element("id"),
                                                  translation_id = (int)verse.Element("translation_id"),
                                                  chapter_id = (int)verse.Element("chapter_id"),
                                                  verse_id = (int)verse.Element("verse_id"),
                                                  verse_text = (string)verse.Element("verse_text")
                                              }).ToList();
                        // close
                        str.Close();

                        //busyIndicator.Content = "Downloading Chapter " + chapterNo + " ...";
                        for (int i = 0; i < verses.Count(); i++)
                        {
                            (Application.Current as App).db.AddVerseTrans(verses[i]);
                            System.Diagnostics.Debug.WriteLine(verses[i].chapter_id + ":" + verses[i].verse_id);
                            busyIndicator.Content = "Downloading (" + verses[i].chapter_id + ":" + verses[i].verse_id + ") ...";

                        }

                        busyIndicator.IsRunning = false;
                        status = 1;

                        FillData();

                    };

                    client.OpenReadAsync(new Uri(xmlUrl, UriKind.Absolute));
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.StackTrace);
                    MessageBox.Show("Internet connection required.");
                }
            });
            return status;
        }
Example #24
0
        public void read_api(string content_id)
        {
            WebClient myService = new WebClient();
            url = null;
            try
            {
                if (content_id != null)
                {
                    SetLoadingPanelVisibility(true);

                    url = "http://mstage.truelife.com/api_movietv/drama/music?method=getinfo&content_id=";


                    Debug.WriteLine(url + content_id);

                    myService.DownloadStringAsync(new Uri(url + content_id));
                    myService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(GetTotal_Completed);
                }
                else
                {
                    throw new Exception("Content id is NULL !");
                }

            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
 public void UpdatePACFromGFWList(Configuration config)
 {
     WebClient http = new WebClient();
     http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);
     http.DownloadStringCompleted += http_DownloadStringCompleted;
     http.DownloadStringAsync(new Uri(GFWLIST_URL));
 }
        private ImageSettings GetLatestImageInfo()
        {
            ImageSettings iSettings = null;
            try
            {
                using (var wc = new WebClient())
                {
                    var json = wc.DownloadString("http://himawari8-dl.nict.go.jp/himawari8/img/D531106/latest.json?" + Guid.NewGuid());
                    var iInfo = JsonConvert.DeserializeObject<ImageInfo>(json);
                    iSettings = new ImageSettings
                    {
                        Width = 550,
                        Level = "4d",
                        NumBlocks = 4,
                        TimeString = iInfo.Date.AddHours(Settings.Default.Difference).ToString("yyyy/MM/dd/HHmmss", CultureInfo.InvariantCulture)
                    };
                }
            }
            catch (WebException ex)
            {
                _notify(NotifificationType.Error, "Error receiving image information: " + ex.Message);
            }
            catch (Exception ex)
            {
                _notify(NotifificationType.Error, "Unknown error receiving image information: " + ex.Message);
                throw;
            }

            return iSettings;
        }
 public User GetUserDetailsFrom(string token)
 {
     User user = new User();
     string parameters = String.Format("apiKey={0}&token={1}&format=xml", ApplicationSettingsFactory.GetApplicationSettings().JanrainApiKey, token);
     string response;
     using (var w = new WebClient())
     {
         response = w.UploadString("https://rpxnow.com/api/v2/auth_info", parameters);
     }
     var xmlResponse = XDocument.Parse(response);
     var userProfile = (from x in xmlResponse.Descendants("profile")
                        select new
                        {
                            id = x.Element("identifier").Value,
                            email = (string)x.Element("email") ?? "No Email"
                        }).SingleOrDefault();
     if (userProfile != null)
     {
         user.AuthenticationToken = userProfile.id;
         user.Email = userProfile.email;
         user.IsAuthenticated = true;
     }
     else
         user.IsAuthenticated = false;
     return user;
 }
Example #28
0
        public void Download(DownloadTarget target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            Console.WriteLine("[Downloader] Processing " + target.Target.ToString());

            try
            {
                WebClient client = new WebClient();
                target.Content = client.DownloadString(target.Target);

                Console.WriteLine(
                    string.Format(CultureInfo.InvariantCulture, "URL {0} downloaded", target.TargetAddress));
            }
            catch (System.Net.WebException)
            {
                Console.WriteLine(
                   string.Format(
                   CultureInfo.InvariantCulture,
                   "URL could not be downloaded",
                   target.TargetAddress));

                return;
            }

            this.Harvester.Send(harvester => harvester.HarvestLinks(target));

            Console.WriteLine("[Downloader] Processed " + target.Target.ToString());
        }
        // get Weather Data by Location (Long, Lat)
        public WeatherData GetWeatherData(WeatherDataEnum platform)
        {
            var json_data = string.Empty;

            if (platform != WeatherDataEnum.OPEN_WEATHER_MAP)
                throw new WeatherDataServiceException("Unrecognized Enum Type. Try to use OPEN_WEATHER_MAP");

            using (var w = new WebClient())
            {
                // attempt to download JSON data as a string
                try
                {
                    string url = "http://api.openweathermap.org/data/2.5/weather?lat=" + this.location.latitude.ToString() + "&lon=" + this.location.longitude.ToString();
                    Console.WriteLine(url);
                    json_data = w.DownloadString(url);
                    // if string with JSON data is not empty, deserialize it to class and return its instance
                    return !string.IsNullOrEmpty(json_data) ? JsonConvert.DeserializeObject<WeatherData>(json_data) : WeatherData.GetInstance(null);
                    //return this.GetWeather();
                }
                catch (WeatherDataServiceException e)
                {
                    Console.WriteLine("Error : " + e.StackTrace);
                }
            }

            return null;
        }
        public async Task<long> GetPageSize(CancellationToken cToken)
        {
            WebClient wc = new WebClient();
            Stopwatch sw = Stopwatch.StartNew();

            byte[] apressData = await wc.DownloadDataTaskAsync(TargetUrl);
            Debug.WriteLine("Elapsed ms: {0}", sw.ElapsedMilliseconds);
            return apressData.LongLength;

            //List<long> results = new List<long>();

            //for (int i = 0; i < 10; i++)
            //{
            //    if (!cToken.IsCancellationRequested)
            //    {
            //        Debug.WriteLine("Making Request: {0}", i);
            //        byte[] apressData = await wc.DownloadDataTaskAsync(TargetUrl);
            //        results.Add(apressData.LongLength);
            //    }
            //    else
            //    {
            //        Debug.WriteLine("Cancelled");
            //        return 0;
            //    }
            //}
            ////byte[] apressData = await wc.DownloadDataTaskAsync(TargetUrl);
            //Debug.WriteLine("Elapsed ms: {0}", sw.ElapsedMilliseconds);
            ////return apressData.LongLength;
            //return (long)results.Average();
        }