예제 #1
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 添加权限控制项
        /// </summary>
        /// <param name="AuthCtrl"></param>
        /// <returns></returns>
        public int AddAuthCtrl(IAuthControl AuthCtrl)
        {
            IDvTable dvt = entityfactory.CreateDriveTable(AuthCtrl);
            int      i   = dvt.Insert();

            return(i);
        }
예제 #2
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        ///// <summary>
        ///// 添加权限类型
        ///// </summary>
        ///// <param name="AuthType"></param>
        ///// <returns></returns>
        //public int AddAuthType(IAuthType AuthType)
        //{
        //    IDvTable dvt = entityfactory.CreateDriveTable(AuthType);
        //    int i = dvt.Insert();
        //    return i;
        //}
        ///// <summary>
        ///// 删除权限类型
        ///// </summary>
        ///// <param name="AuthCode"></param>
        ///// <returns></returns>
        //public int RemoveAuthType(string AuthCode)
        //{
        //    IAuthType atype = entityfactory.CreateEntityInstance<IAuthType>();
        //    IDvTable dvt = entityfactory.CreateDriveTable(atype);
        //    atype.AuthCode = AuthCode;
        //    dvt.WhereClause("AuthCode", Operator.Deng, LinkOperator.nul);
        //    int i = dvt.Delete();
        //    return i;
        //}
        ///// <summary>
        ///// 获取新的权限类型编码
        ///// </summary>
        ///// <param name="AuthType"></param>
        ///// <returns></returns>
        //public int GetNewAuthTypeCode(IAuthType AuthType)
        //{
        //    int i = 0;
        //    i = GetMaxField(AuthType, "AuthCode") + 1;
        //    return i;
        //}
        ///// <summary>
        ///// 查询所有权限类型
        ///// </summary>
        ///// <returns></returns>
        //public List<IAuthType> QueryAuthType()
        //{
        //    IAuthType atype = entityfactory.CreateEntityInstance<IAuthType>();
        //    IDvTable dvt = entityfactory.CreateDriveTable(atype);
        //    DataSet ds = dvt.Select();
        //    List<IAuthType> list = Convert<IAuthType>(atype.GetType(), ds);
        //    return list;
        //}
        ///// <summary>
        ///// 根据角色名称查询角色
        ///// </summary>
        ///// <param name="AuthName">角色名称</param>
        ///// <returns></returns>
        //public IAuthType QueryAuthType(string AuthName)
        //{
        //    IAuthType atype = entityfactory.CreateEntityInstance<IAuthType>();
        //    IDvTable dvt = entityfactory.CreateDriveTable(atype);
        //    atype.AuthName = AuthName;
        //    dvt.WhereClause("AuthName", Operator.Deng, LinkOperator.nul);
        //    DataSet ds = dvt.Select();
        //    atype = this.Convert<IAuthType>(atype.GetType(), ds, 0);
        //    return atype;
        //}
        ///// <summary>
        ///// 更新权限类型
        ///// </summary>
        ///// <param name="AuthType"></param>
        ///// <returns></returns>
        //public int UpdateAuthType(IAuthType AuthType)
        //{
        //    IDvTable dvt = entityfactory.CreateDriveTable(AuthType);
        //    dvt.WhereClause("AuthCode", Operator.Deng, LinkOperator.nul);
        //    int i = dvt.Update();
        //    return i;
        //}

        #endregion

        #region 权限控制项

        /// <summary>
        /// 获取新的权限控制项流水码
        /// </summary>
        /// <param name="AuthCtrl"></param>
        /// <returns></returns>
        public long GetNewAuthCtrlCode(IAuthControl AuthCtrl)
        {
            DataHelper dh = new DataHelper();
            long       i  = 0;

            i = dh.GetMaxField(AuthCtrl, "RowCode", this.entityfactory) + 1;
            return(i);
        }
예제 #3
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 查询所有权限控制项
        /// </summary>
        /// <returns></returns>
        public List <IAuthControl> QueryAuthCtrl()
        {
            IAuthControl        actrl = entityfactory.CreateEntityInstance <IAuthControl>();
            IDvTable            dvt   = entityfactory.CreateDriveTable(actrl);
            DataSet             ds    = dvt.Select();
            List <IAuthControl> list  = this.dh.Convert <IAuthControl>(actrl.GetType(), ds);

            return(list);
        }
예제 #4
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 更新权限项目
        /// </summary>
        /// <param name="AuthCtrl"></param>
        /// <returns></returns>
        public int UpdateAuthCtrl(IAuthControl AuthCtrl)
        {
            IDvTable dvt = entityfactory.CreateDriveTable(AuthCtrl);

            dvt.WhereClause("RowCode", Operator.Deng, LinkOperator.nul);
            int i = dvt.Update();

            return(i);
        }
예제 #5
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 根据权限类型名称查询权限控制项
        /// </summary>
        /// <param name="AuthType"></param>
        /// <returns></returns>
        public List <IAuthControl> QueryAuthCtrl(AuthType AuthType)
        {
            IAuthControl actrl = entityfactory.CreateEntityInstance <IAuthControl>();
            IDvTable     dvt   = entityfactory.CreateDriveTable(actrl);

            actrl.AuthCode = long.Parse(Enum.Parse(typeof(AuthType), AuthType.ToString()).ToString());
            DataSet             ds   = dvt.Select();
            List <IAuthControl> list = this.dh.Convert <IAuthControl>(actrl.GetType(), ds);

            return(list);
        }
