private void LoadRoles() { if (m_roles != null) { return; } m_roles = new RobotList <Role>(); // No roles to load on new users. if (IsNew) { return; } Query q = new StoredProc("usp_GetUsersRoles"); q.CnnStr = Helpers.Config["DB:Security"]; q.Parameters.AddWithValue("@Username", Login); IList <int> roles = q.ExecuteList <int>(); foreach (int role in roles) { Role r = UserSecurity.Roles.Find(Role.ById, role); if (r != null) { m_roles.Add(r); } } }
static public RobotList <User> GetUsers() { Query q = new StoredProc("usp_GetAllUsers"); q.CnnStr = Helpers.Config["DB:Security"]; RobotList <User> rval = new RobotList <User>( q.ExecuteList <User>()); rval.ApplySort("FullName", ListSortDirection.Ascending); return(rval); }
private void LoadActions() { if (m_actions != null) { return; } m_actions = new ActionList(); m_actions.m_parent = this; // Load action list for non-administrator roles if (m_id != 0) { Query q = new StoredProc("usp_GetRoleActions"); q.CnnStr = Helpers.Config["DB:Security"]; q.Parameters.AddWithValue("@RoleId", m_id); IList <int> l = q.ExecuteList <int>(); foreach (int i in l) { foreach (Action a in UserSecurity.Actions) { if (a.Value == i) { m_actions.Add(a); break; } } } } else { foreach (Action a in UserSecurity.Actions) { m_actions.Add(a); } } m_actions.m_isDirty = false; }