/// <summary> /// /// </summary> void RunSchoolInfoConsumer() { ISchoolInfoConsumer schoolInfoConsumer = new SchoolInfoConsumer("HITS", null, "0EE41AE6-C43F-11E3-9050-E0F4DBD909AB", "HITS"); schoolInfoConsumer.Register(); try { ICollection <SchoolInfo> schools = schoolInfoConsumer.Retrieve(); } finally { schoolInfoConsumer.Unregister(); } }
void RunSchoolInfoConsumer() { SchoolInfoConsumer schoolInfoConsumer = new SchoolInfoConsumer("HITS", null, "0EE41AE6-C43F-11E3-9050-E0F4DBD909AB", "HITS"); schoolInfoConsumer.Register(); try { // Query all schools. IEnumerable <SchoolInfo> allSchools = schoolInfoConsumer.Query(); foreach (SchoolInfo school in allSchools) { if (log.IsInfoEnabled) { log.Info("School " + school.SchoolName + " has a RefId of " + school.RefId + "."); } } if (log.IsInfoEnabled) { log.Info("School count is " + allSchools.Count()); } // Create multiple schools. MultipleCreateResponse createResponse = schoolInfoConsumer.Create(CreateSchools()); foreach (CreateStatus status in createResponse.StatusRecords) { SchoolInfo school = schoolInfoConsumer.Query(status.Id); if (log.IsInfoEnabled) { log.Info("New school " + school.SchoolName + " has a RefId of " + school.RefId + "."); } } // Update multiple schools. List <SchoolInfo> schoolsToUpdate = new List <SchoolInfo>(); foreach (CreateStatus status in createResponse.StatusRecords) { SchoolInfo school = schoolInfoConsumer.Query(status.Id); school.SchoolName += "x"; schoolsToUpdate.Add(school); } MultipleUpdateResponse updateResponse = schoolInfoConsumer.Update(schoolsToUpdate); foreach (UpdateStatus status in updateResponse.StatusRecords) { SchoolInfo school = schoolInfoConsumer.Query(status.Id); if (log.IsInfoEnabled) { log.Info("Updated school " + school.SchoolName + " has a RefId of " + school.RefId + "."); } } // Delete multiple schools. ICollection <string> schoolsToDelete = new List <string>(); foreach (CreateStatus status in createResponse.StatusRecords) { schoolsToDelete.Add(status.Id); } MultipleDeleteResponse deleteResponse = schoolInfoConsumer.Delete(schoolsToDelete); foreach (DeleteStatus status in deleteResponse.StatusRecords) { SchoolInfo school = schoolInfoConsumer.Query(status.Id); if (school == null) { if (log.IsInfoEnabled) { log.Info("School with RefId of " + status.Id + " has been deleted."); } } else { if (log.IsInfoEnabled) { log.Info("School " + school.SchoolName + " with RefId of " + school.RefId + " FAILED deletion."); } } } } finally { schoolInfoConsumer.Unregister(); } }