Exemple #1
0
        static string GetNumbers(string street)
        {
            try
            {
                TotalStreets = 0;
                IExtractor           extractor = new Extractor();
                IEnumerable <string> er        = extractor.Extract(street);
                bool          first            = true;
                StringBuilder result           = new StringBuilder();

                foreach (var r in er)
                {
                    TotalStreets++;
                    if (first)
                    {
                        result.Append(r);
                        first = false;
                    }
                    else
                    {
                        result.Append(string.Concat(",", r));
                    }
                }
                return(result.ToString());
            }
            catch (Exception exception)
            {
                if (Global.Language == Global.Languages.English)
                {
                    Console.Error.WriteLine($"ERROR: {exception.Message}");
                }
                else if (Global.Language == Global.Languages.German)
                {
                    Console.Error.WriteLine($"FEHLER: {exception.Message}");
                }
                return(string.Empty);
            }
        }
Exemple #2
0
        static bool GetAll(bool toExcel)
        {
            if (Global.Language == Global.Languages.English)
            {
                Console.Clear();
                Console.WriteLine("..:: dynamic address components help system ::..");
                Console.WriteLine("################################################");
                Console.WriteLine("");
                Console.WriteLine("export all numbers of all streets");
                Console.WriteLine("---------------------------------");
            }
            else if (Global.Language == Global.Languages.German)
            {
                Console.Clear();
                Console.WriteLine("..:: dynamic address components help system ::..");
                Console.WriteLine("################################################");
                Console.WriteLine("");
                Console.WriteLine("exportiere alle Nummern aller Straßen");
                Console.WriteLine("-------------------------------------");
            }

            Dictionary <string, string> result = new Dictionary <string, string>();
            string fileExtension = string.Empty;

            IExtractor extractor = new Extractor();

            IEnumerable <string> streets = extractor.ExtractAllStreets();

            TotalStreets = 0;

            foreach (string street in streets)
            {
                TotalStreets++;
            }

            if (Global.Language == Global.Languages.English)
            {
                Console.WriteLine($"number of known streets: {TotalStreets}");
                Console.WriteLine("processing.. please wait(~10-15 min)");
            }
            else if (Global.Language == Global.Languages.German)
            {
                Console.WriteLine($"Anzahl aller bekannten Straßen: {TotalStreets}");
                Console.WriteLine("Bearbeite.. Bitte warten(~10-15 Minuten)");
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Reset();
            stopwatch.Start();

            int count = 0;

            foreach (string name in streets)
            {
                var           extract = extractor.Extract(name);
                StringBuilder numbers = new StringBuilder();

                foreach (var r in extract)
                {
                    count++;
                    if (numbers.Length == 0)
                    {
                        numbers.Append(r);
                    }
                    else
                    {
                        numbers.Append(string.Concat(",", r));
                    }
                }

                result.Add(name, numbers.ToString());
            }

            stopwatch.Stop();

            if (Global.Language == Global.Languages.English)
            {
                Console.WriteLine($"done in {stopwatch.Elapsed.ToString("h'h 'm'm 's's'")}!");
                Console.WriteLine($"total numbers: {count}.");
            }
            else if (Global.Language == Global.Languages.German)
            {
                Console.WriteLine($"Erledigt in {stopwatch.Elapsed.ToString("h'h 'm'm 's's'")}!");
                Console.WriteLine($"Anzahl aller Hausnummern: {count}.");
            }

            Console.WriteLine(Environment.NewLine);
            if (toExcel)
            {
                Console.Write("Excel-Export");
                fileExtension = ".xlsx";
            }
            else
            {
                ToCSV(result);
                Console.Write("CSV-Export");
                fileExtension = ".csv";
            }

            if (Global.Language == Global.Languages.English)
            {
                Console.Write($", done.{Environment.NewLine}");
                Console.WriteLine($"Path: {Environment.CurrentDirectory}{Path.PathSeparator}dachs{fileExtension}");
                Console.WriteLine("press any key to continue ..");
                Console.ReadKey();
            }
            else if (Global.Language == Global.Languages.German)
            {
                Console.Write($", abgeschlossen.{Environment.NewLine}");
                Console.WriteLine($"Pfad: {Environment.CurrentDirectory}{Path.PathSeparator}dachs{fileExtension}");
                Console.WriteLine("Drücke eine Taste zum Fortfahren ..");
                Console.ReadKey();
            }

            Console.ReadKey();

            return(true);
        }