public virtual StandardizedAddress StandardizeAddress(string street, string city, string state, string zipCode)
        {
            string endpointUri         = "";
            StandardizedAddress result = new StandardizedAddress {
                Street = street, City = city, State = state, ZipCode = zipCode, MelissaAddressWashSucceeded = false, ErrorOccurred = "true"
            };

            try
            {
                endpointUri = BuildStandarizedAddressEndpointUri(street, city, state, zipCode);
                XElement xml = GetXml(endpointUri);
                result = xml.ToStandardizedAddress(endpointUri);
                if (String.IsNullOrWhiteSpace(result.CountyName))
                {
                    result.CountyID = LookupCountyID(zipCodeNumber: zipCode);
                }
                else
                {
                    result.CountyID = LookupCountyID(countyName: result.CountyName);
                }
            }
            catch (Exception ex)
            {
                using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
                {
                    ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                    services.ErrorReporting.Report(StandardizedAddressErrorMessage("AddressServiceProxy::StandardizeAddress", endpointUri, ex), ex);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static StandardizedAddress ToStandardizedAddress(this XElement element, string endPointUri)
        {
            var        standardizedAddress = new StandardizedAddress();
            XNamespace ns = element.GetDefaultNamespace();

            standardizedAddress.Message    = "Result";
            standardizedAddress.Company    = element.Element(ns + "Company").Value;
            standardizedAddress.Street     = element.Element(ns + "Street").Value;
            standardizedAddress.City       = element.Element(ns + "City").Value;
            standardizedAddress.State      = element.Element(ns + "State").Value;
            standardizedAddress.ZipCode    = element.Element(ns + "Zip").Value;
            standardizedAddress.CountyName = element.Element(ns + "CountyName").Value;
            standardizedAddress.CountyFIPS = element.Element(ns + "CountyFIPS").Value;
            //standardizedAddress.CountyID = element.Element(ns + "CountyID").Value;
            standardizedAddress.ErrorOccurred                    = element.Element(ns + "ErrorOccurred").Value;
            standardizedAddress.ErrorMessage                     = element.Element(ns + "ErrorMessage").Value;
            standardizedAddress.MelissaErrorCode                 = element.Element(ns + "MelissaErrorCode").Value;
            standardizedAddress.MelissaStatusCode                = element.Element(ns + "MelissaStatusCode").Value;
            standardizedAddress.MelissaAddressWashConfidence     = element.Element(ns + "MelissaAddressWashConfidence").Value;
            standardizedAddress.MelissaAddressWashStatusText     = element.Element(ns + "MelissaAddressWashStatusText").Value;
            standardizedAddress.MelissaAddressWashAdditionalInfo = element.Element(ns + "MelissaAddressWashAdditionalInfo").Value;
            standardizedAddress.MelissaAddressWashResults        = element.Element(ns + "MelissaAddressWashResults").Value;
            standardizedAddress.Range     = element.Element(ns + "Range").Value;
            standardizedAddress.Suite     = element.Element(ns + "Suite").Value;
            standardizedAddress.SuiteName = element.Element(ns + "SuiteName").Value;
            standardizedAddress.Suffix    = element.Element(ns + "Suffix").Value;
            //standardizedAddress.CountyID = element.Element(ns + "CountyID").Value;
            standardizedAddress.PostDirection = element.Element(ns + "PostDirection").Value;
            standardizedAddress.StreetName    = element.Element(ns + "StreetName").Value;
            standardizedAddress.PreDirection  = element.Element(ns + "PreDirection").Value;
            standardizedAddress.GeographicReferencePointID   = Convert.ToInt32(element.Element(ns + "GeographicReferencePointID").Value);
            standardizedAddress.HorizontalReferenceDatumID   = Convert.ToInt32(element.Element(ns + "HorizontalReferenceDatumID").Value);
            standardizedAddress.HorizontalCollectionMethodID = Convert.ToInt32(element.Element(ns + "HorizontalCollectionMethodID").Value);
            standardizedAddress.DataCollectionDate           = Convert.ToDateTime(element.Element(ns + "DataCollectionDate").Value);
            standardizedAddress.EndpointUri = endPointUri;
            if (element.Element(ns + "MelissaAddressWashSuceeded") != null)
            {
                standardizedAddress.MelissaAddressWashSucceeded = Convert.ToBoolean(element.Element(ns + "MelissaAddressWashSuceeded").Value);
            }
            else
            {
                standardizedAddress.MelissaAddressWashSucceeded = true;
            }

            return(standardizedAddress);
        }