/// <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(); }
public static bool ContainsRole(this RoleCollection roles, Role role) { foreach (Role r in roles) { if (r.ID == role.ID) { return(true); } } return(false); }
/// <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; }
/// <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; } }
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()); }
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); }
/// <summary> /// 用户的默认构造函数 /// </summary> public User() { departments = new List <Department>(); roles = new RoleCollection(); userGroups = new List <UserGroup>(); }
/// <summary> /// 默认构造函数 /// </summary> public Department() { roles = new RoleCollection(); }
/// <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)); }
public static RoleCollection Roles(this UserGroup thisUG) { RoleCollection rs = Common.GetRoles(Common.GetRolesStr(thisUG.Roles)); return(rs); }
public static RoleCollection Roles(this Department thisDep) { RoleCollection rs = Common.GetRoles(Common.GetRolesStr(thisDep.Roles)); return(rs); }
/// <summary> /// 构造函数 /// </summary> public UserGroup() { roles = new RoleCollection(); }