/// <summary>
        ///
        /// </summary>
        void RunStudentPersonalConsumer()
        {
            IStudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer("Sif3DemoApp");

            studentPersonalConsumer.Register();
            if (log.IsInfoEnabled)
            {
                log.Info("Registered the Consumer.");
            }

            try
            {
                // Retrieve Bart Simpson.
                Name name = new Name {
                    FamilyName = "Simpson", GivenName = "Bart"
                };
                PersonInfo personInfo = new PersonInfo {
                    Name = name
                };
                StudentPersonal studentPersonal = new StudentPersonal {
                    PersonInfo = personInfo
                };
                ICollection <StudentPersonal> filteredStudents = studentPersonalConsumer.Retrieve(studentPersonal);

                foreach (StudentPersonal student in filteredStudents)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                // Create and then retrieve a new student.
                Name newStudentName = new Name()
                {
                    FamilyName = "Wayne", GivenName = "Bruce", Type = NameType.LGL
                };
                PersonInfo newStudentInfo = new PersonInfo()
                {
                    Name = newStudentName
                };
                StudentPersonal newStudent = new StudentPersonal()
                {
                    LocalId = "555", PersonInfo = newStudentInfo
                };
                Guid newStudentId = studentPersonalConsumer.Create(newStudent);
                if (log.IsInfoEnabled)
                {
                    log.Info("Created new student " + newStudent.PersonInfo.Name.GivenName + " " + newStudent.PersonInfo.Name.FamilyName);
                }
                StudentPersonal retrievedNewStudent = studentPersonalConsumer.Retrieve(newStudentId);
                if (log.IsInfoEnabled)
                {
                    log.Info("Retrieved new student " + retrievedNewStudent.PersonInfo.Name.GivenName + " " + retrievedNewStudent.PersonInfo.Name.FamilyName);
                }

                // Retrieve all students.
                ICollection <StudentPersonal> students = studentPersonalConsumer.Retrieve();

                foreach (StudentPersonal student in students)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                // Retrieve a single student.
                Guid            studentId     = students.ElementAt(1).Id;
                StudentPersonal secondStudent = studentPersonalConsumer.Retrieve(studentId);
                if (log.IsInfoEnabled)
                {
                    log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);
                }

                // Update that student and confirm.
                secondStudent.PersonInfo.Name.GivenName  = "Homer";
                secondStudent.PersonInfo.Name.FamilyName = "Simpson";
                studentPersonalConsumer.Update(secondStudent);
                secondStudent = studentPersonalConsumer.Retrieve(studentId);
                if (log.IsInfoEnabled)
                {
                    log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);
                }

                // Delete that student and confirm.
                studentPersonalConsumer.Delete(studentId);
                students = studentPersonalConsumer.Retrieve();
                bool studentDeleted = true;

                foreach (StudentPersonal student in students)
                {
                    if (studentId == student.Id)
                    {
                        studentDeleted = false;
                        break;
                    }
                }

                if (studentDeleted)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted.");
                    }
                }
                else
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted.");
                    }
                }

                // Retrieve students based on Teaching Group.
                EqualCondition condition = new EqualCondition()
                {
                    Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0"
                };
                IList <EqualCondition> conditions = new List <EqualCondition>();
                conditions.Add(condition);
                ICollection <StudentPersonal> teachingGroupStudents = studentPersonalConsumer.Retrieve(conditions);

                foreach (StudentPersonal student in teachingGroupStudents)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                studentPersonalConsumer.Unregister();
                if (log.IsInfoEnabled)
                {
                    log.Info("Unregistered the Consumer.");
                }
            }
        }
