Example #1
0
 /// <summary>
 /// 以名称创建部门对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 public Department(int id, string name)
 {
     this.id = id;
     if (name != null && name.Trim() != "")
     {
         this.name = name;
     }
     roles = new RoleCollection();
 }
Example #2
0
 public static bool ContainsRole(this RoleCollection roles, Role role)
 {
     foreach (Role r in roles)
     {
         if (r.ID == role.ID)
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
 /// <summary>
 /// 由用户名和密码构造用户对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 public User(int id, string userName, string password)
 {
     this.id     = id;
     departments = new List <Department>();
     roles       = new RoleCollection();
     userGroups  = new List <UserGroup>();
     if (userName != null && userName.Trim() != "")
     {
         this.userName = userName;
     }
     this.password = password;
 }
Example #4
0
 /// <summary>
 /// 以名称和角色集合创建部门对象
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 /// <param name="roles"></param>
 public Department(int id, string name, RoleCollection roles)
 {
     this.id = id;
     if (name != null && name.Trim() != "")
     {
         this.name = name;
     }
     if (roles == null)
     {
         this.roles = new RoleCollection();
     }
     else
     {
         this.roles = roles;
     }
 }
Example #5
0
        public static string GetRolesStr(RoleCollection roles)
        {
            StringBuilder sb = new StringBuilder();

            foreach (Role role in roles)
            {
                if (sb.Length == 0)
                {
                    sb.Append(role.ID.ToString());
                }
                else
                {
                    sb.Append("," + role.ID.ToString());
                }
            }
            return(sb.ToString());
        }
Example #6
0
        public static RoleCollection GetRoles(string roleids, RoleLogic rl = null)
        {
            RoleCollection roles = new RoleCollection();

            string[] ids = roleids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (rl == null)
            {
                rl = RoleLogic.GetInstance();
            }
            foreach (string id in ids)
            {
                int I;
                if (int.TryParse(id, out I))
                {
                    Role role = rl.GetRole(I);
                    roles.Add(role);
                }
            }
            return(roles);
        }
Example #7
0
 /// <summary>
 /// 用户的默认构造函数
 /// </summary>
 public User()
 {
     departments = new List <Department>();
     roles       = new RoleCollection();
     userGroups  = new List <UserGroup>();
 }
Example #8
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 public Department()
 {
     roles = new RoleCollection();
 }
Example #9
0
 /// <summary>
 /// 以指定的名称创建子部门
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 /// <param name="roles"></param>
 /// <returns></returns>
 public Department CreateSubDepartment(int id, string name, RoleCollection roles)
 {
     return(new Department(id, name, roles, this.ID));
 }
Example #10
0
        public static RoleCollection Roles(this UserGroup thisUG)
        {
            RoleCollection rs = Common.GetRoles(Common.GetRolesStr(thisUG.Roles));

            return(rs);
        }
Example #11
0
        public static RoleCollection Roles(this Department thisDep)
        {
            RoleCollection rs = Common.GetRoles(Common.GetRolesStr(thisDep.Roles));

            return(rs);
        }
Example #12
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public UserGroup()
 {
     roles = new RoleCollection();
 }