Esempio n. 1
0
        public static void ParseResultBase(XDocument resultDocument, ResultBase resultBase)
        {
            if (resultDocument != null)
            {
                if (resultDocument.Descendants("error").Count() > 0)
                {
                    string errMsg = resultDocument.Descendants("error").ElementAt(0).Attribute("code").Value;
                    throw new ApplicationException(errMsg);
                }

                resultBase.ResultCode = resultDocument.Descendants("success").ElementAt(0).Attribute("code").Value;

                int remaingCount = -1;
                int.TryParse(resultDocument.Descendants("success").ElementAt(0).Attribute("remaining").Value,
                             out remaingCount);
                resultBase.RemainingMessageCount = remaingCount;

                resultBase.TimeStamp = resultDocument.Descendants("success").ElementAt(0).Attribute("resetdate").Value;
            }
        }
Esempio n. 2
0
        private XDocument GetResultDocument(Dictionary <string, string> parameters, string method, ResultBase resultBase)
        {
            HttpWebRequest httpWebRequest = BuildRequest(BASE_URL, method, parameters);

            WebResponse response = default(WebResponse);

            try {
                response = httpWebRequest.GetResponse();
            }
            catch (TimeoutException e) {
                throw new TimeoutException("Timeout delivery uncertain");
            }
            XDocument resultDocument = XDocument.Load(response.GetResponseStream());

            ResultParser.ParseResultBase(resultDocument, resultBase);

            return(resultDocument);
        }