Example #1
0
        /// <summary>
        /// DownloadString
        /// </summary>
        /// <param name="url"></param>
        public void WebDownloadString(string url, WebProxy webProxy, string userAgent)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol();

                WebClientEx ws = new WebClientEx();
                if (webProxy != null)
                {
                    ws.Proxy = webProxy;
                }

                if (Utils.IsNullOrEmpty(userAgent))
                {
                    userAgent = $"{Utils.GetVersion(false)}";
                }
                ws.Headers.Add("user-agent", userAgent);

                ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
                ws.DownloadStringAsync(new Uri(url));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Example #2
0
 void MQOEvents_onRequestStatUpdate(object obj)
 {
     if (!ChatWebClient.IsBusy)
     {
         Uri temp = new Uri("http://midenquest.com/getCharactersShort.aspx?null=&sid=" + GetSID().ToString());
         StatsWebClient.DownloadStringAsync(temp);
     }
 }
Example #3
0
 void MQOEvents_onRequestChatUpdate(object obj)
 {
     //when its done throw the chat update event
     if (!ChatWebClient.IsBusy)
     {
         Uri temp = new Uri("http://midenquest.com/getChatLog.aspx");
         ChatWebClient.DownloadStringAsync(temp);
     }
 }
Example #4
0
        private void IssueTrackerLogout()
        {
            try
            {
                WebClientEx webClient = new WebClientEx();
                webClient.Headers.Add("user-agent", userAgent);
                webClient.Method = "GET";

                webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(IssueTrackerLogout_Completed);
                webClient.DownloadStringAsync(new Uri(issueTrackerUrl + "?do=nakedauth&logout=1"));
            }
            catch (WebException)
            {
                ConnectionError();
            }
        }
Example #5
0
        /// <summary>
        /// DownloadString
        /// </summary>
        /// <param name="url"></param>
        public void WebDownloadString(string url)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol();

                WebClientEx ws = new WebClientEx();
                ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
                ws.DownloadStringAsync(new Uri(url));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Example #6
0
        /// <summary>
        /// DownloadString
        /// </summary> 
        /// <param name="url"></param>
        public void WebDownloadString(string url)
        {
            string source = string.Empty;
            try
            {
                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //TLS 1.2
                ServicePointManager.DefaultConnectionLimit = 256;

                WebClientEx ws = new WebClientEx();
                ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
                ws.DownloadStringAsync(new Uri(url));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Example #7
0
        /// <summary>
        /// DownloadString
        /// </summary>
        /// <param name="url"></param>
        public void WebDownloadString(string url, string userAgent)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol();

                WebClientEx ws = new WebClientEx();
                if (!Utils.IsNullOrEmpty(userAgent))
                {
                    ws.Headers.Add("user-agent", userAgent);
                }

                ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
                ws.DownloadStringAsync(new Uri(url));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Example #8
0
        /// <summary>
        /// DownloadString
        /// </summary>
        /// <param name="url"></param>
        public void WebDownloadString(string url)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol();

                WebClientEx ws    = new WebClientEx();
                Regex       rx    = new Regex(@"^(?<protocol>.+?//)(?<username>.+?)(?::(?<password>.+?))?@(?<address>.+)$");
                Match       match = rx.Match(url);
                if (match.Success)
                {
                    ws.Credentials = new NetworkCredential(match.Groups["username"].Value, match.Groups["password"].Value);
                }
                ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
                ws.DownloadStringAsync(new Uri(url));
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Example #9
0
        /// <summary>
        /// DownloadString
        /// </summary>
        /// <param name="url"></param>
        public void WebDownloadString(string url, WebProxy webProxy, string userAgent)
        {
            string source = string.Empty;

            try
            {
                Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);

                WebClientEx ws = new WebClientEx();
                ws.Encoding = Encoding.UTF8;
                if (webProxy != null)
                {
                    ws.Proxy = webProxy;
                }

                if (Utils.IsNullOrEmpty(userAgent))
                {
                    userAgent = $"{Utils.GetVersion(false)}";
                }
                ws.Headers.Add("user-agent", userAgent);

                Uri uri = new Uri(url);
                //Authorization Header
                if (!Utils.IsNullOrEmpty(uri.UserInfo))
                {
                    ws.Headers.Add(HttpRequestHeader.Authorization, "Basic " + Utils.Base64Encode(uri.UserInfo));
                }

                ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
                ws.DownloadStringAsync(uri);
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }