Пример #1
0
        private JToken PostRequest(Dictionary <string, string> dictionary)
        {
            JToken data = null;

            try
            {
                Action action = delegate()
                {
                    WebRequest request = System.Net.WebRequest.Create(serverURL);
                    request.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy();
                    byte[] postData = ToPostData(dictionary);
                    request.ContentLength = postData.Length;
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.Method        = "POST";
                    Stream stream = request.GetRequestStream();
                    stream.Write(postData, 0, postData.Length);
                    stream.Close();
                    data = ParseResponse(request);
                };
                WebServiceRetry.ExponentialBackoff(action, TimeSpan.FromMilliseconds(512), 3);
            }
            catch (Exception exception)
            {
                OnException(exception);
            }
            return(data);
        }
Пример #2
0
        private JToken GetRequest(Dictionary <string, string> dictionary)
        {
            JToken data = null;
            String url  = serverURL + "?" + ToGetString(dictionary);

            try
            {
                Action action = delegate()
                {
                    WebRequest request = System.Net.WebRequest.Create(url);
                    request.Proxy  = System.Net.GlobalProxySelection.GetEmptyWebProxy();
                    request.Method = "GET";
                    data           = ParseResponse(request);
                };
                WebServiceRetry.ExponentialBackoff(action, TimeSpan.FromMilliseconds(512), 3);
            }
            catch (Exception e)
            {
                OnException(e);
            }
            return(data);
        }