예제 #1
0
        private MiddleResult GetMiddleResult(HttpResponseMessage httpResponseMessage)
        {
            //将httpResponseMessage转换为MiddleResult
            HttpStatusCode status = httpResponseMessage.StatusCode;

            if (status.Equals(HttpStatusCode.OK) || status.Equals(HttpStatusCode.Created) || status.Equals(HttpStatusCode.Accepted))
            {
                string httpJsonString = httpResponseMessage.Content.ReadAsStringAsync().Result;
                return(MiddleResult.JsonToMiddleResult(httpJsonString));
            }
            else
            {
                throw new FrameException($"{HttpConst}服务调用错误:{httpResponseMessage.Content.ReadAsStringAsync()}");
            }
        }
예제 #2
0
        public static MiddleResult JsonToMiddleResult(string jsonStr)
        {
            MiddleResult result = JsonConvert.DeserializeObject <MiddleResult>(jsonStr);

            return(result);
        }