public static UserGroupLogic GetInstance() { if (instance == null) { instance = new UserGroupLogic(); } return(instance); }
public static List <int> GetUserGroupIds(string ugroups, UserGroupLogic ul = null) { List <int> ugrps = new List <int>(); string[] ids = ugroups.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (ul == null) { ul = UserGroupLogic.GetInstance(); } foreach (string id in ids) { int I; if (int.TryParse(id, out I)) { ugrps.Add(I); } } return(ugrps); }
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); }