Beispiel #1
0
        private static BoulevardCollection ParseBoulevards(string path)
        {
            StreamReader  streamReader = new StreamReader(path);
            XmlSerializer serializer   = new XmlSerializer(typeof(BoulevardCollection));

            GovDataReader govDataReader = new GovDataReader(streamReader, serializer);

            BoulevardCollection boulevardCollection = govDataReader.ParseBoulevards();

            return(boulevardCollection);
        }
        private static void Main(string[] args)
        {
            Console.WriteLine("Please make your choice: ");
            Console.WriteLine("1. Streets");
            Console.WriteLine("2. Boulevards");

            string userChoice = Console.ReadLine();

            int.TryParse(userChoice, out int userOption);

            FailureTrackerDbContext context = InitializeContext();

            switch (userOption)
            {
            case 1:
                StreetCollection streetCollection = ParseStreets("artere_1.xml");
                foreach (var street in streetCollection.Streets)
                {
                    context.Streets.Add(street);
                }
                break;

            case 2:
                BoulevardCollection boulevardCollection = ParseBoulevards("artere_2.xml");
                foreach (var boulevard in boulevardCollection.Boulevards)
                {
                    context.Boulevards.Add(boulevard);
                }
                break;

            default:
                throw new ArgumentException("Please choose a number from the list!");
            }

            context.SaveChanges();

            Console.WriteLine("Data imported successfully!");
        }
Beispiel #3
0
        private static async Task Main(string[] args)
        {
            LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());

            NormalizerConfig normalizerConfig = new NormalizerConfig
            {
                StreetTypesAbbreviations = new List <string>
                {
                    "Bd.", "Str.", "Al.", "Cal.", "Şos."
                }
            };

            Console.WriteLine("Please make your choice: ");
            Console.WriteLine("1. Streets");
            Console.WriteLine("2. Boulevards");

            string userChoice = Console.ReadLine();

            int.TryParse(userChoice, out int userOption);

            FailureTrackerDbContext context = InitializeContext();

            switch (userOption)
            {
            case 1:
                StreetCollection streetCollection = ParseStreets("artere_1.xml");
                foreach (var street in streetCollection.Streets)
                {
                    context.Streets.Add(street);
                }
                break;

            case 2:
                BoulevardCollection boulevardCollection = ParseBoulevards("artere_2.xml");
                foreach (var boulevard in boulevardCollection.Boulevards)
                {
                    context.Boulevards.Add(boulevard);
                }
                break;

            default:
                throw new ArgumentException("Please choose a number from the list!");
            }

            context.SaveChanges();

            Console.WriteLine("Data imported successfully!");

            //var json = @$"{GlobalConfig.Path}\result.json";
            //var fileContent = File.ReadAllText(json);
            //var deserialization = JsonConvert.DeserializeObject<List<Table>>(fileContent);
            //var dataNormalizer = new DataNormalizer(normalizerConfig);
            //IEnumerable<Failure> failures = dataNormalizer.DoWork(deserialization);

            //foreach(var failure in failures)
            //{
            //    Console.WriteLine(failure.Address);
            //}

            //var scheduler = new Scheduler(new StdSchedulerFactory());
            //await scheduler.Schedule();

            //await Task.Delay(TimeSpan.FromSeconds(30));
        }