// ----------------------------------------------------------------------------------------------- // Extract names from the xml string // ----------------------------------------------------------------------------------------------- public static DataTable DisplayNamesInGrid(ServiceReferenceAbnLookupRpc.Payload payload) { DataRow MatchingName; DataTable MatchingNames = CreateNewNamesDataTable(); int NameIndex = 0; ServiceReferenceAbnLookupRpc.ResponseSearchResultsList Names = (ServiceReferenceAbnLookupRpc.ResponseSearchResultsList)payload.Response.ResponseBody; try { while (NameIndex < Names.NumberOfRecords) { ServiceReferenceAbnLookupRpc.SearchResultsRecord Name = Names.SearchResultsRecord[NameIndex]; MatchingName = MatchingNames.NewRow(); MatchingName["ABN"] = Name.ABN[0].IdentifierValue; ServiceReferenceAbnLookupRpc.OrganisationSimpleName SimpleName = (ServiceReferenceAbnLookupRpc.OrganisationSimpleName)Name.Name[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 the web service proxies using Rpc style soap. // Serialising the Payload does not work for RPC without modifing the information generated from // the web reference file. Therefore just pull out some of the information for display. // ----------------------------------------------------------------------------------------------- private void UseStronglyTypedRpcSearch() { ServiceReferenceAbnLookupRpc.Payload SearchPayload = null; try { if (this.radioButtonAbn.Checked) { // SearchPayload response will contain a Buisness Entity when searching By ABN SearchPayload = ProxyXmlRpcSearch.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 = ProxyXmlRpcSearch.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 = ProxyXmlRpcSearch.NameSearch(this.textBoxGuid.Text, InitialiseRpcNameSearchCriteria()); DisplayNamesInGrid(SearchPayload); } else if (this.radioButtonPostcode.Checked) { // SearchPayload response will contain a ABN List when searching By postcode SearchPayload = ProxyXmlRpcSearch.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(ServiceReferenceAbnLookupRpc.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(ServiceReferenceAbnLookupRpc.Payload searchPayload) { try { MemoryStream XmlStream = new MemoryStream(); StreamReader XmlReader = new StreamReader(XmlStream); XmlSerializer Serializer = new XmlSerializer(typeof(ServiceReferenceAbnLookupRpc.Payload), ExtraTypes()); Serializer.Serialize(XmlStream, searchPayload); XmlStream.Seek(0, System.IO.SeekOrigin.Begin); return(XmlReader.ReadToEnd()); } catch { throw; } }