public void Submit()
        {
            var address = Address.Value.Trim();

            if (string.IsNullOrWhiteSpace(address))
            {
                ErrorMessage.InnerText = "Please enter an address or a 9-digit zip";
            }
            else
            {
                var result = AddressFinder.Find(Address.Value, true, null, Remember.Checked);
                if (result.Success)
                {
                    if (UrlManager.CurrentDomainDataCode == "US")
                    {
                        var cookie = new HttpCookie("Address", result.OriginalInput);
                        if (Remember.Checked)
                        {
                            cookie.Expires = DateTime.UtcNow.AddYears(1);
                        }
                        Response.Cookies.Add(cookie);
                    }
                    Response.Redirect(result.RedirectUrl);
                }
                else
                {
                    ErrorMessage.InnerText = result.ErrorMessage;
                }
            }
        }
Esempio n. 2
0
    public void OnDestroy()
    {
        ExternalServerList.OnMasterServerListChanged    -= ReceiveMasterListChanged;
        ExternalServerList.OnMasterServerListFetchError -= ReceiveMasterListFetchError;
        ExternalServerList.Dispose();

        AddressFinder.Dispose();
    }
Esempio n. 3
0
        public static T ToObject <T>(IntPtr ptr) where T : class
        {
            var finder = new AddressFinder <T>();
            var addr   = &finder.addr;

            *(IntPtr *)&addr[-1] = ptr;
            return(finder.obj);
        }
Esempio n. 4
0
        public static IntPtr AddressOf <T>(T obj) where T : class
        {
            var finder = new AddressFinder <T> {
                obj = obj
            };
            var addr = &finder.addr;

            return(*(IntPtr *)&addr[-1]);
        }
        protected AddressAbstractBuilder(string street, string number, string city, string state)
        {
            /* Criação do serviço deve ficar em um container de DI
             * mas para fins de simplicidade e exemplo será realizado no proprio builder */
            var addressFinder  = new AddressFinder();
            var addressService = new AddressService(addressFinder);

            address = BuildAddress(street, number, city, state, addressService);
        }
Esempio n. 6
0
 public MyForm()
 {
     InitializeComponent();
     _addressFinder              = new AddressFinder(new AddressFinderConfigurationProvider());
     _addressSuggestionsUpdated += AddressSuggestions_Updated;
     MyComboBox.DropDownStyle    = ComboBoxStyle.DropDown;
     MyComboBox.DisplayMember    = "Value";
     MyComboBox.ValueMember      = "Key";
 }
        private static string IncrementAddress(string low, string high, string oddEven)
        {
            // Returns the next sequential address after low,
            // taking the oddEven ("B", "O" or "E") and the various variabilities
            // into account

            if (low.Length != high.Length)
            {
                return(null);
            }

            // First we handle the numeric case
            var isNumericLow  = AddressFinder.IsNumericHouseNumber(low);
            var isNumericHigh = AddressFinder.IsNumericHouseNumber(high);

            if (isNumericLow && isNumericHigh)
            {
                var increment = oddEven == "B" ? 1 : 2;
                return((long.Parse(low) + increment).ToString()
                       .ZeroPad(AddressFinder.MaxHouseNumberLength));
            }
            if (isNumericLow || isNumericHigh) // mismatch
            {
                return(null);
            }

            // Try each of the four alphanumeric patterns
            // This is set to true if the patterns match even if the addresses
            // do not. We can stop looking when this turns true.
            var stop = false;

            var result = IncrementAddress99Hyphen99(low, high, oddEven,
                                                    ref stop);

            if (!stop)
            {
                result = IncrementAddressXXHyphenXX(low, high, oddEven,
                                                    ref stop);
            }

            if (!stop)
            {
                result = IncrementAddressXX99XX99XX(low, high, oddEven,
                                                    ref stop);
            }

            if (!stop)
            {
                result = IncrementAddressFractionals(low, high, oddEven,
                                                     ref stop);
            }

            return(result);
        }
