private void IsSuccess(MiddleResult middleResult) { if (!middleResult.ErrorCode.Equals("0")) { throw new FrameworkException(middleResult.ErrorCode, middleResult.ErrorMessage); } }
private void IsSuccess(MiddleResult middleResult) { if (!middleResult.ErrorNo.Equals("0") && !middleResult.ErrorNo.Equals("404")) { throw new FrameException(middleResult.ErrorNo, middleResult.ErrorInfo); } }
public void Post(string urlShcme, string serviceName, string serviceLink, IList <IDictionary <string, object> > middleParams) { // 1、获取中台url string url = middleUrl.GetMiddleUrl(urlShcme, serviceName); // 2、请求 MiddleResult middleResult = middleService.Post(url + serviceLink, middleParams); // 3、判断是否成功 IsSuccess(middleResult); }
public void Delete(string urlShcme, string serviceName, string serviceLink, IDictionary <string, object> middleParam) { // 1、获取中台url https://localhost:5001 servicenode localhost:5001 string url = middleUrl.GetMiddleUrl(urlShcme, serviceName); // 2、请求 MiddleResult middleResult = middleService.Delete(url + serviceLink, middleParam); // 3、判断是否成功 IsSuccess(middleResult); }
public void Put(string urlScheme, string serviceName, string serviceLink, IDictionary <string, object> middleParam) { // 1、获取中台url string url = _dynamicMiddleUrl.GetMiddleUrl(urlScheme, serviceName); // 2、请求 MiddleResult middleResult = _middleService.Put(url + serviceLink, middleParam); // 3、判断是否成功 IsSuccess(middleResult); }
public dynamic PostDynamic(string urlShcme, string serviceName, string serviceLink, dynamic middleParam) { // 1、获取中台url string url = middleUrl.GetMiddleUrl(urlShcme, serviceName); // 2、请求 MiddleResult middleResult = middleService.PostDynamic(url + serviceLink, middleParam); // 3、判断是否成功 IsSuccess(middleResult); return(middleResult.Result); }
public dynamic DeleteDynamic(string urlShcme, string serviceName, string serviceLink, IDictionary <string, object> middleParam) { // 1、获取中台url string url = middleUrl.GetMiddleUrl(urlShcme, serviceName); // 2、请求 MiddleResult middleResult = middleService.Delete(url + serviceLink, middleParam); // 3、判断是否成功 IsSuccess(middleResult); return(middleResult.Result); }
public IList <IDictionary <string, object> > GetList(string urlShcme, string serviceName, string serviceLink, IDictionary <string, object> middleParam) { // 1、获取中台url string url = middleUrl.GetMiddleUrl(urlShcme, serviceName); // 2、请求 MiddleResult middleResult = middleService.Get(url + serviceLink, middleParam); // 3、判断是否成功 IsSuccess(middleResult); return(middleResult.resultList); }
public T Get <T>(string urlScheme, string serviceName, string serviceLink, IDictionary <string, object> middleParam) where T : new() { // 1、获取中台url string url = _dynamicMiddleUrl.GetMiddleUrl(urlScheme, serviceName); // 2、请求 MiddleResult middleResult = _middleService.Get(url + serviceLink, middleParam); // 3、判断是否成功 IsSuccess(middleResult); // 4、结果进行转换对象 return(ConvertUtil.MiddleResultToObject <T>(middleResult)); }
private MiddleResult GetMiddleResult(HttpResponseMessage httpResponseMessage) { // 3、将HttpResponseMessage转换成MiddleResult if (httpResponseMessage.StatusCode.Equals(HttpStatusCode.OK) || httpResponseMessage.StatusCode.Equals(HttpStatusCode.Created) || httpResponseMessage.StatusCode.Equals(HttpStatusCode.Accepted)) { string httpJsonString = httpResponseMessage.Content.ReadAsStringAsync().Result; // 3.1 创建MiddleResult return(MiddleResult.JsonToMiddleResult(httpJsonString)); } else { throw new FrameException($"{HttpConst}服务调用错误:{httpResponseMessage.Content.ReadAsStringAsync().ToString()}"); } }
/// <summary> /// 中台结果转换成集合对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dic"></param> /// <returns></returns> static public IList <T> MiddleResultToList <T>(MiddleResult middleResult) where T : new() { return(ListToObject <T>(middleResult.resultList)); }
/// <summary> /// 中台结果转换成对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dic"></param> /// <returns></returns> static public T MiddleResultToObject <T>(MiddleResult middleResult) where T : new() { return(DicToObject <T>(middleResult.resultDic)); }