コード例 #1
0
        public AddrValidationResponseModel ValidateAddress(AddressModel addr)
        {
            _log.Debug("START ValidateAddress");
            _log.Debug(addr.ToString());
            QASearch       search = TranslateAddrValidationModel.MapAddressToQasSearch(addr);
            QASearchResult result = _proxy.ValidateAddress(search);
            AddrValidationResponseModel response = TranslateAddrValidationModel.MapGetResponseToModel(result);

            _log.Debug("END ValidateAddress");
            return(response);
        }
コード例 #2
0
        public AddrValidationResponseModel ValidateAddress(string addr1, string addr2, string city, string state, string zip, string country)
        {
            AddrValidationResponseModel avrModel = null;

            AddressModel addr = new AddressModel(addr1, addr2, city, state, zip, country);

            try
            {
                _log.Info("ASA.Web.Services.AddrValidationService.ValidateAddress() starting ...");

                if (addr != null && addr.IsValid() && (Config.QasOn == true))
                {
                    // only send US addrs to QAS
                    if (addr.CountryID.ToUpper() == "USA" || addr.CountryID.ToUpper() == "US" || addr.CountryID.ToUpper() == "UNITED STATES")
                    {
                        avrModel = _addressValidation.ValidateAddress(addr);
                    }
                    else //dont send foreign addrs to QAS.
                    {
                        //avrModel = new AddrValidationResponseModel(QasProWeb.VerifyLevelType.None);
                        avrModel = new AddrValidationResponseModel();
                        ErrorModel error = new ErrorModel("Foreign addresses are not validated by QAS.", "Web AddressValidation Service");
                        avrModel.ErrorList.Add(error);
                        _log.Info("Foreign addresses are not validated by QAS.");
                    }
                }
                else
                {
                    avrModel = new AddrValidationResponseModel();
                    ErrorModel error = new ErrorModel("Invalid search criteria", "Web AddressValidation Service");
                    if (Config.QasOn != true)
                    {
                        error = new ErrorModel("Qas is configured to bypass address validation.", "Web AddressValidation Service");
                    }
                    avrModel.ErrorList.Add(error);
                    _log.Info("ASA.Web.Services.AddrValidationService.ValidateAddress(): Invalid search criteria or QAS is currently disabled.");
                }

                _log.Info("ASA.Web.Services.AddrValidationService.ValidateAddress() ending ...");
            }
            catch (Exception ex)
            {
                avrModel = new AddrValidationResponseModel();
                ErrorModel error = new ErrorModel(ex.ToString(), "Web AddressValidation Service");
                avrModel.ErrorList.Add(error);
                _log.Error("ASA.Web.Services.AddrValidationService.ValidateAddress(): Exception => " + ex.ToString());
            }

            return(avrModel);
        }
コード例 #3
0
        public static DataContracts.AddrValidationResponseModel MapGetResponseToModel(QasProWeb.QASearchResult result)
        {
            _log.Debug("START MapGetResponseToModel");
            AddrValidationResponseModel avrModel = new AddrValidationResponseModel();

            if (result != null)
            {
                //note: VerifyLevel is not checkd for null here because VerifyLevel type is non-nullable. it would never happen.
                avrModel.VerifyLevel = result.VerifyLevel.ToString();
                _log.Debug("VerifyLevel = " + result.VerifyLevel.ToString());

                if (result.QAAddress != null && result.QAAddress.AddressLine != null && result.QAAddress.AddressLine.Length > 5)
                {
                    _log.Debug("VerifiedAddress exists in the results from QAS");
                    avrModel.VerifiedAddress = new AddressModel(); // ASA.Web.Services.AddrValidationService.DataContracts.
                    avrModel.VerifiedAddress.AddressLine1 = result.QAAddress.AddressLine[0].Line;
                    if (result.QAAddress.AddressLine[1].Line != null)
                    {
                        avrModel.VerifiedAddress.AddressLine2 = result.QAAddress.AddressLine[1].Line;
                    }
                    if (result.QAAddress.AddressLine[2].Line != null)
                    {
                        avrModel.VerifiedAddress.AddressLine2 += result.QAAddress.AddressLine[2].Line;
                    }
                    avrModel.VerifiedAddress.City    = result.QAAddress.AddressLine[3].Line;
                    avrModel.VerifiedAddress.StateID = result.QAAddress.AddressLine[4].Line;
                    string strFullPostalZip = result.QAAddress.AddressLine[5].Line; // long zip is returned -- may need to be truncated for UI
                    avrModel.VerifiedAddress.Zip       = strFullPostalZip.Substring(0, 5);
                    avrModel.VerifiedAddress.CountryID = "US";
                }

                avrModel.SuggestedAddresses = ConvertPickListToAddressListModel(result.QAPicklist);
            }
            _log.Debug("END MapGetResponseToModel");

            return(avrModel);
        }