/// <summary> /// Gets the results from the web service. /// </summary> /// <param name="criteria">The course search criteria.</param> /// <param name="sortBy">The column on which to sort the results.</param> /// <param name="recordsPerPage">The number of records to return per page.</param> /// <param name="pageNo">The number of the page of data to get.</param> /// <returns>A list of found courses.</returns> private CourseListOutput GetResults(SearchCriteriaStructure criteria, string sortBy, string recordsPerPage, string pageNo) { CourseListOutput output = new CourseListOutput(); ServiceInterface client = new ServiceInterfaceClient("CourseSearchService"); CourseListRequestStructure listRequestStructure = new CourseListRequestStructure { CourseSearchCriteria = criteria, RecordsPerPage = recordsPerPage, PageNo = pageNo }; if (!string.IsNullOrEmpty(sortBy)) { SortType tempSortType; Enum.TryParse(sortBy, out tempSortType); listRequestStructure.SortBy = tempSortType; listRequestStructure.SortBySpecified = true; } CourseListInput request = new CourseListInput(listRequestStructure); try { output = client.CourseList(request); } catch (Exception ex) { ResultsOverviewLabel.Text = ex.Message + "\n" + ex.StackTrace; } return(output); }
/// <summary> /// Gets the results from the web service. /// </summary> /// <param name="criteria">The course search criteria.</param> /// <returns>A list of found courses.</returns> private static CourseListOutput GetResults(SearchCriteriaStructure criteria) { ServiceInterface client = new ServiceInterfaceClient("CourseSearchService"); CourseListRequestStructure listRequestStructure = new CourseListRequestStructure { CourseSearchCriteria = criteria, RecordsPerPage = "10", PageNo = "1", SortBy = SortType.D, SortBySpecified = true }; CourseListInput request = new CourseListInput(listRequestStructure); CourseListOutput output = client.CourseList(request); return(output); }
protected Int32 ProcessRequest(String searchTerm, String location, Int32 pageNumber) { //while (lastRequest.AddTicks(100000000 * 2) <= DateTime.Now) //{ // // Wait at least 2/10th of a second //} //lastRequest = DateTime.Now; ServiceInterface client = new ServiceInterfaceClient("CourseSearchService"); CourseListRequestStructure listRequestStructure = new CourseListRequestStructure { CourseSearchCriteria = new SearchCriteriaStructure { //APIKey APIKey = ConfigurationManager.AppSettings["APIKey"], // SUBJECT SubjectKeyword = searchTerm, Location = location }, RecordsPerPage = "10", PageNo = pageNumber.ToString(), SortBy = SortType.D, SortBySpecified = true }; CourseListInput request = new CourseListInput(listRequestStructure); try { CourseListOutput output = client.CourseList(request); WriteLog(String.Format("Term:{0} Location:{1} PageNum:{2} Results:{3}", searchTerm, location, pageNumber, output.CourseListResponse.ResultInfo.NoOfRecords)); return(String.IsNullOrEmpty(output.CourseListResponse.ResultInfo.NoOfPages) ? 0 : Convert.ToInt32(output.CourseListResponse.ResultInfo.NoOfPages)); } catch (Exception ex) { WriteLog(String.Format("Term:{0} Location:{1} PageNum:{2} Error:{3}", searchTerm, location, pageNumber, ex.Message)); } return(0); }
/// <summary> /// On clicking CourseList button, calls CourseSearchService ClientList() method wtih test data. /// </summary> private void btnCourseList_Click(object sender, EventArgs e) { txtResult.Text = "Processing ..."; ServiceInterface client = new ServiceInterfaceClient("CourseSearch"); CourseListRequestStructure listRequestStructure = new CourseListRequestStructure(); listRequestStructure.CourseSearchCriteria = new SearchCriteriaStructure(); listRequestStructure.CourseSearchCriteria.SubjectKeyword = "chemistry"; // listRequestStructure.CourseSearchCriteria.ProviderID = "4517"; // 4517 University of Bristol listRequestStructure.CourseSearchCriteria.Location = "grantham"; // listRequestStructure.CourseSearchCriteria.Distance = 30.0f; // listRequestStructure.CourseSearchCriteria.DistanceSpecified = true; CourseListInput request = new CourseListInput(listRequestStructure); try { CourseListOutput response = client.CourseList(request); StringBuilder sb = new StringBuilder(); sb.Append("Request details:"); sb.Append("\nCourse Search Criteria:"); sb.Append("\n A10 codes: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.A10Codes); sb.Append("\n Adult LR status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.AdultLRStatus); sb.Append("\n Attendance Modes: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendanceModes != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendanceModes.ToString() : "null")); sb.Append("\n Attendance Patterns: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendancePatterns != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendancePatterns.ToString() : "null")); sb.Append("\n Distance: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.Distance.ToString()); sb.Append("\n Distance specified: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.DistanceSpecified.ToString()); sb.Append("\n Earliest Start date: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.EarliestStartDate); sb.Append("\n ER app status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ERAppStatus); sb.Append("\n ER TTG status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ERTtgStatus); sb.Append("\n Flex start date: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.FlexStartFlag); sb.Append("\n IES flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.IESFlag); sb.Append("\n ILS flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ILSFlag); sb.Append("\n LDCS Category code: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.LDCS != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.LDCS.CategoryCode.ToString() : "")); sb.Append("\n Location: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.Location); sb.Append("\n Opps App closed flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.OppsAppClosedFlag); sb.Append("\n Other funding status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.OtherFundingStatus); sb.Append("\n Provider ID: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ProviderID); sb.Append("\n Provider Keyword: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ProviderKeyword); sb.Append("\n Qualification levels: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationLevels != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationLevels.ToString() : "null")); sb.Append("\n Qualification types: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationTypes != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationTypes.ToString() : "null")); sb.Append("\n SFL flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.SFLFlag); sb.Append("\n Study modes: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.StudyModes != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.StudyModes.ToString() : "null")); sb.Append("\n Subject keyword: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.SubjectKeyword); sb.Append("\n TQS flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.TQSFlag); sb.Append("\n TTG flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.TTGFlag); sb.Append("\n\n"); sb.Append("Course Details:"); if (response.CourseListResponse.CourseDetails != null) { foreach (CourseStructure courseStructure in response.CourseListResponse.CourseDetails) { sb.Append("\n" + courseStructure.Course.CourseID); sb.Append("\n" + courseStructure.Provider); sb.Append("\n" + courseStructure.Course.CourseTitle); sb.Append("\n" + courseStructure.Course.QualificationType); sb.Append("\n" + courseStructure.Course.QualificationLevel); sb.Append("\n" + courseStructure.Course.CourseSummary); sb.Append("\n" + courseStructure.Course.NoOfOpps); sb.Append("\n" + courseStructure.Opportunity.OpportunityId); sb.Append("\n" + courseStructure.Opportunity.StudyMode); sb.Append("\n" + courseStructure.Opportunity.AttendanceMode); sb.Append("\n" + courseStructure.Opportunity.AttendancePattern); sb.Append("\n" + courseStructure.Opportunity.StartDate.Item); sb.Append("\n" + courseStructure.Opportunity.Duration.DurationValue); sb.Append("\n" + courseStructure.Opportunity.Duration.DurationUnit); sb.Append("\n" + courseStructure.Opportunity.Duration.DurationDescription); if (courseStructure.Opportunity.Item.GetType() == typeof(VenueInfo)) { VenueInfo venue = (VenueInfo)courseStructure.Opportunity.Item; sb.Append("\n" + venue.VenueName); sb.Append("\n" + venue.Distance); sb.Append("\n" + venue.VenueAddress.Address_line_1); sb.Append("\n" + venue.VenueAddress.Address_line_2); sb.Append("\n" + venue.VenueAddress.Town); sb.Append("\n" + venue.VenueAddress.County); sb.Append("\n" + venue.VenueAddress.PostCode); sb.Append("\n" + venue.VenueAddress.Latitude); sb.Append("\n" + venue.VenueAddress.Longitude); } else { sb.Append("\n" + (string)courseStructure.Opportunity.Item); } sb.Append("\n"); } } sb.Append("\n\n"); sb.Append("Matching LDCS Details:"); if (response.CourseListResponse.MatchingLDCS != null) { foreach (CourseListResponseStructureMatchingLDCS mathcingLDCS in response.CourseListResponse.MatchingLDCS) { sb.Append("\n" + mathcingLDCS.LDCS.LDCSCode); sb.Append("\n" + mathcingLDCS.LDCS.LDCSDesc); sb.Append("\n" + mathcingLDCS.Counts); } } sb.Append("\n\n"); txtResult.Text = sb.ToString(); } catch (Exception ex) { txtResult.Text = ex.Message; } }