Difference between revisions of "PAV I VB"

From CDYNE Wiki
Jump to navigation Jump to search
imported>Bdriggers
(Created page with "Button click handler: <code type=vb.net> Private Sub button1_Click(sender As Object, e As RoutedEventArgs) Dim request As New PavIntService.AddressInternationa...")
 
imported>Bdriggers
Line 2: Line 2:
  
 
<code type=vb.net>
 
<code type=vb.net>
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)  
+
Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
       
 
        Dim request As New PavIntService.AddressInternationalRequest()
 
  
'Check each textbox and add corresponding field if the textbox is not empty
+
Dim service As PavInternationalServiceClient = New PavInternationalServiceClient("paviws")
Dim availableFields As New List(Of KeyValue)()
+
Dim request As New AddressInternationalRequest()
AddKeyValue(availableFields, ORGANISATION, "ORGANISATION")
 
AddKeyValue(availableFields, SUBBUILDING, "SUBBUILDING")
 
AddKeyValue(availableFields, BUILDINGNAME, "BUILDINGNAME")
 
AddKeyValue(availableFields, BUILDINGNUMBER, "BUILDINGNUMBER")
 
AddKeyValue(availableFields, DEPSTREET, "DEPSTREET")
 
AddKeyValue(availableFields, STREET, "STREET")
 
AddKeyValue(availableFields, DEPLOCALITY, "DEPLOCALITY")
 
AddKeyValue(availableFields, LOCALITY, "LOCALITY")
 
AddKeyValue(availableFields, POSTTOWN, "POSTTOWN")
 
AddKeyValue(availableFields, COUNTY, "COUNTY")
 
AddKeyValue(availableFields, POSTCODE, "POSTCODE")
 
AddKeyValue(availableFields, ADDR, "ADDR")
 
  
'Check what output fields are required on return
+
'Check each textbox and add corresponding field if the textbox is not empty
Dim returnFields As New List(Of String)()
+
Dim availableFields As New List(Of KeyValue)()
GetReturnFields(returnFields)
 
  
'Convert to array and add to the request
+
availableFields.Add(New KeyValue() With {.Key = "ORGANISATION", .Value = ""})
request.AddressFields = availableFields.ToArray()
+
availableFields.Add(New KeyValue() With {.Key = "SUBBUILDING", .Value = ""})
request.ReturnFields = returnFields.ToArray()
+
availableFields.Add(New KeyValue() With {.Key = "BUILDINGNAME", .Value = "Rose House"})
 
+
availableFields.Add(New KeyValue() With {.Key = "BUILDINGNUMBER", .Value = "51-59"})
'Set License key
+
availableFields.Add(New KeyValue() With {.Key = "DEPSTREET", .Value = ""})
request.LicenseKey = "ADD VALID LICENSE KEY HERE"
+
availableFields.Add(New KeyValue() With {.Key = "STREET", .Value = "Circular Road"})
 
+
availableFields.Add(New KeyValue() With {.Key = "DEPLOCALITY", .Value = ""})
'Check if native output is requested
+
availableFields.Add(New KeyValue() With {.Key = "LOCALITY", .Value = ""})
request.ReturnNativeOutput = (chkNATIVE.IsChecked = True)
+
availableFields.Add(New KeyValue() With {.Key = "POSTTOWN", .Value = ""})
 
+
availableFields.Add(New KeyValue() With {.Key = "COUNTY", .Value = ""})
'Call the service
+
availableFields.Add(New KeyValue() With {.Key = "POSTCODE", .Value = "IM1 1AZ"})
Dim response As AddressInternationalResponse = service.VerifyAddressInternational(request)
+
availableFields.Add(New KeyValue() With {.Key = "ADDR", .Value = "United Kingom"}) 'You may place the country or entire address in this parameter
 
+
       
'Update UI with the results
+
'Check what output fields are required on return
UpdateUI(response.AddressFields)
+
Dim returnFields As New List(Of String)()
End Sub
 
  
 +
returnFields.Add("RESCODE")
 +
returnFields.Add("OUTPUTSTATUS")
 +
