コード例 #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();
 }
コード例 #2
0
ファイル: RoleCollection.cs プロジェクト: luiesszhang/Role
 public static bool ContainsRole(this RoleCollection roles, Role role)
 {
     foreach (Role r in roles)
     {
         if (r.ID == role.ID)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #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;
 }
コード例 #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;
     }
 }
コード例 #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());
        }
コード例 #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);
        }
コード例 #7
0
 /// <summary>
 /// 用户的默认构造函数
 /// </summary>
 public User()
 {
     departments = new List <Department>();
     roles       = new RoleCollection();
     userGroups  = new List <UserGroup>();
 }
コード例 #8
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 public Department()
 {
     roles = new RoleCollection();
 }
コード例 #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));
 }
コード例 #10
0
        public static RoleCollection Roles(this UserGroup thisUG)
        {
            RoleCollection rs = Common.GetRoles(Common.GetRolesStr(thisUG.Roles));

            return(rs);
        }
コード例 #11
0
ファイル: DepartmentLogic.cs プロジェクト: luiesszhang/Role
        public static RoleCollection Roles(this Department thisDep)
        {
            RoleCollection rs = Common.GetRoles(Common.GetRolesStr(thisDep.Roles));

            return(rs);
        }
コード例 #12
0
ファイル: UserGroup.cs プロジェクト: luiesszhang/Role
 /// <summary>
 /// 构造函数
 /// </summary>
 public UserGroup()
 {
     roles = new RoleCollection();
 }