I work for a call centre that has been using QAS Pro for near 2 years now. We use a resource DLL inside access databases to talk to the internally hosted QAS server. Its only use is to gather address details based on postcode. So the first function gets a list of address from that postcode, inserts them into a combo box in access. After the operator can select the appropriate address and it inserts it into the correct fields.
This was written by a developer who is no longer with us. Its my job to fix the code. With some testing I've been able to verify it is the c# code we use and not the addresses. As the test harness works fine.
The resource DLL uses the c# test code from QAS with an extra file for a few functions. I'm new to c# and have never worked on something like this before. Any help is appreciated.
This is the code written by an old colleague.
namespace MangoQAS
{
using com.qas.proweb;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[ComVisible(true)]
public class QAS
{
public QAS()
{
QuickAddress address = new QuickAddress("http://10.10.15.7:2021") {
Engine = QuickAddress.EngineTypes.Singleline,
Flatten = true
};
this.searchService = address;
}
private string GetMoniker(string p)
{
return this.searchService.Search("GBR", p, PromptSet.Types.Default, "Database layout").Picklist.Items[0].Moniker;
}
public string[] RefinePostcode(string p)
{
string moniker = this.GetMoniker(p);
FormattedAddress formattedAddress = this.searchService.GetFormattedAddress(moniker, "Database Layout");
return new string[] { formattedAddress.AddressLines[0].Line, formattedAddress.AddressLines[1].Line, formattedAddress.AddressLines[2].Line, formattedAddress.AddressLines[3].Line, formattedAddress.AddressLines[4].Line, formattedAddress.AddressLines[5].Line, formattedAddress.AddressLines[6].Line };
}
public string[] SearchPostcodes(string postCode)
{
SearchResult result = this.searchService.Search("GBR", postCode, PromptSet.Types.OneLine, "Database layout");
string[] strArray = new string[result.Picklist.Length];
for (int i = 0; i < result.Picklist.Length; i++)
{
strArray[i] = result.Picklist.Items[i].Text;
}
return strArray;
}
private QuickAddress searchService { get; set; }
}
}
SearchPostcodes - Brings back a list of addresses based on the postcode. RefinePostcode - takes the address line and sends back a formatted address.
The problem seems to be with RefinePostcode. I have tried formatting the address string as my first thought was it didn't like forward slashes. This did not work.
For example, Using the Postcode: PA169AE.
This gives me: 0/1 15 Brachelston Street, GREENOCK, Renfrewshire, at the top of the combobox.
If I click on this address it will send back: 1 Crossgates, Greenock Road, PA7 5JU.
Changing everything including the postcode I entered.
I believe the problem is with RefinePostcode or GetMoniker. The 2 blocks below are from the sample code and unchanged, but may be required to diagnose.
public FormattedAddress GetFormattedAddress(string sMoniker, string sLayout)
{
Debug.Assert((sMoniker != null) && (sLayout != null));
QAGetAddress qAGetAddress = new QAGetAddress {
Layout = sLayout,
Moniker = sMoniker,
QAConfig = this.m_Config,
Language = this.m_LanguageString
};
FormattedAddress address2 = null;
try
{
address2 = new FormattedAddress(this.SearchService.DoGetAddress(qAGetAddress).QAAddress);
}
catch (Exception exception)
{
this.MapException(exception);
}
return address2;
}
public SearchResult Search(string sDataID, string sSearch, PromptSet.Types tPromptSet, string sLayout)
{
Debug.Assert(sDataID != null);
Debug.Assert(sSearch != null);
QASearch qASearch = new QASearch {
Country = sDataID,
Engine = this.m_Engine
};
qASearch.Engine.PromptSet = (PromptSetType) tPromptSet;
qASearch.Engine.PromptSetSpecified = true;
qASearch.Layout = sLayout;
qASearch.QAConfig = this.m_Config;
qASearch.Search = sSearch;
qASearch.Language = this.m_LanguageString;
SearchResult result = null;
try
{
result = new SearchResult(this.SearchService.DoSearch(qASearch));
}
catch (Exception exception)
{
this.MapException(exception);
}
return result;
}
I've thoroughly searched Google and cant seem to find any reason this would happen. I can post more code samples if required.