Example #1
0
        /// <summary>
        /// 加载单条流程文件夹权限
        /// </summary>
        /// <returns></returns>
        public JsonResult LoadWorkflowFolderAcl(string WorkflowFolderCode, string AclID)
        {
            return(ExecuteFunctionRun(() => {
                WorkflowFolderAclViewModel model = new WorkflowFolderAclViewModel();
                model.WorkflowFolderCode = WorkflowFolderCode;

                if (!string.IsNullOrEmpty(AclID))
                {
                    Acl.FunctionAcl FunctionAcl = this.Engine.FunctionAclManager.GetAcl(AclID);

                    model.ObjectID = FunctionAcl.AclID;
                    model.UserID = FunctionAcl.UserID;
                    OThinker.Organization.Unit unit = this.Engine.Organization.GetUnit(model.UserID);
                    if (unit != null)
                    {
                        model.UserName = unit.Name;
                    }

                    model.WorkflowFolderCode = FunctionAcl.FunctionCode;
                    model.Run = FunctionAcl.Run;
                }
                FunctionNode FunctionNode = this.Engine.FunctionAclManager.GetFunctionNodeByCode(WorkflowFolderCode);

                model.WorkflowFolderName = FunctionNode.DisplayName;
                model.FunctionRun = this.UserValidator.ValidateFunctionRun(WorkflowFolderCode);

                return Json(model, JsonRequestBehavior.AllowGet);
            }));
        }
Example #2
0
        /// <summary>
        /// 添加、保存流程文件夹权限设置
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SaveWorkflowFolderAcl(WorkflowFolderAclViewModel model)
        {
            return(ExecuteFunctionRun(() => {
                ActionResult result = new ActionResult(true, "msgGlobalString.SaveSucced");

                SaveWorkflowFloderAclBase(model);

                ///this.CloseCurrentDialog();
                return Json(result, 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);
            }));
        }