Example #1
0
        private void ProcessZipCodes()
        {
            AppendStatusText("Processing {0} zip codes", ZipCodesToUpdate.Count);
            foreach (string zipCode in ZipCodesToUpdate.Keys)
            {
                bool alreadyExists;

                if (SuppressUpdate)
                {
                    alreadyExists = DB.VoteZipNew.ZipSingleUszd.ZipCodeExists(zipCode);
                }
                else
                {
                    alreadyExists = DB.VoteZipNew.ZipSingleUszd.DeleteByZipCode(zipCode) > 0;
                }

                ZipSingleUszdWriter writer = new ZipSingleUszdWriter(SuppressUpdate);
                writer.Feedback = AppendStatusText;
                bool single = writer.DoOneZipCode(zipCode);

                if (alreadyExists && !single)
                {
                    SingleZipCodesRemoved++;
                }
                else if (!alreadyExists && single)
                {
                    SingleZipCodesAdded++;
                }
            }
            AppendStatusText("Finished {0} zip codes", ZipCodesToUpdate.Count);
            AppendStatusText("{0} added, {1} removed", SingleZipCodesAdded, SingleZipCodesRemoved);
        }
        //private static IEnumerable<string> CreateZipPlus4List(ZipStreetsDownloadedTable table)
        //{
        //  Dictionary<string, object> zip4Dictionary = new Dictionary<string, object>();
        //  foreach (var row in table)
        //  {
        //    if (row.Plus4Low == row.Plus4High)
        //      zip4Dictionary[row.Plus4Low] = null;
        //    else
        //    {
        //      int low = int.Parse(row.Plus4Low);
        //      int high = int.Parse(row.Plus4High);
        //      // high = Math.Min(high, low + 199);
        //      for (int n = low; n <= high; n++)
        //        zip4Dictionary[n.ToString().ZeroPad(4)] = null;
        //    }
        //  }
        //  return zip4Dictionary.Keys;
        //}

        private bool DoOneZipCode(string zipCode)
        {
            ZipSingleUszdWriter writer = new ZipSingleUszdWriter(SuppressUpdate);

            writer.Feedback = AppendStatusText;
            return(writer.DoOneZipCode(zipCode));
        }