/// <summary> /// 调用接口(结果) /// </summary> /// <param name="context"></param> /// <param name="SvrID"></param> /// <param name="method"></param> /// <returns></returns> internal static object GetHttpResult(HttpContext context, string SvrID, string method) { ErrorResponse result; try { var path = Directory.GetParent("wwwroot" + context.Request.Path.ToString().Replace(".assx", ".json")).ToString(); if (!File.Exists(path)) { result = CreateFailResult2("服务未定义" + SvrID); } else { ServiceDefine serviceDefine = ServiceDefineCache.GetServiceDefineByPath(path); Type intf = ServiceDefineCache.GetTypeByPath(path); if (intf != null) { return(GetServiceResult(context, intf, serviceDefine, method)); } else { result = CreateFailResult2("未找到接口定义" + serviceDefine.IntfName + " ;"); } } } catch (ServiceException ex) { result = CreateFailResult2(ex.code, ex.msg); } catch (Exception ex) { result = CreateFailResult2(ex.Message + ex.InnerException?.Message != null ? ex.InnerException.Message.ToString() : ""); } return(result); }
/// <summary> /// 调用接口(restful封装) /// </summary> /// <param name="context"></param> /// <param name="SvrID"></param> /// <param name="method"></param> /// <returns></returns> internal static Result GetRestfulHttpResult(HttpContext context, string SvrID, string method) { Result result; try { var path = Directory.GetParent("wwwroot" + context.Request.Path.ToString().Replace(".rsfs", ".json")).ToString(); if (!File.Exists(path)) { result = CreateFailResult("服务未定义" + SvrID); } else { ServiceDefine serviceDefine = ServiceDefineCache.GetServiceDefineByPath(path); Type intf = ServiceDefineCache.GetTypeByPath(path); if (intf != null) { result = new Result { data = GetServiceResult(context, intf, serviceDefine, method), code = (int)TYPE_OF_RESULT_TYPE.success, msg = "Success" }; } else { result = CreateFailResult("未找到接口定义" + serviceDefine.IntfName + " ;"); } } } catch (ServiceException ex) { result = CreateFailResult(ex.code, ex.msg); } catch (Exception ex) { result = CreateFailResult(ex.Message + ex.InnerException?.Message != null ? ex.InnerException.Message.ToString() : ""); } return(result); }