Example #1
0
        /// <summary>添加权限
        /// 添加权限
        /// </summary>
        /// <param name="rights"></param>
        public virtual void AddRights(IEnumerable <Rights> rightsList)
        {
            if (Rights == null)
            {
                Rights = new List <Rights>();
            }

            foreach (Rights rights in rightsList)
            {
                if (rights.IsLeaf)
                {
                    Rights.Add(rights);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="name"></param>
        /// <param name="descriptin"></param>
        /// <returns></returns>
        public virtual Rights AddChild(string name, string url, string descriptin, bool isshow)
        {
            Rights rights = new Rights(this, name, url, descriptin, isshow, this.Level + 1);

            if (Child == null)
            {
                Child = new List <Rights>();
                Child.Add(rights);
            }
            else
            {
                Child.Add(rights);
            }

            return(rights);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private List <int> GetRightsId(Rights model)
        {
            List <int> result = new List <int>();

            if (model != null)
            {
                result.Add(model.Id);
                List <int> l = GetRightsId(model.Parent);
                foreach (int one in l)
                {
                    if (!result.Contains(one))
                    {
                        result.Add(one);
                    }
                }
            }
            return(result);
        }
Example #4
0
 public Rights(Rights parent, string name, string url, string description, bool isshow, int level, string icon)
 {
     this.Name        = name;
     this.Url         = url;
     this.Description = description;
     this.IsShow      = isshow;
     this.Level       = level;
     this.CreateDate  = DateTime.Now;
     this.Parent      = parent;
     this.IsLeaf      = true;
     if (level == 2)
     {
         this.PathName = parent.Name;
     }
     else if (level > 2)
     {
         this.PathName = parent.PathName + "/" + parent.Name;
     }
     this.Icon = icon;
 }
Example #5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="name"></param>
        /// <param name="descriptin"></param>
        /// <returns></returns>
        public virtual Rights AddChild(string name, string url, string description, bool isshow, string icon)
        {
            Rights rights = new Rights(this, name, url, description, isshow, this.Level + 1, icon);

            if (Child == null)
            {
                Child = new List <Rights>();
                Child.Add(rights);
            }
            else
            {
                Child.Add(rights);
            }
            if (this.Child.Count > 0)
            {
                this.IsLeaf = false;
            }
            else
            {
                this.IsLeaf = true;
            }
            return(rights);
        }