/// <summary> /// 保存方法 /// </summary> /// <returns></returns> public JsonResult SaveMethod(BizServiceMethodViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true, ""); OThinker.H3.BizBus.BizService.BizService Service = GetService(model.ServiceCode); OThinker.H3.BizBus.BizService.BizServiceMethod Method = null; bool Creating = string.IsNullOrEmpty(model.ObjectID); // 更新属性 if (Creating) { Method = new OThinker.H3.BizBus.BizService.BizServiceMethod(); } else { Method = Service.GetMethod(model.MethodName); } Method.MethodName = model.MethodName; Method.DisplayName = model.DisplayName; Method.Description = model.Description; Method.ReturnType = (H3.BizBus.BizService.MethodReturnType)Enum.Parse(typeof(H3.BizBus.BizService.MethodReturnType), model.ReturnType); Method.MethodSetting = Server.UrlDecode(model.MethodSetting);//传递之前有编码,这里需要解码 if (Creating) { if (!Service.AddMethod(Method)) { result.Success = false; result.Message = "BizServiceMethod.SaveFailed1";//添加方法失败,可能是方法重名 return Json(result); } } H3.ValidationResult r = this.Engine.BizBus.UpdateBizService(Service, true); string result2 = r.ToString(); if (string.IsNullOrEmpty(result2)) { result.Success = true; result.Message = "msgGlobalString.SaveSucced"; } else { result.Success = false; result.Message = "msgGlobalString.SaveFailed"; result.Extend = result2; } return Json(result); })); }
/// <summary> /// 获取服务方法列表 /// </summary> /// <param name="serviceCode"></param> /// <returns></returns> public JsonResult GetDataList(string serviceCode) { return(ExecuteFunctionRun(() => { List <BizServiceMethodViewModel> lists = new List <BizServiceMethodViewModel>(); OThinker.H3.BizBus.BizService.BizService Service = GetService(serviceCode); if (Service.Methods != null) { BizServiceMethodViewModel data; foreach (BizServiceMethod method in Service.Methods) { data = new BizServiceMethodViewModel(); data.ObjectID = method.ObjectID; data.DisplayName = method.DisplayName; data.MethodName = method.MethodName; data.ReturnType = method.ReturnType.ToString(); data.MethodSetting = method.MethodSetting; lists.Add(data); } } var gridData = CreateLigerUIGridData(lists.ToArray()); return Json(gridData, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 获取方法信息 /// </summary> /// <param name="serviceCode"></param> /// <param name="methodName"></param> /// <returns></returns> public JsonResult GetMethod(string serviceCode, string methodName) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true, ""); // 编辑模式 OThinker.H3.BizBus.BizService.BizService Service = GetService(serviceCode); Settings.BizDbConnectionConfig DbConnectionConfig = null; OThinker.H3.BizBus.BizService.BizServiceMethod Method = null; if (Service == null) { result.Success = false; result.Message = "BizServiceMethod.ServiceNotExists"; //ShowErrorMessage(PortalResource.GetString("EditBizServiceMethod_Msg1")); //CloseCurrentDialog(); 客户端执行 return Json(result, JsonRequestBehavior.AllowGet); } //如果是DbSqlAdapter else if (OThinker.H3.BizBus.Declaration.DbSqlAdapter_Code == Service.BizAdapterCode) { //获取参数前缀符号 DbConnectionConfig = GetDbConnectionConfig(Service); } // 方法名称 if (!string.IsNullOrEmpty(methodName)) { Method = Service.GetMethod(methodName); if (Method == null) { //ShowErrorMessage(PortalResource.GetString("EditBizServiceMethod_Msg2")); //CloseCurrentDialog(); result.Message = "BizServiceMethod.MethodNotExist"; result.Success = false; } else { BizServiceMethodViewModel model = new BizServiceMethodViewModel() { ObjectID = Method.ObjectID, MethodName = Method.MethodName, BizAdapterCode = Service.BizAdapterCode, DisplayName = Method.DisplayName, Description = Method.Description, ReturnType = Method.ReturnType.ToString(), MethodSetting = Method.MethodSetting, ServiceCode = serviceCode, ParameterPrefix = _ParameterPrefix }; result.Extend = model; } return Json(result, JsonRequestBehavior.AllowGet); } else { BizServiceMethodViewModel model = new BizServiceMethodViewModel() { ParameterPrefix = _ParameterPrefix, BizAdapterCode = Service.BizAdapterCode, ServiceCode = serviceCode }; result.Extend = model; } result.Success = true; result.Message = ""; return Json(result, JsonRequestBehavior.AllowGet); })); }