public static void Main() { var appSettings = AppSettings.LoadAppSettings(); InitLogger(); var onenoteApp = new Application(); var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; Log.Debug($"CurrentCulture : {CultureInfo.CurrentCulture}"); Log.Debug($"OneNoteMdExporter version {assemblyVersion}"); var notebooks = onenoteApp.GetNotebooks(); Log.Information("-----------------------"); Log.Information("- OneNote Md Exporter -"); Log.Information($" v{assemblyVersion}"); Log.Information("-----------------------\n"); Log.Information(Localizer.GetString("NotebookFounds"), notebooks.Count); Log.Information(Localizer.GetString("ExportAllNotebooks")); for (int i = 1; i <= notebooks.Count; i++) { Log.Information(Localizer.GetString("ExportNotebookPositionX"), i, notebooks.ElementAt(i - 1).Title); } var input = Console.ReadLine(); if (!Int32.TryParse(input, out var inputInt)) { Log.Information(Localizer.GetString("BadInput")); return; } IList <Notebook> notebookToProcess; if (inputInt == 0) { notebookToProcess = notebooks; } else { try { notebookToProcess = new List <Notebook> { notebooks.ElementAt(inputInt - 1) }; } catch (ArgumentOutOfRangeException) { Log.Information(Localizer.GetString("NotebookNotFound")); return; } } Log.Information(Localizer.GetString("ChooseExportFormat")); Log.Information(Localizer.GetString("ChooseExportFormat1")); Log.Information(Localizer.GetString("ChooseExportFormat2")); var exportFormatTxt = Console.ReadLine(); Log.Information(""); if (!Enum.TryParse <ExportFormat>(exportFormatTxt, true, out var exportFormat)) { Log.Information(Localizer.GetString("BadInput")); return; } var exportService = ExportServiceFactory.GetExportService(exportFormat, appSettings, onenoteApp); foreach (Notebook notebook in notebookToProcess) { Log.Information("\n***************************************"); Log.Information(Localizer.GetString("StartExportingNotebook"), notebook.Title); Log.Information("***************************************"); exportService.ExportNotebook(notebook); var exportPath = Path.GetFullPath(notebook.Title); Log.Information(""); Log.Information(Localizer.GetString("ExportSuccessful"), exportPath); Log.Information(""); } Log.Information(Localizer.GetString("EndOfExport")); Console.ReadLine(); }
private void Export(object obj) { SortedListsOfImagesNames imagesCollectionType = (SortedListsOfImagesNames)obj; ExportService exportService = ExportServiceFactory.GetExportService(ExportTypes.ExportToZip); switch (imagesCollectionType) { case SortedListsOfImagesNames.BeachesSeaside: exportService.Export(BeachesSeaside, imagesCollectionType.ToString()); BeachesSeaside.Clear(); break; case SortedListsOfImagesNames.CarsVehicles: exportService.Export(CarsVehicles, imagesCollectionType.ToString()); CarsVehicles.Clear(); break; case SortedListsOfImagesNames.EventsParties: exportService.Export(EventsParties, imagesCollectionType.ToString()); EventsParties.Clear(); break; case SortedListsOfImagesNames.FoodDrinks: exportService.Export(FoodDrinks, imagesCollectionType.ToString()); FoodDrinks.Clear(); break; case SortedListsOfImagesNames.InteriorObjects: exportService.Export(InteriorObjects, imagesCollectionType.ToString()); InteriorObjects.Clear(); break; case SortedListsOfImagesNames.MacroFlowers: exportService.Export(MacroFlowers, imagesCollectionType.ToString()); MacroFlowers.Clear(); break; case SortedListsOfImagesNames.NatureLandscape: exportService.Export(NatureLandscape, imagesCollectionType.ToString()); NatureLandscape.Clear(); break; case SortedListsOfImagesNames.PaintingsArt: exportService.Export(PaintingsArt, imagesCollectionType.ToString()); PaintingsArt.Clear(); break; case SortedListsOfImagesNames.PeoplePortraits: exportService.Export(PeoplePortraits, imagesCollectionType.ToString()); PeoplePortraits.Clear(); break; case SortedListsOfImagesNames.PetsAnimals: exportService.Export(PetsAnimals, imagesCollectionType.ToString()); PetsAnimals.Clear(); break; case SortedListsOfImagesNames.StreetviewArchitecture: exportService.Export(StreetviewArchitecture, imagesCollectionType.ToString()); StreetviewArchitecture.Clear(); break; case SortedListsOfImagesNames.SunrisesSunsets: exportService.Export(SunrisesSunsets, imagesCollectionType.ToString()); SunrisesSunsets.Clear(); break; case SortedListsOfImagesNames.TextVisuals: exportService.Export(TextVisuals, imagesCollectionType.ToString()); TextVisuals.Clear(); break; default: throw new NoSuchCategoryException("There is no such images category! Contact the application manufacturer!"); } }