public IList<AttributeChange> GetChanges(string dn, ObjectModificationType modType, SchemaType type, object source)
        {
            List<AttributeChange> attributeChanges = new List<AttributeChange>();

            CourseStudents students = source as CourseStudents;

            if (students == null)
            {
                GoogleCourse course = source as GoogleCourse;

                if (course == null)
                {
                    throw new InvalidOperationException();
                }
                else
                {
                    students = course.Students;
                }
            }

            foreach (IAttributeAdapter typeDef in ManagementAgent.Schema[SchemaConstants.Course].AttributeAdapters.Where(t => t.Api == this.Api))
            {
                foreach (string attributeName in typeDef.MmsAttributeNames)
                {
                    if (type.HasAttribute(attributeName))
                    {
                        attributeChanges.AddRange(typeDef.CreateAttributeChanges(dn, modType, students));
                    }
                }
            }

            return attributeChanges;
        }
コード例 #2
0
ファイル: Course.cs プロジェクト: jayjodev/jayjodev.github.io
 public CourseStudent AddStudent(Student student)
 {
     if (student.Courses.Contains(this))
     {
         return(null);
     }
     else
     {
         CourseStudent cs = new CourseStudent(this, student);
         CourseStudents.Add(cs);
         student.CourseStudents.Add(cs);
         return(cs);
     }
 }
コード例 #3
0
ファイル: Course.cs プロジェクト: jayjodev/jayjodev.github.io
 public CourseStudent DeleteStudent(Student student)
 {
     if (!student.Courses.Contains(this))
     {
         return(null);
     }
     else
     {
         CourseStudent cs = CourseStudents.FirstOrDefault(
             cst => cst.CourseId == CourseId && cst.StudentId == student.StudentId);
         CourseStudents.Remove(cs);
         student.CourseStudents.Remove(cs);
         return(cs);
     }
 }
コード例 #4
0
        public CourseStudents GetCourseStudents(string courseId)
        {
            CourseStudents courseStudents = new CourseStudents();

            using (PoolItem <ClassroomService> poolService = this.classRoomServicePool.Take(NullValueHandling.Ignore))
            {
                string token = null;
                CoursesResource.StudentsResource.ListRequest request = poolService.Item.Courses.Students.List(courseId);
                request.PrettyPrint = false;
                Trace.WriteLine($"Getting students from course {courseId}");

                do
                {
                    request.PageToken = token;
                    ListStudentsResponse students;

                    try
                    {
                        this.WaitForGate();
                        students = request.ExecuteWithRetry(RetryEvents.Backoff | RetryEvents.Timeout, RetryCount);
                    }
                    finally
                    {
                        this.ReleaseGate();
                    }

                    if (students.Students != null)
                    {
                        foreach (Student student in students.Students)
                        {
                            if (!string.IsNullOrWhiteSpace(student.UserId))
                            {
                                courseStudents.AddStudent(student.UserId);
                            }
                        }
                    }

                    token = students.NextPageToken;
                } while (token != null);
            }

            Trace.WriteLine($"Returned {courseStudents.Count} students in course {courseId}");

            return(courseStudents);
        }
        private void GetStudentChangesFromCSEntryChange(CSEntryChange csentry, out CourseStudents adds, out CourseStudents deletes, out CourseStudents reportedAdds, out CourseStudents reportedDeletes, bool replacing)
        {
            adds = new CourseStudents();
            deletes = new CourseStudents();
            reportedAdds = new CourseStudents();
            reportedDeletes = new CourseStudents();

            CourseStudents existingStudents;

            if (replacing)
            {
                // Translate existing students from Id to PrimaryEmail
                existingStudents = new CourseStudents(this.CourseApiInterface.TranslateMembers(this.config.ClassroomService.StudentFactory.GetCourseStudents(csentry.DN).GetAllStudents()));
            }
            else
            {
                existingStudents = new CourseStudents();
            }

            this.GetStudentChangesFromCSEntryChange(csentry, adds.Students, deletes.Students, existingStudents.Students, SchemaConstants.Students, replacing);

            reportedAdds.MergeStudents(adds);
            reportedDeletes.MergeStudents(deletes);
        }
コード例 #6
0
ファイル: Course.cs プロジェクト: DannyCKing/ExampleCSharp
 /// <summary>
 /// Add a student to a couse
 /// </summary>
 /// <param name="student"></param>
 public void AddStudent(Student student)
 {
     CourseStudents.Add(student);
 }