示例#1
0
        public DispatchResult <ISmsDispatch> Dispatch(ISmsDispatch dispatch)
        {
            string returnValue = null;

            Uri.Query = AppendQueryValue(Uri.Query, "to", dispatch.To);
            Uri.Query = AppendQueryValue(Uri.Query, "from", dispatch.From);
            Uri.Query = AppendQueryValue(Uri.Query, "text", dispatch.Text);

            var request = (HttpWebRequest)WebRequest.Create(Uri.ToString());

            request.Method        = "GET";
            request.ContentLength = 0;
            request.Timeout       = 130000; // Set the Dynmark recommended timeout of 130 seconds

            try
            {
                var response = (HttpWebResponse)request.GetResponse();

                /**
                 * // Read the XML from the response - don't bother doing this if successful
                 * using (var sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                 * {
                 *  returnValue = sr.ReadToEnd();
                 * }
                 **/

                return(new DispatchResult <ISmsDispatch> {
                    Dispatched = true, Processed = true, Error = false, Reference = Guid.NewGuid()
                });
            }
            catch (WebException ex)
            {
                return(DispatchResultFromWebEx(ex));
            }
        }
示例#2
0
        public DispatchResult<ISmsDispatch> Dispatch(ISmsDispatch dispatch)
        {
            string returnValue = null;

            Uri.Query = AppendQueryValue(Uri.Query, "to", dispatch.To);
            Uri.Query = AppendQueryValue(Uri.Query, "from", dispatch.From);
            Uri.Query = AppendQueryValue(Uri.Query, "text", dispatch.Text);

            var request = (HttpWebRequest)WebRequest.Create(Uri.ToString());
            request.Method = "GET";
            request.ContentLength = 0;
            request.Timeout = 130000; // Set the Dynmark recommended timeout of 130 seconds

            try
            {
                var response = (HttpWebResponse)request.GetResponse();

                /**
                // Read the XML from the response - don't bother doing this if successful
                using (var sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    returnValue = sr.ReadToEnd();
                }
                **/

                return new DispatchResult<ISmsDispatch> { Dispatched = true, Processed = true, Error = false, Reference = Guid.NewGuid() };
            }
            catch (WebException ex)
            {
                return DispatchResultFromWebEx(ex);
            }
        }