/// <summary> /// 获取相应层级子模块 /// </summary> /// <param name="level">当前层级向下层级</param> /// <returns></returns> public SysModule[] GetSubs(int level) { int currLevel = this.PathLevel.GetValueOrDefault(); int maxLevel = this.PathLevel.GetValueOrDefault() + level; DetachedCriteria crits = DetachedCriteria.For <SysModule>(); crits.Add(Expression.Gt("PathLevel", currLevel)); crits.Add(Expression.Le("PathLevel", maxLevel)); return(SysModule.FindAll(crits)); }
/// <summary> /// 由权限列表获取所有用户模块 /// </summary> /// <param name="authList"></param> /// <returns></returns> public static IList <SysModule> RetrieveAllModulesFromAuthList(IList <SysAuth> authList) { IList <SysModule> ents = new List <SysModule>(); List <string> ids = new List <string>(); foreach (SysAuth auth in authList) { // 类型为1 为入口权限(Application或Module) if (auth.Type == 1 && !String.IsNullOrEmpty(auth.ModuleID)) { ids.Add(auth.ModuleID); } } ICriterion hqlCriterion = Expression.In("ModuleID", ids); ents = SysModule.FindAll(hqlCriterion); return(ents); }
/// <summary> /// 获取指定应用区间级别的模块 /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public IList <SysModule> GetModulesByLevel(int from, int to) { IList <SysModule> mdls = new List <SysModule>(); if (from >= 0) { if (from == to) { return(SysModule.FindAllByProperty("PathLevel", from)); } else if (from < to) { DetachedCriteria crits = DetachedCriteria.For <SysModule>(); crits.Add(Expression.Eq("ApplicationID", this.ApplicationID)); crits.Add(Expression.Ge("PathLevel", from)); crits.Add(Expression.Le("PathLevel", to)); return(SysModule.FindAll(crits)); } } return(mdls); }
/// <summary> /// 获取可访问模块 /// </summary> /// <returns></returns> public static IList <SysModule> GetModulesByAuths(IList <SysAuth> auths) { IEnumerable <string> mdlids = auths.Where(v => v.Type == 1 && !String.IsNullOrEmpty(v.ModuleID)).Select(v => v.ModuleID); return(SysModule.FindAllByPrimaryKeys(mdlids.ToArray())); }
/// <summary> /// 由系统模块更新权限 /// </summary> public void UpdateByModule(SysModule mdl) { this.SetDataByModule(mdl); // 根据对应的SysModule设置数据 this.DoUpdate(); }
/// <summary> /// 由系统模块更新权限 /// </summary> public void UpdateByModule(string mdlid) { SysModule mdl = SysModule.Find(mdlid); this.UpdateByModule(mdl); }
/// <summary> /// 添加子模块 /// </summary> /// <param name="module"></param> public void CreateAsSub(string parentID) { SysModule parent = SysModule.Find(parentID); CreateAsSub(parent); }
/// <summary> /// 添加兄弟模块 /// </summary> /// <param name="module"></param> public void CreateAsSib(string sibID) { SysModule sib = SysModule.Find(sibID); CreateAsSib(sib); }
/// <summary> /// 有模块键获取模块 /// </summary> /// <param name="code"></param> public static SysModule FindByCode(string code) { SysModule mdl = SysModule.FindFirstByProperties("Code", code); return(mdl); }