本文整理汇总了C#中ServiceClient.doAddressCheck方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.doAddressCheck方法的具体用法?C# ServiceClient.doAddressCheck怎么用?C# ServiceClient.doAddressCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.doAddressCheck方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyLocation
/// <summary>
/// Standardizes the address
/// </summary>
/// <param name="location">The location.</param>
/// <param name="reVerify">Should location be reverified even if it has already been succesfully verified</param>
/// <param name="result">The result code unique to the service.</param>
/// <returns>
/// True/False value of whether the address was standardized succesfully
/// </returns>
public override bool VerifyLocation( Rock.Model.Location location, bool reVerify, out string result )
{
result = string.Empty;
if ( location != null &&
(!location.StandardizedDateTime.HasValue || reVerify ) )
{
var requestArray = new RequestArray();
requestArray.CustomerID = GetAttributeValue("CustomerId");
requestArray.OptAddressParsed = "True";
RequestArrayRecord requestAddress = new RequestArrayRecord();
requestAddress.AddressLine1 = location.Street1;
requestAddress.AddressLine2 = location.Street2;
requestAddress.City = location.City;
requestAddress.State = location.State;
requestAddress.Zip = location.PostalCode;
requestAddress.RecordID = "1";
requestArray.Record = new RequestArrayRecord[1];
requestArray.Record[0] = requestAddress;
ServiceClient serviceClient = new ServiceClient();
var responseArray = serviceClient.doAddressCheck( requestArray );
if ( responseArray.TotalRecords == "1" && responseArray.Record[0].RecordID == "1" )
{
result = responseArray.Record[0].Results;
if ( responseArray.Record[0].Results.Contains( "AS01" ) )
{
ResponseArrayRecordAddress responseAddress = responseArray.Record[0].Address;
location.Street1 = responseAddress.Address1;
location.Street2 = responseAddress.Address2;
location.City = responseAddress.City.Name;
location.State = responseAddress.State.Abbreviation;
location.PostalCode = responseAddress.Zip + '-' + responseAddress.Plus4;
if ( location.Street2.Trim() == string.Empty &&
responseAddress.Suite.Trim() != string.Empty )
location.Street2 = responseAddress.Suite;
location.StandardizedDateTime = RockDateTime.Now;
}
}
else
{
result = "No Records Returned";
}
location.StandardizeAttemptedServiceType = "MelissaData";
location.StandardizeAttemptedDateTime = RockDateTime.Now;
location.StandardizeAttemptedResult = result;
}
// MelissaData only standardizes addresses, it does not geocode, therefore
// always return false so that next verifcation service will run
return false;
}
示例2: Standardize
/// <summary>
/// Standardizes the address
/// </summary>
/// <param name="address">The address.</param>
/// <param name="result">The AddressCheck result code</param>
/// <returns>
/// True/False value of whether the address was standardized succesfully
/// </returns>
public override bool Standardize( Rock.CRM.Address address, out string result )
{
if ( address != null )
{
var requestArray = new RequestArray();
requestArray.CustomerID = AttributeValue("CustomerId");
requestArray.OptAddressParsed = "True";
RequestArrayRecord requestAddress = new RequestArrayRecord();
requestAddress.AddressLine1 = address.Street1;
requestAddress.AddressLine2 = address.Street2;
requestAddress.City = address.City;
requestAddress.State = address.State;
requestAddress.Zip = address.Zip;
requestAddress.RecordID = "1";
requestArray.Record = new RequestArrayRecord[1];
requestArray.Record[0] = requestAddress;
ServiceClient serviceClient = new ServiceClient();
var responseArray = serviceClient.doAddressCheck( requestArray );
if ( responseArray.TotalRecords == "1" && responseArray.Record[0].RecordID == "1" )
{
result = responseArray.Record[0].Results;
if ( responseArray.Record[0].Results.Contains( "AS01" ) )
{
ResponseArrayRecordAddress responseAddress = responseArray.Record[0].Address;
address.Street1 = responseAddress.Address1;
address.Street2 = responseAddress.Address2;
address.City = responseAddress.City.Name;
address.State = responseAddress.State.Abbreviation;
address.Zip = responseAddress.Zip + '-' + responseAddress.Plus4;
if ( address.Street2.Trim() == string.Empty &&
responseAddress.Suite.Trim() != string.Empty )
address.Street2 = responseAddress.Suite;
return true;
}
}
else
result = "No Records Returned";
}
else
result = "Null Address";
return false;
}
示例3: Verify
/// <summary>
/// Standardizes the address
/// </summary>
/// <param name="location">The location.</param>
/// <param name="resultMsg">The result MSG.</param>
/// <returns>
/// True/False value of whether the address was standardized successfully
/// </returns>
public override VerificationResult Verify( Rock.Model.Location location, out string resultMsg )
{
VerificationResult result = VerificationResult.None;
resultMsg = string.Empty;
var requestArray = new RequestArray();
requestArray.CustomerID = GetAttributeValue( "CustomerId" );
requestArray.OptAddressParsed = "True";
RequestArrayRecord requestAddress = new RequestArrayRecord();
requestAddress.AddressLine1 = location.Street1;
requestAddress.AddressLine2 = location.Street2;
requestAddress.City = location.City;
requestAddress.State = location.State;
requestAddress.Zip = location.PostalCode;
requestAddress.Country = location.Country;
requestAddress.RecordID = "1";
requestArray.Record = new RequestArrayRecord[1];
requestArray.Record[0] = requestAddress;
ServiceClient serviceClient = new ServiceClient();
var responseArray = serviceClient.doAddressCheck( requestArray );
if ( responseArray.TotalRecords == "1" && responseArray.Record[0].RecordID == "1" )
{
resultMsg = responseArray.Record[0].Results;
if ( string.IsNullOrWhiteSpace( resultMsg ) )
{
resultMsg = responseArray.Results;
}
string[] validResultCodes = new string[] {
"AS01", // Address Fully Verified
"AS09" // Foreign Address
};
if ( validResultCodes.Any( a => responseArray.Record[0].Results.Contains( a ) ) )
{
bool foreignAddress = responseArray.Record[0].Results.Contains("AS09");
ResponseArrayRecordAddress responseAddress = responseArray.Record[0].Address;
location.Street1 = responseAddress.Address1;
location.Street2 = responseAddress.Address2;
location.City = responseAddress.City.Name;
if ( !foreignAddress || !string.IsNullOrWhiteSpace(responseAddress.State.Abbreviation) )
{
// only set the State if we got a AS01 or a State back
location.State = responseAddress.State.Abbreviation;
}
if ( !foreignAddress || !string.IsNullOrWhiteSpace( responseAddress.Zip ) )
{
// only set the PostalCode if we got a AS01 or a Zip back
location.PostalCode = responseAddress.Zip;
if (!string.IsNullOrWhiteSpace(requestAddress.Plus4))
{
location.PostalCode = responseAddress.Zip + '-' + responseAddress.Plus4;
}
else
{
location.PostalCode = responseAddress.Zip;
}
}
if ( location.Street2.Trim() == string.Empty && responseAddress.Suite.Trim() != string.Empty )
{
location.Street2 = responseAddress.Suite;
}
result = VerificationResult.Standardized;
}
}
else
{
result = VerificationResult.ConnectionError;
resultMsg = "No Records Returned";
}
return result;
}
示例4: VerifyLocation
/// <summary>
/// Standardizes the address
/// </summary>
/// <param name="location">The location.</param>
/// <param name="reVerify">Should location be reverified even if it has already been succesfully verified</param>
/// <param name="result">The result code unique to the service.</param>
/// <returns>
/// True/False value of whether the address was standardized succesfully
/// </returns>
public override bool VerifyLocation( Rock.Model.Location location, bool reVerify, out string result )
{
result = string.Empty;
// Only verify if location is valid, has not been locked, and
// has either never been attempted or last attempt was in last 30 secs (prev active service failed) or reverifying
if ( location != null &&
!(location.IsGeoPointLocked ?? false) &&
(
!location.StandardizedDateTime.HasValue ||
location.StandardizedDateTime.Value.CompareTo( RockDateTime.Now.AddSeconds(-30) ) > 0 ||
reVerify
) )
{
var requestArray = new RequestArray();
requestArray.CustomerID = GetAttributeValue( "CustomerId" );
requestArray.OptAddressParsed = "True";
RequestArrayRecord requestAddress = new RequestArrayRecord();
requestAddress.AddressLine1 = location.Street1;
requestAddress.AddressLine2 = location.Street2;
requestAddress.City = location.City;
requestAddress.State = location.State;
requestAddress.Zip = location.PostalCode;
requestAddress.Country = location.Country;
requestAddress.RecordID = "1";
requestArray.Record = new RequestArrayRecord[1];
requestArray.Record[0] = requestAddress;
ServiceClient serviceClient = new ServiceClient();
var responseArray = serviceClient.doAddressCheck( requestArray );
if ( responseArray.TotalRecords == "1" && responseArray.Record[0].RecordID == "1" )
{
result = responseArray.Record[0].Results;
if ( string.IsNullOrWhiteSpace( result ) )
{
result = responseArray.Results;
}
string[] validResultCodes = new string[] {
"AS01", // Address Fully Verified
"AS09" // Foreign Address
};
if ( validResultCodes.Any( a => responseArray.Record[0].Results.Contains( a ) ) )
{
bool foreignAddress = responseArray.Record[0].Results.Contains("AS09");
ResponseArrayRecordAddress responseAddress = responseArray.Record[0].Address;
location.Street1 = responseAddress.Address1;
location.Street2 = responseAddress.Address2;
location.City = responseAddress.City.Name;
if ( !foreignAddress || !string.IsNullOrWhiteSpace(responseAddress.State.Abbreviation) )
{
// only set the State if we got a AS01 or a State back
location.State = responseAddress.State.Abbreviation;
}
if ( !foreignAddress || !string.IsNullOrWhiteSpace( responseAddress.Zip ) )
{
// only set the PostalCode if we got a AS01 or a Zip back
location.PostalCode = responseAddress.Zip;
if (!string.IsNullOrWhiteSpace(requestAddress.Plus4))
{
location.PostalCode = responseAddress.Zip + '-' + responseAddress.Plus4;
}
else
{
location.PostalCode = responseAddress.Zip;
}
}
if ( location.Street2.Trim() == string.Empty &&
responseAddress.Suite.Trim() != string.Empty )
location.Street2 = responseAddress.Suite;
location.StandardizedDateTime = RockDateTime.Now;
}
}
else
{
result = "No Records Returned";
}
location.StandardizeAttemptedServiceType = "MelissaData";
location.StandardizeAttemptedDateTime = RockDateTime.Now;
location.StandardizeAttemptedResult = result;
}
// MelissaData only standardizes addresses, it does not geocode, therefore
//.........这里部分代码省略.........