Пример #2
0
        private void RunStudentPersonalConsumer()
        {
            StudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer(
                SettingsManager.ConsumerSettings.ApplicationKey,
                SettingsManager.ConsumerSettings.InstanceId,
                SettingsManager.ConsumerSettings.UserToken,
                SettingsManager.ConsumerSettings.SolutionId);

            studentPersonalConsumer.Register();
            if (log.IsInfoEnabled)
            {
                log.Info("Registered the Consumer.");
            }

            try
            {
                IEnumerable <StudentPersonal> queriedStudents = studentPersonalConsumer.DynamicQuery("[@id=1234]");

                foreach (StudentPersonal student in queriedStudents)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Queried student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                // Retrieve Bart Simpson using QBE.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve Bart Simpson using QBE.");
                }
                NameOfRecordType name = new NameOfRecordType {
                    FamilyName = "Simpson", GivenName = "Bart"
                };
                PersonInfoType personInfo = new PersonInfoType {
                    Name = name
                };
                StudentPersonal studentPersonal = new StudentPersonal {
                    PersonInfo = personInfo
                };
                IEnumerable <StudentPersonal> filteredStudents = studentPersonalConsumer.QueryByExample(studentPersonal);

                foreach (StudentPersonal student in filteredStudents)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                // Create a new student.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Create a new student.");
                }
                string[] text = new string[]
                {
                    @"
                        <MedicalCondition>
                            <ConditionID>Unique Medical Condition ID</ConditionID>
                            <Condition>Condition</Condition>
                            <Severity>Condition Severity</Severity>
                            <Details>Condition Details</Details>
                        </MedicalCondition>
                    "
                };
                SIF_ExtendedElementsTypeSIF_ExtendedElement extendedElement = new SIF_ExtendedElementsTypeSIF_ExtendedElement {
                    Name = "MedicalConditions", Text = text
                };
                SIF_ExtendedElementsTypeSIF_ExtendedElement[] extendedElements = new SIF_ExtendedElementsTypeSIF_ExtendedElement[] { extendedElement };
                NameOfRecordType newStudentName = new NameOfRecordType {
                    FamilyName = "Wayne", GivenName = "Bruce", Type = NameOfRecordTypeType.LGL
                };
                PersonInfoType newStudentInfo = new PersonInfoType {
                    Name = newStudentName
                };
                string          studentID  = Guid.NewGuid().ToString();
                StudentPersonal newStudent = new StudentPersonal {
                    RefId = studentID, LocalId = "555", PersonInfo = newStudentInfo, SIF_ExtendedElements = extendedElements
                };

                try
                {
                    StudentPersonal retrievedNewStudent = studentPersonalConsumer.Create(newStudent, true);
                    if (log.IsInfoEnabled)
                    {
                        log.Info($"Created new student {newStudent.PersonInfo.Name.GivenName} {newStudent.PersonInfo.Name.FamilyName} with ID of {studentID}.");
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info($"Access to create a new student is rejected.");
                    }
                }

                // Create multiple new students.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Create multiple new students.");
                }
                List <StudentPersonal> newStudents = CreateStudents(5);

                try
                {
                    MultipleCreateResponse multipleCreateResponse = studentPersonalConsumer.Create(newStudents);
                    int count = 0;

                    foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Create status code is " + status.StatusCode);
                        }
                        newStudents[count++].RefId = status.Id;
                    }

                    // Update multiple students.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Update multiple students.");
                    }
                    foreach (StudentPersonal student in newStudents)
                    {
                        student.PersonInfo.Name.GivenName += "o";
                    }

                    try
                    {
                        MultipleUpdateResponse multipleUpdateResponse = studentPersonalConsumer.Update(newStudents);

                        foreach (UpdateStatus status in multipleUpdateResponse.StatusRecords)
                        {
                            if (log.IsInfoEnabled)
                            {
                                log.Info("Update status code is " + status.StatusCode);
                            }
                        }
                    }
                    catch (UnauthorizedAccessException)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info($"Access to update multiple students is rejected.");
                        }
                    }

                    // Delete multiple students.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Delete multiple students.");
                    }
                    ICollection <string> refIds = new List <string>();

                    foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                    {
                        refIds.Add(status.Id);
                    }

                    try
                    {
                        MultipleDeleteResponse multipleDeleteResponse = studentPersonalConsumer.Delete(refIds);

                        foreach (DeleteStatus status in multipleDeleteResponse.StatusRecords)
                        {
                            if (log.IsInfoEnabled)
                            {
                                log.Info("Delete status code is " + status.StatusCode);
                            }
                        }
                    }
                    catch (UnauthorizedAccessException)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info($"Access to delete multiple students is rejected.");
                        }
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info($"Access to create multiple new students is rejected.");
                    }
                }

                // Retrieve all students from zone "Gov" and context "Curr".
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve all students from zone \"Gov\" and context \"Curr\".");
                }
                IEnumerable <StudentPersonal> students = studentPersonalConsumer.Query(zoneId: "Gov", contextId: "Curr");

                foreach (StudentPersonal student in students)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                if (students.Count() > 1)
                {
                    // Retrieve a single student.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Retrieve a single student.");
                    }
                    string          studentId     = students.ElementAt(1).RefId;
                    StudentPersonal secondStudent = studentPersonalConsumer.Query(studentId);
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);
                    }

                    // Update that student and confirm.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Update that student and confirm.");
                    }
                    secondStudent.PersonInfo.Name.GivenName  = "Homer";
                    secondStudent.PersonInfo.Name.FamilyName = "Simpson";

                    try
                    {
                        studentPersonalConsumer.Update(secondStudent);
                        secondStudent = studentPersonalConsumer.Query(studentId);
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);
                        }
                    }
                    catch (UnauthorizedAccessException)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info($"Access to update a student is rejected.");
                        }
                    }

                    // Delete that student and confirm.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Delete that student and confirm.");
                    }

                    try
                    {
                        studentPersonalConsumer.Delete(studentId);
                        StudentPersonal deletedStudent = studentPersonalConsumer.Query(studentId);
                        bool            studentDeleted = (deletedStudent == null ? true : false);

                        if (studentDeleted)
                        {
                            if (log.IsInfoEnabled)
                            {
                                log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted.");
                            }
                        }
                        else
                        {
                            if (log.IsInfoEnabled)
                            {
                                log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted.");
                            }
                        }
                    }
                    catch (UnauthorizedAccessException)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info($"Access to delete a student is rejected.");
                        }
                    }
                }

                // Retrieve students based on Teaching Group using Service Paths.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve students based on Teaching Group using Service Paths.");
                }
                EqualCondition condition = new EqualCondition()
                {
                    Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0"
                };
                IList <EqualCondition> conditions = new List <EqualCondition>
                {
                    condition
                };

                try
                {
                    IEnumerable <StudentPersonal> teachingGroupStudents = studentPersonalConsumer.QueryByServicePath(conditions);

                    foreach (StudentPersonal student in teachingGroupStudents)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                        }

                        if (student.SIF_ExtendedElements != null && student.SIF_ExtendedElements.Length > 0)
                        {
                            foreach (SIF_ExtendedElementsTypeSIF_ExtendedElement element in student.SIF_ExtendedElements)
                            {
                                foreach (string content in element.Text)
                                {
                                    if (log.IsInfoEnabled)
                                    {
                                        log.Info("Extended element text is ...\n" + content);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Access to query students by Service Path TeachingGroups/{}/StudentPersonals is rejected.");
                    }
                }

                // Retrieve student changes since a particular point as defined by the Changes Since marker.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve student changes since a particular point as defined by the Changes Since marker.");
                }
                string changesSinceMarker = studentPersonalConsumer.GetChangesSinceMarker();
                IEnumerable <StudentPersonal> changedStudents = studentPersonalConsumer.QueryChangesSince(changesSinceMarker, out string nextChangesSinceMarker);
                if (log.IsInfoEnabled)
                {
                    log.Info("Iteration 1 - Student changes based on Changes Since marker - " + changesSinceMarker);
                }

                if (changedStudents == null || changedStudents.Count() == 0)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("No student changes");
                    }
                }
                else
                {
                    foreach (StudentPersonal student in changedStudents)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                        }
                    }
                }

                changesSinceMarker     = nextChangesSinceMarker;
                nextChangesSinceMarker = null;
                changedStudents        = studentPersonalConsumer.QueryChangesSince(changesSinceMarker, out nextChangesSinceMarker);
                if (log.IsInfoEnabled)
                {
                    log.Info("Iteration 2 - Student changes based on Changes Since marker - " + changesSinceMarker);
                }

                if (changedStudents == null || changedStudents.Count() == 0)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("No student changes");
                    }
                }
                else
                {
                    foreach (StudentPersonal student in changedStudents)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                        }
                    }
                }

                changesSinceMarker     = nextChangesSinceMarker;
                nextChangesSinceMarker = null;
                changedStudents        = studentPersonalConsumer.QueryChangesSince(changesSinceMarker, out nextChangesSinceMarker);
                if (log.IsInfoEnabled)
                {
                    log.Info("Iteration 3 - Student changes based on Changes Since marker - " + changesSinceMarker);
                }

                if (changedStudents == null || changedStudents.Count() == 0)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("No student changes");
                    }
                }
                else
                {
                    foreach (StudentPersonal student in changedStudents)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                        }
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                if (log.IsInfoEnabled)
                {
                    log.Info($"Access to query students is rejected.");
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Error running the StudentPersonal Consumer.\n" + ExceptionUtils.InferErrorResponseMessage(e), e);
                }
            }
            finally
            {
                studentPersonalConsumer.Unregister();
                if (log.IsInfoEnabled)
                {
                    log.Info("Unregistered the Consumer.");
                }
            }
        }
