/// <summary> /// Process the exportation /// </summary> /// <returns><see cref="Task"/></returns> public async Task Export() { try { var loggingTraceBegin = $@"Export started at {DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture)}"; _loggingService.Telemetry.TrackTrace(loggingTraceBegin); Console.WriteLine(loggingTraceBegin); var exports = new[] { ExportType.Shows, ExportType.Movies }; foreach (var export in exports) { // Load export var documents = await _exportService.LoadExport(export); IImportService importService; // Import the documents according to export type switch (export) { case ExportType.Shows: importService = new ImportShowService(new AssetsShowService(_fileService), _loggingService); await importService.Import(documents); break; case ExportType.Movies: importService = new ImportMovieService(new AssetsMovieService(_fileService), _loggingService); await importService.Import(documents); break; default: throw new NotImplementedException(); } } _loggingService.Telemetry.TrackTrace("Flushing Redis database..."); await _cachingService.Flush(); _loggingService.Telemetry.TrackTrace("Flushing Redis database completed."); var loggingTraceEnd = $@"Export ended at {DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture)}"; _loggingService.Telemetry.TrackTrace(loggingTraceEnd); } catch (Exception ex) { _loggingService.Telemetry.TrackException(ex); } }
/// <summary> /// Process the exportation /// </summary> /// <returns><see cref="Task"/></returns> public async Task Export() { try { var loggingTraceBegin = $@"Export started at { DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture) }"; _loggingService.Telemetry.TrackTrace(loggingTraceBegin); Console.WriteLine(loggingTraceBegin); var exports = new[] { ExportType.Movies, ExportType.Shows }; var overProgressOptions = new ProgressBarOptions { BackgroundColor = ConsoleColor.DarkGray }; using (var pbar = Schim.ProgressBar.Create(exports.Length * 2, "overall progress", overProgressOptions)) { foreach (var export in exports) { var stepBarOptions = new ProgressBarOptions { ForegroundColor = ConsoleColor.Cyan, ForegroundColorDone = ConsoleColor.DarkGreen, ProgressCharacter = '─', BackgroundColor = ConsoleColor.DarkGray, }; using (var childProgress = pbar.Spawn(2, $"step {export.ToFriendlyString().ToLowerInvariant()} progress", stepBarOptions)) { // Load export var imports = await _exportService.LoadExport(export, childProgress) ; pbar.Tick(); IImportService importService; // Import the documents according to export type switch (export) { case ExportType.Shows: importService = new ImportShowService( new AssetsShowService(_loggingService, _fileService), _loggingService, _fileService); break; case ExportType.Movies: importService = new ImportMovieService( new AssetsMovieService(_loggingService, _fileService), _loggingService, _fileService); break; default: throw new NotImplementedException(); } await importService.Import(imports, childProgress); pbar.Tick(); } } } await _cachingService.Flush(); var loggingTraceEnd = $@"Export ended at { DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture) }"; _loggingService.Telemetry.TrackTrace(loggingTraceEnd); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); _loggingService.Telemetry.TrackException(ex); } }