예제 #6
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 构造菜单权限项
        /// </summary>
        /// <param name="MenuCode">菜单编码</param>
        /// <param name="MenuTitle">菜单标题</param>
        /// <param name="RoleCode">角色编码</param>
        /// <param name="TypeCode">权限类型编码</param>
        /// <returns></returns>
        public IAuthControl BuildMenuAuthCtrl(string MenuCode, string MenuTitle
                                              , long RoleCode, long TypeCode)
        {
            IAuthControl actrl = this.entityfactory.CreateEntityInstance <IAuthControl>();

            actrl.RoleCode  = RoleCode;
            actrl.AuthCode  = TypeCode;
            actrl.FItemCode = MenuCode.ToString();
            actrl.FItemName = MenuTitle;
            actrl.RowCode   = this.GetNewAuthCtrlCode(actrl);
            return(actrl);
        }
예제 #7
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 移除指定权限项编码的控制项
        /// </summary>
        /// <param name="FItemCode"></param>
        /// <returns></returns>
        public int RemoveAuthCtrl(string FItemCode)
        {
            IAuthControl auth = entityfactory.CreateEntityInstance <IAuthControl>();

            auth.FItemCode = FItemCode;
            IDvTable dvt = entityfactory.CreateDriveTable(auth);

            dvt.WhereClause("FItemCode", Operator.Deng, LinkOperator.nul);
            int i = dvt.Delete();

            return(i);
        }
예제 #8
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 根据角色名称查询权限控制项
        /// </summary>
        /// <param name="Role"></param>
        /// <returns></returns>
        public List <IAuthControl> QueryAuthCtrl(IRole Role)
        {
            IAuthControl actrl = entityfactory.CreateEntityInstance <IAuthControl>();
            IDvTable     dvt   = entityfactory.CreateDriveTable(actrl);

            actrl.RoleCode = Role.RoleCode;
            dvt.WhereClause("RoleCode", Operator.Deng, LinkOperator.nul);
            DataSet             ds   = dvt.Select();
            List <IAuthControl> list = this.dh.Convert <IAuthControl>(actrl.GetType(), ds);

            return(list);
        }
예제 #9
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 根据权限项和角色查询权限控制项
        /// </summary>
        /// <param name="AuthItem"></param>
        /// <param name="Role"></param>
        /// <returns></returns>
        public IAuthControl QueryAuthCtrl(IAuthItem AuthItem, IRole Role)
        {
            IAuthControl actrl = entityfactory.CreateEntityInstance <IAuthControl>();
            IDvTable     dvt   = entityfactory.CreateDriveTable(actrl);

            actrl.FItemCode = AuthItem.AuthItemCode.ToString();
            actrl.RoleCode  = Role.RoleCode;
            dvt.WhereClause("FItemCode", Operator.Deng, LinkOperator.and);
            dvt.WhereClause("RoleCode", Operator.Deng, LinkOperator.nul);
            DataSet ds = dvt.Select();

            actrl = this.dh.Convert <IAuthControl>(actrl.GetType(), ds, 0);
            return(actrl);
        }
예제 #10
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 根据角色名和菜单类型查询菜单
        /// </summary>
        /// <param name="Role">角色</param>
        /// <param name="MType">菜单类型</param>
        /// <returns></returns>
        public List <IMenu> QueryMenus(IRole Role, MenuType MType)
        {
            IMenu menu = entityfactory.CreateEntityInstance <IMenu>();

            menu.MENUTYPE = MType.ToString();
            IAuthControl actrl = entityfactory.CreateEntityInstance <IAuthControl>();

            actrl.RoleCode = Role.RoleCode;
            IDvTable dvt = entityfactory.CreateDriveTable(menu);

            dvt.Join.Entitys.Add(actrl);
            dvt.WhereClause("MENUTYPE", Operator.Deng, LinkOperator.and);
            dvt.WhereClause(actrl, "RoleCode", Operator.Deng, LinkOperator.nul);
            DataSet      ds     = dvt.Select();
            List <IMenu> list   = this.dh.Convert <IMenu>(menu.GetType(), ds);
            List <IMenu> result = RefactoringMenu(list);

            return(result);
        }
예제 #11
0
파일: Manager.cs 프로젝트: rsfc/LemonadeWin
        /// <summary>
        /// 是否缺少菜单权限
        /// 当用户角色权限大于目标角色时 false
        /// 当用户角色权限小于目标角色时 true 即缺少权限
        /// </summary>
        public virtual bool IsLackRoleMenuAuth(IRole UserRole, IRole TargetRole, IMenu Menu)
        {
            bool result = false;
            //IRole userRole = manager.QueryRoleForCode(this.MainForm.SysState.LogonUser.RoleCode);
            //IMenu menu = this.manager.QueryMenu(this.GetType().BaseType.FullName);
            IAuthControl userAuth   = this.QueryAuthCtrl(Menu, UserRole);
            IAuthControl targetAuth = this.QueryAuthCtrl(Menu, TargetRole);

            if (userAuth == null)
            {
                //缺少权限
                return(true);
            }
            if (targetAuth == null)
            {
                return(false);
            }
            if (userAuth.AuthCode < targetAuth.AuthCode)
            {
                //缺少权限
                result = true;
            }
            return(result);
        }