Esempio n. 8
0
        private void FindButton_Click(object sender, EventArgs e)
        {
            ResultsTextBox.Clear();
            string input = AddressTextBox.Text;

            if (LookupRadioButton.Checked)
            {
                var result = AddressFinder.Find(input);
                ResultsTextBox.Text = result.ToString();
            }
            else
            {
                var result = AddressFinder.Parse(input);
                ResultsTextBox.Text = result.ToString();
            }
        }
        public IActionResult Index()
        {
            Address address = null;

            if (LoggedInUser != null)
            {
                address = _context.Address.Where(n => n.UserId == LoggedInUser.Id).SingleOrDefault();
            }

            AddressFinder addressFinder = new AddressFinder
            {
                Address1 = address?.AddressLine1 ?? String.Empty,
                Postcode = address?.PostCode ?? String.Empty,
            };

            return(View(addressFinder));
        }
Esempio n. 10
0
        private void CheckForMergeableItems(IList <StreetAnalysisData> list,
                                            string oddEven)
        {
            var hasWildcard = (list.Count > 0) && list[0].IsWildcard;
            var n           = hasWildcard ? 2 : 1;

            if (list.Count < n + 1)
            {
                return;               // nothing to check
            }
            while (n < list.Count)
            {
                // Look for merge opportuinities
                // We can be more aggressive on numeric "B" merges if there is no wildcard.
                // "O" and "E" can't merge in gaps because they might be overriding a "B" value.
                var canMerge = list[n - 1].LdsInfo == list[n].LdsInfo;
                // lds's must be the same
                if (!hasWildcard && (oddEven == "B") &&
                    AddressFinder.IsNumericHouseNumber(list[n].PrimaryLowNumber))
                {
                    // ok as is
                }
                else
                {
                    //if (oddEven != "B" || !AddressFinder.IsNumericHouseNumber(list[n].PrimaryLowNumber))
                    // make sure there are no gaps
                    canMerge &= CanMergeAddresses(list[n - 1].PrimaryHighNumber,
                                                  list[n].PrimaryLowNumber, oddEven);
                }
                if (canMerge && list[n - 1].MatchesSecondary(list[n]))
                {
                    list[n - 1].PrimaryHighNumber = list[n].PrimaryHighNumber;
                    list.RemoveAt(n);
                    _Statistics.Merged++;
                }
                n++;
            }
        }
Esempio n. 11
0
        public GeographicalCoordinates GetCoordinates(AddressInfo address)
        {
            Console.WriteLine("Calling GetCoordinates");
            Console.WriteLine("Performing authentication - " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
            var auth = new Authentication();

            auth.Timeout = 1000;
            var authToken = auth.getToken(ConfigurationManager.AppSettings["MaplinkUser"], ConfigurationManager.AppSettings["MaplinkPassword"]);

            Console.WriteLine("Finished authentication process - " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));

            Console.WriteLine("Starting address finder process - " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
            var service = new AddressFinder();

            service.Timeout = 1000;

            var addr = new Address();

            addr.street      = address.Address;
            addr.houseNumber = address.Number;
            addr.district    = address.District;
            addr.city        = new City()
            {
                name  = address.City,
                state = address.State
            };
            addr.zip = address.Zipcode;

            var coordinates = service.getXY(addr, authToken);

            Console.WriteLine("Finished service call - " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));

            var coords = new GeographicalCoordinates();

            coords.Latitude  = coordinates.x;
            coords.Longitude = coordinates.y;
            return(coords);
        }
 public TestForm()
 {
     InitializeComponent();
     _addressFinder              = new AddressFinder(new AddressFinderConfigurationProvider());
     _addressSuggestionsUpdated += AddressSuggestions_Updated;
 }
