Пример #1
0
        public ResponseInfo <FinishOrderDatamap> Finish(string orderid, string memberid, string provideid)
        {
            FinishOrderInfo info = new FinishOrderInfo()
            {
                memberId = memberid, orderId = orderid, providerId = provideid
            };

            var config   = new ApiSetting(null);
            var response = SecurityHttpClient.Post <FinishOrderInfo, FinishOrderDatamap>(config.JavaOrder_Uri + "finishedCall", info);

            if (response.respCode != "0")
            {
                throw new ApplicationException(response.respMsg);
            }
            return(response);
        }
Пример #2
0
        public FinishOrderResponse Finish(string orderid, string memberid, string provideid)
        {
            FinishOrderInfo info = new FinishOrderInfo()
            {
                memberId = memberid, orderId = orderid, providerId = provideid
            };
            string mid = memberid;

            if (string.IsNullOrWhiteSpace(mid))
            {
                mid = DefaultMemberId;
            }
            info.memberId = mid;
            var password = GetPassword(mid);
            var datetime = DateTime.Now;
            var request  = new ConfirmOrderRequest
            {
                dataMap = info,
                sign    = BuildSign(info, datetime, password),
                reqTime = datetime.ToString(DateTimeFormat)
            };
            var jSetting = new JsonSerializerSettings();

            jSetting.NullValueHandling = NullValueHandling.Ignore;
            var content = JsonConvert.SerializeObject(request, jSetting);

            _log.Debug("Post data:" + content);
            var config = new CommonConfig(null);

            var req = (HttpWebRequest)WebRequest.Create(config.JavaOrder_Uri + "finishedCall");

            req.Method      = "POST";
            req.ContentType = "Application/Json";
            req.Credentials = CredentialCache.DefaultCredentials;
            req.Timeout     = 300000;
            // 如果服务器返回错误,他还会继续再去请求,不会使用之前的错误数据,做返回数据
            //req.ServicePoint.Expect100Continue = false;
            WriteRequestData(req, content);
            var response = req.GetResponse();

            if (response == null)
            {
                throw new Exception("请求失败!");
            }
            var stream = response.GetResponseStream();

            if (stream == null)
            {
                throw new Exception("请求Stream为空!");
            }
            var sr     = new StreamReader(stream, Encoding.UTF8);
            var retXml = sr.ReadToEnd();

            sr.Close();
            _log.Debug(retXml);
            var obj = JsonConvert.DeserializeObject <FinishOrderResponse>(retXml);

            if (obj.respCode != "0")
            {
                throw new ApplicationException(obj.respMsg);
            }
            return(obj);
        }