Beispiel #1
0
        public ResponseModel DoRequest(RequestPayload sender)
        {
            //if (sender != null)
            //{
            //    sender.callingline = HttpUtility.UrlEncode(sender.callingline);
            //    sender.company = HttpUtility.UrlEncode(sender.company);
            //    sender.contextparm = HttpUtility.UrlEncode(sender.contextparm);
            //    sender.key = HttpUtility.UrlEncode(sender.key);
            //}
            var responseModel = new ResponseModel();

            try
            {
                var audio = new ChuangLanAudioJson
                {
                    userinfo = sender
                };
                var userinfo = JsonHelper.Serialize(audio);
                var encoding = Encoding.GetEncoding("GBK");
                userinfo = HttpUtility.UrlEncode(userinfo, encoding);
                var res       = BaseUrl + "/" + ResouceUrl + "?userinfo=" + userinfo;
                var myRequest = (HttpWebRequest)WebRequest.Create(res);
                myRequest.ContentType = "text/html; charset=GBK";
                var myResponse = (HttpWebResponse)myRequest.GetResponse();
                responseModel.Status = myResponse.StatusCode;

                if (myResponse.StatusCode == HttpStatusCode.OK)
                {
                    var reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("GBK"));
                    responseModel         = JsonHelper.Deserialize <ResponseModel>(reader.ReadToEnd());
                    responseModel.Success = true;
                }
                else
                {
                    //访问失败
                }
                return(responseModel);
            }
            catch (Exception ex)
            {
                responseModel.Msg = ex.ToString();
                return(responseModel);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="chuangLanRequest">创蓝请求参数实体类</param>
 public ChuangLanAudioMessageSender(RequestPayload chuangLanRequest)
 {
     _chuangLanRequest = chuangLanRequest;
     _response         = new ResponseModel();
 }