Esempio n. 13
0
        private void ApplyLdsInfoToPoBoxes(ICollection <StreetAnalysisData> dataList)
        {
            if ((dataList == null) || (dataList.Count == 0))
            {
                return;
            }

            // These are for list adjustments to be done after examining
            // all data items.
            var deletions = new List <StreetAnalysisData>();
            var additions = new List <StreetAnalysisData>();

            foreach (var data in dataList)
            {
                if (data.StreetName == PoBox)
                {
                    try
                    {
                        // All these fields must be empty
                        data.DirectionPrefix     = string.Empty;
                        data.StreetSuffix        = string.Empty;
                        data.DirectionSuffix     = string.Empty;
                        data.BuildingName        = string.Empty;
                        data.SecondaryType       = string.Empty;
                        data.SecondaryLowNumber  = string.Empty;
                        data.SecondaryHighNumber = string.Empty;
                        data.SecondaryOddEven    = string.Empty;
                        // Always "B"
                        data.PrimaryOddEven = "B";

                        // Validate the zip4List -> must be 4 digit numeric,
                        // properly collated
                        if ((data.Plus4Low.Length != 4) || !data.Plus4Low.IsDigits() ||
                            (data.Plus4High.Length != 4) || !data.Plus4High.IsDigits() ||
                            data.Plus4Low.IsGt(data.Plus4High))
                        {
                            data.SetMissingLdsInfo();
                            throw new VoteException("{0} Invalid PO BOX zip4List: {1} {2}",
                                                    data.UpdateKey, data.Plus4Low, data.Plus4High);
                        }

                        // Case 1: PrimaryLowNumber == PrimaryHighNumber
                        if (data.PrimaryLowNumber == data.PrimaryHighNumber)
                        {
                            // If they are both blank, it is a wildcard
                            //if (data.PrimaryHighNumber == string.Empty)
                            //  data.PrimaryHighNumber = HighPrimaryKey;
                            var zip4List      = CreateZip4List(data.Plus4Low, data.Plus4High);
                            var ldsDictionary = GetLdsInfoDictionary(data.ZipCode, zip4List);
                            // Summarize
                            var ldsUniqueDictionary = new Dictionary <LdsInfo, object>();
                            foreach (var info in ldsDictionary.Values)
                            {
                                ldsUniqueDictionary[info] = null;
                            }
                            if (ldsUniqueDictionary.Count != 1)
                            {
                                data.SetMissingLdsInfo();
                                if (ldsUniqueDictionary.Count == 0)
                                {
                                    //LogMissingZipPlus4(data.ZipCode, data.Plus4Low);
                                    //throw new VoteException("{0} missing PO BOX Lds info {1}-{2}",
                                    //  data.UpdateKey, data.ZipCode, data.Plus4Low);
                                }
                            }
                            else
                            {
                                data.LdsInfo = ldsUniqueDictionary.Keys.Single();
                            }
                            continue;
                        }

                        // Case 2: Plus4Low == Plus4High
                        if (data.Plus4Low == data.Plus4High)
                        {
                            data.LdsInfo = AddressFinder.GetLdsInfoOrMissing(data.ZipCode,
                                                                             data.Plus4Low);
                            if (data.LdsInfo.IsMissing)
                            {
                                //LogMissingZipPlus4(data.ZipCode, data.Plus4Low);
                                //throw new VoteException("{0} missing PO BOX Lds info {1}-{2}",
                                //  data.UpdateKey, data.ZipCode, data.Plus4Low);
                            }
                            continue;
                        }

                        // Validate the addresses -> at this point it must be MaxHouseNumberLength digit numeric,
                        // properly collated
                        if (!AddressFinder.IsNumericHouseNumber(data.PrimaryLowNumber) ||
                            !AddressFinder.IsNumericHouseNumber(data.PrimaryHighNumber) ||
                            data.PrimaryLowNumber.IsGt(data.PrimaryHighNumber))
                        {
                            data.SetMissingLdsInfo();
                            throw new VoteException("{0} Invalid PO BOX Primaries: {1} {2}",
                                                    data.UpdateKey, data.PrimaryLowNumber, data.PrimaryHighNumber);
                        }

                        var success = CheckPoBoxRange(data, deletions, additions);

                        if (!success)
                        {
                            throw new VoteException("{0} Invalid PO BOX Primaries: {1} {2}",
                                                    data.UpdateKey, data.PrimaryLowNumber, data.PrimaryHighNumber);
                        }
                    }
                    catch (VoteException ex)
                    {
                        if (!ex.Message.StartsWith("*"))
                        {
                            ReportError(ex.Message);
                        }
                        data.SetMissingLdsInfo();
                    }
                }
            }

            // Handle additions and deletions
            if ((deletions.Count > 0) || (additions.Count > 0))
            {
                _Statistics.Expanded += additions.Count - deletions.Count;
                foreach (var toDelete in deletions)
                {
                    dataList.Remove(toDelete);
                }
                foreach (var toAdd in additions)
                {
                    dataList.Add(toAdd);
                }
            }
        }
