/// <summary> /// 获取业务规则信息 /// </summary> /// <param name="ruleCode"></param> /// <returns></returns> public JsonResult GetBizRule(string ruleCode) { return(ExecuteFunctionRun(() => { OThinker.H3.BizBus.BizRule.BizRuleTable Rule = this.Engine.BizBus.GetBizRule(ruleCode); BizRuleViewModel model = new BizRuleViewModel(); if (Rule != null) { model.ObjectID = "-";//随便赋值一个值,用于判断是否为新增 model.Code = Rule.Code; model.DisplayName = Rule.DisplayName; model.Description = Rule.Description; } return Json(model, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 保存规则 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult SaveBizRule(BizRuleViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); OThinker.H3.BizBus.BizRule.BizRuleTable Rule = null; bool IsCreate = string.IsNullOrEmpty(model.ObjectID); if (!BizRuleAuthorized) { result.Success = false; result.Message = "BizRule.NotAuthorized"; return Json(result); } if (IsCreate) { if (string.IsNullOrEmpty(model.Code) || string.IsNullOrEmpty(model.Code.Trim())) { //ShowWarningMessage(PortalResource.GetString("EditBizRuleTable_InvalidCode")); result.Success = false; result.Message = "msgGlobalString.InvalidCode"; return Json(result); } //业务规则必须以字母开始,不让创建到数据库表字段时报错 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^[a-zA-Z\\u4e00-\\u9fa5][0-9a-zA-Z\\u4e00-\\u9fa5_]*$"); if (!regex.Match(model.Code).Success) { result.Success = false; result.Message = "EditBizObjectSchemaProperty.Msg4"; return Json(result); } Rule = new OThinker.H3.BizBus.BizRule.BizRuleTable(model.Code.Trim()); Rule.DisplayName = model.DisplayName; Rule.Description = model.Description; if (Engine.BizBus.GetBizRule(Rule.Code) != null) { //ShowWarningMessage(PortalResource.GetString("EditBizRuleTable_CodeExisted")); result.Success = false; result.Message = "msgGlobalString.CodeExisted"; return Json(result); } if (Engine.BizBus.AddBizRule(Rule, model.ParentCode)) { result.Success = true; //ReLoadParentTreeNode(ParentID); } } else { Rule = this.Engine.BizBus.GetBizRule(model.Code); Rule.DisplayName = model.DisplayName; Rule.Description = model.Description; result.Success = this.Engine.BizBus.UpdateBizRule(Rule); } if (result.Success) { result.Message = "msgGlobalString.SaveSucced"; return Json(result); } else { result.Message = "msgGlobalString.SaveFailed"; return Json(result); } })); }