/// <summary> /// 获取文件夹节点信息 /// </summary> /// <param name="nodeId"></param> /// <returns></returns> public JsonResult GetFolderInfo(string nodeId) { return(ExecuteFunctionRun(() => { FunctionNode node = this.Engine.FunctionAclManager.GetFunctionNode(nodeId); ProcessFolderViewModel model = new ProcessFolderViewModel(); model.ObjectID = node.ObjectID; model.Code = node.Code; model.Name = node.DisplayName; model.ParentID = node.ParentObjectID; model.ParentCode = node.ParentCode; model.SortKey = node.SortKey; FunctionNode pNode = this.Engine.FunctionAclManager.GetFunctionNode(node.ParentCode); if (pNode != null) { model.ParentName = pNode.DisplayName; } return Json(model, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 保存文件夹 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult SaveFolder(ProcessFolderViewModel model) { //根据Model的ObjectIDea判断是保存还是更新 return(ExecuteFunctionRun(() => { bool isCreateNew = (string.IsNullOrEmpty(model.ObjectID)); FunctionNode _Node = new FunctionNode(); ActionResult result = new ActionResult(); if (isCreateNew) { _Node.ParentCode = model.ParentCode; _Node.Code = model.Code;//此处编码不需要用户维护 // _Node.NodeType = (FunctionNodeType)Enum.Parse(typeof(FunctionNodeType), model.ObjectType.ToString()); _Node.NodeType = FunctionNodeType.ReportFolder; } else { _Node = this.Engine.FunctionAclManager.GetFunctionNode(model.ObjectID); } if (string.IsNullOrWhiteSpace(model.Name)) { result.Success = false; result.Message = "ProcessFolder.NameNotNull"; return Json(result); } //同目录下的兄弟节点 FunctionNode[] brothers = this.Engine.FunctionAclManager.GetFunctionNodesByParentCode(model.ParentCode); //判断文件夹重名 if (brothers != null && brothers.Any(p => !string.IsNullOrWhiteSpace(p.DisplayName) && p.DisplayName.Equals(model.Name) && p.NodeType == _Node.NodeType && p.ObjectID != _Node.ObjectID)) { result.Success = false; result.Message = "ProcessFolder.NameExisted"; return Json(result); } _Node.DisplayName = model.Name; _Node.SortKey = model.SortKey; bool result2; if (isCreateNew) { _Node.ObjectID = _Node.Code = Guid.NewGuid().ToString(); _Node.IconCss = "fa fa-folder-o"; result2 = this.Engine.FunctionAclManager.AddFunctionNode(_Node) == ErrorCode.SUCCESS; //判断当前用户是否管理员,如果不是管理员,添加目录权限 if (result2 && !this.UserValidator.User.IsAdministrator) { WorkflowFolderAclViewModel aclmodel = new WorkflowFolderAclViewModel(); aclmodel.FunctionRun = true; aclmodel.UserID = this.UserValidator.UserID; aclmodel.WorkflowFolderCode = _Node.Code; aclmodel.WorkflowFolderName = _Node.DisplayName; aclmodel.UserName = this.UserValidator.UserName; aclmodel.Run = true; SaveWorkflowFloderAclBase(aclmodel); } } else { result2 = this.Engine.FunctionAclManager.UpdateFunctionNode(_Node) == ErrorCode.SUCCESS; } if (result2) { result.Message = "ProcessFolder.Msg_SaveSuccess"; result.Success = true; } else { result.Message = "ProcessFolder.Msg_SaveFailed"; result.Success = false; } return Json(result); })); }