Esempio n. 14
0
        private void PostCsv()
        {
            var now      = DateTime.UtcNow;
            var messages = new List <string>();
            var good     = 0;
            var bad      = 0;

            try
            {
                if (Request.Files.Count != 1 || Request.Files[0].ContentLength == 0)
                {
                    throw new VoteException("Could not find CSV file");
                }
                using (var parser = new TextFieldParser(Request.Files[0].InputStream, Encoding.UTF8))
                {
                    parser.TextFieldType             = FieldType.Delimited;
                    parser.HasFieldsEnclosedInQuotes = true;
                    parser.SetDelimiters(",");
                    // look for the field names -- they aren't the first row so find a row whose
                    // first column is "FirstName"

                    string[] columnNames = null;
                    while (!parser.EndOfData)
                    {
                        var row = parser.ReadFields();
                        // ReSharper disable once PossibleNullReferenceException
                        if (row.Length > 0 && row[0] == "FirstName")
                        {
                            columnNames = row;
                            break;
                        }
                    }

                    if (columnNames == null)
                    {
                        throw new VoteException("Could not find column names row (\"FirstName\" in first column");
                    }
                    var maxColumnInx       = -1;
                    var firstNameInx       = GetColumnIndex(columnNames, "FirstName", ref maxColumnInx);
                    var lastNameInx        = GetColumnIndex(columnNames, "LastName", ref maxColumnInx);
                    var address1Inx        = GetColumnIndex(columnNames, "Address1", ref maxColumnInx);
                    var address2Inx        = GetColumnIndex(columnNames, "Address2", ref maxColumnInx);
                    var cityInx            = GetColumnIndex(columnNames, "City", ref maxColumnInx);
                    var stateProvinceInx   = GetColumnIndex(columnNames, "StateProvince", ref maxColumnInx);
                    var zipCodeInx         = GetColumnIndex(columnNames, "ZipCode", ref maxColumnInx);
                    var emailInx           = GetColumnIndex(columnNames, "Email", ref maxColumnInx);
                    var phoneInx           = GetColumnIndex(columnNames, "Phone", ref maxColumnInx);
                    var transactionDateInx = GetColumnIndex(columnNames, "TransactionDate", ref maxColumnInx);
                    var totalChangedInx    = GetColumnIndex(columnNames, "TotalCharged", ref maxColumnInx);

                    while (!parser.EndOfData)
                    {
                        var row = parser.ReadFields();
                        try
                        {
                            // ReSharper disable once PossibleNullReferenceException
                            if (row.Length <= maxColumnInx)
                            {
                                throw new VoteException($"Contains only {row.Length} columns, {maxColumnInx + 1} required.");
                            }

                            var email = row[emailInx];
                            if (string.IsNullOrWhiteSpace(email))
                            {
                                throw new VoteException("Email is missing");
                            }
                            if (!Validation.IsValidEmailAddress(email))
                            {
                                throw new VoteException($"Invalid Email: {email}");
                            }

                            var firstName = row[firstNameInx];
                            var lastName  = row[lastNameInx];
                            var fullName  = firstName + " " + lastName;
                            if (string.IsNullOrWhiteSpace(fullName))
                            {
                                throw new VoteException("FirstName or LastName is missing");
                            }

                            var address  = row[address1Inx];
                            var address2 = row[address2Inx];
                            if (!string.IsNullOrWhiteSpace(address) && !string.IsNullOrWhiteSpace(address2))
                            {
                                address += ", " + address2;
                            }

                            var city = row[cityInx];
                            if (string.IsNullOrWhiteSpace(city))
                            {
                                throw new VoteException("City is missing");
                            }

                            var stateCode = row[stateProvinceInx];
                            if (string.IsNullOrWhiteSpace(stateCode))
                            {
                                throw new VoteException("StateProvince is missing");
                            }
                            if (!StateCache.IsValidStateCode(stateCode))
                            {
                                // might be state name
                                stateCode = StateCache.GetStateCode(stateCode);
                                if (!StateCache.IsValidStateCode(stateCode))
                                {
                                    throw new VoteException("Invaid state or state code");
                                }
                            }

                            var zipCode = row[zipCodeInx];
                            if (string.IsNullOrWhiteSpace(zipCode))
                            {
                                NonFatalError(messages, parser.LineNumber, $"ZipCode is missing ({email})");
                            }
                            var zipMatch = Regex.Match(zipCode, @"(?<zip5>\d{5})(?:\D?(?<zip4>\d{4}))?");
                            var zip5     = string.Empty;
                            var zip4     = string.Empty;
                            if (!zipMatch.Success)
                            {
                                NonFatalError(messages, parser.LineNumber, $"Could not parse ZipCode: {zipCode} ({email})");
                            }
                            else
                            {
                                zip5 = zipMatch.Groups["zip5"].Value;
                                zip4 = zipMatch.Groups["zip4"].Value;
                            }

                            var phone = row[phoneInx].NormalizePhoneNumber();

                            DateTime transactionDate;
                            if (!DateTime.TryParse(row[transactionDateInx], out transactionDate))
                            {
                                throw new VoteException($"Could not parse TransactionDate: {row[transactionDateInx]}");
                            }

                            decimal totalChanged;
                            if (!decimal.TryParse(row[totalChangedInx], out totalChanged))
                            {
                                throw new VoteException($"Could not parse TotalCharged: {row[totalChangedInx]}");
                            }

                            if (Donations.EmailDateExists(email, transactionDate))
                            {
                                throw new VoteException(
                                          "A donation for this email, date and time already exists" +
                                          $" ({email}, {transactionDate:G}, {totalChanged:C})");
                            }
                            Donations.Insert(email, transactionDate, firstName, lastName, fullName,
                                             address, city, stateCode, zip5, zip4, phone, totalChanged, false);

                            // Get the encoding
                            var input = address + " " + city + " " + stateCode + " " + zip5;
                            if (!string.IsNullOrWhiteSpace(zip4))
                            {
                                input += "-" + zip4;
                            }
                            var result = AddressFinder.Find(input, null, false);
                            if ((result.Congress != null) && (result.Congress.Length == 3))
                            {
                                result.Congress = result.Congress.Substring(1);
                            }
                            var table = Addresses.GetDataByEmail(email);
                            if (table.Count == 0) // Insert
                            {
                                Addresses.Insert(firstName, lastName, address,
                                                 city, stateCode, zip5, zip4, email,
                                                 phone, now, "DONR", false, false, false, DefaultDbDate, string.Empty,
                                                 result.Congress.SafeString(), result.StateSenate.SafeString(),
                                                 result.StateHouse.SafeString(), result.County.SafeString(),
                                                 result.Success ? now : DefaultDbDate, 0, DefaultDbDate, true);
                            }
                            else if (result.Success) // update all matching Addresses
                            {
                                foreach (var r in table)
                                {
                                    if (!string.IsNullOrWhiteSpace(firstName))
                                    {
                                        r.FirstName = firstName;
                                    }
                                    if (!string.IsNullOrWhiteSpace(lastName))
                                    {
                                        r.LastName = lastName;
                                    }
                                    if (!string.IsNullOrWhiteSpace(phone))
                                    {
                                        r.Phone = phone;
                                    }
                                    r.IsDonor = true;
                                    if (!string.IsNullOrWhiteSpace(result.Congress))
                                    {
                                        r.Address               = address;
                                        r.City                  = city;
                                        r.StateCode             = stateCode;
                                        r.Zip5                  = zip5;
                                        r.Zip4                  = zip4;
                                        r.CongressionalDistrict = result.Congress;
                                        r.StateSenateDistrict   = result.StateSenate;
                                        r.StateHouseDistrict    = result.StateHouse;
                                        r.County                = result.County;
                                        r.DistrictLookupDate    = now;
                                    }
                                }
                                Addresses.UpdateTable(table);
                            }

                            messages.Add(
                                $"<p>{totalChanged:C} donation added for {fullName}&lt;{email}&gt; on {transactionDate:G}</p>");
                            good++;
                        }
                        catch (Exception ex)
                        {
                            messages.Add(
                                $"<p class=\"error\">Error on row {parser.LineNumber}: {ex.Message}</p>");
                            bad++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                messages.Add(
                    $"<p class=\"error\">Error: {ex.Message}</p>");
                bad++;
            }
            messages.Add($"<p>{good} donations added. {bad} errors.</p>");
            SummaryPlaceHolder.Controls.Add(new LiteralControl(string.Join(string.Empty, messages)));
            SummaryContainer.RemoveCssClass("hidden");
        }
Esempio n. 15
0
        private void FillInLegislativeDistricts()
        {
            AppendStatusText("Starting...");

            int  rowCount            = 0;
            int  fromUszd            = 0;
            int  successfulLookups   = 0;
            int  unsuccessfulLookups = 0;
            bool done = false;

            while (!done)
            {
                using (var reader = Addresses.GetDataReaderForLegislativeCoding(
                           FillInLegislativeDistrictsOnlyEmailsCheckBox.Checked,
                           FillInLegislativeDistrictsOnlyUncodedCheckBox.Checked, 0))
                {
                    try
                    {
                        while (reader.Read())
                        {
                            rowCount++;
                            string congressionalDistrict = string.Empty.ZeroPad(
                                Addresses.CongressionalDistrictMaxLength);
                            string stateSenateDistrict = string.Empty.ZeroPad(
                                Addresses.StateSenateDistrictMaxLength);
                            string stateHouseDistrict = string.Empty.ZeroPad(
                                Addresses.StateHouseDistrictMaxLength);
                            string county = string.Empty.ZeroPad(
                                Addresses.CountyMaxLength);
                            bool lookup = true;
                            if (reader.Zip5.Length == 5 && reader.Zip4.Length == 4)
                            {
                                // use USZD
                                var uszdTable = Uszd.GetDataByZip5Zip4(reader.Zip5, reader.Zip4);
                                if (uszdTable.Count > 0)
                                {
                                    var uszdRow = uszdTable[0];
                                    congressionalDistrict = uszdRow.Congress;
                                    stateSenateDistrict   = uszdRow.StateSenate;
                                    stateHouseDistrict    = uszdRow.StateHouse;
                                    county = uszdRow.County;
                                    lookup = false;
                                    fromUszd++;
                                }
                            }
                            if (lookup)
                            {
                                var result = AddressFinder.Find(reader.Address + ' ' +
                                                                reader.City + ' ' + reader.StateCode, null);
                                if (result.Success)
                                {
                                    congressionalDistrict = result.Congress;
                                    stateSenateDistrict   = result.StateSenate;
                                    stateHouseDistrict    = result.StateHouse;
                                    county = result.County;
                                    successfulLookups++;
                                }
                                else
                                {
                                    unsuccessfulLookups++;
                                }
                            }
                            // congresionalDistrictFixup
                            if (congressionalDistrict.Length == 3 && congressionalDistrict[0] == '0')
                            {
                                congressionalDistrict = congressionalDistrict.Substring(1);
                            }
                            var addressesTable = Addresses.GetDataById(reader.Id);
                            addressesTable[0].CongressionalDistrict = congressionalDistrict;
                            addressesTable[0].StateSenateDistrict   = stateSenateDistrict;
                            addressesTable[0].StateHouseDistrict    = stateHouseDistrict;
                            addressesTable[0].County             = county;
                            addressesTable[0].DistrictLookupDate = DateTime.Now.Date;
                            Addresses.UpdateTable(addressesTable);
                            if (rowCount % 1000 == 0)
                            {
                                AppendStatusText("{0} rows processed", rowCount);
                            }
                        }
                        done = true;
                    }
                    catch { }
                }
            }

            AppendStatusText("{0} rows with email and missing legislative districts found", rowCount);
            AppendStatusText("{0} filled in from USZD", fromUszd);
            AppendStatusText("{0} successful lookups", successfulLookups);
            AppendStatusText("{0} unsuccessful lookups", unsuccessfulLookups);
            AppendStatusText("Completed.");
        }
Esempio n. 16
0
 public AddressFinderResult FindAddress(string input)
 {
     return(AddressFinder.Find(input));
 }
Esempio n. 17
0
        private void AnalyzeContainment(IList <StreetAnalysisData> list)
        {
            var hasWildcard = (list.Count > 0) && list[0].IsWildcard;
            var n           = hasWildcard ? 2 : 1;

            if (list.Count < n + 1)
            {
                return;               // nothing to check
            }
            while (n < list.Count)
            {
                if (AddressFinder.IsNumericHouseNumber(list[n].PrimaryLowNumber) &&
                    AddressFinder.IsNumericHouseNumber(list[n - 1].PrimaryLowNumber))
                {
                    if (
                        string.CompareOrdinal(list[n - 1].PrimaryHighNumber, list[n].PrimaryLowNumber) >
                        0) // First check for containment
                    {
                        if (ContainsPrimary(list[n - 1], list[n]))
                        {
                            if ((list[n - 1].LdsInfo == list[n].LdsInfo) &&
                                list[n - 1].MatchesSecondary(list[n]))
                            {
                                // First contains second, remove second
                                list.RemoveAt(n);
                                _Statistics.Summarized++;
                                continue;
                            }
                        }
                        else if (ContainsPrimary(list[n], list[n - 1]))
                        {
                            if ((list[n - 1].LdsInfo == list[n].LdsInfo) &&
                                list[n - 1].MatchesSecondary(list[n]))
                            {
                                // Second contains first, remove first
                                list.RemoveAt(n - 1);
                                _Statistics.Summarized++;
                                continue;
                            }
                        }
                        else if (list[n - 1].LdsInfo != list[n].LdsInfo)
                        {
                            // We only report overlap errors if there is no
                            // secondary data to go on
                            if (list[n - 1].MatchesSecondary(list[n]))
                            {
                                ReportError("{0} {1} Overlap", list[n - 1].UpdateKey,
                                            list[n].UpdateKey);
                            }
                        }
                        else if (list[n - 1].MatchesSecondary(list[n]))
                        {
                            // We know they are numeric addresses. Merge the two into one
                            list[n - 1].PrimaryHighNumber = list[n].PrimaryHighNumber;
                            list.RemoveAt(n);
                            continue;
                        }
                    }
                }
                n++;
            }
        }
        //private void CheckOld(int rowCount, string addr1, string addr2, string city, string stateCode, string zip5, string zip4)
        //{
        //  DataRow dataRow = Default1.Process_Address_Using_Db_Tables(addr1, city, stateCode);
        //  if (dataRow == null)
        //  {
        //    AppendStatusText("{0} Old failed", rowCount);
        //    AppendStatusText("Input: {0}:{1}:{2}", addr1, city, stateCode);
        //    AppendStatusText(string.Empty);
        //  }
        //  else if (UseZip)
        //  {
        //    string zip5Found = dataRow["ZIP5"].ToString();
        //    string zip4Found = dataRow["ZIP4"].ToString();
        //    if (zip5Found != zip5 || zip4Found != zip4)
        //    {
        //      AppendStatusText("{0} Old failed", rowCount);
        //      AppendStatusText("Input: {0}:{1}:{2}:{3}", addr1, addr2, city, stateCode);
        //      AppendStatusText("Non-matching Zip+4: {0}-{1}", zip5, zip4);
        //      AppendStatusText("Found {0}-{1}", zip5Found, zip4Found);
        //      AppendStatusText(string.Empty);
        //    }
        //  }
        //}

        private void CheckNew(int rowCount, string addr1, string addr2, string city, string stateCode, string zip5, string zip4)
        {
            // Try Addr1 + Addr2 + City + StateCode
            // Check that result is successful && Zip5-Zip4 is in zip list
            string input  = addr1 + " " + addr2 + " " + city + " " + stateCode;
            var    result = AddressFinder.Find(input);

            if (result.SuccessMessage == null) // failure
            {
                AppendStatusText("{0} Failed on input: {1}", rowCount, input);
                if (UseZip)
                {
                    AppendStatusText("Zip+4: {0}-{1}", zip5, zip4);
                }
                AppendErrorMessages(result);
                AppendStatusText(string.Empty);
            }
            else if (UseZip)
            {
                string foundMessage = "Found " + zip5 + "-" + zip4;
                if (!result.ErrorMessages.Contains("Zip5 match"))
                {
                    if (!result.ErrorMessages.Contains(foundMessage))
                    {
                        if (!LdsInfoMatches(zip5, zip4, result))
                        {
                            AppendStatusText("{0} Failed on input: {1}", rowCount, input);
                            AppendStatusText("Non-matching Zip+4: {0}-{1}", zip5, zip4);
                            AppendStatusText("Addr1 Addr2, City, State: {0} {1}, {2}, {3}",
                                             addr1, addr2, city, stateCode);
                            AppendErrorMessages(result);
                            AppendStatusText(string.Empty);
                        }
                    }
                }
            }

            // Try Addr1 + Addr2 + Zip5
            // Check that result is successful && Zip5-Zip4 is in zip list
            input  = addr1 + " " + addr2 + " " + zip5;
            result = AddressFinder.Find(input);
            if (result.SuccessMessage == null) // failure
            {
                AppendStatusText("{0} Failed on input: {1}", rowCount, input);
                AppendStatusText("City, State: {0}, {1}", city, stateCode);
                AppendErrorMessages(result);
                AppendStatusText(string.Empty);
            }
            else if (UseZip)
            {
                string foundMessage = "Found " + zip5 + "-" + zip4;
                if (!result.ErrorMessages.Contains("Zip5 match"))
                {
                    if (!result.ErrorMessages.Contains(foundMessage))
                    {
                        if (!LdsInfoMatches(zip5, zip4, result))
                        {
                            AppendStatusText("{0} Failed on input: {1}", rowCount, input);
                            AppendStatusText("Non-matching Zip+4: {0}-{1}", zip5, zip4);
                            AppendStatusText("Addr1 Addr2, City, State: {0} {1}, {2}, {3}",
                                             addr1, addr2, city, stateCode);
                            AppendErrorMessages(result);
                            AppendStatusText(string.Empty);
                        }
                    }
                }
            }

            // Try Zip5-Zip4
            // Check that result is successful
            if (UseZip)
            {
                input  = zip5 + "-" + zip4;
                result = AddressFinder.Find(input);
                if (result.SuccessMessage == null) // failure
                {
                    AppendStatusText("{0} Failed on input: {1}", rowCount, input);
                    AppendStatusText("Zip+4 not found: {0}-{1}", zip5, zip4);
                    AppendStatusText("Addr1 Addr2, City, State: {0} {1}, {2}, {3}",
                                     addr1, addr2, city, stateCode);
                    AppendErrorMessages(result);
                    AppendStatusText(string.Empty);
                }
            }
        }
 public AddressFinderWrapper()
     : base()
 {
     _finder = new AddressFinder();
     base.ConfigureProxy(_finder);
 }
 public AddressService(AddressFinder addressFinder)
 {
     _addressFinder = addressFinder;
 }