public static RoleLogic GetInstance() { if (instance == null) { instance = new RoleLogic(); } return(instance); }
public static List <int> GetRoleIds(string roleids, RoleLogic rl = null) { List <int> roles = new List <int>(); 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)) { roles.Add(I); } } return(roles); }
public List <User> GetAllUsers() { List <User> users = new List <User>(); string sql = "select * from [User]"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { DepartmentLogic dl = DepartmentLogic.GetInstance(); RoleLogic rl = RoleLogic.GetInstance(); UserGroupLogic ul = UserGroupLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { User user = new User(); user.ID = Convert.ToInt32(dt.Rows[i]["ID"]); user.Username = dt.Rows[i]["Username"].ToString(); user.Departments = Common.GetDepartments(dt.Rows[i]["Depart"].ToString(), dl); user.Flag = Convert.ToInt32(dt.Rows[i]["Flag"]); if (dt.Rows[i]["Password"] != null && dt.Rows[i]["Password"] != DBNull.Value) { user.Password = dt.Rows[i]["Password"].ToString(); } else { user.Password = ""; } if (dt.Rows[i]["Roles"] != null && dt.Rows[i]["Roles"] != DBNull.Value) { user.Roles = Common.GetRoles(dt.Rows[i]["Roles"].ToString(), rl); } if (dt.Rows[i]["Usergroup"] != null && dt.Rows[i]["Usergroup"] != DBNull.Value) { user.Usergroups = Common.GetUserGroups(dt.Rows[i]["Usergroup"].ToString(), ul); } if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value) { user.Remark = dt.Rows[i]["Remark"].ToString(); } users.Add(user); } } return(users); }
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); }