Esempio n. 1
0
        public async Task StartAsync(string inpxFile, string genresFile, IEnumerable <string> languages, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Import parameters:\n\tinpxFile={0}\n\tgenresFile={1} ", inpxFile, genresFile);

            if (!File.Exists(inpxFile))
            {
                throw new FileNotFoundException($"INPX file '{inpxFile}' not found");
            }
            if (!File.Exists(genresFile))
            {
                throw new FileNotFoundException($"Genres file '{genresFile}' not found");
            }


            _logger.LogInformation("Clean database...");
            _db.CreateSchema();
            _db.Clear();

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            _logger.LogInformation("Loading genres...");
            await LoadGenresAsync(genresFile, cancellationToken);

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            await LoadInpx(inpxFile, languages, cancellationToken);

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            _logger.LogInformation("Vacuum database...");
            _db.Vacuum();

            _logger.LogInformation("Done!");
        }