Esempio n. 1
0
        internal void DoOneZipCode(string zipCode)
        {
            if (!SuppressUpdate && TextWriter == null)
            {
                ZipStreets.DeleteByZipCode(zipCode, 0);
            }

            using (
                var reader = ZipStreetsDownloaded.GetAnalysisDataReaderByZipCode(zipCode, 0)
                )
            {
                var first = true;

                string currentDirectionPrefix = null;
                string currentStreetName      = null;
                string currentStreetSuffix    = null;
                string currentDirectionSuffix = null;

                List <StreetAnalysisData> dataList = null;

                while (reader.Read())
                {
                    if (!StateCache.IsValidStateCode(reader.State))
                    {
                        continue;                       // skip PR etc
                    }
                    if (reader.Plus4Low.EndsWith("ND")) // no delivery
                    {
                        continue;
                    }

                    if (first)
                    {
                        AppendStatusText("{1} Beginning zipCode {0}", zipCode, RowsWritten);
                        first = false;
                    }
                    var directionPrefix = reader.DirectionPrefix;
                    var streetName      = reader.StreetName;
                    var streetSuffix    = reader.StreetSuffix;
                    var directionSuffix = reader.DirectionSuffix;
                    if (directionPrefix != currentDirectionPrefix ||
                        streetName != currentStreetName || streetSuffix != currentStreetSuffix ||
                        directionSuffix != currentDirectionSuffix)
                    {
                        if (dataList != null)
                        {
                            RowsWritten += AnalyzeStreet(dataList);
                        }
                        dataList = new List <StreetAnalysisData>();
                        currentDirectionPrefix = directionPrefix;
                        currentStreetName      = streetName;
                        currentStreetSuffix    = streetSuffix;
                        currentDirectionSuffix = directionSuffix;
                    }
                    if (dataList != null)
                    {
                        dataList.Add(new StreetAnalysisData(reader));
                    }
                }
                if (dataList != null)
                {
                    RowsWritten += AnalyzeStreet(dataList);
                }
            }
        }