コード例 #1
0
        private void InsertModulePermission(IRBSModule module, string roleId)
        {
            sql_helper.ExecuteNoneQuery(string.Format(AddGWQX, roleId, module.ModuleId, module.ModuleName, "", ""));

            for (int i = 0; i < module.FunctionList.Count; i++)
            {
                IRBSFunction function = module.FunctionList[i];
                sql_helper.ExecuteNoneQuery(string.Format(AddGWQX, roleId, module.ModuleId, module.ModuleName, function.FunctionId, function.FunctionName));
            }
        }
コード例 #2
0
 /// <summary>
 /// AddAFunction
 /// </summary>
 /// <param name="function"></param>
 public void AddAFunction(IRBSFunction function)
 {
     if (_functionList == null)
     {
         _functionList = new Collection <IRBSFunction>();
     }
     if (_functionList != null)
     {
         _functionList.Add(function);
     }
 }
コード例 #3
0
ファイル: Account.cs プロジェクト: xuanximoming/key
        /// <summary>
        /// 判断帐户是否具有方法权限
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="className"></param>
        /// <param name="functionName"></param>
        /// <returns></returns>
        public bool HasPermission(string assemblyName, string className, string functionName)
        {
            if (IsAdministrator())
            {
                return(true);
            }
            if (_permission == null)
            {
                return(false);
            }
            for (int i = 0; i < _permission.Count; i++)
            {
                IPermission role = _permission[i];
                if (role.IsAdministrators)
                {
                    return(true);
                }
                for (int j = 0; j < role.ModuleList.Count; j++)
                {
                    IRBSModule module = role.ModuleList[j];


                    if (string.IsNullOrEmpty(functionName))
                    {
                        if (module.ModuleId.Trim() == className.Trim() + "_" + assemblyName.Trim())
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        for (int k = 0; k < module.FunctionList.Count; k++)
                        {
                            IRBSFunction function = module.FunctionList[k];
                            if (function.FunctionId == functionName)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #4
0
        /// <summary>
        /// 更新角色的单个权限
        /// </summary>
        /// <param name="permission"></param>
        /// <param name="module"></param>
        /// <param name="function"></param>
        /// <param name="setRight"></param>
        public void UpdateRolePermission(IPermission permission, IRBSModule module, IRBSFunction function, bool setRight)
        {
            if (permission == null)
            {
                return;
            }
            if (module == null)
            {
                return;
            }
            //Job2Permission j2p = new Job2Permission { ID = permission.RoleId, Moduleid = module.ModuleId, Modulename = module.ModuleName, Functionid = function.FunctionId, Functionname = function.FunctionName };

            if (setRight)
            {
                if (function != null)
                {
                    sql_helper.ExecuteNoneQuery(string.Format(AddGWQX, permission.RoleId, module.ModuleId, module.ModuleName, function.FunctionId, function.FunctionName));
                }
                else
                {
                    for (int i = 0; i < module.FunctionList.Count; i++)
                    {
                        string functionid   = module.FunctionList[i].FunctionId;
                        string functionName = module.FunctionList[i].FunctionName;
                        sql_helper.ExecuteNoneQuery(string.Format(AddGWQX, permission.RoleId, module.ModuleId, module.ModuleName, functionid, functionName));
                    }
                }
            }
            else
            {
                if (function != null)
                {
                    sql_helper.ExecuteNoneQuery(string.Format(DeleteFunctionGWQX, permission.RoleId, module.ModuleId, function.FunctionId));
                }
                else
                {
                    sql_helper.ExecuteNoneQuery(string.Format(DeleteModuleGWQX, permission.RoleId, module.ModuleId, function.FunctionId));
                }
            }
        }
コード例 #5
0
        private void UpdateModulePermission(IRBSModule module, IRBSModule oldModule, string roleId)
        {
            // 删除不存在的权限
            for (int i = 0; i < oldModule.FunctionList.Count; i++)
            {
                IRBSFunction function = oldModule.FunctionList[i];
                if (!module.FunctionList.Contains(function))
                {
                    sql_helper.ExecuteNoneQuery(string.Format(DeleteFunctionGWQX, roleId, oldModule.ModuleId, function.FunctionId));
                }
            }

            // 添加新增的权限
            for (int i = 0; i < module.FunctionList.Count; i++)
            {
                IRBSFunction function = module.FunctionList[i];
                if (!oldModule.FunctionList.Contains(function))
                {
                    sql_helper.ExecuteNoneQuery(string.Format(AddGWQX, roleId, module.ModuleId, module.ModuleName, function.FunctionId, function.FunctionName));
                }
            }
        }