Exemplo n.º 1
0
        /// <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);
            }));
        }
        public JsonResult ValidateBizObjectSchema(BizObjectSchemaViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                this.SchemaCode = model.Code;
                if (!this.ParseParam())
                {
                    result.Success = false;
                    result.Message = "EditBizObjectSchema.Msg0";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                H3.ValidationResult r = this.Engine.BizObjectManager.ValidateBizObjectSchema(this.Schema.SchemaCode);
                result.Success = r.Valid;
                result.Message = r.Valid ? "EditBizObjectSchema.Msg18" : r.ToString().Replace(System.Environment.NewLine, "<br>").Replace(";", "<br>");

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }