Exemplo n.º 1
0
        internal async Task AddToQueryAndImportDatabaseAsync(
            ImportIndexItem importIndexItem,
            ImportSettingsModel importSettings)
        {
            if (!importSettings.IndexMode || _importQuery?.TestConnection() != true)
            {
                if (_appSettings.IsVerbose())
                {
                    _logger.LogInformation(" AddToQueryAndImportDatabaseAsync Ignored - " +
                                           $"IndexMode {importSettings.IndexMode} " +
                                           $"TestConnection {_importQuery?.TestConnection()}");
                }
                return;
            }

            // Add to Normal File Index database
            var query = new QueryFactory(new SetupDatabaseTypes(_appSettings), _query,
                                         _memoryCache, _appSettings, _logger).Query();
            await query !.AddItemAsync(importIndexItem.FileIndexItem);

            // Add to check db, to avoid duplicate input
            var importQuery = new ImportQueryFactory(new SetupDatabaseTypes(_appSettings), _importQuery, _console, _logger).ImportQuery();
            await importQuery.AddAsync(importIndexItem, importSettings.IsConsoleOutputModeDefault());

            await query.DisposeAsync();
        }
Exemplo n.º 2
0
        private void WriteOutputStatus(ImportSettingsModel importSettings, List <ImportIndexItem> result, Stopwatch stopWatch)
        {
            if (importSettings.IsConsoleOutputModeDefault())
            {
                var okCount = result.Count(p => p.Status == ImportStatus.Ok);
                _console.WriteLine($"\nDone Importing {okCount}");
                if (okCount != 0)
                {
                    _console.WriteLine($"Time: {Math.Round(stopWatch.Elapsed.TotalSeconds, 1)} " +
                                       $"sec. or {Math.Round(stopWatch.Elapsed.TotalMinutes, 1)} min.");
                }
                _console.WriteLine($"Failed: {result.Count(p => p.Status != ImportStatus.Ok)}");
            }

            if (importSettings.ConsoleOutputMode != ConsoleOutputMode.Csv)
            {
                return;
            }

            _console.WriteLine($"Id;Status;SourceFullFilePath;SubPath;FileHash");
            foreach (var item in result)
            {
                var filePath = item.Status == ImportStatus.Ok
                                        ? item.FilePath : "";
                _console.WriteLine($"{item.Id};{item.Status};" +
                                   $"{item.SourceFullFilePath};" +
                                   $"{filePath};" +
                                   $"{item.GetFileHashWithUpdate()}");
            }
        }