Пример #3
0
        void RunStudentPersonalConsumer()
        {
            StudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer("Sif3DemoApp");

            studentPersonalConsumer.Register();
            if (log.IsInfoEnabled)
            {
                log.Info("Registered the Consumer.");
            }

            try
            {
                // Retrieve Bart Simpson using QBE.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve Bart Simpson using QBE.");
                }
                NameOfRecordType name = new NameOfRecordType {
                    FamilyName = "Simpson", GivenName = "Bart"
                };
                PersonInfoType personInfo = new PersonInfoType {
                    Name = name
                };
                StudentPersonal studentPersonal = new StudentPersonal {
                    PersonInfo = personInfo
                };
                IEnumerable <StudentPersonal> filteredStudents = studentPersonalConsumer.QueryByExample(studentPersonal);

                foreach (StudentPersonal student in filteredStudents)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                // Create a new student.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Create a new student.");
                }
                string[] text = new string[]
                {
                    @"
                        <MedicalCondition>
                            <ConditionID>Unique Medical Condition ID</ConditionID>
                            <Condition>Condition</Condition>
                            <Severity>Condition Severity</Severity>
                            <Details>Condition Details</Details>
                        </MedicalCondition>
                    "
                };
                SIF_ExtendedElementsTypeSIF_ExtendedElement extendedElement = new SIF_ExtendedElementsTypeSIF_ExtendedElement {
                    Name = "MedicalConditions", Text = text
                };
                SIF_ExtendedElementsTypeSIF_ExtendedElement[] extendedElements = new SIF_ExtendedElementsTypeSIF_ExtendedElement[] { extendedElement };
                NameOfRecordType newStudentName = new NameOfRecordType {
                    FamilyName = "Wayne", GivenName = "Bruce", Type = NameOfRecordTypeType.LGL
                };
                PersonInfoType newStudentInfo = new PersonInfoType {
                    Name = newStudentName
                };
                StudentPersonal newStudent = new StudentPersonal {
                    LocalId = "555", PersonInfo = newStudentInfo, SIF_ExtendedElements = extendedElements
                };
                StudentPersonal retrievedNewStudent = studentPersonalConsumer.Create(newStudent);
                if (log.IsInfoEnabled)
                {
                    log.Info("Created new student " + newStudent.PersonInfo.Name.GivenName + " " + newStudent.PersonInfo.Name.FamilyName);
                }

                // Create multiple new students.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Create multiple new students.");
                }
                List <StudentPersonal> newStudents            = CreateStudents(5);
                MultipleCreateResponse multipleCreateResponse = studentPersonalConsumer.Create(newStudents);
                int count = 0;

                foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Create status code is " + status.StatusCode);
                    }
                    newStudents[count++].RefId = status.Id;
                }

                // Update multiple students.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Update multiple students.");
                }
                foreach (StudentPersonal student in newStudents)
                {
                    student.PersonInfo.Name.GivenName += "o";
                }

                MultipleUpdateResponse multipleUpdateResponse = studentPersonalConsumer.Update(newStudents);

                foreach (UpdateStatus status in multipleUpdateResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Update status code is " + status.StatusCode);
                    }
                }

                // Delete multiple students.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Delete multiple students.");
                }
                ICollection <string> refIds = new List <string>();

                foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                {
                    refIds.Add(status.Id);
                }

                MultipleDeleteResponse multipleDeleteResponse = studentPersonalConsumer.Delete(refIds);

                foreach (DeleteStatus status in multipleDeleteResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Delete status code is " + status.StatusCode);
                    }
                }

                // Retrieve all students from zone "Gov" and context "Curr".
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve all students from zone \"Gov\" and context \"Curr\".");
                }
                IEnumerable <StudentPersonal> students = studentPersonalConsumer.Query(zone: "Gov", context: "Curr");

                foreach (StudentPersonal student in students)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }
                }

                if (students.Count() > 1)
                {
                    // Retrieve a single student.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Retrieve a single student.");
                    }
                    string          studentId     = students.ElementAt(1).RefId;
                    StudentPersonal secondStudent = studentPersonalConsumer.Query(studentId);
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);
                    }

                    // Update that student and confirm.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Update that student and confirm.");
                    }
                    secondStudent.PersonInfo.Name.GivenName  = "Homer";
                    secondStudent.PersonInfo.Name.FamilyName = "Simpson";
                    studentPersonalConsumer.Update(secondStudent);
                    secondStudent = studentPersonalConsumer.Query(studentId);
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);
                    }

                    // Delete that student and confirm.
                    if (log.IsInfoEnabled)
                    {
                        log.Info("*** Delete that student and confirm.");
                    }
                    studentPersonalConsumer.Delete(studentId);
                    StudentPersonal deletedStudent = studentPersonalConsumer.Query(studentId);
                    bool            studentDeleted = (deletedStudent == null ? true : false);

                    if (studentDeleted)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted.");
                        }
                    }
                    else
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted.");
                        }
                    }
                }

                // Retrieve students based on Teaching Group using Service Paths.
                if (log.IsInfoEnabled)
                {
                    log.Info("*** Retrieve students based on Teaching Group using Service Paths.");
                }
                EqualCondition condition = new EqualCondition()
                {
                    Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0"
                };
                IList <EqualCondition> conditions = new List <EqualCondition>();
                conditions.Add(condition);
                IEnumerable <StudentPersonal> teachingGroupStudents = studentPersonalConsumer.QueryByServicePath(conditions);

                foreach (StudentPersonal student in teachingGroupStudents)
                {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                    }

                    if (student.SIF_ExtendedElements != null && student.SIF_ExtendedElements.Length > 0)
                    {
                        foreach (SIF_ExtendedElementsTypeSIF_ExtendedElement element in student.SIF_ExtendedElements)
                        {
                            foreach (string content in element.Text)
                            {
                                if (log.IsInfoEnabled)
                                {
                                    log.Info("Extended element text is ...\n" + content);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                studentPersonalConsumer.Unregister();
                if (log.IsInfoEnabled)
                {
                    log.Info("Unregistered the Consumer.");
                }
            }
        }