Esempio n. 1
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var configuration = builder.Build();
            var genres        = new Genres(configuration);
            var types         = new Types(configuration);
            var animes        = new Animes(configuration);
            var animeGenres   = new AnimeGenres(configuration);
            var animeStaging  = new AnimeStaging(configuration);
            var stopWatch     = new System.Diagnostics.Stopwatch();

            stopWatch.Start();
            try
            {
                var anime = animeStaging.Read();
                animes.Save(anime);
                animeGenres.Save(anime);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine($"Run time: {stopWatch.ElapsedMilliseconds} ms");
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var configuration = builder.Build();

            System.Net.ServicePointManager.DefaultConnectionLimit = Int32.MaxValue;
            var genres       = new Genres(configuration);
            var types        = new Types(configuration);
            var animes       = new Animes(configuration);
            var animeGenres  = new AnimeGenres(configuration);
            var animeStaging = new AnimeStaging(configuration);
            var stopWatch    = new System.Diagnostics.Stopwatch();

            stopWatch.Start();
            try
            {
                var saves = animeStaging.Read().Select(async(animeAsync) =>
                {
                    var anime = await animeAsync;
                    await animes.Save(anime);
                    await animeGenres.Save(anime.Id, anime.GenreIds);
                });
                await Task.WhenAll(saves);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine($"Run time: {stopWatch.ElapsedMilliseconds} ms");
        }