Beispiel #1
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            if (CheckConfiguration(configuration))
            {
                Console.WriteLine("Descargando fichero...");

                var downloader = new Downloader(configuration["FileURL:URL"], configuration["FileURL:Directory"]);
                var result     = downloader.Download();

                Console.WriteLine($"Path: {result.FilePath}");
                Console.WriteLine($"Tamaño: {result.Size}bytes");
                Console.WriteLine($"Tiempo de Descarga: {result.DownloadTime.TotalSeconds}s");
                Console.WriteLine($"Hilos en Paralelo: {result.ParallelDownloads}");

                Console.WriteLine("Insertando datos en BBDD...");
                var reader = new CSVReader <StockHistory, StockHistoryMapping>(result.FilePath);
                var bulk   = new BulkInsert <StockHistory>();
                bulk.Execute(configuration.GetConnectionString("StockBBDD"), reader.Read());
                Console.WriteLine("Proceso finalizado!");
                Console.ReadLine();
            }
        }