public MeetingPermissionCollectionResult GetAllMeetingEnrollments(string meetingId) { if (string.IsNullOrWhiteSpace(meetingId)) { throw new ArgumentException("Meeting SCO can't be empty", nameof(meetingId)); } PermissionCollectionResult result = null; result = GetPermissionsInfo(meetingId, CommandParams.Permissions.Filter.PermissionId.MeetingAll); // ACLTI-2307 - workaround. Need to remove when migrated to HttpClient. WebResponse throws IOException (unexpected EOF) in some cases. if (!result.Success && result.Status.UnderlyingExceptionInfo is IOException) { int i = 0; int chunk = 30; //for 30 records server does not return header Transfer-Encoding: chunked PermissionCollectionResult res; List <PermissionInfo> permissions = new List <PermissionInfo>(); do { // action=permissions-info var commandParams = string.Format(CommandParams.Permissions.AclId + "&{1}", meetingId, CommandParams.Permissions.Filter.PermissionId.MeetingAll); res = DoCallPermissionsInfo(Commands.Permissions.Info, commandParams, chunk * i++, chunk); if (res.Success) { permissions.AddRange(res.Values); } }while (res.Values.Any()); var meetingPermissions = permissions.Select(x => new MeetingPermissionInfo(x)).ToList(); return(new MeetingPermissionCollectionResult(res.Status, meetingPermissions)); } return(result.ConvertForMeeting()); }
public JsonResult GetUsers() { var users = CourseAPI.GetUsersForCourse(Credentials.CanvasDomain, Credentials.CanvasToken, Model.custom_canvas_course_id); users = users.GroupBy(u => u.id).Select( ug => { var teacher = ug.FirstOrDefault(u => u.canvas_role.ToLower() == "teacher"); if (teacher != null) { return(teacher); } teacher = ug.FirstOrDefault(u => u.canvas_role.ToLower() == "ta"); if (teacher != null) { return(teacher); } teacher = ug.FirstOrDefault(u => u.canvas_role.ToLower() == "designer"); if (teacher != null) { return(teacher); } teacher = ug.FirstOrDefault(u => u.canvas_role.ToLower() == "student"); if (teacher != null) { return(teacher); } return(ug.First()); }).ToList(); var meeting = this.CanvasCourseMeetingModel.GetOneByCourseId(Credentials.Id, Model.custom_canvas_course_id).Value; if (meeting == null) { return(this.Json(users)); } var provider = this.GetProvider(); PermissionCollectionResult hosts = provider.GetMeetingHosts(meeting.ScoId), participants = provider.GetMeetingParticipants(meeting.ScoId), presenters = provider.GetMeetingPresenters(meeting.ScoId); foreach (var user in users) { if (user.login_id == null && user.email == null) { //user.ac_role = "not_allowed"; continue; } ; var acUser = provider.GetAllByEmail(HttpUtility.UrlEncode(user.login_id ?? user.email)); if (acUser.Values == null || !acUser.Values.Any()) { //user.ac_role = "not_allowed"; continue; } user.ac_id = acUser.Values.First().PrincipalId; if (hosts.Values != null && hosts.Values.Any(v => v.PrincipalId == user.ac_id)) { user.ac_role = "Host"; hosts.Values = hosts.Values.Where(v => v.PrincipalId != user.ac_id).ToList(); } else if (presenters.Values != null && presenters.Values.Any(v => v.PrincipalId == user.ac_id)) { user.ac_role = "Presenter"; presenters.Values = presenters.Values.Where(v => v.PrincipalId != user.ac_id).ToList(); } else if (participants.Values != null && participants.Values.Any(v => v.PrincipalId == user.ac_id)) { user.ac_role = "Participant"; participants.Values = participants.Values.Where(v => v.PrincipalId != user.ac_id).ToList(); } } foreach (var u in hosts.Values) { users.Add(new UserDTO() { ac_id = u.PrincipalId, name = u.Name, ac_role = "Host" }); } foreach (var u in presenters.Values) { users.Add(new UserDTO() { ac_id = u.PrincipalId, name = u.Name, ac_role = "Presenter" }); } foreach (var u in participants.Values) { users.Add(new UserDTO() { ac_id = u.PrincipalId, name = u.Name, ac_role = "Participant" }); } return(Json(users)); }