/// <summary>
        /// 获取相应层级子节点
        /// </summary>
        /// <returns></returns>
        public DynamicAuth[] GetSubs()
        {
            int        currLevel = this.PathLevel.GetValueOrDefault();
            ICriterion crit      = Expression.Gt("PathLevel", currLevel);

            return(DynamicAuth.FindAll(crit));
        }
        /// <summary>
        /// 删除操作
        /// </summary>
        public void DoDelete()
        {
            // 同时删除相关权限
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    DynamicAuth[] auths = DynamicAuth.FindAllByProperty("CatalogCode", this.Code);
                    foreach (DynamicAuth tauth in auths)
                    {
                        tauth.DoDelete();
                    }

                    base.Delete();

                    trans.VoteCommit();
                }
                catch (Exception ex)
                {
                    trans.VoteRollBack();

                    throw ex;
                }
            }
        }
        /// <summary>
        /// 添加子节点
        /// </summary>
        /// <param name="module"></param>
        public void CreateAsSub(DynamicAuth parent)
        {
            this.ParentID    = parent.DynamicAuthID;
            this.CatalogCode = parent.CatalogCode;
            this.Path        = String.Format("{0}.{1}", (parent.Path == null ? String.Empty : parent.Path), parent.DynamicAuthID);
            this.PathLevel   = parent.PathLevel + 1;

            this.DoCreate();
        }
        /// <summary>
        /// 添加兄弟节点
        /// </summary>
        /// <param name="module"></param>
        public void CreateAsSib(DynamicAuth sib)
        {
            this.ParentID    = sib.ParentID;
            this.Path        = sib.Path;
            this.PathLevel   = sib.PathLevel;
            this.CatalogCode = sib.CatalogCode;

            this.DoCreate();
        }
        /// <summary>
        /// 获取相应层级子节点
        /// </summary>
        /// <param name="level">当前层级向下层级</param>
        /// <returns></returns>
        public DynamicAuth[] GetSubs(int level)
        {
            int currLevel = this.PathLevel.GetValueOrDefault();
            int maxLevel  = this.PathLevel.GetValueOrDefault() + level;

            DetachedCriteria crits = DetachedCriteria.For <DynamicAuth>();

            crits.Add(Expression.Gt("PathLevel", currLevel));
            crits.Add(Expression.Le("PathLevel", maxLevel));

            return(DynamicAuth.FindAll(crits));
        }
 public static void GrantDAuthToUsers(DynamicAuth auth, IList <string> userIDs, IList <string> operations, string tag, string granterID, string granterName)
 {
     GrantDAuthsToUsers(new DynamicAuth[] { auth }, userIDs, operations, tag, granterID, granterName);
 }
 public static void GrantDAuthToRole(DynamicAuth auth, string roleID, IList <string> operations, string tag, string granterID, string granterName)
 {
     GrantDAuthsToRoles(new DynamicAuth[] { auth }, new string[] { roleID }, operations, tag, granterID, granterName);
 }
        /// <summary>
        /// 添加子模块
        /// </summary>
        /// <param name="module"></param>
        public void CreateAsSub(string parentID)
        {
            DynamicAuth parent = DynamicAuth.Find(parentID);

            CreateAsSub(parent);
        }
        /// <summary>
        /// 添加兄弟节点
        /// </summary>
        /// <param name="module"></param>
        public void CreateAsSib(string sibID)
        {
            DynamicAuth sib = DynamicAuth.Find(sibID);

            CreateAsSib(sib);
        }