returnFields.Add("MATCHLVL")
 +
returnFields.Add("ADDR")
 +
returnFields.Add("ORGANISATION")
 +
returnFields.Add("BUILDINGNUMBER")
 +
returnFields.Add("BUILDINGNAME")
 +
returnFields.Add("SUBBUILDING")
 +
returnFields.Add("STREET")
 +
returnFields.Add("DEPSTREET")
 +
returnFields.Add("LOCALITY")
 +
returnFields.Add("DEPLOCALITY")
 +
returnFields.Add("POSTTOWN")
 +
returnFields.Add("COUNTY")
 +
returnFields.Add("POSTCODE")
 +
returnFields.Add("COUNTRY")
 +
returnFields.Add("COUNTRYCODE")
 +
       
 +
'Convert to array and add to the request
 +
request.AddressFields = availableFields.ToArray()
 +
request.ReturnFields = returnFields.ToArray()
 +
       
 +
'Set License key
 +
request.LicenseKey = "YOUR LICENSE KEY"
 +
       
 +
'Check if native output is requested
 +
request.ReturnNativeOutput = (chkNATIVE.Checked = True)
 +
       
 +
'Call the service
 +
Dim response As AddressInternationalResponse = service.VerifyAddressInternational(request)
 +
response = service.VerifyAddressInternational(request)
 +
       
 +
       
 +
'Update UI with the results - in this example the results returned to a GridView
 +
gridview1.DataSource = response.AddressFields
 +
gridview1.DataBind()
 +
gridview1.AutoGenerateColumns = True
 
</code>
 
</code>

Revision as of 11:09, 3 October 2012

Button click handler:

Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click

Dim service As PavInternationalServiceClient = New PavInternationalServiceClient("paviws") Dim request As New AddressInternationalRequest()

'Check each textbox and add corresponding field if the textbox is not empty Dim availableFields As New List(Of KeyValue)()

availableFields.Add(New KeyValue() With {.Key = "ORGANISATION", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "SUBBUILDING", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "BUILDINGNAME", .Value = "Rose House"}) availableFields.Add(New KeyValue() With {.Key = "BUILDINGNUMBER", .Value = "51-59"}) availableFields.Add(New KeyValue() With {.Key = "DEPSTREET", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "STREET", .Value = "Circular Road"}) availableFields.Add(New KeyValue() With {.Key = "DEPLOCALITY", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "LOCALITY", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "POSTTOWN", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "COUNTY", .Value = ""}) availableFields.Add(New KeyValue() With {.Key = "POSTCODE", .Value = "IM1 1AZ"}) availableFields.Add(New KeyValue() With {.Key = "ADDR", .Value = "United Kingom"}) 'You may place the country or entire address in this parameter

'Check what output fields are required on return Dim returnFields As New List(Of String)()

returnFields.Add("RESCODE") returnFields.Add("OUTPUTSTATUS") returnFields.Add("MATCHLVL") returnFields.Add("ADDR") returnFields.Add("ORGANISATION") returnFields.Add("BUILDINGNUMBER") returnFields.Add("BUILDINGNAME") returnFields.Add("SUBBUILDING") returnFields.Add("STREET") returnFields.Add("DEPSTREET") returnFields.Add("LOCALITY") returnFields.Add("DEPLOCALITY") returnFields.Add("POSTTOWN") returnFields.Add("COUNTY") returnFields.Add("POSTCODE") returnFields.Add("COUNTRY") returnFields.Add("COUNTRYCODE")

'Convert to array and add to the request request.AddressFields = availableFields.ToArray() request.ReturnFields = returnFields.ToArray()

'Set License key request.LicenseKey = "YOUR LICENSE KEY"

'Check if native output is requested request.ReturnNativeOutput = (chkNATIVE.Checked = True)

'Call the service Dim response As AddressInternationalResponse = service.VerifyAddressInternational(request) response = service.VerifyAddressInternational(request)


'Update UI with the results - in this example the results returned to a GridView gridview1.DataSource = response.AddressFields gridview1.DataBind() gridview1.AutoGenerateColumns = True