// ----------------------------------------------------------------------------------------------- // Extract names from the xml string // ----------------------------------------------------------------------------------------------- public static DataTable DisplayNamesInGrid(ServiceReferenceAbnLookup.Payload payload) { DataRow MatchingName; DataTable MatchingNames = CreateNewNamesDataTable(); int NameIndex = 0; ServiceReferenceAbnLookup.ResponseBody ReponseBody = (ServiceReferenceAbnLookup.ResponseBody)payload.response.Item; ServiceReferenceAbnLookup.ResponseSearchResultsList Names = (ServiceReferenceAbnLookup.ResponseSearchResultsList)ReponseBody; try { while (NameIndex < Names.numberOfRecords) { ServiceReferenceAbnLookup.SearchResultsRecord Name = Names.searchResultsRecord[NameIndex]; MatchingName = MatchingNames.NewRow(); MatchingName["ABN"] = Name.ABN[0].identifierValue; ServiceReferenceAbnLookup.OrganisationSimpleName SimpleName = (ServiceReferenceAbnLookup.OrganisationSimpleName)Name.Items[0]; MatchingName["Entity Name"] = SimpleName.organisationName; MatchingName["Score"] = SimpleName.score; MatchingName["State"] = Name.mainBusinessPhysicalAddress[0].stateCode; MatchingName["Postcode"] = Name.mainBusinessPhysicalAddress[0].postcode; MatchingNames.Rows.Add(MatchingName); NameIndex++; } return(MatchingNames); } catch { throw; } }
// ----------------------------------------------------------------------------------------------- // Call web service proxies using document style soap // ----------------------------------------------------------------------------------------------- private void UseStronglyTypedDocumentSearch() { ServiceReferenceAbnLookup.Payload SearchPayload = null; try { if (this.radioButtonAbn.Checked) { // SearchPayload response will contain a Buisness Entity when searching By ABN SearchPayload = ProxyXmlSearch.AbnSearch(this.textBoxCriteria.Text, SetFlag(this.checkBoxHistory.Checked), this.textBoxGuid.Text); this.richTextBoxResults.Text = ResultsInterpreter.SerialisePayload(SearchPayload); } else if (this.radioButtonAsic.Checked) { // SearchPayload response will contain a Buisness Entity when searching by ASIC SearchPayload = ProxyXmlSearch.AsicSearch(this.textBoxCriteria.Text, SetFlag(this.checkBoxHistory.Checked), this.textBoxGuid.Text); this.richTextBoxResults.Text = ResultsInterpreter.SerialisePayload(SearchPayload); } else if (this.radioButtonName.Checked) { // SearchPayload response will contain a Search Results List when searching By name SearchPayload = ProxyXmlSearch.NameSearch(this.textBoxGuid.Text, InitialiseNameSearchCriteria()); DisplayNamesInGrid(SearchPayload); } else if (this.radioButtonPostcode.Checked) { // SearchPayload response will contain a ABN List when searching By postcode SearchPayload = ProxyXmlSearch.PostcodeSearch(this.textBoxGuid.Text, this.textBoxCriteria.Text); this.richTextBoxResults.Text = ResultsInterpreter.SerialisePayload(SearchPayload); } } catch (Exception e) { ShowException(e.ToString()); } }
// ----------------------------------------------------------------------------------------------- // Extract names from the xml string // ----------------------------------------------------------------------------------------------- private void DisplayNamesInGrid(ServiceReferenceAbnLookup.Payload payload) { this.richTextBoxResults.Visible = false; this.dataGridNames.Visible = true; try { this.dataGridNames.DataSource = ResultsInterpreter.DisplayNamesInGrid(payload); this.dataGridNames.Refresh(); } catch (Exception exp) { ShowException(exp.ToString()); throw; } }
// ----------------------------------------------------------------------------------------------- // Return payload as an XML String // ----------------------------------------------------------------------------------------------- public static string SerialisePayload(ServiceReferenceAbnLookup.Payload searchPayload) { try { MemoryStream XmlStream = new MemoryStream(); StreamReader XmlReader = new StreamReader(XmlStream); XmlSerializer Serializer = new XmlSerializer(typeof(ServiceReferenceAbnLookup.Payload)); Serializer.Serialize(XmlStream, searchPayload); XmlStream.Seek(0, System.IO.SeekOrigin.Begin); return(XmlReader.ReadToEnd()); } catch { throw; } }