From 2dc8bd90d95f18402076ab736cc37681574fa395 Mon Sep 17 00:00:00 2001
From: libgenapps <33476799+libgenapps@users.noreply.github.com>
Date: Mon, 11 May 2020 02:38:56 +0300
Subject: [PATCH] 1.4.0
---
.editorconfig | 16 +
LibgenDesktop.Setup/AppFiles.cs | 3 +
LibgenDesktop.Setup/Constants.cs | 4 +-
.../LibgenDesktop.Setup.csproj | 29 +-
LibgenDesktop.Setup/Utils.cs | 3 +-
LibgenDesktop.Setup/packages.config | 4 +-
LibgenDesktop.sln | 9 +-
LibgenDesktop/App.config | 3 +
LibgenDesktop/App.xaml | 6 +-
LibgenDesktop/App.xaml.cs | 103 ++-
LibgenDesktop/Common/Constants.cs | 37 +-
LibgenDesktop/Common/Environment.cs | 4 +-
LibgenDesktop/Infrastructure/FuncCommand.cs | 20 +-
.../Infrastructure/IWindowContext.cs | 6 +
.../Infrastructure/RegisteredWindows.cs | 8 +-
.../Infrastructure/ViewModelEvent.cs | 3 +-
LibgenDesktop/Infrastructure/WindowContext.cs | 40 +-
.../Infrastructure/WindowExtensions.cs | 88 +++
LibgenDesktop/Infrastructure/WindowManager.cs | 72 +-
LibgenDesktop/LibgenDesktop.csproj | 367 +++++++--
.../Models/Database/LocalDatabase.cs | 577 ++++----------
LibgenDesktop/Models/Database/Migration.cs | 58 +-
.../Models/Database/SearchQueryParser.cs | 58 +-
LibgenDesktop/Models/Database/SqlScripts.cs | 154 ++--
.../{Downloader.cs => DownloadManager.cs} | 325 ++++----
...gs.cs => DownloadManagerBatchEventArgs.cs} | 4 +-
...entArgs.cs => DownloadManagerEventArgs.cs} | 0
...rage.cs => DownloadManagerQueueStorage.cs} | 2 +-
.../Models/Download/DownloadUtils.cs | 263 +++++++
.../Models/Download/LibgenDumpDownloader.cs | 201 +++++
.../Models/Entities/DatabaseMetadata.cs | 10 +
LibgenDesktop/Models/Entities/FictionBook.cs | 185 +----
LibgenDesktop/Models/Export/CsvExporter.cs | 4 +-
LibgenDesktop/Models/Export/Exporter.cs | 3 +-
.../Models/Export/FictionExportObject.cs | 12 +-
.../Models/Export/NonFictionExportObject.cs | 4 +-
.../Models/Export/SciMagExportObject.cs | 4 +-
.../Models/Export/XlsxExportWriter.cs | 1 +
LibgenDesktop/Models/Export/XlsxExporter.cs | 4 +-
.../Models/Import/FictionImporter.cs | 2 +-
LibgenDesktop/Models/Import/Importer.cs | 10 +-
LibgenDesktop/Models/JsonApi/JsonApiClient.cs | 20 +-
LibgenDesktop/Models/Localization/Language.cs | 45 +-
.../Models/Localization/LanguageFormatter.cs | 30 +-
.../Localization/LocalizationStorage.cs | 114 ++-
.../Localizators/AboutWindowLocalizator.cs | 41 -
.../ApplicationUpdateLocalizator.cs | 48 --
.../CommonDetailsTabLocalizator.cs | 44 --
.../CreateDatabaseWindowLocalizator.cs | 49 --
.../Localizators/DatabaseWindowLocalizator.cs | 60 --
.../Localizators/DetailsTabLocalizator.cs | 49 --
.../DownloadManagerLocalizator.cs | 116 ---
.../Localizators/ErrorWindowLocalizator.cs | 27 -
.../Export/ExportPanelLocalizator.cs | 89 +++
.../Export/ExporterLocalizator.cs | 48 ++
.../Export/FictionExporterLocalizator.cs | 60 ++
.../Export/NonFictionExporterLocalizator.cs | 112 +++
.../Export/SciMagExporterLocalizator.cs | 88 +++
.../Localizators/ExportPanelLocalizator.cs | 91 ---
.../Localizators/ExporterLocalizator.cs | 52 --
.../FictionDetailsTabLocalizator.cs | 70 --
.../FictionExporterLocalizator.cs | 64 --
...tionSearchResultsGridColumnsLocalizator.cs | 36 -
.../FictionSearchResultsTabLocalizator.cs | 26 -
.../Localizators/ImportLocalizator.cs | 110 ---
.../Localizators/LibraryTabLocalizator.cs | 59 --
.../Localization/Localizators/Localizator.cs | 17 +-
.../Localizators/MainWindowLocalizator.cs | 48 --
.../Localizators/MessageBoxLocalizator.cs | 25 -
.../NonFictionDetailsTabLocalizator.cs | 136 ----
.../NonFictionExporterLocalizator.cs | 110 ---
...tionSearchResultsGridColumnsLocalizator.cs | 37 -
.../NonFictionSearchResultsTabLocalizator.cs | 26 -
.../SciMagDetailsTabLocalizator.cs | 100 ---
.../Localizators/SciMagExporterLocalizator.cs | 93 ---
...iMagSearchResultsGridColumnsLocalizator.cs | 33 -
.../SciMagSearchResultsTabLocalizator.cs | 26 -
...tionSearchResultsGridColumnsLocalizator.cs | 32 +
...tionSearchResultsGridColumnsLocalizator.cs | 33 +
...iMagSearchResultsGridColumnsLocalizator.cs | 27 +
.../SearchResultsTabLocalizator.cs | 54 --
.../Localizators/SearchTabLocalizator.cs | 53 --
.../Localizators/SettingsWindowLocalizator.cs | 143 ----
.../CollectionsSetupStepLocalizator.cs | 45 ++
.../ConfirmationSetupStepLocalizator.cs | 25 +
.../CreateDatabaseSetupStepLocalizator.cs | 37 +
.../DatabaseOperationSetupStepLocalizator.cs | 19 +
.../DownloadDumpInfoSetupStepLocalizator.cs | 23 +
.../DownloadDumpLinksSetupStepLocalizator.cs | 35 +
.../DownloadDumpsSetupStepLocalizator.cs | 38 +
.../DownloadModeSetupStepLocalizator.cs | 23 +
.../ImportDumpsSetupStepLocalizator.cs | 37 +
.../LanguageSetupStepLocalizator.cs | 15 +
.../SetupModeSetupStepLocalizator.cs | 19 +
.../StepListSetupStepLocalizator.cs | 25 +
.../SqlDebuggerWindowLocalizator.cs | 27 -
.../SynchronizationLocalizator.cs | 93 ---
.../Tabs/CommonDetailsTabLocalizator.cs | 45 ++
.../Tabs/DetailsTabLocalizator.cs | 55 ++
.../Tabs/DownloadManagerTabLocalizator.cs | 132 ++++
.../Tabs/FictionDetailsTabLocalizator.cs | 62 ++
.../FictionSearchResultsTabLocalizator.cs | 22 +
.../Tabs/LibraryTabLocalizator.cs | 57 ++
.../Tabs/NonFictionDetailsTabLocalizator.cs | 132 ++++
.../NonFictionSearchResultsTabLocalizator.cs | 22 +
.../Tabs/SciMagDetailsTabLocalizator.cs | 90 +++
.../Tabs/SciMagSearchResultsTabLocalizator.cs | 22 +
.../Tabs/SearchResultsTabLocalizator.cs | 66 ++
.../Localizators/Tabs/SearchTabLocalizator.cs | 49 ++
.../Windows/AboutWindowLocalizator.cs | 36 +
.../ApplicationUpdateWindowLocalizator.cs | 43 +
.../Windows/DatabaseErrorWindowLocalizator.cs | 39 +
.../Windows/DatabaseWindowLocalizator.cs | 59 ++
.../Windows/ErrorWindowLocalizator.cs | 21 +
.../Windows/ImportWindowLocalizator.cs | 126 +++
.../Windows/MainWindowLocalizator.cs | 40 +
.../Windows/MessageBoxLocalizator.cs | 19 +
.../Windows/SettingsWindowLocalizator.cs | 157 ++++
...tupWizardProxySettingsWindowLocalizator.cs | 37 +
.../Windows/SetupWizardWindowLocalizator.cs | 62 ++
.../Windows/SqlDebuggerWindowLocalizator.cs | 21 +
.../SynchronizationWindowLocalizator.cs | 99 +++
.../Models/Localization/Translation.cs | 227 +++++-
LibgenDesktop/Models/MainModel.cs | 463 +++++------
.../ProgressArgs/DownloadFileProgress.cs | 6 +-
.../ProgressArgs/ImportObjectsProgress.cs | 16 +-
.../ImportWrongTableDefinitionProgress.cs | 14 +
LibgenDesktop/Models/Settings/AppSettings.cs | 79 +-
LibgenDesktop/Models/Settings/Mirrors.cs | 11 +
.../Models/SqlDump/PositioningStreamReader.cs | 6 +
LibgenDesktop/Models/SqlDump/SqlDumpReader.cs | 20 +-
.../Models/SqlDump/TableDefinitions.cs | 59 +-
LibgenDesktop/Models/Update/Updater.cs | 43 +-
LibgenDesktop/Models/Utils/FileUtils.cs | 2 +-
LibgenDesktop/Models/Utils/UrlGenerator.cs | 244 +++---
LibgenDesktop/Resources/Languages/English.lng | 207 ++++-
LibgenDesktop/Resources/Languages/French.lng | 22 -
LibgenDesktop/Resources/Languages/Italian.lng | 745 ++++++++++++++++++
.../Resources/Languages/Portuguse_BR.lng | 745 ++++++++++++++++++
.../Resources/Languages/Romanian.lng | 23 -
LibgenDesktop/Resources/Languages/Russian.lng | 207 ++++-
.../Languages/Simplified Chinese.lng | 23 -
LibgenDesktop/Resources/Languages/Spanish.lng | 22 -
LibgenDesktop/Resources/Languages/Turkish.lng | 23 -
.../Resources/Languages/Ukrainian.lng | 22 -
.../Mirrors/genlibrusec_dbdumps.xslt | 25 +
.../Resources/Mirrors/mirrors.config | 15 +-
LibgenDesktop/Styles/Common.xaml | 71 ++
.../Controls/ExportPanel.xaml} | 0
.../Controls/ImportLogPanel.xaml} | 0
.../Controls/Tab.xaml} | 2 +-
.../Controls/Toolbar.xaml} | 0
.../Styles/SetupSteps/Collections.xaml | 51 ++
.../Styles/SetupSteps/Confirmation.xaml | 37 +
.../Styles/SetupSteps/CreateDatabase.xaml | 27 +
.../Styles/SetupSteps/DatabaseOperation.xaml | 14 +
.../Styles/SetupSteps/DownloadDumpInfo.xaml | 32 +
.../Styles/SetupSteps/DownloadDumpLinks.xaml | 30 +
.../Styles/SetupSteps/DownloadDumps.xaml | 46 ++
.../Styles/SetupSteps/DownloadMode.xaml | 25 +
.../Styles/SetupSteps/ImportDumps.xaml | 19 +
LibgenDesktop/Styles/SetupSteps/Language.xaml | 16 +
.../Styles/SetupSteps/SetupMode.xaml | 15 +
LibgenDesktop/Styles/SetupSteps/StepList.xaml | 21 +
.../Tabs/DownloadManager.xaml} | 8 +-
.../Tabs/FictionDetails.xaml} | 0
.../Tabs/FictionSearchResults.xaml} | 4 +-
.../Tabs/Library.xaml} | 2 +-
.../Tabs/NonFictionDetails.xaml} | 0
.../Tabs/NonFictionSearchResults.xaml} | 4 +-
.../Tabs/SciMagDetails.xaml} | 0
.../Tabs/SciMagSearchResults.xaml} | 2 +-
.../Tabs/Search.xaml} | 2 +-
.../TabStyles.xaml => Styles/Tabs/Tab.xaml} | 0
.../Windows/About.xaml} | 0
.../Windows/ApplicationUpdate.xaml} | 0
.../Windows/Database.xaml} | 0
.../Windows/DatabaseError.xaml} | 4 +-
.../Windows/Error.xaml} | 0
.../Windows/Import.xaml} | 0
.../Windows/Main.xaml} | 3 -
.../Windows/MessageBox.xaml} | 0
.../Windows/Settings.xaml} | 47 +-
LibgenDesktop/Styles/Windows/SetupWizard.xaml | 39 +
.../Windows/SetupWizardProxySettings.xaml | 35 +
.../Windows/SqlDebugger.xaml} | 0
.../Windows/Synchronization.xaml} | 0
.../Windows/Windows.xaml} | 28 +-
.../FictionDetailsItemViewModel.cs | 24 +-
.../NonFictionDetailsItemViewModel.cs | 2 +-
.../SciMagDetailsItemViewModel.cs | 5 +-
.../Library/FictionScanResultItemViewModel.cs | 4 +-
.../NonFictionScanResultItemViewModel.cs | 4 +-
.../ViewModels/Panels/ExportPanelViewModel.cs | 50 +-
.../FictionSearchResultItemViewModel.cs | 7 +
.../NonFictionSearchResultItemViewModel.cs | 9 +-
.../SciMagSearchResultItemViewModel.cs | 8 +-
.../SearchResultItemViewModel.cs | 21 +-
.../Settings/LanguageItemViewModel.cs | 20 +
.../SetupSteps/CollectionsPageViewModel.cs | 392 +++++++++
.../SetupSteps/ConfirmationPageViewModel.cs | 121 +++
.../SetupSteps/CreateDatabasePageViewModel.cs | 269 +++++++
.../DatabaseOperationPageViewModel.cs | 85 ++
.../DownloadDumpInfoPageViewModel.cs | 240 ++++++
.../DownloadDumpLinksPageViewModel.cs | 175 ++++
.../SetupSteps/DownloadDumpsPageViewModel.cs | 463 +++++++++++
.../SetupSteps/DownloadModePageViewModel.cs | 178 +++++
.../SetupSteps/ImportDumpsPageViewModel.cs | 361 +++++++++
.../SetupSteps/LanguagePageViewModel.cs | 72 ++
.../SetupSteps/SetupModePageViewModel.cs | 78 ++
.../SetupSteps/SetupStepPageViewModel.cs | 219 +++++
.../ViewModels/SetupSteps/SetupWizardStep.cs | 19 +
.../SetupSteps/SharedSetupContext.cs | 82 ++
.../SetupSteps/StepListPageViewModel.cs | 65 ++
.../ViewModels/Tabs/DetailsTabViewModel.cs | 40 +-
.../Tabs/DownloadManagerTabViewModel.cs | 109 +--
.../Tabs/FictionDetailsTabViewModel.cs | 7 +-
.../Tabs/FictionSearchResultsTabViewModel.cs | 14 +-
.../ViewModels/Tabs/LibraryTabViewModel.cs | 2 +-
.../Tabs/NonFictionDetailsTabViewModel.cs | 2 +-
.../NonFictionSearchResultsTabViewModel.cs | 14 +-
.../Tabs/SciMagDetailsTabViewModel.cs | 2 +-
.../Tabs/SciMagSearchResultsTabViewModel.cs | 2 +-
.../Tabs/SearchResultsTabViewModel.cs | 39 +-
.../ViewModels/Tabs/SearchTabViewModel.cs | 15 +-
.../Windows/AboutWindowViewModel.cs | 2 +-
.../ApplicationUpdateWindowViewModel.cs | 32 +-
.../Windows/CreateDatabaseWindowViewModel.cs | 192 -----
.../Windows/DatabaseErrorWindowViewModel.cs | 185 +++++
.../Windows/DatabaseWindowViewModel.cs | 124 ++-
.../Windows/ErrorWindowViewModel.cs | 12 +-
.../Windows/ImportWindowViewModel.cs | 158 +++-
.../Windows/LibgenWindowViewModel.cs | 3 +-
.../ViewModels/Windows/MainWindowViewModel.cs | 60 +-
.../Windows/SettingsWindowViewModel.cs | 41 +-
...SetupWizardProxySettingsWindowViewModel.cs | 207 +++++
.../Windows/SetupWizardWindowViewModel.cs | 204 +++++
.../Windows/SqlDebuggerWindowViewModel.cs | 8 +-
.../Windows/SynchronizationWindowViewModel.cs | 8 +-
.../Controls/BookAttributeValueLabel.xaml | 4 +-
.../Controls/BookDataGridContextMenu.xaml | 14 +
.../Views/Controls/ControlExtensions.cs | 3 +-
...erListBox.cs => DownloadManagerListBox.cs} | 13 +-
LibgenDesktop/Views/Controls/ExportPanel.xaml | 2 +-
.../Views/Controls/ImportLogPanel.xaml | 2 +-
.../Views/Controls/LanguageComboBox.xaml | 97 +++
.../Views/Controls/LanguageComboBox.xaml.cs | 28 +
.../Views/Controls/LibgenDesktopWindow.cs | 39 +-
LibgenDesktop/Views/Controls/Link.xaml | 20 +
LibgenDesktop/Views/Controls/Link.xaml.cs | 76 ++
LibgenDesktop/Views/Controls/Toolbar.xaml | 4 +-
LibgenDesktop/Views/Controls/Toolbar.xaml.cs | 4 +-
.../Views/SetupSteps/CollectionsPage.xaml | 52 ++
.../Views/SetupSteps/CollectionsPage.xaml.cs | 12 +
.../Views/SetupSteps/ConfirmationPage.xaml | 21 +
.../Views/SetupSteps/ConfirmationPage.xaml.cs | 12 +
.../Views/SetupSteps/CreateDatabasePage.xaml | 25 +
.../SetupSteps/CreateDatabasePage.xaml.cs | 12 +
.../SetupSteps/DatabaseOperationPage.xaml | 14 +
.../SetupSteps/DatabaseOperationPage.xaml.cs | 12 +
.../SetupSteps/DownloadDumpInfoPage.xaml | 25 +
.../SetupSteps/DownloadDumpInfoPage.xaml.cs | 12 +
.../SetupSteps/DownloadDumpLinksPage.xaml | 28 +
.../SetupSteps/DownloadDumpLinksPage.xaml.cs | 12 +
.../Views/SetupSteps/DownloadDumpsPage.xaml | 74 ++
.../SetupSteps/DownloadDumpsPage.xaml.cs | 12 +
.../Views/SetupSteps/DownloadModePage.xaml | 22 +
.../Views/SetupSteps/DownloadModePage.xaml.cs | 12 +
.../Views/SetupSteps/ImportDumpsPage.xaml | 38 +
.../Views/SetupSteps/ImportDumpsPage.xaml.cs | 12 +
.../Views/SetupSteps/LanguagePage.xaml | 13 +
.../Views/SetupSteps/LanguagePage.xaml.cs | 12 +
.../Views/SetupSteps/SetupModePage.xaml | 14 +
.../Views/SetupSteps/SetupModePage.xaml.cs | 12 +
.../Views/SetupSteps/StepListPage.xaml | 28 +
.../Views/SetupSteps/StepListPage.xaml.cs | 12 +
LibgenDesktop/Views/Styles/CommonStyles.xaml | 27 -
.../Views/Tabs/DownloadManagerTab.xaml | 13 +-
.../Views/Tabs/DownloadManagerTab.xaml.cs | 4 +-
.../Views/Tabs/FictionDetailsTab.xaml | 42 +-
.../Views/Tabs/FictionDetailsTab.xaml.cs | 18 +-
.../Views/Tabs/FictionSearchResultsTab.xaml | 7 +-
LibgenDesktop/Views/Tabs/LibraryTab.xaml | 2 +-
.../Views/Tabs/NonFictionDetailsTab.xaml | 2 +-
.../Views/Tabs/NonFictionDetailsTab.xaml.cs | 18 +-
.../Tabs/NonFictionSearchResultsTab.xaml | 7 +-
.../Views/Tabs/SciMagDetailsTab.xaml | 2 +-
.../Views/Tabs/SciMagDetailsTab.xaml.cs | 18 +-
.../Views/Tabs/SciMagSearchResultsTab.xaml | 2 +-
LibgenDesktop/Views/Tabs/SearchTab.xaml | 2 +-
.../Views/Utils/DataGridExtensions.cs | 4 +-
.../Views/Utils/PasswordBoxExtensions.cs | 33 +-
LibgenDesktop/Views/Windows/AboutWindow.xaml | 2 +-
.../Windows/ApplicationUpdateWindow.xaml | 2 +-
.../Views/Windows/CreateDatabaseWindow.xaml | 26 -
.../Views/Windows/DatabaseErrorWindow.xaml | 23 +
...ow.xaml.cs => DatabaseErrorWindow.xaml.cs} | 4 +-
.../Views/Windows/DatabaseWindow.xaml | 3 +-
LibgenDesktop/Views/Windows/ErrorWindow.xaml | 2 +-
LibgenDesktop/Views/Windows/ImportWindow.xaml | 4 +-
LibgenDesktop/Views/Windows/MainWindow.xaml | 2 +-
.../Views/Windows/MessageBoxWindow.xaml | 2 +-
.../Views/Windows/MessageBoxWindow.xaml.cs | 3 +-
.../Views/Windows/SettingsWindow.xaml | 6 +-
.../SetupWizardProxySettingsWindow.xaml | 50 ++
.../SetupWizardProxySettingsWindow.xaml.cs | 20 +
.../Views/Windows/SetupWizardWindow.xaml | 61 ++
.../Views/Windows/SetupWizardWindow.xaml.cs | 10 +
.../Views/Windows/SqlDebuggerWindow.xaml | 2 +-
.../Views/Windows/SynchronizationWindow.xaml | 2 +-
LibgenDesktop/app.manifest | 6 +
311 files changed, 12245 insertions(+), 4519 deletions(-)
create mode 100644 .editorconfig
create mode 100644 LibgenDesktop/Infrastructure/WindowExtensions.cs
rename LibgenDesktop/Models/Download/{Downloader.cs => DownloadManager.cs} (90%)
rename LibgenDesktop/Models/Download/{DownloaderBatchEventArgs.cs => DownloadManagerBatchEventArgs.cs} (91%)
rename LibgenDesktop/Models/Download/{DownloaderEventArgs.cs => DownloadManagerEventArgs.cs} (100%)
rename LibgenDesktop/Models/Download/{DownloadQueueStorage.cs => DownloadManagerQueueStorage.cs} (99%)
create mode 100644 LibgenDesktop/Models/Download/DownloadUtils.cs
create mode 100644 LibgenDesktop/Models/Download/LibgenDumpDownloader.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/AboutWindowLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/ApplicationUpdateLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/CommonDetailsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/CreateDatabaseWindowLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/DatabaseWindowLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/DetailsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/DownloadManagerLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/ErrorWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Export/ExportPanelLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Export/ExporterLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Export/FictionExporterLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Export/NonFictionExporterLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Export/SciMagExporterLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/ExportPanelLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/ExporterLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/FictionDetailsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/FictionExporterLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/FictionSearchResultsGridColumnsLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/FictionSearchResultsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/ImportLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/LibraryTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/MainWindowLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/MessageBoxLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/NonFictionDetailsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/NonFictionExporterLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/NonFictionSearchResultsGridColumnsLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/NonFictionSearchResultsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SciMagDetailsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SciMagExporterLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SciMagSearchResultsGridColumnsLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SciMagSearchResultsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SearchResultGrids/FictionSearchResultsGridColumnsLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SearchResultGrids/NonFictionSearchResultsGridColumnsLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SearchResultGrids/SciMagSearchResultsGridColumnsLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SearchResultsTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SearchTabLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SettingsWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/CollectionsSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/ConfirmationSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/CreateDatabaseSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/DatabaseOperationSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/DownloadDumpInfoSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/DownloadDumpLinksSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/DownloadDumpsSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/DownloadModeSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/ImportDumpsSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/LanguageSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/SetupModeSetupStepLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/SetupSteps/StepListSetupStepLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SqlDebuggerWindowLocalizator.cs
delete mode 100644 LibgenDesktop/Models/Localization/Localizators/SynchronizationLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/CommonDetailsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/DetailsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/DownloadManagerTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/FictionDetailsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/FictionSearchResultsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/LibraryTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/NonFictionDetailsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/NonFictionSearchResultsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/SciMagDetailsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/SciMagSearchResultsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/SearchResultsTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Tabs/SearchTabLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/AboutWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/ApplicationUpdateWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/DatabaseErrorWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/DatabaseWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/ErrorWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/ImportWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/MainWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/MessageBoxLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/SettingsWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/SetupWizardProxySettingsWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/SetupWizardWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/SqlDebuggerWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/Localization/Localizators/Windows/SynchronizationWindowLocalizator.cs
create mode 100644 LibgenDesktop/Models/ProgressArgs/ImportWrongTableDefinitionProgress.cs
create mode 100644 LibgenDesktop/Resources/Languages/Italian.lng
create mode 100644 LibgenDesktop/Resources/Languages/Portuguse_BR.lng
create mode 100644 LibgenDesktop/Resources/Mirrors/genlibrusec_dbdumps.xslt
create mode 100644 LibgenDesktop/Styles/Common.xaml
rename LibgenDesktop/{Views/Styles/ExportPanelStyles.xaml => Styles/Controls/ExportPanel.xaml} (100%)
rename LibgenDesktop/{Views/Styles/ImportLogPanelStyles.xaml => Styles/Controls/ImportLogPanel.xaml} (100%)
rename LibgenDesktop/{Views/Styles/TabControlStyles.xaml => Styles/Controls/Tab.xaml} (99%)
rename LibgenDesktop/{Views/Styles/ToolbarStyles.xaml => Styles/Controls/Toolbar.xaml} (100%)
create mode 100644 LibgenDesktop/Styles/SetupSteps/Collections.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/Confirmation.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/CreateDatabase.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/DatabaseOperation.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/DownloadDumpInfo.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/DownloadDumpLinks.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/DownloadDumps.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/DownloadMode.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/ImportDumps.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/Language.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/SetupMode.xaml
create mode 100644 LibgenDesktop/Styles/SetupSteps/StepList.xaml
rename LibgenDesktop/{Views/Styles/DownloadManagerTabStyles.xaml => Styles/Tabs/DownloadManager.xaml} (95%)
rename LibgenDesktop/{Views/Styles/FictionDetailsTabStyles.xaml => Styles/Tabs/FictionDetails.xaml} (100%)
rename LibgenDesktop/{Views/Styles/FictionSearchResultsTabStyles.xaml => Styles/Tabs/FictionSearchResults.xaml} (89%)
rename LibgenDesktop/{Views/Styles/LibraryTabStyles.xaml => Styles/Tabs/Library.xaml} (95%)
rename LibgenDesktop/{Views/Styles/NonFictionDetailsTabStyles.xaml => Styles/Tabs/NonFictionDetails.xaml} (100%)
rename LibgenDesktop/{Views/Styles/NonFictionSearchResultsTabStyles.xaml => Styles/Tabs/NonFictionSearchResults.xaml} (90%)
rename LibgenDesktop/{Views/Styles/SciMagDetailsTabStyles.xaml => Styles/Tabs/SciMagDetails.xaml} (100%)
rename LibgenDesktop/{Views/Styles/SciMagSearchResultsTabStyles.xaml => Styles/Tabs/SciMagSearchResults.xaml} (97%)
rename LibgenDesktop/{Views/Styles/SearchTabStyles.xaml => Styles/Tabs/Search.xaml} (97%)
rename LibgenDesktop/{Views/Styles/TabStyles.xaml => Styles/Tabs/Tab.xaml} (100%)
rename LibgenDesktop/{Views/Styles/AboutWindowStyles.xaml => Styles/Windows/About.xaml} (100%)
rename LibgenDesktop/{Views/Styles/ApplicationUpdateWindowStyles.xaml => Styles/Windows/ApplicationUpdate.xaml} (100%)
rename LibgenDesktop/{Views/Styles/DatabaseWindowStyles.xaml => Styles/Windows/Database.xaml} (100%)
rename LibgenDesktop/{Views/Styles/CreateDatabaseWindowStyles.xaml => Styles/Windows/DatabaseError.xaml} (90%)
rename LibgenDesktop/{Views/Styles/ErrorWindowStyles.xaml => Styles/Windows/Error.xaml} (100%)
rename LibgenDesktop/{Views/Styles/ImportWindowStyles.xaml => Styles/Windows/Import.xaml} (100%)
rename LibgenDesktop/{Views/Styles/MainWindowStyles.xaml => Styles/Windows/Main.xaml} (88%)
rename LibgenDesktop/{Views/Styles/MessageBoxWindowStyles.xaml => Styles/Windows/MessageBox.xaml} (100%)
rename LibgenDesktop/{Views/Styles/SettingsWindowStyles.xaml => Styles/Windows/Settings.xaml} (75%)
create mode 100644 LibgenDesktop/Styles/Windows/SetupWizard.xaml
create mode 100644 LibgenDesktop/Styles/Windows/SetupWizardProxySettings.xaml
rename LibgenDesktop/{Views/Styles/SqlDebuggerWindowStyles.xaml => Styles/Windows/SqlDebugger.xaml} (100%)
rename LibgenDesktop/{Views/Styles/SynchronizationWindowStyles.xaml => Styles/Windows/Synchronization.xaml} (100%)
rename LibgenDesktop/{Views/Styles/WindowStyles.xaml => Styles/Windows/Windows.xaml} (85%)
create mode 100644 LibgenDesktop/ViewModels/Settings/LanguageItemViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/CollectionsPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/ConfirmationPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/CreateDatabasePageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/DatabaseOperationPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/DownloadDumpInfoPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/DownloadDumpLinksPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/DownloadDumpsPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/DownloadModePageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/ImportDumpsPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/LanguagePageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/SetupModePageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/SetupStepPageViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/SetupWizardStep.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/SharedSetupContext.cs
create mode 100644 LibgenDesktop/ViewModels/SetupSteps/StepListPageViewModel.cs
delete mode 100644 LibgenDesktop/ViewModels/Windows/CreateDatabaseWindowViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/Windows/DatabaseErrorWindowViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/Windows/SetupWizardProxySettingsWindowViewModel.cs
create mode 100644 LibgenDesktop/ViewModels/Windows/SetupWizardWindowViewModel.cs
rename LibgenDesktop/Views/Controls/{DownloaderListBox.cs => DownloadManagerListBox.cs} (91%)
create mode 100644 LibgenDesktop/Views/Controls/LanguageComboBox.xaml
create mode 100644 LibgenDesktop/Views/Controls/LanguageComboBox.xaml.cs
create mode 100644 LibgenDesktop/Views/Controls/Link.xaml
create mode 100644 LibgenDesktop/Views/Controls/Link.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/CollectionsPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/CollectionsPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/ConfirmationPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/ConfirmationPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/CreateDatabasePage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/CreateDatabasePage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/DatabaseOperationPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/DatabaseOperationPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadDumpInfoPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadDumpInfoPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadDumpLinksPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadDumpLinksPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadDumpsPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadDumpsPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadModePage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/DownloadModePage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/ImportDumpsPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/ImportDumpsPage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/LanguagePage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/LanguagePage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/SetupModePage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/SetupModePage.xaml.cs
create mode 100644 LibgenDesktop/Views/SetupSteps/StepListPage.xaml
create mode 100644 LibgenDesktop/Views/SetupSteps/StepListPage.xaml.cs
delete mode 100644 LibgenDesktop/Views/Styles/CommonStyles.xaml
delete mode 100644 LibgenDesktop/Views/Windows/CreateDatabaseWindow.xaml
create mode 100644 LibgenDesktop/Views/Windows/DatabaseErrorWindow.xaml
rename LibgenDesktop/Views/Windows/{CreateDatabaseWindow.xaml.cs => DatabaseErrorWindow.xaml.cs} (57%)
create mode 100644 LibgenDesktop/Views/Windows/SetupWizardProxySettingsWindow.xaml
create mode 100644 LibgenDesktop/Views/Windows/SetupWizardProxySettingsWindow.xaml.cs
create mode 100644 LibgenDesktop/Views/Windows/SetupWizardWindow.xaml
create mode 100644 LibgenDesktop/Views/Windows/SetupWizardWindow.xaml.cs
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..3a8bbb3
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+[*.cs]
+
+# CA1810: Initialize reference type static fields inline
+dotnet_diagnostic.CA1810.severity = none
+
+# CA1031: Do not catch general exception types
+dotnet_diagnostic.CA1031.severity = none
+
+# IDE0039: Use local function
+csharp_style_pattern_local_over_anonymous_function = true:none
+
+# CA2100: Review SQL queries for security vulnerabilities
+dotnet_diagnostic.CA2100.severity = none
+
+# IDE0049: Simplify Names
+dotnet_style_predefined_type_for_locals_parameters_members = false:silent
diff --git a/LibgenDesktop.Setup/AppFiles.cs b/LibgenDesktop.Setup/AppFiles.cs
index e2b99ce..64397bb 100644
--- a/LibgenDesktop.Setup/AppFiles.cs
+++ b/LibgenDesktop.Setup/AppFiles.cs
@@ -27,6 +27,8 @@ static AppFiles()
X64.Add(new AppFile(@"x64\SQLite.Interop.dll", "SQLite.Interop.dll"));
AddFile(@"Languages\English.lng");
AddFile(@"Languages\French.lng");
+ AddFile(@"Languages\Italian.lng");
+ AddFile(@"Languages\Portuguse_BR.lng");
AddFile(@"Languages\Romanian.lng");
AddFile(@"Languages\Russian.lng");
AddFile(@"Languages\Simplified Chinese.lng");
@@ -39,6 +41,7 @@ static AppFiles()
AddFile(@"Mirrors\booklid_org_step2.xslt");
AddFile(@"Mirrors\booksc_org_step1.xslt");
AddFile(@"Mirrors\booksc_org_step2.xslt");
+ AddFile(@"Mirrors\genlibrusec_dbdumps.xslt");
AddFile(@"Mirrors\libgen_lc_fiction.xslt");
AddFile(@"Mirrors\libgen_lc_nonfiction.xslt");
AddFile(@"Mirrors\libgen_lc_scimag.xslt");
diff --git a/LibgenDesktop.Setup/Constants.cs b/LibgenDesktop.Setup/Constants.cs
index ebc1e3b..e463b4a 100644
--- a/LibgenDesktop.Setup/Constants.cs
+++ b/LibgenDesktop.Setup/Constants.cs
@@ -2,8 +2,8 @@
{
internal static class Constants
{
- public const string CURRENT_VERSION = "1.3.5";
- public const string TITLE_VERSION = "1.3.5";
+ public const string CURRENT_VERSION = "1.4.0";
+ public const string TITLE_VERSION = "1.4.0";
public const string PRODUCT_TITLE_FORMAT = "Libgen Desktop " + TITLE_VERSION + " ({0}-bit)";
public const string SHORTCUT_TITLE_FORMAT = "Libgen Desktop ({0}-bit)";
public const string PRODUCT_COMPANY = "Libgen Apps";
diff --git a/LibgenDesktop.Setup/LibgenDesktop.Setup.csproj b/LibgenDesktop.Setup/LibgenDesktop.Setup.csproj
index df7d341..ac26cfe 100644
--- a/LibgenDesktop.Setup/LibgenDesktop.Setup.csproj
+++ b/LibgenDesktop.Setup/LibgenDesktop.Setup.csproj
@@ -11,7 +11,8 @@
WixSharp Setup
v3.5
512
-
+
+
AnyCPU
@@ -43,10 +44,10 @@
- ..\packages\WixSharp.bin.1.9.2\lib\BootstrapperCore.dll
+ ..\packages\WixSharp.bin.1.14.3\lib\BootstrapperCore.dll
- ..\packages\WixSharp.bin.1.9.2\lib\Microsoft.Deployment.WindowsInstaller.dll
+ ..\packages\WixSharp.bin.1.14.3\lib\Microsoft.Deployment.WindowsInstaller.dll
..\packages\SharpCompress.0.22.0\lib\net35\SharpCompress.dll
@@ -57,14 +58,14 @@
-
- ..\packages\WixSharp.bin.1.9.2\lib\WixSharp.dll
+
+ ..\packages\WixSharp.bin.1.14.3\lib\WixSharp.dll
-
- ..\packages\WixSharp.bin.1.9.2\lib\WixSharp.Msi.dll
+
+ ..\packages\WixSharp.bin.1.14.3\lib\WixSharp.Msi.dll
-
- ..\packages\WixSharp.bin.1.9.2\lib\WixSharp.UI.dll
+
+ ..\packages\WixSharp.bin.1.14.3\lib\WixSharp.UI.dll
@@ -92,14 +93,14 @@
-->
-
+
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
+
+
-
-
+
\ No newline at end of file
diff --git a/LibgenDesktop.Setup/Utils.cs b/LibgenDesktop.Setup/Utils.cs
index 62690ca..d917ca1 100644
--- a/LibgenDesktop.Setup/Utils.cs
+++ b/LibgenDesktop.Setup/Utils.cs
@@ -1,5 +1,4 @@
-using System.Collections.Generic;
-using System.IO;
+using System.IO;
namespace LibgenDesktop.Setup
{
diff --git a/LibgenDesktop.Setup/packages.config b/LibgenDesktop.Setup/packages.config
index b1dc5fa..2ec7426 100644
--- a/LibgenDesktop.Setup/packages.config
+++ b/LibgenDesktop.Setup/packages.config
@@ -1,6 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/LibgenDesktop.sln b/LibgenDesktop.sln
index 69123a8..65dafba 100644
--- a/LibgenDesktop.sln
+++ b/LibgenDesktop.sln
@@ -1,12 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2010
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29911.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibgenDesktop", "LibgenDesktop\LibgenDesktop.csproj", "{7158E1EB-44F7-4C26-BF9A-DA055F85D0BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibgenDesktop.Setup", "LibgenDesktop.Setup\LibgenDesktop.Setup.csproj", "{44555887-C439-470C-944D-8866EC3D7067}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DD4F677-B56F-4422-90B9-4A8A1CC6D69B}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug x64|Any CPU = Debug x64|Any CPU
diff --git a/LibgenDesktop/App.config b/LibgenDesktop/App.config
index 8e15646..7bf9820 100644
--- a/LibgenDesktop/App.config
+++ b/LibgenDesktop/App.config
@@ -3,4 +3,7 @@
+
+
+
\ No newline at end of file
diff --git a/LibgenDesktop/App.xaml b/LibgenDesktop/App.xaml
index 12ba901..7e5ae58 100644
--- a/LibgenDesktop/App.xaml
+++ b/LibgenDesktop/App.xaml
@@ -10,9 +10,9 @@
-
-
-
+
+
+
diff --git a/LibgenDesktop/App.xaml.cs b/LibgenDesktop/App.xaml.cs
index b6272de..026fa0c 100644
--- a/LibgenDesktop/App.xaml.cs
+++ b/LibgenDesktop/App.xaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using LibgenDesktop.Common;
@@ -10,22 +11,106 @@ namespace LibgenDesktop
{
public partial class App : Application
{
+ private enum DatabaseOpenResult
+ {
+ IN_PROGRESS = 1,
+ DATABASE_OPENED,
+ SHOW_SETUP_WIZARD,
+ EXIT_REQUESTED
+ }
+
private MainModel mainModel;
- protected override void OnStartup(StartupEventArgs e)
+ protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SetupExceptionHandlers();
try
{
mainModel = new MainModel();
- if (mainModel.LocalDatabaseStatus == MainModel.DatabaseStatus.OPENED)
+ string databaseFilePath = mainModel.AppSettings.DatabaseFileName;
+ bool saveDatabaseFilePathAfterSuccessfulOpen = false;
+ MainModel.OpenDatabaseOptions openDatabaseOptions = MainModel.OpenDatabaseOptions.NONE;
+ DatabaseOpenResult databaseOpenResult = DatabaseOpenResult.IN_PROGRESS;
+ while (databaseOpenResult == DatabaseOpenResult.IN_PROGRESS)
{
- ShowMainWindow(mainModel);
+ MainModel.DatabaseStatus databaseStatus = await mainModel.OpenDatabase(databaseFilePath, openDatabaseOptions);
+ if (databaseStatus == MainModel.DatabaseStatus.OPENED)
+ {
+ databaseOpenResult = DatabaseOpenResult.DATABASE_OPENED;
+ if (saveDatabaseFilePathAfterSuccessfulOpen)
+ {
+ mainModel.AppSettings.DatabaseFileName = MainModel.GetDatabaseNormalizedPath(databaseFilePath);
+ mainModel.SaveSettings();
+ }
+ }
+ else if (databaseStatus == MainModel.DatabaseStatus.NOT_SET)
+ {
+ databaseOpenResult = DatabaseOpenResult.SHOW_SETUP_WIZARD;
+ }
+ else
+ {
+ DatabaseErrorWindowViewModel.OptionSet optionSet;
+ switch (databaseStatus)
+ {
+ case MainModel.DatabaseStatus.NOT_FOUND:
+ optionSet = DatabaseErrorWindowViewModel.OptionSet.DATABASE_NOT_FOUND;
+ break;
+ case MainModel.DatabaseStatus.POSSIBLE_DUMP_FILE:
+ optionSet = DatabaseErrorWindowViewModel.OptionSet.DATABASE_DUMP_FILE;
+ break;
+ case MainModel.DatabaseStatus.OLD_FICTION_SCHEMA:
+ optionSet = DatabaseErrorWindowViewModel.OptionSet.OLD_FICTION_SCHEMA;
+ break;
+ case MainModel.DatabaseStatus.CORRUPTED:
+ optionSet = DatabaseErrorWindowViewModel.OptionSet.DATABASE_NOT_VALID;
+ break;
+ case MainModel.DatabaseStatus.SERVER_DATABASE:
+ optionSet = DatabaseErrorWindowViewModel.OptionSet.SERVER_DATABASE;
+ break;
+ default:
+ throw new Exception($"Unknown database status: {databaseStatus}.");
+ }
+ DatabaseErrorWindowViewModel databaseErrorWindowViewModel = new DatabaseErrorWindowViewModel(mainModel, optionSet, databaseFilePath);
+ IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.DATABASE_ERROR_WINDOW,
+ databaseErrorWindowViewModel);
+ windowContext.ShowDialog();
+ switch (databaseErrorWindowViewModel.Result)
+ {
+ case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.OPEN_ANOTHER_DATABASE:
+ OpenFileDialogResult selectDatabaseFileDialogResult = DatabaseWindowViewModel.SelectDatabaseFile(mainModel);
+ if (selectDatabaseFileDialogResult.DialogResult)
+ {
+ databaseFilePath = selectDatabaseFileDialogResult.SelectedFilePaths.First();
+ saveDatabaseFilePathAfterSuccessfulOpen = true;
+ }
+ break;
+ case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.START_SETUP_WIZARD:
+ databaseOpenResult = DatabaseOpenResult.SHOW_SETUP_WIZARD;
+ break;
+ case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.DELETE_FICTION:
+ openDatabaseOptions = MainModel.OpenDatabaseOptions.MIGRATE_FICTION;
+ break;
+ case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.EXIT:
+ case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.CANCEL:
+ databaseOpenResult = DatabaseOpenResult.EXIT_REQUESTED;
+ break;
+ default:
+ throw new Exception($"Unknown database error view model result: {databaseErrorWindowViewModel.Result}.");
+ }
+ }
}
- else
+ switch (databaseOpenResult)
{
- ShowCreateDatabaseWindow(mainModel);
+ case DatabaseOpenResult.DATABASE_OPENED:
+ ShowMainWindow(mainModel);
+ break;
+ case DatabaseOpenResult.SHOW_SETUP_WIZARD:
+ ShowSetupWizardWindow(mainModel);
+ break;
+ default:
+ Close();
+ break;
}
}
catch (Exception exception)
@@ -44,10 +129,10 @@ private void ShowMainWindow(MainModel mainModel)
windowContext.Show();
}
- private void ShowCreateDatabaseWindow(MainModel mainModel)
+ private void ShowSetupWizardWindow(MainModel mainModel)
{
- CreateDatabaseWindowViewModel createDatabaseWindowViewModel = new CreateDatabaseWindowViewModel(mainModel);
- IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.CREATE_DATABASE_WINDOW, createDatabaseWindowViewModel);
+ SetupWizardWindowViewModel setupWizardWindowViewModel = new SetupWizardWindowViewModel(mainModel);
+ IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.SETUP_WIZARD_WINDOW, setupWizardWindowViewModel);
bool? result = windowContext.ShowDialog();
if (result == true)
{
@@ -101,7 +186,7 @@ private void Close()
{
if (mainModel != null)
{
- mainModel.Downloader.Shutdown();
+ mainModel.DownloadManager.Shutdown();
mainModel.Dispose();
}
Shutdown();
diff --git a/LibgenDesktop/Common/Constants.cs b/LibgenDesktop/Common/Constants.cs
index f5bddea..856dd10 100644
--- a/LibgenDesktop/Common/Constants.cs
+++ b/LibgenDesktop/Common/Constants.cs
@@ -5,10 +5,10 @@ namespace LibgenDesktop.Common
internal static class Constants
{
public const string DATABASE_METADATA_APP_NAME = "LibgenDesktop";
- public const string CURRENT_VERSION = "1.3.5";
- public const string CURRENT_GITHUB_RELEASE_NAME = "1.3.5";
- public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2019, 11, 13);
- public const string CURRENT_DATABASE_VERSION = "1.2.1";
+ public const string CURRENT_VERSION = "1.4.0";
+ public const string CURRENT_GITHUB_RELEASE_NAME = "1.4.0";
+ public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2020, 05, 10);
+ public const string CURRENT_DATABASE_VERSION = "1.4";
public const string APP_SETTINGS_FILE_NAME = "libgen.config";
public const string MIRRORS_DIRECTORY_NAME = "Mirrors";
@@ -18,6 +18,7 @@ internal static class Constants
public const string DEFAULT_DOWNLOAD_DIRECTORY_NAME = "Downloads";
public const string DOWNLOAD_LIST_FILE_NAME = "downloads.json";
+ public const double DEFAULT_FONT_SIZE = 15;
public const int MAIN_WINDOW_MIN_WIDTH = 1050;
public const int MAIN_WINDOW_MIN_HEIGHT = 500;
public const int NON_FICTION_DETAILS_WINDOW_MIN_WIDTH = 1000;
@@ -26,6 +27,7 @@ internal static class Constants
public const int NON_FICTION_GRID_AUTHORS_COLUMN_MIN_WIDTH = 150;
public const int NON_FICTION_GRID_SERIES_COLUMN_MIN_WIDTH = 150;
public const int NON_FICTION_GRID_YEAR_COLUMN_MIN_WIDTH = 60;
+ public const int NON_FICTION_GRID_LANGUAGE_COLUMN_MIN_WIDTH = 150;
public const int NON_FICTION_GRID_PUBLISHER_COLUMN_MIN_WIDTH = 150;
public const int NON_FICTION_GRID_FORMAT_COLUMN_MIN_WIDTH = 80;
public const int NON_FICTION_GRID_FILESIZE_COLUMN_MIN_WIDTH = 130;
@@ -37,6 +39,7 @@ internal static class Constants
public const int FICTION_GRID_AUTHORS_COLUMN_MIN_WIDTH = 150;
public const int FICTION_GRID_SERIES_COLUMN_MIN_WIDTH = 150;
public const int FICTION_GRID_YEAR_COLUMN_MIN_WIDTH = 60;
+ public const int FICTION_GRID_LANGUAGE_COLUMN_MIN_WIDTH = 150;
public const int FICTION_GRID_PUBLISHER_COLUMN_MIN_WIDTH = 150;
public const int FICTION_GRID_FORMAT_COLUMN_MIN_WIDTH = 80;
public const int FICTION_GRID_FILESIZE_COLUMN_MIN_WIDTH = 130;
@@ -59,7 +62,8 @@ internal static class Constants
public const int ERROR_WINDOW_MIN_HEIGHT = 300;
public const int IMPORT_WINDOW_MIN_WIDTH = 530;
public const int IMPORT_WINDOW_MIN_HEIGHT = 400;
- public const int CREATE_DATABASE_WINDOW_WIDTH = 500;
+ public const int SETUP_WIZARD_WINDOW_MIN_WIDTH = 1050;
+ public const int SETUP_WIZARD_WINDOW_MIN_HEIGHT = 500;
public const int LIBRARY_WINDOW_DEFAULT_WIDTH = 760;
public const int LIBRARY_WINDOW_DEFAULT_HEIGHT = 550;
public const int LIBRARY_WINDOW_MIN_WIDTH = 760;
@@ -73,6 +77,7 @@ internal static class Constants
public const int SYNCHRONIZATION_WINDOW_MIN_HEIGHT = 400;
public const int APPLICATION_UPDATE_WINDOW_WIDTH = 700;
public const int DATABASE_WINDOW_WIDTH = 500;
+ public const int DATABASE_ERROR_WINDOW_WIDTH = 700;
public const int ABOUT_WINDOW_WIDTH = 670;
public const int MESSAGE_BOX_WINDOW_WIDTH = 500;
public const int SQL_DEBUGGER_WINDOW_DEFAULT_WIDTH = 620;
@@ -90,6 +95,7 @@ internal static class Constants
public const int DEFAULT_NON_FICTION_GRID_AUTHORS_COLUMN_WIDTH = 200;
public const int DEFAULT_NON_FICTION_GRID_SERIES_COLUMN_WIDTH = 180;
public const int DEFAULT_NON_FICTION_GRID_YEAR_COLUMN_WIDTH = 60;
+ public const int DEFAULT_NON_FICTION_GRID_LANGUAGE_COLUMN_WIDTH = 180;
public const int DEFAULT_NON_FICTION_GRID_PUBLISHER_COLUMN_WIDTH = 180;
public const int DEFAULT_NON_FICTION_GRID_FORMAT_COLUMN_WIDTH = 100;
public const int DEFAULT_NON_FICTION_GRID_FILESIZE_COLUMN_WIDTH = 150;
@@ -101,6 +107,7 @@ internal static class Constants
public const int DEFAULT_FICTION_GRID_AUTHORS_COLUMN_WIDTH = 200;
public const int DEFAULT_FICTION_GRID_SERIES_COLUMN_WIDTH = 180;
public const int DEFAULT_FICTION_GRID_YEAR_COLUMN_WIDTH = 60;
+ public const int DEFAULT_FICTION_GRID_LANGUAGE_COLUMN_WIDTH = 180;
public const int DEFAULT_FICTION_GRID_PUBLISHER_COLUMN_WIDTH = 180;
public const int DEFAULT_FICTION_GRID_FORMAT_COLUMN_WIDTH = 100;
public const int DEFAULT_FICTION_GRID_FILESIZE_COLUMN_WIDTH = 150;
@@ -114,8 +121,11 @@ internal static class Constants
public const int DEFAULT_SCI_MAG_GRID_FILESIZE_COLUMN_WIDTH = 150;
public const int DEFAULT_SCI_MAG_GRID_DOI_COLUMN_WIDTH = 290;
public const int DEFAULT_SCI_MAG_GRID_EXISTS_IN_LIBRARY_COLUMN_WIDTH = 55;
+ public const int DEFAULT_SETUP_WIZARD_WINDOW_WIDTH = 1050;
+ public const int DEFAULT_SETUP_WIZARD_WINDOW_HEIGHT = 650;
public const string DEFAULT_DOWNLOAD_MIRROR_NAME = "gen.lib.rus.ec";
public const string DEFAULT_SYNCHRONIZATION_MIRROR_NAME = "gen.lib.rus.ec";
+ public const string DEFAULT_DATABASE_DUMP_MIRROR_NAME = "gen.lib.rus.ec";
public const int DEFAULT_MAXIMUM_SEARCH_RESULT_COUNT = 50000;
public const double SEARCH_PROGRESS_REPORT_INTERVAL = 0.1;
@@ -127,7 +137,7 @@ internal static class Constants
public const int DATABASE_TRANSACTION_BATCH = 500;
public const int MAX_EXPORT_ROWS_PER_FILE = 1048575;
public const int LARGE_NUMBER_OF_ITEMS_TO_DOWNLOAD_WARNING_THRESHOLD = 1000;
- public const int LARGE_DOWNLOADER_BATCH_UPDATE_ITEM_COUNT = 1000;
+ public const int LARGE_DOWNLOAD_MANAGER_BATCH_UPDATE_ITEM_COUNT = 1000;
public const int MIN_DOWNLOAD_TIMEOUT = 15;
public const int MAX_DOWNLOAD_TIMEOUT = 9999;
public const int DEFAULT_DOWNLOAD_TIMEOUT = 120;
@@ -138,7 +148,20 @@ internal static class Constants
public const int MAX_DOWNLOAD_REDIRECT_COUNT = 10;
public const int ASYNC_LOG_QUEUE_SIZE = 10000;
- public const string GITHUB_RELEASE_API_URL = "https://api.github.com/repos/libgenapps/LibgenDesktop/releases";
+ public const decimal NON_FICTION_APPROXIMATE_DOWNLOAD_SIZE_IN_MB = 300;
+ public const decimal FICTION_APPROXIMATE_DOWNLOAD_SIZE_IN_MB = 800;
+ public const decimal SCIMAG_APPROXIMATE_DOWNLOAD_SIZE_IN_GB = 10;
+ public const int NON_FICTION_IMPORT_TIME_IN_MINUTES_FROM = 2;
+ public const int NON_FICTION_IMPORT_TIME_IN_MINUTES_TO = 16;
+ public const int FICTION_IMPORT_TIME_IN_MINUTES_FROM = 1;
+ public const int FICTION_IMPORT_TIME_IN_MINUTES_TO = 8;
+ public const decimal SCIMAG_IMPORT_TIME_IN_HOURS_FROM = 1.5m;
+ public const decimal SCIMAG_IMPORT_TIME_IN_HOURS_TO = 12;
+ public const decimal NON_FICTION_APPROXIMATE_DATABASE_SIZE_IN_GB = 1.6m;
+ public const decimal FICTION_APPROXIMATE_DATABASE_SIZE_IN_GB = 0.9m;
+ public const decimal SCIMAG_APPROXIMATE_DATABASE_SIZE_IN_GB = 42;
+
+ public const string DEFAULT_GITHUB_RELEASE_API_URL = "https://api.github.com/repos/libgenapps/LibgenDesktop/releases";
public const string USER_AGENT = "LibgenDesktop/" + CURRENT_VERSION;
public const int MIN_PROXY_PORT = 1;
public const int MAX_PROXY_PORT = 65535;
diff --git a/LibgenDesktop/Common/Environment.cs b/LibgenDesktop/Common/Environment.cs
index 983fedf..9120432 100644
--- a/LibgenDesktop/Common/Environment.cs
+++ b/LibgenDesktop/Common/Environment.cs
@@ -43,11 +43,12 @@ static Environment()
Directory.CreateDirectory(AppDataDirectory);
}
}
- string logFileName = $"{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.log";
+ string logFileName = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log";
LogFilePath = Path.Combine(AppDataDirectory, "Logs", logFileName);
AppSettingsFilePath = Path.Combine(AppDataDirectory, APP_SETTINGS_FILE_NAME);
MirrorsDirectoryPath = Path.Combine(AppBinariesDirectory, MIRRORS_DIRECTORY_NAME);
LanguagesDirectoryPath = Path.Combine(AppBinariesDirectory, LANGUAGES_DIRECTORY_NAME);
+ TempDirectoryPath = Path.Combine(Path.GetTempPath(), "LibgenDesktop");
OsVersion = GetOsVersion();
NetFrameworkVersion = GetNetFrameworkVersion();
IsIn64BitProcess = System.Environment.Is64BitProcess;
@@ -134,6 +135,7 @@ private static string GetNetFrameworkVersion()
public static string AppSettingsFilePath { get; }
public static string MirrorsDirectoryPath { get; }
public static string LanguagesDirectoryPath { get; }
+ public static string TempDirectoryPath { get; }
public static string OsVersion { get; }
public static string NetFrameworkVersion { get; }
public static bool IsInPortableMode { get; }
diff --git a/LibgenDesktop/Infrastructure/FuncCommand.cs b/LibgenDesktop/Infrastructure/FuncCommand.cs
index f217f85..195b109 100644
--- a/LibgenDesktop/Infrastructure/FuncCommand.cs
+++ b/LibgenDesktop/Infrastructure/FuncCommand.cs
@@ -3,11 +3,11 @@
namespace LibgenDesktop.Infrastructure
{
- public class FuncCommand : ICommand
+ public class FuncCommand : ICommand
{
- private readonly Func executeFunction;
+ private readonly Func executeFunction;
- public FuncCommand(Func executeFunction)
+ public FuncCommand(Func executeFunction)
{
this.executeFunction = executeFunction;
}
@@ -21,12 +21,20 @@ public bool CanExecute(object parameter)
public void Execute(object parameter)
{
- Execute();
+ switch (parameter)
+ {
+ case TParameter typedParameter:
+ ExecuteWithTypedParameter(typedParameter);
+ break;
+ default:
+ ExecuteWithTypedParameter(default);
+ break;
+ }
}
- public TResult Execute()
+ public TResult ExecuteWithTypedParameter(TParameter parameter)
{
- TResult result = executeFunction != null ? executeFunction() : default;
+ TResult result = executeFunction != null ? executeFunction(parameter) : default;
OnCanExecuteChanged();
return result;
}
diff --git a/LibgenDesktop/Infrastructure/IWindowContext.cs b/LibgenDesktop/Infrastructure/IWindowContext.cs
index 2cda478..efc9bda 100644
--- a/LibgenDesktop/Infrastructure/IWindowContext.cs
+++ b/LibgenDesktop/Infrastructure/IWindowContext.cs
@@ -16,5 +16,11 @@ public interface IWindowContext
void Focus();
void Show(int? width = null, int? height = null, bool showMaximized = false);
bool? ShowDialog(int? width = null, int? height = null, bool showMaximized = false);
+ void AddWindowMinimizeButton();
+ void AddWindowMaximizeButton();
+ void AddWindowCloseButton();
+ void RemoveWindowMinimizeButton();
+ void RemoveWindowMaximizeButton();
+ void RemoveWindowCloseButton();
}
}
\ No newline at end of file
diff --git a/LibgenDesktop/Infrastructure/RegisteredWindows.cs b/LibgenDesktop/Infrastructure/RegisteredWindows.cs
index d1428c7..dab7276 100644
--- a/LibgenDesktop/Infrastructure/RegisteredWindows.cs
+++ b/LibgenDesktop/Infrastructure/RegisteredWindows.cs
@@ -15,12 +15,14 @@ internal enum WindowKey
SCI_MAG_DETAILS_WINDOW,
ERROR_WINDOW,
IMPORT_WINDOW,
- CREATE_DATABASE_WINDOW,
+ SETUP_WIZARD_WINDOW,
+ SETUP_WIZARD_PROXY_SETTINGS_WINDOW,
SETTINGS_WINDOW,
SYNCHRONIZATION_WINDOW,
APPLICATION_UPDATE_WINDOW,
LIBRARY_WINDOW,
DATABASE_WINDOW,
+ DATABASE_ERROR_WINDOW,
ABOUT_WINDOW,
SQL_DEBUGGER_WINDOW
}
@@ -48,11 +50,13 @@ static RegisteredWindows()
RegisterWindow(WindowKey.SCI_MAG_DETAILS_WINDOW, typeof(SciMagDetailsWindow), typeof(SciMagDetailsWindowViewModel));
RegisterWindow(WindowKey.ERROR_WINDOW, typeof(ErrorWindow), typeof(ErrorWindowViewModel));
RegisterWindow(WindowKey.IMPORT_WINDOW, typeof(ImportWindow), typeof(ImportWindowViewModel));
- RegisterWindow(WindowKey.CREATE_DATABASE_WINDOW, typeof(CreateDatabaseWindow), typeof(CreateDatabaseWindowViewModel));
+ RegisterWindow(WindowKey.SETUP_WIZARD_WINDOW, typeof(SetupWizardWindow), typeof(SetupWizardWindowViewModel));
+ RegisterWindow(WindowKey.SETUP_WIZARD_PROXY_SETTINGS_WINDOW, typeof(SetupWizardProxySettingsWindow), typeof(SetupWizardProxySettingsWindowViewModel));
RegisterWindow(WindowKey.SETTINGS_WINDOW, typeof(SettingsWindow), typeof(SettingsWindowViewModel));
RegisterWindow(WindowKey.SYNCHRONIZATION_WINDOW, typeof(SynchronizationWindow), typeof(SynchronizationWindowViewModel));
RegisterWindow(WindowKey.APPLICATION_UPDATE_WINDOW, typeof(ApplicationUpdateWindow), typeof(ApplicationUpdateWindowViewModel));
RegisterWindow(WindowKey.DATABASE_WINDOW, typeof(DatabaseWindow), typeof(DatabaseWindowViewModel));
+ RegisterWindow(WindowKey.DATABASE_ERROR_WINDOW, typeof(DatabaseErrorWindow), typeof(DatabaseErrorWindowViewModel));
RegisterWindow(WindowKey.ABOUT_WINDOW, typeof(AboutWindow), typeof(AboutWindowViewModel));
RegisterWindow(WindowKey.SQL_DEBUGGER_WINDOW, typeof(SqlDebuggerWindow), typeof(SqlDebuggerWindowViewModel));
MessageBox = new MessageBox();
diff --git a/LibgenDesktop/Infrastructure/ViewModelEvent.cs b/LibgenDesktop/Infrastructure/ViewModelEvent.cs
index d0f26fd..e2fd83e 100644
--- a/LibgenDesktop/Infrastructure/ViewModelEvent.cs
+++ b/LibgenDesktop/Infrastructure/ViewModelEvent.cs
@@ -7,7 +7,8 @@ public enum RegisteredEventId
FOCUS_SEARCH_TEXT_BOX = 1,
SCROLL_TO_SELECTION,
BRING_TO_FRONT,
- FOCUS_SQL_QUERY_TEXT_BOX
+ FOCUS_SQL_QUERY_TEXT_BOX,
+ FOCUS_SETUP_WIZARD_PROXY_SETTINGS_ADDRESS_TEXT_BOX
}
public ViewModelEvent(RegisteredEventId eventId)
diff --git a/LibgenDesktop/Infrastructure/WindowContext.cs b/LibgenDesktop/Infrastructure/WindowContext.cs
index 56949d2..ce94cc2 100644
--- a/LibgenDesktop/Infrastructure/WindowContext.cs
+++ b/LibgenDesktop/Infrastructure/WindowContext.cs
@@ -94,6 +94,36 @@ public void Focus()
Window.Focus();
}
+ public void AddWindowMinimizeButton()
+ {
+ Window.AddWindowMinimizeButton();
+ }
+
+ public void AddWindowMaximizeButton()
+ {
+ Window.AddWindowMaximizeButton();
+ }
+
+ public void AddWindowCloseButton()
+ {
+ Window.AddWindowCloseButton();
+ }
+
+ public void RemoveWindowMinimizeButton()
+ {
+ Window.RemoveWindowMinimizeButton();
+ }
+
+ public void RemoveWindowMaximizeButton()
+ {
+ Window.RemoveWindowMaximizeButton();
+ }
+
+ public void RemoveWindowCloseButton()
+ {
+ Window.RemoveWindowCloseButton();
+ }
+
protected virtual void OnActivated()
{
Activated?.Invoke(this, EventArgs.Empty);
@@ -114,6 +144,11 @@ protected virtual void OnClosed()
Closed?.Invoke(this, EventArgs.Empty);
}
+ private static WindowState GetWindowState(bool isMaximized)
+ {
+ return isMaximized ? WindowState.Maximized : WindowState.Normal;
+ }
+
private bool? ShowDialog(bool showMaximized, bool showInTaskbar)
{
Window.ShowInTaskbar = showInTaskbar;
@@ -121,11 +156,6 @@ protected virtual void OnClosed()
return Window.ShowDialog();
}
- private WindowState GetWindowState(bool isMaximized)
- {
- return isMaximized ? WindowState.Maximized : WindowState.Normal;
- }
-
private void Window_Activated(object sender, EventArgs e)
{
OnActivated();
diff --git a/LibgenDesktop/Infrastructure/WindowExtensions.cs b/LibgenDesktop/Infrastructure/WindowExtensions.cs
new file mode 100644
index 0000000..584d99d
--- /dev/null
+++ b/LibgenDesktop/Infrastructure/WindowExtensions.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Interop;
+
+namespace LibgenDesktop.Infrastructure
+{
+ internal static class WindowExtensions
+ {
+ private const int GWL_STYLE = -16;
+ private const int WS_MAXIMIZEBOX = 0x10000;
+ private const int WS_MINIMIZEBOX = 0x20000;
+ private const int WS_SYSMENU = 0x80000;
+ private const int GWL_EXSTYLE = -20;
+ private const int WS_EX_DLGMODALFRAME = 0x0001;
+ private const int SWP_NOSIZE = 0x0001;
+ private const int SWP_NOMOVE = 0x0002;
+ private const int SWP_NOZORDER = 0x0004;
+ private const int SWP_FRAMECHANGED = 0x0020;
+ private const int WM_SETICON = 0x0080;
+
+ [DllImport("user32.dll")]
+ private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
+
+ [DllImport("user32.dll")]
+ private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
+
+ [DllImport("user32.dll")]
+ private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport("user32.dll")]
+ private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags);
+
+ public static void AddWindowMinimizeButton(this Window window)
+ {
+ AddWindowStyle(window, WS_MINIMIZEBOX);
+ }
+
+ public static void AddWindowMaximizeButton(this Window window)
+ {
+ AddWindowStyle(window, WS_MAXIMIZEBOX);
+ }
+
+ public static void AddWindowCloseButton(this Window window)
+ {
+ AddWindowStyle(window, WS_SYSMENU);
+ }
+
+ public static void RemoveWindowMinimizeButton(this Window window)
+ {
+ RemoveWindowStyle(window, WS_MINIMIZEBOX);
+ }
+
+ public static void RemoveWindowMaximizeButton(this Window window)
+ {
+ RemoveWindowStyle(window, WS_MAXIMIZEBOX);
+ }
+
+ public static void RemoveWindowCloseButton(this Window window)
+ {
+ RemoveWindowStyle(window, WS_SYSMENU);
+ }
+
+ public static void RemoveWindowIcon(this Window window)
+ {
+ IntPtr windowHandle = new WindowInteropHelper(window).Handle;
+ int windowExStyle = GetWindowLong(windowHandle, GWL_EXSTYLE);
+ SetWindowLong(windowHandle, GWL_EXSTYLE, windowExStyle | WS_EX_DLGMODALFRAME);
+ SendMessage(windowHandle, WM_SETICON, IntPtr.Zero, IntPtr.Zero);
+ SendMessage(windowHandle, WM_SETICON, new IntPtr(1), IntPtr.Zero);
+ SetWindowPos(windowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ }
+
+ private static void AddWindowStyle(Window window, int styleAttribute)
+ {
+ IntPtr windowHandle = new WindowInteropHelper(window).Handle;
+ int windowStyle = GetWindowLong(windowHandle, GWL_STYLE);
+ SetWindowLong(windowHandle, GWL_STYLE, windowStyle | styleAttribute);
+ }
+
+ private static void RemoveWindowStyle(Window window, int styleAttribute)
+ {
+ IntPtr windowHandle = new WindowInteropHelper(window).Handle;
+ int windowStyle = GetWindowLong(windowHandle, GWL_STYLE);
+ SetWindowLong(windowHandle, GWL_STYLE, windowStyle & ~styleAttribute);
+ }
+ }
+}
diff --git a/LibgenDesktop/Infrastructure/WindowManager.cs b/LibgenDesktop/Infrastructure/WindowManager.cs
index 0463813..900f0c3 100644
--- a/LibgenDesktop/Infrastructure/WindowManager.cs
+++ b/LibgenDesktop/Infrastructure/WindowManager.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
-using System.Runtime.InteropServices;
+using System.Reflection;
using System.Windows;
-using System.Windows.Interop;
using System.Windows.Threading;
using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
@@ -12,35 +12,15 @@ namespace LibgenDesktop.Infrastructure
{
internal static class WindowManager
{
- private const int GWL_STYLE = -16;
- private const int WS_MAXIMIZEBOX = 0x10000;
- private const int WS_MINIMIZEBOX = 0x20000;
- private const int WS_SYSMENU = 0x80000;
- private const int GWL_EXSTYLE = -20;
- private const int WS_EX_DLGMODALFRAME = 0x0001;
- private const int SWP_NOSIZE = 0x0001;
- private const int SWP_NOMOVE = 0x0002;
- private const int SWP_NOZORDER = 0x0004;
- private const int SWP_FRAMECHANGED = 0x0020;
- private const int WM_SETICON = 0x0080;
-
- private static List createdWindowContexts;
-
- [DllImport("user32.dll")]
- private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
-
- [DllImport("user32.dll")]
- private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
-
- [DllImport("user32.dll")]
- private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
-
- [DllImport("user32.dll")]
- private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags);
+ private static readonly List createdWindowContexts;
+ private static readonly FieldInfo menuDropAlignmentField;
static WindowManager()
{
createdWindowContexts = new List();
+ menuDropAlignmentField = typeof(SystemParameters).GetField("_menuDropAlignment", BindingFlags.NonPublic | BindingFlags.Static);
+ ResetPopupAlignment();
+ SystemParameters.StaticPropertyChanged += (sender, e) => ResetPopupAlignment();
}
public static int ScreenWidth
@@ -59,6 +39,7 @@ public static int ScreenHeight
}
}
+ [SuppressMessage("Style", "IDE0019:Use pattern matching")]
public static IWindowContext CreateWindow(RegisteredWindows.WindowKey windowKey, object viewModel = null, IWindowContext parentWindowContext = null)
{
RegisteredWindows.RegisteredWindow registeredWindow = RegisteredWindows.AllWindows[windowKey];
@@ -103,6 +84,7 @@ public static bool ShowPrompt(string title, string text, string yes, string no,
return RegisteredWindows.MessageBox.ShowPrompt(title, text, yes, no, parentWindowContext);
}
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
public static OpenFileDialogResult ShowOpenFileDialog(OpenFileDialogParameters openFileDialogParameters)
{
if (openFileDialogParameters == null)
@@ -129,6 +111,7 @@ public static OpenFileDialogResult ShowOpenFileDialog(OpenFileDialogParameters o
return result;
}
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
public static SaveFileDialogResult ShowSaveFileDialog(SaveFileDialogParameters saveFileDialogParameters)
{
if (saveFileDialogParameters == null)
@@ -159,6 +142,7 @@ public static SaveFileDialogResult ShowSaveFileDialog(SaveFileDialogParameters s
return result;
}
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
public static SelectFolderDialogResult ShowSelectFolderDialog(SelectFolderDialogParameters selectFolderDialogParameters)
{
using (CommonOpenFileDialog commonOpenFileDialog = new CommonOpenFileDialog())
@@ -173,41 +157,17 @@ public static SelectFolderDialogResult ShowSelectFolderDialog(SelectFolderDialog
}
}
- public static void RemoveWindowMinimizeButton(Window window)
- {
- RemoveWindowStyle(window, WS_MINIMIZEBOX);
- }
-
- public static void RemoveWindowMaximizeButton(Window window)
- {
- RemoveWindowStyle(window, WS_MAXIMIZEBOX);
- }
-
- public static void RemoveWindowCloseButton(Window window)
- {
- RemoveWindowStyle(window, WS_SYSMENU);
- }
-
- public static void RemoveWindowIcon(Window window)
- {
- IntPtr windowHandle = new WindowInteropHelper(window).Handle;
- int windowExStyle = GetWindowLong(windowHandle, GWL_EXSTYLE);
- SetWindowLong(windowHandle, GWL_EXSTYLE, windowExStyle | WS_EX_DLGMODALFRAME);
- SendMessage(windowHandle, WM_SETICON, IntPtr.Zero, IntPtr.Zero);
- SendMessage(windowHandle, WM_SETICON, new IntPtr(1), IntPtr.Zero);
- SetWindowPos(windowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
- }
-
public static void SetClipboardText(string text)
{
Clipboard.SetDataObject(text);
}
- private static void RemoveWindowStyle(Window window, int styleAttribute)
+ private static void ResetPopupAlignment()
{
- IntPtr windowHandle = new WindowInteropHelper(window).Handle;
- int windowStyle = GetWindowLong(windowHandle, GWL_STYLE);
- SetWindowLong(windowHandle, GWL_STYLE, windowStyle & ~styleAttribute);
+ if (SystemParameters.MenuDropAlignment && menuDropAlignmentField != null)
+ {
+ menuDropAlignmentField.SetValue(null, false);
+ }
}
private static void WindowContext_Closed(object sender, EventArgs e)
diff --git a/LibgenDesktop/LibgenDesktop.csproj b/LibgenDesktop/LibgenDesktop.csproj
index 27ee3ac..29880a2 100644
--- a/LibgenDesktop/LibgenDesktop.csproj
+++ b/LibgenDesktop/LibgenDesktop.csproj
@@ -140,21 +140,24 @@
+
-
-
-
+
+
+
-
+
+
+
@@ -177,44 +180,59 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -252,10 +270,26 @@
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -265,6 +299,7 @@
+
@@ -274,6 +309,8 @@
+
+
@@ -287,7 +324,6 @@
-
@@ -296,6 +332,9 @@
+
+ Link.xaml
+
BookDataGridContextMenu.xaml
@@ -304,6 +343,45 @@
LibraryTabHeader.xaml
+
+ LanguageComboBox.xaml
+
+
+ CollectionsPage.xaml
+
+
+ DownloadDumpLinksPage.xaml
+
+
+ DownloadModePage.xaml
+
+
+ DownloadDumpInfoPage.xaml
+
+
+ DownloadDumpsPage.xaml
+
+
+ ImportDumpsPage.xaml
+
+
+ CreateDatabasePage.xaml
+
+
+ StepListPage.xaml
+
+
+ ConfirmationPage.xaml
+
+
+ SetupModePage.xaml
+
+
+ LanguagePage.xaml
+
+
+ DatabaseOperationPage.xaml
+
ApplicationUpdateWindow.xaml
@@ -315,7 +393,7 @@
CloseTabButton.xaml
-
+
ExportPanel.xaml
@@ -332,9 +410,18 @@
LibraryTab.xaml
+
+ DatabaseErrorWindow.xaml
+
DatabaseWindow.xaml
+
+ SetupWizardProxySettingsWindow.xaml
+
+
+ SetupWizardWindow.xaml
+
SqlDebuggerWindow.xaml
@@ -367,9 +454,6 @@
Toolbar.xaml
-
- CreateDatabaseWindow.xaml
-
ErrorWindow.xaml
@@ -412,6 +496,58 @@
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
@@ -420,19 +556,83 @@
Designer
MSBuild:Compile
-
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
@@ -468,10 +668,22 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
@@ -480,23 +692,23 @@
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
@@ -532,10 +744,6 @@
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
@@ -564,39 +772,39 @@
MainWindow.xaml
Code
-
+
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
-
+
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
@@ -636,39 +844,35 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
- MSBuild:Compile
- Designer
-
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
@@ -701,6 +905,10 @@
PreserveNewest
Mirrors\mirrors.config
+
+ PreserveNewest
+ Mirrors\genlibrusec_dbdumps.xslt
+
PreserveNewest
Mirrors\libgen_lc_nonfiction.xslt
@@ -773,6 +981,14 @@
PreserveNewest
Languages\Turkish.lng
+
+ PreserveNewest
+ Languages\Portuguse_BR.lng
+
+
+ PreserveNewest
+ Languages\Italian.lng
+
@@ -783,6 +999,7 @@
+
diff --git a/LibgenDesktop/Models/Database/LocalDatabase.cs b/LibgenDesktop/Models/Database/LocalDatabase.cs
index 92625f1..bc0e667 100644
--- a/LibgenDesktop/Models/Database/LocalDatabase.cs
+++ b/LibgenDesktop/Models/Database/LocalDatabase.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
@@ -659,158 +660,66 @@ public void AddFictionBooks(List books)
{
insertCommand.CommandText = SqlScripts.INSERT_FICTION;
insertCommand.Parameters.AddWithValue("@Id", null);
- SQLiteParameter authorFamily1Parameter = insertCommand.Parameters.Add("@AuthorFamily1", DbType.String);
- SQLiteParameter authorName1Parameter = insertCommand.Parameters.Add("@AuthorName1", DbType.String);
- SQLiteParameter authorSurname1Parameter = insertCommand.Parameters.Add("@AuthorSurname1", DbType.String);
- SQLiteParameter role1Parameter = insertCommand.Parameters.Add("@Role1", DbType.String);
- SQLiteParameter pseudonim1Parameter = insertCommand.Parameters.Add("@Pseudonim1", DbType.String);
- SQLiteParameter authorFamily2Parameter = insertCommand.Parameters.Add("@AuthorFamily2", DbType.String);
- SQLiteParameter authorName2Parameter = insertCommand.Parameters.Add("@AuthorName2", DbType.String);
- SQLiteParameter authorSurname2Parameter = insertCommand.Parameters.Add("@AuthorSurname2", DbType.String);
- SQLiteParameter role2Parameter = insertCommand.Parameters.Add("@Role2", DbType.String);
- SQLiteParameter pseudonim2Parameter = insertCommand.Parameters.Add("@Pseudonim2", DbType.String);
- SQLiteParameter authorFamily3Parameter = insertCommand.Parameters.Add("@AuthorFamily3", DbType.String);
- SQLiteParameter authorName3Parameter = insertCommand.Parameters.Add("@AuthorName3", DbType.String);
- SQLiteParameter authorSurname3Parameter = insertCommand.Parameters.Add("@AuthorSurname3", DbType.String);
- SQLiteParameter role3Parameter = insertCommand.Parameters.Add("@Role3", DbType.String);
- SQLiteParameter pseudonim3Parameter = insertCommand.Parameters.Add("@Pseudonim3", DbType.String);
- SQLiteParameter authorFamily4Parameter = insertCommand.Parameters.Add("@AuthorFamily4", DbType.String);
- SQLiteParameter authorName4Parameter = insertCommand.Parameters.Add("@AuthorName4", DbType.String);
- SQLiteParameter authorSurname4Parameter = insertCommand.Parameters.Add("@AuthorSurname4", DbType.String);
- SQLiteParameter role4Parameter = insertCommand.Parameters.Add("@Role4", DbType.String);
- SQLiteParameter pseudonim4Parameter = insertCommand.Parameters.Add("@Pseudonim4", DbType.String);
- SQLiteParameter series1Parameter = insertCommand.Parameters.Add("@Series1", DbType.String);
- SQLiteParameter series2Parameter = insertCommand.Parameters.Add("@Series2", DbType.String);
- SQLiteParameter series3Parameter = insertCommand.Parameters.Add("@Series3", DbType.String);
- SQLiteParameter series4Parameter = insertCommand.Parameters.Add("@Series4", DbType.String);
- SQLiteParameter titleParameter = insertCommand.Parameters.Add("@Title", DbType.String);
- SQLiteParameter formatParameter = insertCommand.Parameters.Add("@Format", DbType.String);
- SQLiteParameter versionParameter = insertCommand.Parameters.Add("@Version", DbType.String);
- SQLiteParameter sizeInBytesParameter = insertCommand.Parameters.Add("@SizeInBytes", DbType.Int64);
SQLiteParameter md5HashParameter = insertCommand.Parameters.Add("@Md5Hash", DbType.String);
- SQLiteParameter pathParameter = insertCommand.Parameters.Add("@Path", DbType.String);
+ SQLiteParameter titleParameter = insertCommand.Parameters.Add("@Title", DbType.String);
+ SQLiteParameter authorsParameter = insertCommand.Parameters.Add("@Authors", DbType.String);
+ SQLiteParameter seriesParameter = insertCommand.Parameters.Add("@Series", DbType.String);
+ SQLiteParameter editionParameter = insertCommand.Parameters.Add("@Edition", DbType.String);
SQLiteParameter languageParameter = insertCommand.Parameters.Add("@Language", DbType.String);
- SQLiteParameter pagesParameter = insertCommand.Parameters.Add("@Pages", DbType.String);
- SQLiteParameter identifierParameter = insertCommand.Parameters.Add("@Identifier", DbType.String);
SQLiteParameter yearParameter = insertCommand.Parameters.Add("@Year", DbType.String);
SQLiteParameter publisherParameter = insertCommand.Parameters.Add("@Publisher", DbType.String);
- SQLiteParameter editionParameter = insertCommand.Parameters.Add("@Edition", DbType.String);
- SQLiteParameter commentaryParameter = insertCommand.Parameters.Add("@Commentary", DbType.String);
- SQLiteParameter addedDateTimeParameter = insertCommand.Parameters.Add("@AddedDateTime", DbType.String);
- SQLiteParameter lastModifiedDateTimeParameter = insertCommand.Parameters.Add("@LastModifiedDateTime", DbType.String);
- SQLiteParameter russianAuthorFamilyParameter = insertCommand.Parameters.Add("@RussianAuthorFamily", DbType.String);
- SQLiteParameter russianAuthorNameParameter = insertCommand.Parameters.Add("@RussianAuthorName", DbType.String);
- SQLiteParameter russianAuthorSurnameParameter = insertCommand.Parameters.Add("@RussianAuthorSurname", DbType.String);
- SQLiteParameter coverParameter = insertCommand.Parameters.Add("@Cover", DbType.String);
+ SQLiteParameter pagesParameter = insertCommand.Parameters.Add("@Pages", DbType.String);
+ SQLiteParameter identifierParameter = insertCommand.Parameters.Add("@Identifier", DbType.String);
SQLiteParameter googleBookIdParameter = insertCommand.Parameters.Add("@GoogleBookId", DbType.String);
SQLiteParameter asinParameter = insertCommand.Parameters.Add("@Asin", DbType.String);
- SQLiteParameter authorHashParameter = insertCommand.Parameters.Add("@AuthorHash", DbType.String);
- SQLiteParameter titleHashParameter = insertCommand.Parameters.Add("@TitleHash", DbType.String);
+ SQLiteParameter coverUrlParameter = insertCommand.Parameters.Add("@CoverUrl", DbType.String);
+ SQLiteParameter formatParameter = insertCommand.Parameters.Add("@Format", DbType.String);
+ SQLiteParameter sizeInBytesParameter = insertCommand.Parameters.Add("@SizeInBytes", DbType.Int64);
+ SQLiteParameter libraryParameter = insertCommand.Parameters.Add("@Library", DbType.String);
+ SQLiteParameter issueParameter = insertCommand.Parameters.Add("@Issue", DbType.String);
+ SQLiteParameter locatorParameter = insertCommand.Parameters.Add("@Locator", DbType.String);
+ SQLiteParameter commentaryParameter = insertCommand.Parameters.Add("@Commentary", DbType.String);
+ SQLiteParameter genericParameter = insertCommand.Parameters.Add("@Generic", DbType.String);
SQLiteParameter visibleParameter = insertCommand.Parameters.Add("@Visible", DbType.String);
+ SQLiteParameter addedDateTimeParameter = insertCommand.Parameters.Add("@AddedDateTime", DbType.String);
+ SQLiteParameter lastModifiedDateTimeParameter = insertCommand.Parameters.Add("@LastModifiedDateTime", DbType.String);
SQLiteParameter libgenIdParameter = insertCommand.Parameters.Add("@LibgenId", DbType.Int32);
insertFtsCommand.CommandText = SqlScripts.INSERT_FICTION_FTS_WITHOUT_ID;
SQLiteParameter titleFtsParameter = insertFtsCommand.Parameters.Add("@Title", DbType.String);
- SQLiteParameter authorFamily1FtsParameter = insertFtsCommand.Parameters.Add("@AuthorFamily1", DbType.String);
- SQLiteParameter authorName1FtsParameter = insertFtsCommand.Parameters.Add("@AuthorName1", DbType.String);
- SQLiteParameter authorSurname1FtsParameter = insertFtsCommand.Parameters.Add("@AuthorSurname1", DbType.String);
- SQLiteParameter pseudonim1FtsParameter = insertFtsCommand.Parameters.Add("@Pseudonim1", DbType.String);
- SQLiteParameter authorFamily2FtsParameter = insertFtsCommand.Parameters.Add("@AuthorFamily2", DbType.String);
- SQLiteParameter authorName2FtsParameter = insertFtsCommand.Parameters.Add("@AuthorName2", DbType.String);
- SQLiteParameter authorSurname2FtsParameter = insertFtsCommand.Parameters.Add("@AuthorSurname2", DbType.String);
- SQLiteParameter pseudonim2FtsParameter = insertFtsCommand.Parameters.Add("@Pseudonim2", DbType.String);
- SQLiteParameter authorFamily3FtsParameter = insertFtsCommand.Parameters.Add("@AuthorFamily3", DbType.String);
- SQLiteParameter authorName3FtsParameter = insertFtsCommand.Parameters.Add("@AuthorName3", DbType.String);
- SQLiteParameter authorSurname3FtsParameter = insertFtsCommand.Parameters.Add("@AuthorSurname3", DbType.String);
- SQLiteParameter pseudonim3FtsParameter = insertFtsCommand.Parameters.Add("@Pseudonim3", DbType.String);
- SQLiteParameter authorFamily4FtsParameter = insertFtsCommand.Parameters.Add("@AuthorFamily4", DbType.String);
- SQLiteParameter authorName4FtsParameter = insertFtsCommand.Parameters.Add("@AuthorName4", DbType.String);
- SQLiteParameter authorSurname4FtsParameter = insertFtsCommand.Parameters.Add("@AuthorSurname4", DbType.String);
- SQLiteParameter pseudonim4FtsParameter = insertFtsCommand.Parameters.Add("@Pseudonim4", DbType.String);
- SQLiteParameter russianAuthorFamilyFtsParameter = insertFtsCommand.Parameters.Add("@RussianAuthorFamily", DbType.String);
- SQLiteParameter russianAuthorNameFtsParameter = insertFtsCommand.Parameters.Add("@RussianAuthorName", DbType.String);
- SQLiteParameter russianAuthorSurnameFtsParameter = insertFtsCommand.Parameters.Add("@RussianAuthorSurname", DbType.String);
- SQLiteParameter series1FtsParameter = insertFtsCommand.Parameters.Add("@Series1", DbType.String);
- SQLiteParameter series2FtsParameter = insertFtsCommand.Parameters.Add("@Series2", DbType.String);
- SQLiteParameter series3FtsParameter = insertFtsCommand.Parameters.Add("@Series3", DbType.String);
- SQLiteParameter series4FtsParameter = insertFtsCommand.Parameters.Add("@Series4", DbType.String);
+ SQLiteParameter authorsFtsParameter = insertFtsCommand.Parameters.Add("@Authors", DbType.String);
+ SQLiteParameter seriesFtsParameter = insertFtsCommand.Parameters.Add("@Series", DbType.String);
SQLiteParameter publisherFtsParameter = insertFtsCommand.Parameters.Add("@Publisher", DbType.String);
SQLiteParameter identifierFtsParameter = insertFtsCommand.Parameters.Add("@Identifier", DbType.String);
foreach (FictionBook book in books)
{
- authorFamily1Parameter.Value = book.AuthorFamily1;
- authorName1Parameter.Value = book.AuthorName1;
- authorSurname1Parameter.Value = book.AuthorSurname1;
- role1Parameter.Value = book.Role1;
- pseudonim1Parameter.Value = book.Pseudonim1;
- authorFamily2Parameter.Value = book.AuthorFamily2;
- authorName2Parameter.Value = book.AuthorName2;
- authorSurname2Parameter.Value = book.AuthorSurname2;
- role2Parameter.Value = book.Role2;
- pseudonim2Parameter.Value = book.Pseudonim2;
- authorFamily3Parameter.Value = book.AuthorFamily3;
- authorName3Parameter.Value = book.AuthorName3;
- authorSurname3Parameter.Value = book.AuthorSurname3;
- role3Parameter.Value = book.Role3;
- pseudonim3Parameter.Value = book.Pseudonim3;
- authorFamily4Parameter.Value = book.AuthorFamily4;
- authorName4Parameter.Value = book.AuthorName4;
- authorSurname4Parameter.Value = book.AuthorSurname4;
- role4Parameter.Value = book.Role4;
- pseudonim4Parameter.Value = book.Pseudonim4;
- series1Parameter.Value = book.Series1;
- series2Parameter.Value = book.Series2;
- series3Parameter.Value = book.Series3;
- series4Parameter.Value = book.Series4;
- titleParameter.Value = book.Title;
- formatParameter.Value = book.Format;
- versionParameter.Value = book.Version;
- sizeInBytesParameter.Value = book.SizeInBytes;
md5HashParameter.Value = book.Md5Hash;
- pathParameter.Value = book.Path;
+ titleParameter.Value = book.Title;
+ authorsParameter.Value = book.Authors;
+ seriesParameter.Value = book.Series;
+ editionParameter.Value = book.Edition;
languageParameter.Value = book.Language;
- pagesParameter.Value = book.Pages;
- identifierParameter.Value = book.Identifier;
yearParameter.Value = book.Year;
publisherParameter.Value = book.Publisher;
- editionParameter.Value = book.Edition;
- commentaryParameter.Value = book.Commentary;
- addedDateTimeParameter.Value = book.AddedDateTime?.ToString("s");
- lastModifiedDateTimeParameter.Value = book.LastModifiedDateTime.ToString("s");
- russianAuthorFamilyParameter.Value = book.RussianAuthorFamily;
- russianAuthorNameParameter.Value = book.RussianAuthorName;
- russianAuthorSurnameParameter.Value = book.RussianAuthorSurname;
- coverParameter.Value = book.Cover;
+ pagesParameter.Value = book.Pages;
+ identifierParameter.Value = book.Identifier;
googleBookIdParameter.Value = book.GoogleBookId;
asinParameter.Value = book.Asin;
- authorHashParameter.Value = book.AuthorHash;
- titleHashParameter.Value = book.TitleHash;
+ coverUrlParameter.Value = book.CoverUrl;
+ formatParameter.Value = book.Format;
+ sizeInBytesParameter.Value = book.SizeInBytes;
+ libraryParameter.Value = book.Library;
+ issueParameter.Value = book.Issue;
+ locatorParameter.Value = book.Locator;
+ commentaryParameter.Value = book.Commentary;
+ genericParameter.Value = book.Generic;
visibleParameter.Value = book.Visible;
+ addedDateTimeParameter.Value = book.AddedDateTime?.ToString("s");
+ lastModifiedDateTimeParameter.Value = book.LastModifiedDateTime?.ToString("s");
libgenIdParameter.Value = book.LibgenId;
insertCommand.ExecuteNonQuery();
titleFtsParameter.Value = book.Title.SeparateCjkCharactersWithSpaces();
- authorFamily1FtsParameter.Value = book.AuthorFamily1.SeparateCjkCharactersWithSpaces();
- authorName1FtsParameter.Value = book.AuthorName1.SeparateCjkCharactersWithSpaces();
- authorSurname1FtsParameter.Value = book.AuthorSurname1.SeparateCjkCharactersWithSpaces();
- pseudonim1FtsParameter.Value = book.Pseudonim1.SeparateCjkCharactersWithSpaces();
- authorFamily2FtsParameter.Value = book.AuthorFamily2.SeparateCjkCharactersWithSpaces();
- authorName2FtsParameter.Value = book.AuthorName2.SeparateCjkCharactersWithSpaces();
- authorSurname2FtsParameter.Value = book.AuthorSurname2.SeparateCjkCharactersWithSpaces();
- pseudonim2FtsParameter.Value = book.Pseudonim2.SeparateCjkCharactersWithSpaces();
- authorFamily3FtsParameter.Value = book.AuthorFamily3.SeparateCjkCharactersWithSpaces();
- authorName3FtsParameter.Value = book.AuthorName3.SeparateCjkCharactersWithSpaces();
- authorSurname3FtsParameter.Value = book.AuthorSurname3.SeparateCjkCharactersWithSpaces();
- pseudonim3FtsParameter.Value = book.Pseudonim3.SeparateCjkCharactersWithSpaces();
- authorFamily4FtsParameter.Value = book.AuthorFamily4.SeparateCjkCharactersWithSpaces();
- authorName4FtsParameter.Value = book.AuthorName4.SeparateCjkCharactersWithSpaces();
- authorSurname4FtsParameter.Value = book.AuthorSurname4.SeparateCjkCharactersWithSpaces();
- pseudonim4FtsParameter.Value = book.Pseudonim4.SeparateCjkCharactersWithSpaces();
- russianAuthorFamilyFtsParameter.Value = book.RussianAuthorFamily;
- russianAuthorNameFtsParameter.Value = book.RussianAuthorName;
- russianAuthorSurnameFtsParameter.Value = book.RussianAuthorSurname;
- series1FtsParameter.Value = book.Series1.SeparateCjkCharactersWithSpaces();
- series2FtsParameter.Value = book.Series2.SeparateCjkCharactersWithSpaces();
- series3FtsParameter.Value = book.Series3.SeparateCjkCharactersWithSpaces();
- series4FtsParameter.Value = book.Series4.SeparateCjkCharactersWithSpaces();
+ authorsFtsParameter.Value = book.Authors.SeparateCjkCharactersWithSpaces();
+ seriesFtsParameter.Value = book.Series.SeparateCjkCharactersWithSpaces();
publisherFtsParameter.Value = book.Publisher.SeparateCjkCharactersWithSpaces();
identifierFtsParameter.Value = book.Identifier;
insertFtsCommand.ExecuteNonQuery();
@@ -831,214 +740,80 @@ public void UpdateFictionBooks(List books)
deleteFtsCommand.CommandText = SqlScripts.DELETE_FICTION_FTS;
SQLiteParameter idDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Id", DbType.Int32);
SQLiteParameter titleDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Title", DbType.String);
- SQLiteParameter authorFamily1DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorFamily1", DbType.String);
- SQLiteParameter authorName1DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorName1", DbType.String);
- SQLiteParameter authorSurname1DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorSurname1", DbType.String);
- SQLiteParameter pseudonim1DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Pseudonim1", DbType.String);
- SQLiteParameter authorFamily2DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorFamily2", DbType.String);
- SQLiteParameter authorName2DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorName2", DbType.String);
- SQLiteParameter authorSurname2DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorSurname2", DbType.String);
- SQLiteParameter pseudonim2DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Pseudonim2", DbType.String);
- SQLiteParameter authorFamily3DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorFamily3", DbType.String);
- SQLiteParameter authorName3DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorName3", DbType.String);
- SQLiteParameter authorSurname3DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorSurname3", DbType.String);
- SQLiteParameter pseudonim3DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Pseudonim3", DbType.String);
- SQLiteParameter authorFamily4DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorFamily4", DbType.String);
- SQLiteParameter authorName4DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorName4", DbType.String);
- SQLiteParameter authorSurname4DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@AuthorSurname4", DbType.String);
- SQLiteParameter pseudonim4DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Pseudonim4", DbType.String);
- SQLiteParameter russianAuthorFamilyDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@RussianAuthorFamily", DbType.String);
- SQLiteParameter russianAuthorNameDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@RussianAuthorName", DbType.String);
- SQLiteParameter russianAuthorSurnameDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@RussianAuthorSurname", DbType.String);
- SQLiteParameter series1DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Series1", DbType.String);
- SQLiteParameter series2DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Series2", DbType.String);
- SQLiteParameter series3DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Series3", DbType.String);
- SQLiteParameter series4DeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Series4", DbType.String);
+ SQLiteParameter authorsDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Authors", DbType.String);
+ SQLiteParameter seriesDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Series", DbType.String);
SQLiteParameter publisherDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Publisher", DbType.String);
SQLiteParameter identifierDeleteFtsParameter = deleteFtsCommand.Parameters.Add("@Identifier", DbType.String);
updateCommand.CommandText = SqlScripts.UPDATE_FICTION;
SQLiteParameter idParameter = updateCommand.Parameters.Add("@Id", DbType.Int32);
- SQLiteParameter authorFamily1Parameter = updateCommand.Parameters.Add("@AuthorFamily1", DbType.String);
- SQLiteParameter authorName1Parameter = updateCommand.Parameters.Add("@AuthorName1", DbType.String);
- SQLiteParameter authorSurname1Parameter = updateCommand.Parameters.Add("@AuthorSurname1", DbType.String);
- SQLiteParameter role1Parameter = updateCommand.Parameters.Add("@Role1", DbType.String);
- SQLiteParameter pseudonim1Parameter = updateCommand.Parameters.Add("@Pseudonim1", DbType.String);
- SQLiteParameter authorFamily2Parameter = updateCommand.Parameters.Add("@AuthorFamily2", DbType.String);
- SQLiteParameter authorName2Parameter = updateCommand.Parameters.Add("@AuthorName2", DbType.String);
- SQLiteParameter authorSurname2Parameter = updateCommand.Parameters.Add("@AuthorSurname2", DbType.String);
- SQLiteParameter role2Parameter = updateCommand.Parameters.Add("@Role2", DbType.String);
- SQLiteParameter pseudonim2Parameter = updateCommand.Parameters.Add("@Pseudonim2", DbType.String);
- SQLiteParameter authorFamily3Parameter = updateCommand.Parameters.Add("@AuthorFamily3", DbType.String);
- SQLiteParameter authorName3Parameter = updateCommand.Parameters.Add("@AuthorName3", DbType.String);
- SQLiteParameter authorSurname3Parameter = updateCommand.Parameters.Add("@AuthorSurname3", DbType.String);
- SQLiteParameter role3Parameter = updateCommand.Parameters.Add("@Role3", DbType.String);
- SQLiteParameter pseudonim3Parameter = updateCommand.Parameters.Add("@Pseudonim3", DbType.String);
- SQLiteParameter authorFamily4Parameter = updateCommand.Parameters.Add("@AuthorFamily4", DbType.String);
- SQLiteParameter authorName4Parameter = updateCommand.Parameters.Add("@AuthorName4", DbType.String);
- SQLiteParameter authorSurname4Parameter = updateCommand.Parameters.Add("@AuthorSurname4", DbType.String);
- SQLiteParameter role4Parameter = updateCommand.Parameters.Add("@Role4", DbType.String);
- SQLiteParameter pseudonim4Parameter = updateCommand.Parameters.Add("@Pseudonim4", DbType.String);
- SQLiteParameter series1Parameter = updateCommand.Parameters.Add("@Series1", DbType.String);
- SQLiteParameter series2Parameter = updateCommand.Parameters.Add("@Series2", DbType.String);
- SQLiteParameter series3Parameter = updateCommand.Parameters.Add("@Series3", DbType.String);
- SQLiteParameter series4Parameter = updateCommand.Parameters.Add("@Series4", DbType.String);
- SQLiteParameter titleParameter = updateCommand.Parameters.Add("@Title", DbType.String);
- SQLiteParameter formatParameter = updateCommand.Parameters.Add("@Format", DbType.String);
- SQLiteParameter versionParameter = updateCommand.Parameters.Add("@Version", DbType.String);
- SQLiteParameter sizeInBytesParameter = updateCommand.Parameters.Add("@SizeInBytes", DbType.Int64);
SQLiteParameter md5HashParameter = updateCommand.Parameters.Add("@Md5Hash", DbType.String);
- SQLiteParameter pathParameter = updateCommand.Parameters.Add("@Path", DbType.String);
+ SQLiteParameter titleParameter = updateCommand.Parameters.Add("@Title", DbType.String);
+ SQLiteParameter authorsParameter = updateCommand.Parameters.Add("@Authors", DbType.String);
+ SQLiteParameter seriesParameter = updateCommand.Parameters.Add("@Series", DbType.String);
+ SQLiteParameter editionParameter = updateCommand.Parameters.Add("@Edition", DbType.String);
SQLiteParameter languageParameter = updateCommand.Parameters.Add("@Language", DbType.String);
- SQLiteParameter pagesParameter = updateCommand.Parameters.Add("@Pages", DbType.String);
- SQLiteParameter identifierParameter = updateCommand.Parameters.Add("@Identifier", DbType.String);
SQLiteParameter yearParameter = updateCommand.Parameters.Add("@Year", DbType.String);
SQLiteParameter publisherParameter = updateCommand.Parameters.Add("@Publisher", DbType.String);
- SQLiteParameter editionParameter = updateCommand.Parameters.Add("@Edition", DbType.String);
- SQLiteParameter commentaryParameter = updateCommand.Parameters.Add("@Commentary", DbType.String);
- SQLiteParameter addedDateTimeParameter = updateCommand.Parameters.Add("@AddedDateTime", DbType.String);
- SQLiteParameter lastModifiedDateTimeParameter = updateCommand.Parameters.Add("@LastModifiedDateTime", DbType.String);
- SQLiteParameter russianAuthorFamilyParameter = updateCommand.Parameters.Add("@RussianAuthorFamily", DbType.String);
- SQLiteParameter russianAuthorNameParameter = updateCommand.Parameters.Add("@RussianAuthorName", DbType.String);
- SQLiteParameter russianAuthorSurnameParameter = updateCommand.Parameters.Add("@RussianAuthorSurname", DbType.String);
- SQLiteParameter coverParameter = updateCommand.Parameters.Add("@Cover", DbType.String);
+ SQLiteParameter pagesParameter = updateCommand.Parameters.Add("@Pages", DbType.String);
+ SQLiteParameter identifierParameter = updateCommand.Parameters.Add("@Identifier", DbType.String);
SQLiteParameter googleBookIdParameter = updateCommand.Parameters.Add("@GoogleBookId", DbType.String);
SQLiteParameter asinParameter = updateCommand.Parameters.Add("@Asin", DbType.String);
- SQLiteParameter authorHashParameter = updateCommand.Parameters.Add("@AuthorHash", DbType.String);
- SQLiteParameter titleHashParameter = updateCommand.Parameters.Add("@TitleHash", DbType.String);
+ SQLiteParameter coverUrlParameter = updateCommand.Parameters.Add("@CoverUrl", DbType.String);
+ SQLiteParameter formatParameter = updateCommand.Parameters.Add("@Format", DbType.String);
+ SQLiteParameter sizeInBytesParameter = updateCommand.Parameters.Add("@SizeInBytes", DbType.Int64);
+ SQLiteParameter libraryParameter = updateCommand.Parameters.Add("@Library", DbType.String);
+ SQLiteParameter issueParameter = updateCommand.Parameters.Add("@Issue", DbType.String);
+ SQLiteParameter locatorParameter = updateCommand.Parameters.Add("@Locator", DbType.String);
+ SQLiteParameter commentaryParameter = updateCommand.Parameters.Add("@Commentary", DbType.String);
+ SQLiteParameter genericParameter = updateCommand.Parameters.Add("@Generic", DbType.String);
SQLiteParameter visibleParameter = updateCommand.Parameters.Add("@Visible", DbType.String);
+ SQLiteParameter addedDateTimeParameter = updateCommand.Parameters.Add("@AddedDateTime", DbType.String);
+ SQLiteParameter lastModifiedDateTimeParameter = updateCommand.Parameters.Add("@LastModifiedDateTime", DbType.String);
insertFtsWithIdCommand.CommandText = SqlScripts.INSERT_FICTION_FTS_WITH_ID;
SQLiteParameter idFtsParameter = insertFtsWithIdCommand.Parameters.Add("@Id", DbType.Int32);
SQLiteParameter titleFtsParameter = insertFtsWithIdCommand.Parameters.Add("@Title", DbType.String);
- SQLiteParameter authorFamily1FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorFamily1", DbType.String);
- SQLiteParameter authorName1FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorName1", DbType.String);
- SQLiteParameter authorSurname1FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorSurname1", DbType.String);
- SQLiteParameter pseudonim1FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Pseudonim1", DbType.String);
- SQLiteParameter authorFamily2FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorFamily2", DbType.String);
- SQLiteParameter authorName2FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorName2", DbType.String);
- SQLiteParameter authorSurname2FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorSurname2", DbType.String);
- SQLiteParameter pseudonim2FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Pseudonim2", DbType.String);
- SQLiteParameter authorFamily3FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorFamily3", DbType.String);
- SQLiteParameter authorName3FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorName3", DbType.String);
- SQLiteParameter authorSurname3FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorSurname3", DbType.String);
- SQLiteParameter pseudonim3FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Pseudonim3", DbType.String);
- SQLiteParameter authorFamily4FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorFamily4", DbType.String);
- SQLiteParameter authorName4FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorName4", DbType.String);
- SQLiteParameter authorSurname4FtsParameter = insertFtsWithIdCommand.Parameters.Add("@AuthorSurname4", DbType.String);
- SQLiteParameter pseudonim4FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Pseudonim4", DbType.String);
- SQLiteParameter russianAuthorFamilyFtsParameter = insertFtsWithIdCommand.Parameters.Add("@RussianAuthorFamily", DbType.String);
- SQLiteParameter russianAuthorNameFtsParameter = insertFtsWithIdCommand.Parameters.Add("@RussianAuthorName", DbType.String);
- SQLiteParameter russianAuthorSurnameFtsParameter = insertFtsWithIdCommand.Parameters.Add("@RussianAuthorSurname", DbType.String);
- SQLiteParameter series1FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Series1", DbType.String);
- SQLiteParameter series2FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Series2", DbType.String);
- SQLiteParameter series3FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Series3", DbType.String);
- SQLiteParameter series4FtsParameter = insertFtsWithIdCommand.Parameters.Add("@Series4", DbType.String);
+ SQLiteParameter authorsFtsParameter = insertFtsWithIdCommand.Parameters.Add("@Authors", DbType.String);
+ SQLiteParameter seriesFtsParameter = insertFtsWithIdCommand.Parameters.Add("@Series", DbType.String);
SQLiteParameter publisherFtsParameter = insertFtsWithIdCommand.Parameters.Add("@Publisher", DbType.String);
SQLiteParameter identifierFtsParameter = insertFtsWithIdCommand.Parameters.Add("@Identifier", DbType.String);
foreach (FictionBook book in books)
{
idDeleteFtsParameter.Value = book.Id;
titleDeleteFtsParameter.Value = book.Title.SeparateCjkCharactersWithSpaces();
- authorFamily1DeleteFtsParameter.Value = book.AuthorFamily1.SeparateCjkCharactersWithSpaces();
- authorName1DeleteFtsParameter.Value = book.AuthorName1.SeparateCjkCharactersWithSpaces();
- authorSurname1DeleteFtsParameter.Value = book.AuthorSurname1.SeparateCjkCharactersWithSpaces();
- pseudonim1DeleteFtsParameter.Value = book.Pseudonim1.SeparateCjkCharactersWithSpaces();
- authorFamily2DeleteFtsParameter.Value = book.AuthorFamily2.SeparateCjkCharactersWithSpaces();
- authorName2DeleteFtsParameter.Value = book.AuthorName2.SeparateCjkCharactersWithSpaces();
- authorSurname2DeleteFtsParameter.Value = book.AuthorSurname2.SeparateCjkCharactersWithSpaces();
- pseudonim2DeleteFtsParameter.Value = book.Pseudonim2.SeparateCjkCharactersWithSpaces();
- authorFamily3DeleteFtsParameter.Value = book.AuthorFamily3.SeparateCjkCharactersWithSpaces();
- authorName3DeleteFtsParameter.Value = book.AuthorName3.SeparateCjkCharactersWithSpaces();
- authorSurname3DeleteFtsParameter.Value = book.AuthorSurname3.SeparateCjkCharactersWithSpaces();
- pseudonim3DeleteFtsParameter.Value = book.Pseudonim3.SeparateCjkCharactersWithSpaces();
- authorFamily4DeleteFtsParameter.Value = book.AuthorFamily4.SeparateCjkCharactersWithSpaces();
- authorName4DeleteFtsParameter.Value = book.AuthorName4.SeparateCjkCharactersWithSpaces();
- authorSurname4DeleteFtsParameter.Value = book.AuthorSurname4.SeparateCjkCharactersWithSpaces();
- pseudonim4DeleteFtsParameter.Value = book.Pseudonim4.SeparateCjkCharactersWithSpaces();
- russianAuthorFamilyDeleteFtsParameter.Value = book.RussianAuthorFamily;
- russianAuthorNameDeleteFtsParameter.Value = book.RussianAuthorName;
- russianAuthorSurnameDeleteFtsParameter.Value = book.RussianAuthorSurname;
- series1DeleteFtsParameter.Value = book.Series1.SeparateCjkCharactersWithSpaces();
- series2DeleteFtsParameter.Value = book.Series2.SeparateCjkCharactersWithSpaces();
- series3DeleteFtsParameter.Value = book.Series3.SeparateCjkCharactersWithSpaces();
- series4DeleteFtsParameter.Value = book.Series4.SeparateCjkCharactersWithSpaces();
+ authorsDeleteFtsParameter.Value = book.Authors.SeparateCjkCharactersWithSpaces();
+ seriesDeleteFtsParameter.Value = book.Series.SeparateCjkCharactersWithSpaces();
publisherDeleteFtsParameter.Value = book.Publisher.SeparateCjkCharactersWithSpaces();
identifierDeleteFtsParameter.Value = book.Identifier;
deleteFtsCommand.ExecuteNonQuery();
idParameter.Value = book.Id;
- authorFamily1Parameter.Value = book.AuthorFamily1;
- authorName1Parameter.Value = book.AuthorName1;
- authorSurname1Parameter.Value = book.AuthorSurname1;
- role1Parameter.Value = book.Role1;
- pseudonim1Parameter.Value = book.Pseudonim1;
- authorFamily2Parameter.Value = book.AuthorFamily2;
- authorName2Parameter.Value = book.AuthorName2;
- authorSurname2Parameter.Value = book.AuthorSurname2;
- role2Parameter.Value = book.Role2;
- pseudonim2Parameter.Value = book.Pseudonim2;
- authorFamily3Parameter.Value = book.AuthorFamily3;
- authorName3Parameter.Value = book.AuthorName3;
- authorSurname3Parameter.Value = book.AuthorSurname3;
- role3Parameter.Value = book.Role3;
- pseudonim3Parameter.Value = book.Pseudonim3;
- authorFamily4Parameter.Value = book.AuthorFamily4;
- authorName4Parameter.Value = book.AuthorName4;
- authorSurname4Parameter.Value = book.AuthorSurname4;
- role4Parameter.Value = book.Role4;
- pseudonim4Parameter.Value = book.Pseudonim4;
- series1Parameter.Value = book.Series1;
- series2Parameter.Value = book.Series2;
- series3Parameter.Value = book.Series3;
- series4Parameter.Value = book.Series4;
- titleParameter.Value = book.Title;
- formatParameter.Value = book.Format;
- versionParameter.Value = book.Version;
- sizeInBytesParameter.Value = book.SizeInBytes;
md5HashParameter.Value = book.Md5Hash;
- pathParameter.Value = book.Path;
+ titleParameter.Value = book.Title;
+ authorsParameter.Value = book.Authors;
+ seriesParameter.Value = book.Series;
+ editionParameter.Value = book.Edition;
languageParameter.Value = book.Language;
- pagesParameter.Value = book.Pages;
- identifierParameter.Value = book.Identifier;
yearParameter.Value = book.Year;
publisherParameter.Value = book.Publisher;
- editionParameter.Value = book.Edition;
- commentaryParameter.Value = book.Commentary;
- addedDateTimeParameter.Value = book.AddedDateTime?.ToString("s");
- lastModifiedDateTimeParameter.Value = book.LastModifiedDateTime.ToString("s");
- russianAuthorFamilyParameter.Value = book.RussianAuthorFamily;
- russianAuthorNameParameter.Value = book.RussianAuthorName;
- russianAuthorSurnameParameter.Value = book.RussianAuthorSurname;
- coverParameter.Value = book.Cover;
+ pagesParameter.Value = book.Pages;
+ identifierParameter.Value = book.Identifier;
googleBookIdParameter.Value = book.GoogleBookId;
asinParameter.Value = book.Asin;
- authorHashParameter.Value = book.AuthorHash;
- titleHashParameter.Value = book.TitleHash;
+ coverUrlParameter.Value = book.CoverUrl;
+ formatParameter.Value = book.Format;
+ sizeInBytesParameter.Value = book.SizeInBytes;
+ libraryParameter.Value = book.Library;
+ issueParameter.Value = book.Issue;
+ locatorParameter.Value = book.Locator;
+ commentaryParameter.Value = book.Commentary;
+ genericParameter.Value = book.Generic;
visibleParameter.Value = book.Visible;
+ addedDateTimeParameter.Value = book.AddedDateTime?.ToString("s");
+ lastModifiedDateTimeParameter.Value = book.LastModifiedDateTime?.ToString("s");
updateCommand.ExecuteNonQuery();
idFtsParameter.Value = book.Id;
titleFtsParameter.Value = book.Title.SeparateCjkCharactersWithSpaces();
- authorFamily1FtsParameter.Value = book.AuthorFamily1.SeparateCjkCharactersWithSpaces();
- authorName1FtsParameter.Value = book.AuthorName1.SeparateCjkCharactersWithSpaces();
- authorSurname1FtsParameter.Value = book.AuthorSurname1.SeparateCjkCharactersWithSpaces();
- pseudonim1FtsParameter.Value = book.Pseudonim1.SeparateCjkCharactersWithSpaces();
- authorFamily2FtsParameter.Value = book.AuthorFamily2.SeparateCjkCharactersWithSpaces();
- authorName2FtsParameter.Value = book.AuthorName2.SeparateCjkCharactersWithSpaces();
- authorSurname2FtsParameter.Value = book.AuthorSurname2.SeparateCjkCharactersWithSpaces();
- pseudonim2FtsParameter.Value = book.Pseudonim2.SeparateCjkCharactersWithSpaces();
- authorFamily3FtsParameter.Value = book.AuthorFamily3.SeparateCjkCharactersWithSpaces();
- authorName3FtsParameter.Value = book.AuthorName3.SeparateCjkCharactersWithSpaces();
- authorSurname3FtsParameter.Value = book.AuthorSurname3.SeparateCjkCharactersWithSpaces();
- pseudonim3FtsParameter.Value = book.Pseudonim3.SeparateCjkCharactersWithSpaces();
- authorFamily4FtsParameter.Value = book.AuthorFamily4.SeparateCjkCharactersWithSpaces();
- authorName4FtsParameter.Value = book.AuthorName4.SeparateCjkCharactersWithSpaces();
- authorSurname4FtsParameter.Value = book.AuthorSurname4.SeparateCjkCharactersWithSpaces();
- pseudonim4FtsParameter.Value = book.Pseudonim4.SeparateCjkCharactersWithSpaces();
- russianAuthorFamilyFtsParameter.Value = book.RussianAuthorFamily;
- russianAuthorNameFtsParameter.Value = book.RussianAuthorName;
- russianAuthorSurnameFtsParameter.Value = book.RussianAuthorSurname;
- series1FtsParameter.Value = book.Series1.SeparateCjkCharactersWithSpaces();
- series2FtsParameter.Value = book.Series2.SeparateCjkCharactersWithSpaces();
- series3FtsParameter.Value = book.Series3.SeparateCjkCharactersWithSpaces();
- series4FtsParameter.Value = book.Series4.SeparateCjkCharactersWithSpaces();
+ authorsFtsParameter.Value = book.Authors.SeparateCjkCharactersWithSpaces();
+ seriesFtsParameter.Value = book.Series.SeparateCjkCharactersWithSpaces();
publisherFtsParameter.Value = book.Publisher.SeparateCjkCharactersWithSpaces();
identifierFtsParameter.Value = book.Identifier;
insertFtsWithIdCommand.ExecuteNonQuery();
@@ -1053,6 +828,12 @@ public List GetFictionIndexList()
return GetIndexList(SqlScripts.GET_FICTION_INDEX_LIST);
}
+ public void DropFictionTables()
+ {
+ ExecuteCommands(SqlScripts.DROP_FICTION_FTS_TABLE);
+ ExecuteCommands(SqlScripts.DROP_FICTION_TABLE);
+ }
+
public void CreateSciMagTables()
{
ExecuteCommands(SqlScripts.CREATE_SCIMAG_TABLE);
@@ -1277,10 +1058,18 @@ public void CreateFilesTable()
ExecuteCommands(SqlScripts.CREATE_FILES_TABLE);
}
- public void AddFileIdColumns()
+ public void AddFileIdColumnToNonFictionTable()
{
ExecuteCommands(SqlScripts.ALTER_NON_FICTION_ADD_FILE_ID);
+ }
+
+ public void AddFileIdColumnToFictionTable()
+ {
ExecuteCommands(SqlScripts.ALTER_FICTION_ADD_FILE_ID);
+ }
+
+ public void AddFileIdColumnToSciMagTable()
+ {
ExecuteCommands(SqlScripts.ALTER_SCIMAG_ADD_FILE_ID);
}
@@ -1430,8 +1219,54 @@ public string RunCustomSqlQuery(string sqlQuery)
return resultBuilder.ToString();
}
+ private static string EscapeSearchQuery(string originalSearchQuery)
+ {
+ return SearchQueryParser.GetEscapedQuery(originalSearchQuery.SeparateCjkCharactersWithSpaces());
+ }
+
+ private static string GetSearchCommandWithLimit(string searchCommand, int? resultLimit)
+ {
+ return searchCommand + (resultLimit.HasValue ? " LIMIT " + resultLimit.Value : String.Empty);
+ }
+
+ private static int ParseIntScalarResult(object objectResult)
+ {
+ return objectResult != DBNull.Value ? (int)(long)objectResult : 0;
+ }
+
+ private static int? ParseNullableIntScalarResult(object objectResult)
+ {
+ return objectResult != DBNull.Value ? (int?)(long)objectResult : null;
+ }
+
+ private static string ParseNullableDbString(object input)
+ {
+ return input != DBNull.Value ? input.ToString() : null;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static DateTime ParseDbDate(string input)
+ {
+ return DateTime.ParseExact(input, "s", CultureInfo.InvariantCulture);
+ }
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private NonFictionBook ReadNonFictionBook(SQLiteDataReader dataReader)
+ private static DateTime? ParseNullableDbDate(object input)
+ {
+ if (input is string inputString)
+ {
+ if (String.IsNullOrEmpty(inputString))
+ {
+ return null;
+ }
+ return ParseDbDate(inputString);
+ }
+ return null;
+ }
+
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static NonFictionBook ReadNonFictionBook(SQLiteDataReader dataReader)
{
NonFictionBook book = new NonFictionBook();
book.Id = dataReader.GetInt32(0);
@@ -1486,66 +1321,43 @@ private NonFictionBook ReadNonFictionBook(SQLiteDataReader dataReader)
return book;
}
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private FictionBook ReadFictionBook(SQLiteDataReader dataReader)
+ private static FictionBook ReadFictionBook(SQLiteDataReader dataReader)
{
FictionBook book = new FictionBook();
book.Id = dataReader.GetInt32(0);
- book.AuthorFamily1 = dataReader.GetString(1);
- book.AuthorName1 = dataReader.GetString(2);
- book.AuthorSurname1 = dataReader.GetString(3);
- book.Role1 = dataReader.GetString(4);
- book.Pseudonim1 = dataReader.GetString(5);
- book.AuthorFamily2 = dataReader.GetString(6);
- book.AuthorName2 = dataReader.GetString(7);
- book.AuthorSurname2 = dataReader.GetString(8);
- book.Role2 = dataReader.GetString(9);
- book.Pseudonim2 = dataReader.GetString(10);
- book.AuthorFamily3 = dataReader.GetString(11);
- book.AuthorName3 = dataReader.GetString(12);
- book.AuthorSurname3 = dataReader.GetString(13);
- book.Role3 = dataReader.GetString(14);
- book.Pseudonim3 = dataReader.GetString(15);
- book.AuthorFamily4 = dataReader.GetString(16);
- book.AuthorName4 = dataReader.GetString(17);
- book.AuthorSurname4 = dataReader.GetString(18);
- book.Role4 = dataReader.GetString(19);
- book.Pseudonim4 = dataReader.GetString(20);
- book.Series1 = dataReader.GetString(21);
- book.Series2 = dataReader.GetString(22);
- book.Series3 = dataReader.GetString(23);
- book.Series4 = dataReader.GetString(24);
- book.Title = dataReader.GetString(25);
- book.Format = dataReader.GetString(26);
- book.Version = dataReader.GetString(27);
- book.SizeInBytes = dataReader.GetInt64(28);
- book.Md5Hash = dataReader.GetString(29);
- book.Path = dataReader.GetString(30);
- book.Language = dataReader.GetString(31);
- book.Pages = dataReader.GetString(32);
- book.Identifier = dataReader.GetString(33);
- book.Year = dataReader.GetString(34);
- book.Publisher = dataReader.GetString(35);
- book.Edition = dataReader.GetString(36);
- book.Commentary = dataReader.GetString(37);
- book.AddedDateTime = ParseNullableDbDate(dataReader.GetValue(38));
- book.LastModifiedDateTime = ParseDbDate(dataReader.GetString(39));
- book.RussianAuthorFamily = dataReader.GetString(40);
- book.RussianAuthorName = dataReader.GetString(41);
- book.RussianAuthorSurname = dataReader.GetString(42);
- book.Cover = dataReader.GetString(43);
- book.GoogleBookId = dataReader.GetString(44);
- book.Asin = dataReader.GetString(45);
- book.AuthorHash = dataReader.GetString(46);
- book.TitleHash = dataReader.GetString(47);
- book.Visible = dataReader.GetString(48);
- book.LibgenId = dataReader.GetInt32(49);
- book.FileId = ParseNullableIntScalarResult(dataReader.GetValue(50));
+ book.Md5Hash = dataReader.GetString(1);
+ book.Title = dataReader.GetString(2);
+ book.Authors = dataReader.GetString(3);
+ book.Series = dataReader.GetString(4);
+ book.Edition = dataReader.GetString(5);
+ book.Language = dataReader.GetString(6);
+ book.Year = dataReader.GetString(7);
+ book.Publisher = dataReader.GetString(8);
+ book.Pages = dataReader.GetString(9);
+ book.Identifier = dataReader.GetString(10);
+ book.GoogleBookId = dataReader.GetString(11);
+ book.Asin = dataReader.GetString(12);
+ book.CoverUrl = dataReader.GetString(13);
+ book.Format = dataReader.GetString(14);
+ book.SizeInBytes = dataReader.GetInt64(15);
+ book.Library = dataReader.GetString(16);
+ book.Issue = dataReader.GetString(17);
+ book.Locator = dataReader.GetString(18);
+ book.Commentary = dataReader.GetString(19);
+ book.Generic = dataReader.GetString(20);
+ book.Visible = dataReader.GetString(21);
+ book.AddedDateTime = ParseNullableDbDate(dataReader.GetValue(22));
+ book.LastModifiedDateTime = ParseNullableDbDate(dataReader.GetValue(23));
+ book.LibgenId = dataReader.GetInt32(24);
+ book.FileId = ParseNullableIntScalarResult(dataReader.GetValue(25));
return book;
}
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private SciMagArticle ReadSciMagArticle(SQLiteDataReader dataReader)
+ private static SciMagArticle ReadSciMagArticle(SQLiteDataReader dataReader)
{
SciMagArticle article = new SciMagArticle();
article.Id = dataReader.GetInt32(0);
@@ -1584,8 +1396,9 @@ private SciMagArticle ReadSciMagArticle(SQLiteDataReader dataReader)
return article;
}
+ [SuppressMessage("Style", "IDE0017:Simplify object initialization")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private LibraryFile ReadFile(SQLiteDataReader dataReader)
+ private static LibraryFile ReadFile(SQLiteDataReader dataReader)
{
LibraryFile file = new LibraryFile();
file.Id = dataReader.GetInt32(0);
@@ -1596,16 +1409,6 @@ private LibraryFile ReadFile(SQLiteDataReader dataReader)
return file;
}
- private string EscapeSearchQuery(string originalSearchQuery)
- {
- return SearchQueryParser.GetEscapedQuery(originalSearchQuery.SeparateCjkCharactersWithSpaces());
- }
-
- private string GetSearchCommandWithLimit(string searchCommand, int? resultLimit)
- {
- return searchCommand + (resultLimit.HasValue ? " LIMIT " + resultLimit.Value : String.Empty);
- }
-
private void ExecuteCommands(params string[] commands)
{
using (SQLiteCommand command = connection.CreateCommand())
@@ -1623,11 +1426,6 @@ private int ExecuteIntScalarCommand(string commandText)
return ParseIntScalarResult(ExecuteScalarCommand(commandText));
}
- private string ExecuteStringScalarCommand(string commandText)
- {
- return ParseNullableDbString(ExecuteScalarCommand(commandText));
- }
-
private object ExecuteScalarCommand(string commandText)
{
using (SQLiteCommand command = connection.CreateCommand())
@@ -1637,41 +1435,6 @@ private object ExecuteScalarCommand(string commandText)
}
}
- private int ParseIntScalarResult(object objectResult)
- {
- return objectResult != DBNull.Value ? (int)(long)objectResult : 0;
- }
-
- private int? ParseNullableIntScalarResult(object objectResult)
- {
- return objectResult != DBNull.Value ? (int?)(long)objectResult : null;
- }
-
- private string ParseNullableDbString(object input)
- {
- return input != DBNull.Value ? input.ToString() : null;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private DateTime ParseDbDate(string input)
- {
- return DateTime.ParseExact(input, "s", CultureInfo.InvariantCulture);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private DateTime? ParseNullableDbDate(object input)
- {
- if (input is string inputString)
- {
- if (String.IsNullOrEmpty(inputString))
- {
- return null;
- }
- return ParseDbDate(inputString);
- }
- return null;
- }
-
private List GetIndexList(string getIndexListQuery)
{
List result = new List();
diff --git a/LibgenDesktop/Models/Database/Migration.cs b/LibgenDesktop/Models/Database/Migration.cs
index c245b30..3118f23 100644
--- a/LibgenDesktop/Models/Database/Migration.cs
+++ b/LibgenDesktop/Models/Database/Migration.cs
@@ -16,6 +16,8 @@ public static bool Migrate(LocalDatabase localDatabase, DatabaseMetadata databas
return MigrateFrom_1_0(localDatabase, databaseMetadata);
case "1.2":
return MigrateFrom_1_2(localDatabase, databaseMetadata);
+ case "1.2.1":
+ return MigrateFrom_1_2_1(localDatabase, databaseMetadata);
case Constants.CURRENT_DATABASE_VERSION:
return true;
default:
@@ -23,19 +25,36 @@ public static bool Migrate(LocalDatabase localDatabase, DatabaseMetadata databas
}
}
+ public static bool UsesOldFictionSchema(DatabaseMetadata databaseMetadata)
+ {
+ Version metadataVersion = databaseMetadata.GetParsedVersion();
+ if (metadataVersion == null)
+ {
+ throw new Exception("Database metadata has an invalid version number.");
+ }
+ return metadataVersion < new Version("1.4");
+ }
+
private static bool MigrateFrom_0_7(LocalDatabase localDatabase, DatabaseMetadata databaseMetadata)
{
- return AddFiles(localDatabase) && UpdateMetadata(localDatabase, databaseMetadata);
+ return AddFilesTable(localDatabase) && RecreateFictionTables(localDatabase) && AddFileIdColumns(localDatabase) &&
+ UpdateMetadata(localDatabase, databaseMetadata);
}
private static bool MigrateFrom_1_0(LocalDatabase localDatabase, DatabaseMetadata databaseMetadata)
{
- return AddFiles(localDatabase) && UpdateMetadata(localDatabase, databaseMetadata);
+ return AddFilesTable(localDatabase) && RecreateFictionTables(localDatabase) && AddFileIdColumns(localDatabase) &&
+ UpdateMetadata(localDatabase, databaseMetadata);
}
private static bool MigrateFrom_1_2(LocalDatabase localDatabase, DatabaseMetadata databaseMetadata)
{
- return UpdateMetadata(localDatabase, databaseMetadata);
+ return RecreateFictionTables(localDatabase) && UpdateMetadata(localDatabase, databaseMetadata);
+ }
+
+ private static bool MigrateFrom_1_2_1(LocalDatabase localDatabase, DatabaseMetadata databaseMetadata)
+ {
+ return RecreateFictionTables(localDatabase) && UpdateMetadata(localDatabase, databaseMetadata);
}
private static bool UpdateMetadata(LocalDatabase localDatabase, DatabaseMetadata databaseMetadata)
@@ -54,12 +73,41 @@ private static bool UpdateMetadata(LocalDatabase localDatabase, DatabaseMetadata
}
}
- private static bool AddFiles(LocalDatabase localDatabase)
+ private static bool AddFilesTable(LocalDatabase localDatabase)
{
try
{
localDatabase.CreateFilesTable();
- localDatabase.AddFileIdColumns();
+ return true;
+ }
+ catch (Exception exception)
+ {
+ Logger.Exception(exception);
+ return false;
+ }
+ }
+
+ private static bool AddFileIdColumns(LocalDatabase localDatabase)
+ {
+ try
+ {
+ localDatabase.AddFileIdColumnToNonFictionTable();
+ localDatabase.AddFileIdColumnToSciMagTable();
+ return true;
+ }
+ catch (Exception exception)
+ {
+ Logger.Exception(exception);
+ return false;
+ }
+ }
+
+ private static bool RecreateFictionTables(LocalDatabase localDatabase)
+ {
+ try
+ {
+ localDatabase.DropFictionTables();
+ localDatabase.CreateFictionTables();
return true;
}
catch (Exception exception)
diff --git a/LibgenDesktop/Models/Database/SearchQueryParser.cs b/LibgenDesktop/Models/Database/SearchQueryParser.cs
index 42091d3..09adc3f 100644
--- a/LibgenDesktop/Models/Database/SearchQueryParser.cs
+++ b/LibgenDesktop/Models/Database/SearchQueryParser.cs
@@ -17,6 +17,35 @@ public static string GetEscapedQuery(string originalSearchQuery)
return new SearchQueryParser(originalSearchQuery).GetEscapedQuery();
}
+ private static void AddSearchQueryPart(List searchQueryBuilder, string searchQueryPart)
+ {
+ if (searchQueryPart.StartsWith("\""))
+ {
+ searchQueryBuilder.Add(searchQueryPart);
+ }
+ else
+ {
+ switch (searchQueryPart)
+ {
+ case "AND":
+ case "OR":
+ case "NOT":
+ searchQueryBuilder.Add(searchQueryPart);
+ break;
+ default:
+ if (searchQueryPart.Length > 1 && searchQueryPart.EndsWith("*"))
+ {
+ searchQueryBuilder.Add($"\"{searchQueryPart.Substring(0, searchQueryPart.Length - 1)}\"*");
+ }
+ else
+ {
+ searchQueryBuilder.Add($"\"{searchQueryPart}\"");
+ }
+ break;
+ }
+ }
+ }
+
private string GetEscapedQuery()
{
List searchQueryBuilder = new List();
@@ -87,34 +116,5 @@ private string GetEscapedQuery()
}
return String.Join(" ", searchQueryBuilder);
}
-
- private void AddSearchQueryPart(List searchQueryBuilder, string searchQueryPart)
- {
- if (searchQueryPart.StartsWith("\""))
- {
- searchQueryBuilder.Add(searchQueryPart);
- }
- else
- {
- switch (searchQueryPart)
- {
- case "AND":
- case "OR":
- case "NOT":
- searchQueryBuilder.Add(searchQueryPart);
- break;
- default:
- if (searchQueryPart.Length > 1 && searchQueryPart.EndsWith("*"))
- {
- searchQueryBuilder.Add($"\"{searchQueryPart.Substring(0, searchQueryPart.Length - 1)}\"*");
- }
- else
- {
- searchQueryBuilder.Add($"\"{searchQueryPart}\"");
- }
- break;
- }
- }
- }
}
}
diff --git a/LibgenDesktop/Models/Database/SqlScripts.cs b/LibgenDesktop/Models/Database/SqlScripts.cs
index 47f3de0..de35c90 100644
--- a/LibgenDesktop/Models/Database/SqlScripts.cs
+++ b/LibgenDesktop/Models/Database/SqlScripts.cs
@@ -177,64 +177,36 @@ internal static class SqlScripts
public const string CREATE_FICTION_TABLE =
"CREATE TABLE IF NOT EXISTS fiction (" +
"Id INTEGER PRIMARY KEY NOT NULL," +
- "AuthorFamily1 TEXT," +
- "AuthorName1 TEXT," +
- "AuthorSurname1 TEXT," +
- "Role1 TEXT," +
- "Pseudonim1 TEXT," +
- "AuthorFamily2 TEXT," +
- "AuthorName2 TEXT," +
- "AuthorSurname2 TEXT," +
- "Role2 TEXT," +
- "Pseudonim2 TEXT," +
- "AuthorFamily3 TEXT," +
- "AuthorName3 TEXT," +
- "AuthorSurname3 TEXT," +
- "Role3 TEXT," +
- "Pseudonim3 TEXT," +
- "AuthorFamily4 TEXT," +
- "AuthorName4 TEXT," +
- "AuthorSurname4 TEXT," +
- "Role4 TEXT," +
- "Pseudonim4 TEXT," +
- "Series1 TEXT," +
- "Series2 TEXT," +
- "Series3 TEXT," +
- "Series4 TEXT," +
- "Title TEXT," +
- "Format TEXT," +
- "Version TEXT," +
- "SizeInBytes INTEGER NOT NULL," +
"Md5Hash TEXT," +
- "Path TEXT," +
+ "Title TEXT," +
+ "Authors TEXT," +
+ "Series TEXT," +
+ "Edition TEXT," +
"Language TEXT," +
- "Pages TEXT," +
- "Identifier TEXT," +
"Year TEXT," +
"Publisher TEXT," +
- "Edition TEXT," +
- "Commentary TEXT," +
- "AddedDateTime TEXT," +
- "LastModifiedDateTime TEXT NOT NULL," +
- "RussianAuthorFamily TEXT," +
- "RussianAuthorName TEXT," +
- "RussianAuthorSurname TEXT," +
- "Cover TEXT," +
+ "Pages TEXT," +
+ "Identifier TEXT," +
"GoogleBookId TEXT," +
"Asin TEXT," +
- "AuthorHash TEXT," +
- "TitleHash TEXT," +
+ "CoverUrl TEXT," +
+ "Format TEXT," +
+ "SizeInBytes INTEGER NOT NULL," +
+ "Library TEXT," +
+ "Issue TEXT," +
+ "Locator TEXT," +
+ "Commentary TEXT," +
+ "Generic TEXT," +
"Visible TEXT," +
+ "AddedDateTime TEXT," +
+ "LastModifiedDateTime TEXT," +
"LibgenId INTEGER NOT NULL," +
"FileId INTEGER," +
"FOREIGN KEY (FileId) REFERENCES files(Id)" +
")";
public const string CREATE_FICTION_FTS_TABLE =
- "CREATE VIRTUAL TABLE IF NOT EXISTS fiction_fts USING fts5 (Title, AuthorFamily1, AuthorName1, AuthorSurname1, Pseudonim1, " +
- "AuthorFamily2, AuthorName2, AuthorSurname2, Pseudonim2, AuthorFamily3, AuthorName3, AuthorSurname3, Pseudonim3, " +
- "AuthorFamily4, AuthorName4, AuthorSurname4, Pseudonim4, RussianAuthorFamily, RussianAuthorName, RussianAuthorSurname, " +
- "Series1, Series2, Series3, Series4, Publisher, Identifier, content=fiction, content_rowid=Id)";
+ "CREATE VIRTUAL TABLE IF NOT EXISTS fiction_fts USING fts5 (Title, Authors, Series, Publisher, Identifier, content=fiction, content_rowid=Id)";
public const string GET_ALL_FICTION_LIBGEN_IDS = "SELECT LibgenId FROM fiction";
@@ -254,87 +226,45 @@ internal static class SqlScripts
public const string SEARCH_FICTION = "SELECT * FROM fiction WHERE Id IN (SELECT rowid FROM fiction_fts WHERE fiction_fts MATCH @SearchQuery) ORDER BY Id";
public const string INSERT_FICTION =
- "INSERT INTO fiction VALUES (@Id,@AuthorFamily1,@AuthorName1,@AuthorSurname1,@Role1,@Pseudonim1,@AuthorFamily2,@AuthorName2,@AuthorSurname2,@Role2,@Pseudonim2," +
- "@AuthorFamily3,@AuthorName3,@AuthorSurname3,@Role3,@Pseudonim3,@AuthorFamily4,@AuthorName4,@AuthorSurname4,@Role4,@Pseudonim4,@Series1,@Series2,@Series3,@Series4," +
- "@Title,@Format,@Version,@SizeInBytes,@Md5Hash,@Path,@Language,@Pages,@Identifier,@Year,@Publisher,@Edition,@Commentary,@AddedDateTime,@LastModifiedDateTime," +
- "@RussianAuthorFamily,@RussianAuthorName,@RussianAuthorSurname,@Cover,@GoogleBookId,@Asin,@AuthorHash,@TitleHash,@Visible,@LibgenId,NULL)";
+ "INSERT INTO fiction VALUES (@Id,@Md5Hash,@Title,@Authors,@Series,@Edition,@Language,@Year,@Publisher,@Pages,@Identifier,@GoogleBookId,@Asin," +
+ "@CoverUrl,@Format,@SizeInBytes,@Library,@Issue,@Locator,@Commentary,@Generic,@Visible,@AddedDateTime,@LastModifiedDateTime,@LibgenId,NULL)";
public const string UPDATE_FICTION =
"UPDATE fiction SET " +
- "AuthorFamily1=@AuthorFamily1," +
- "AuthorName1=@AuthorName1," +
- "AuthorSurname1=@AuthorSurname1," +
- "Role1=@Role1," +
- "Pseudonim1=@Pseudonim1," +
- "AuthorFamily2=@AuthorFamily2," +
- "AuthorName2=@AuthorName2," +
- "AuthorSurname2=@AuthorSurname2," +
- "Role2=@Role2," +
- "Pseudonim2=@Pseudonim2," +
- "AuthorFamily3=@AuthorFamily3," +
- "AuthorName3=@AuthorName3," +
- "AuthorSurname3=@AuthorSurname3," +
- "Role3=@Role3," +
- "Pseudonim3=@Pseudonim3," +
- "AuthorFamily4=@AuthorFamily4," +
- "AuthorName4=@AuthorName4," +
- "AuthorSurname4=@AuthorSurname4," +
- "Role4=@Role4," +
- "Pseudonim4=@Pseudonim4," +
- "Series1=@Series1," +
- "Series2=@Series2," +
- "Series3=@Series3," +
- "Series4=@Series4," +
- "Title=@Title," +
- "Format=@Format," +
- "Version=@Version," +
- "SizeInBytes=@SizeInBytes," +
"Md5Hash=@Md5Hash," +
- "Path=@Path," +
+ "Title=@Title," +
+ "Authors=@Authors," +
+ "Series=@Series," +
+ "Edition=@Edition," +
"Language=@Language," +
- "Pages=@Pages," +
- "Identifier=@Identifier," +
"Year=@Year," +
"Publisher=@Publisher," +
- "Edition=@Edition," +
- "Commentary=@Commentary," +
- "AddedDateTime=@AddedDateTime," +
- "LastModifiedDateTime=@LastModifiedDateTime," +
- "RussianAuthorFamily=@RussianAuthorFamily," +
- "RussianAuthorName=@RussianAuthorName," +
- "RussianAuthorSurname=@RussianAuthorSurname," +
- "Cover=@Cover," +
+ "Pages=@Pages," +
+ "Identifier=@Identifier," +
"GoogleBookId=@GoogleBookId," +
"Asin=@Asin," +
- "AuthorHash=@AuthorHash," +
- "TitleHash=@TitleHash," +
- "Visible=@Visible " +
+ "CoverUrl=@CoverUrl," +
+ "Format=@Format," +
+ "SizeInBytes=@SizeInBytes" +
+ "Library=@Library," +
+ "Issue=@Issue," +
+ "Locator=@Locator," +
+ "Commentary=@Commentary," +
+ "Generic=@Generic," +
+ "Visible=@Visible," +
+ "AddedDateTime=@AddedDateTime," +
+ "LastModifiedDateTime=@LastModifiedDateTime " +
"WHERE Id=@Id";
public const string INSERT_FICTION_FTS_WITHOUT_ID =
- "INSERT INTO fiction_fts VALUES (@Title,@AuthorFamily1,@AuthorName1,@AuthorSurname1,@Pseudonim1," +
- "@AuthorFamily2,@AuthorName2,@AuthorSurname2,@Pseudonim2,@AuthorFamily3,@AuthorName3,@AuthorSurname3,@Pseudonim3," +
- "@AuthorFamily4,@AuthorName4,@AuthorSurname4,@Pseudonim4,@RussianAuthorFamily,@RussianAuthorName,@RussianAuthorSurname," +
- "@Series1,@Series2,@Series3,@Series4,@Publisher,@Identifier)";
+ "INSERT INTO fiction_fts VALUES (@Title,@Authors,@Series,@Publisher,@Identifier)";
public const string INSERT_FICTION_FTS_WITH_ID =
- "INSERT INTO fiction_fts (rowid,Title,AuthorFamily1,AuthorName1,AuthorSurname1,Pseudonim1," +
- "AuthorFamily2,AuthorName2,AuthorSurname2,Pseudonim2,AuthorFamily3,AuthorName3,AuthorSurname3,Pseudonim3," +
- "AuthorFamily4,AuthorName4,AuthorSurname4,Pseudonim4,RussianAuthorFamily,RussianAuthorName,RussianAuthorSurname," +
- "Series1,Series2,Series3,Series4,Publisher,Identifier) VALUES (@Id,@Title,@AuthorFamily1,@AuthorName1,@AuthorSurname1,@Pseudonim1," +
- "@AuthorFamily2,@AuthorName2,@AuthorSurname2,@Pseudonim2,@AuthorFamily3,@AuthorName3,@AuthorSurname3,@Pseudonim3," +
- "@AuthorFamily4,@AuthorName4,@AuthorSurname4,@Pseudonim4,@RussianAuthorFamily,@RussianAuthorName,@RussianAuthorSurname," +
- "@Series1,@Series2,@Series3,@Series4,@Publisher,@Identifier)";
+ "INSERT INTO fiction_fts (rowid,Title,Authors,Series,Publisher,Identifier) VALUES (@Id,@Title,@Authors,@Series,@Publisher,@Identifier)";
public const string DELETE_FICTION_FTS =
- "INSERT INTO fiction_fts (fiction_fts,rowid,Title,AuthorFamily1,AuthorName1,AuthorSurname1,Pseudonim1," +
- "AuthorFamily2,AuthorName2,AuthorSurname2,Pseudonim2,AuthorFamily3,AuthorName3,AuthorSurname3,Pseudonim3," +
- "AuthorFamily4,AuthorName4,AuthorSurname4,Pseudonim4,RussianAuthorFamily,RussianAuthorName,RussianAuthorSurname," +
- "Series1,Series2,Series3,Series4,Publisher,Identifier) "+
- "VALUES ('delete',@Id,@Title,@AuthorFamily1,@AuthorName1,@AuthorSurname1,@Pseudonim1," +
- "@AuthorFamily2,@AuthorName2,@AuthorSurname2,@Pseudonim2,@AuthorFamily3,@AuthorName3,@AuthorSurname3,@Pseudonim3," +
- "@AuthorFamily4,@AuthorName4,@AuthorSurname4,@Pseudonim4,@RussianAuthorFamily,@RussianAuthorName,@RussianAuthorSurname," +
- "@Series1,@Series2,@Series3,@Series4,@Publisher,@Identifier)";
+ "INSERT INTO fiction_fts (fiction_fts,rowid,Title,Authors,Series,Publisher,Identifier) " +
+ "VALUES ('delete',@Id,@Title,@Authors,@Series,@Publisher,@Identifier)";
public const string GET_FICTION_INDEX_LIST = "PRAGMA index_list(fiction)";
@@ -347,6 +277,10 @@ internal static class SqlScripts
public const string CREATE_FICTION_LIBGENID_INDEX = "CREATE UNIQUE INDEX " + FICTION_INDEX_PREFIX + "LibgenId ON fiction (LibgenId ASC)";
+ public const string DROP_FICTION_FTS_TABLE = "DROP TABLE IF EXISTS fiction_fts";
+
+ public const string DROP_FICTION_TABLE = "DROP TABLE IF EXISTS fiction";
+
public const string CREATE_SCIMAG_TABLE =
"CREATE TABLE IF NOT EXISTS scimag (" +
"Id INTEGER PRIMARY KEY NOT NULL," +
diff --git a/LibgenDesktop/Models/Download/Downloader.cs b/LibgenDesktop/Models/Download/DownloadManager.cs
similarity index 90%
rename from LibgenDesktop/Models/Download/Downloader.cs
rename to LibgenDesktop/Models/Download/DownloadManager.cs
index ae77c17..e1a0022 100644
--- a/LibgenDesktop/Models/Download/Downloader.cs
+++ b/LibgenDesktop/Models/Download/DownloadManager.cs
@@ -10,12 +10,9 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using System.Xml;
-using System.Xml.Xsl;
-using HtmlAgilityPack;
using LibgenDesktop.Common;
using LibgenDesktop.Models.Localization;
-using LibgenDesktop.Models.Localization.Localizators;
+using LibgenDesktop.Models.Localization.Localizators.Tabs;
using LibgenDesktop.Models.Utils;
using static LibgenDesktop.Common.Constants;
using static LibgenDesktop.Models.Settings.AppSettings;
@@ -23,29 +20,29 @@
namespace LibgenDesktop.Models.Download
{
- internal class Downloader : IDisposable
+ internal class DownloadManager : IDisposable
{
private readonly object downloadQueueLock;
private readonly string downloadQueueFilePath;
private readonly List downloadQueue;
private readonly Dictionary downloadQueueKeyPairs;
- private readonly BlockingCollection eventQueue;
+ private readonly BlockingCollection eventQueue;
private readonly Task downloadTask;
private readonly AutoResetEvent downloadTaskResetEvent;
- private DownloadManagerLocalizator localization;
+ private DownloadManagerTabLocalizator localization;
private HttpClient httpClient;
private DownloadSettings downloadSettings;
private bool isInOfflineMode;
private bool isShuttingDown;
private bool disposed;
- public Downloader()
+ public DownloadManager()
{
downloadQueueLock = new object();
downloadQueueFilePath = Path.Combine(Environment.AppDataDirectory, DOWNLOAD_LIST_FILE_NAME);
- downloadQueue = DownloadQueueStorage.LoadDownloadQueue(downloadQueueFilePath);
+ downloadQueue = DownloadManagerQueueStorage.LoadDownloadQueue(downloadQueueFilePath);
downloadQueueKeyPairs = downloadQueue.ToDictionary(downloadItem => downloadItem.Id);
- eventQueue = new BlockingCollection();
+ eventQueue = new BlockingCollection();
downloadTaskResetEvent = new AutoResetEvent(false);
localization = null;
httpClient = null;
@@ -57,7 +54,7 @@ public Downloader()
disposed = false;
}
- public event EventHandler DownloaderBatchEvent;
+ public event EventHandler DownloadManagerBatchEvent;
public void Configure(Language currentLanguage, NetworkSettings networkSettings, DownloadSettings downloadSettings)
{
@@ -77,7 +74,7 @@ public void Configure(Language currentLanguage, NetworkSettings networkSettings,
isInOfflineMode = false;
ResumeDownloadTask();
}
- Logger.Debug("Downloader configuration complete.");
+ Logger.Debug("Download manager configuration complete.");
}
public List GetDownloadQueueSnapshot()
@@ -98,9 +95,13 @@ public DownloadItem GetDownloadItemByDownloadPageUrl(string downloadPageUrl)
public void EnqueueDownloadItems(IEnumerable downloadItemRequests)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
foreach (DownloadItemRequest downloadItemRequest in downloadItemRequests)
{
string fileName = String.Concat(FileUtils.RemoveInvalidFileNameCharacters(downloadItemRequest.FileNameWithoutExtension,
@@ -122,10 +123,14 @@ public void EnqueueDownloadItems(IEnumerable downloadItemRe
public void StartDownloads(IEnumerable downloadItemIds)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
lock (downloadQueueLock)
{
bool resumeDownloadTask = false;
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
foreach (Guid downloadItemId in downloadItemIds)
{
if (!downloadQueueKeyPairs.TryGetValue(downloadItemId, out DownloadItem downloadItem))
@@ -161,9 +166,13 @@ public void StartDownloads(IEnumerable downloadItemIds)
public void StopDownloads(IEnumerable downloadItemIds)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
foreach (Guid downloadItemId in downloadItemIds)
{
if (!downloadQueueKeyPairs.TryGetValue(downloadItemId, out DownloadItem downloadItem))
@@ -194,9 +203,13 @@ public void StopDownloads(IEnumerable downloadItemIds)
public void RemoveDownloads(IEnumerable downloadItemIds)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
foreach (Guid downloadItemId in downloadItemIds)
{
if (!downloadQueueKeyPairs.TryGetValue(downloadItemId, out DownloadItem downloadItem))
@@ -240,7 +253,6 @@ public void Shutdown()
SaveDownloadQueue();
foreach (DownloadItem downloadItem in downloadQueue)
{
- downloadItem.Status = DownloadItemStatus.STOPPED;
downloadItem.CancelDownload();
}
}
@@ -253,7 +265,7 @@ public void Shutdown()
{
Logger.Exception(exception);
}
- Logger.Debug("Downloader was shut down successfully.");
+ Logger.Debug("Download manager was shut down successfully.");
}
public void Dispose()
@@ -262,10 +274,127 @@ public void Dispose()
{
eventQueue?.Dispose();
downloadTaskResetEvent?.Dispose();
+ httpClient?.Dispose();
disposed = true;
}
}
+ private static HttpClient CreateNewHttpClient(NetworkSettings networkSettings, DownloadSettings downloadSettings)
+ {
+ WebRequestHandler webRequestHandler = new WebRequestHandler
+ {
+ Proxy = NetworkUtils.CreateProxy(networkSettings),
+ UseProxy = true,
+ AllowAutoRedirect = false,
+ UseCookies = false,
+ ReadWriteTimeout = downloadSettings.Timeout * 1000
+ };
+ return new HttpClient(webRequestHandler)
+ {
+ Timeout = Timeout.InfiniteTimeSpan
+ };
+ }
+
+ private static bool IsRedirect(HttpStatusCode statusCode)
+ {
+ return (int)statusCode >= 300 && (int)statusCode <= 399;
+ }
+
+ private static bool GenerateRedirectUrl(string requestUrl, Uri newLocationUri, out string redirectUrl)
+ {
+ if (newLocationUri.IsAbsoluteUri)
+ {
+ redirectUrl = EncodeInvalidUrlCharacters(newLocationUri.ToString());
+ }
+ else
+ {
+ redirectUrl = EncodeInvalidUrlCharacters(new Uri(new Uri(requestUrl), newLocationUri).ToString());
+ }
+ return Uri.IsWellFormedUriString(redirectUrl, UriKind.Absolute);
+ }
+
+ private static void AppendCookies(Dictionary existingCookies, Uri uri, string cookieHeader)
+ {
+ CookieContainer cookieContainer = new CookieContainer();
+ cookieContainer.SetCookies(uri, cookieHeader);
+ foreach (Cookie cookie in cookieContainer.GetCookies(uri))
+ {
+ if (!cookie.Expired)
+ {
+ existingCookies[cookie.Name] = cookie.Value;
+ }
+ }
+ }
+
+ private static string GenerateCookieHeader(Dictionary cookies)
+ {
+ return String.Join(";", cookies.Select(cookie => $"{cookie.Key}={cookie.Value}"));
+ }
+
+ private static string GenerateFileName(string directory, string fileNameTemplate, string md5Hash)
+ {
+ string mainFileName = fileNameTemplate;
+ string partFileName = mainFileName + ".part";
+ string mainFilePath;
+ string partFilePath;
+ string fileExtension = null;
+ bool isMd5HashFileName = false;
+ try
+ {
+ mainFilePath = Path.GetFullPath(Path.Combine(directory, mainFileName));
+ partFilePath = Path.GetFullPath(Path.Combine(directory, partFileName));
+ }
+ catch (PathTooLongException)
+ {
+ fileExtension = Path.GetExtension(fileNameTemplate);
+ fileNameTemplate = md5Hash + fileExtension;
+ mainFileName = fileNameTemplate;
+ partFileName = mainFileName + ".part";
+ mainFilePath = Path.GetFullPath(Path.Combine(directory, mainFileName));
+ partFilePath = Path.GetFullPath(Path.Combine(directory, partFileName));
+ isMd5HashFileName = true;
+ }
+ string fileNameWithoutExtension = null;
+ int counter = 0;
+ while (File.Exists(mainFilePath) || File.Exists(partFilePath))
+ {
+ if (fileNameWithoutExtension == null)
+ {
+ fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileNameTemplate);
+ fileExtension = Path.GetExtension(fileNameTemplate);
+ }
+ counter++;
+ mainFileName = $"{fileNameWithoutExtension} ({counter}){fileExtension}";
+ partFileName = mainFileName + ".part";
+ try
+ {
+ mainFilePath = Path.GetFullPath(Path.Combine(directory, mainFileName));
+ partFilePath = Path.GetFullPath(Path.Combine(directory, partFileName));
+ }
+ catch (PathTooLongException)
+ {
+ if (isMd5HashFileName)
+ {
+ throw;
+ }
+ fileNameWithoutExtension = md5Hash;
+ mainFileName = md5Hash + fileExtension;
+ partFileName = mainFileName + ".part";
+ mainFilePath = Path.GetFullPath(Path.Combine(directory, mainFileName));
+ partFilePath = Path.GetFullPath(Path.Combine(directory, partFileName));
+ counter = 0;
+ isMd5HashFileName = true;
+ }
+ }
+ return mainFileName;
+ }
+
+ private static string EncodeInvalidUrlCharacters(string url)
+ {
+ return url.Replace(" ", "%20").Replace("^", "%5E").Replace("`", "%60").Replace("<", "%3C").Replace(">", "%3E").
+ Replace("[", "%5B").Replace("]", "%5D").Replace("{", "%7B").Replace("}", "%7D").Replace("|", "%7C");
+ }
+
private void ResumeDownloadTask()
{
downloadTaskResetEvent.Set();
@@ -290,6 +419,10 @@ private Task StartDownloadTask()
{
lock (downloadQueueLock)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
if (downloadItem == null || downloadItem.Status != DownloadItemStatus.DOWNLOADING)
{
downloadItem = downloadQueue.FirstOrDefault(item => item.Status == DownloadItemStatus.QUEUED ||
@@ -338,7 +471,7 @@ private Task StartDownloadTask()
try
{
referer = url;
- url = ExecuteTransformation(pageContent, transformationName);
+ url = DownloadUtils.ExecuteTransformation(pageContent, transformationName, htmlDecode: true);
}
catch (Exception exception)
{
@@ -377,6 +510,10 @@ private Task StartDownloadTask()
bool skipFileDownload = false;
lock (downloadQueueLock)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
if (downloadItem.Status == DownloadItemStatus.DOWNLOADING)
{
downloadItem.DirectFileUrl = url;
@@ -420,6 +557,10 @@ private Task StartDownloadTask()
{
lock (downloadQueueLock)
{
+ if (isShuttingDown)
+ {
+ return;
+ }
ReportError(downloadItem, localization.LogLineMaximumDownloadAttempts);
SaveDownloadQueue();
}
@@ -815,11 +956,6 @@ private async Task DownloadFileAsync(DownloadItem downloadItem, FileStream desti
}
}
- private bool IsRedirect(HttpStatusCode statusCode)
- {
- return (int)statusCode >= 300 && (int)statusCode <= 399;
- }
-
private async Task SendDownloadRequestAsync(DownloadItem downloadItem, string url, string referer, bool waitForFullContent,
long? startPosition = null)
{
@@ -868,7 +1004,7 @@ private async Task SendDownloadRequestAsync(DownloadItem do
HttpResponseMessage response;
try
{
- response = await SendRequestAsync(request, downloadItem.CancellationToken, waitForFullContent);
+ response = await SendRequestAsync(request, waitForFullContent, downloadItem.CancellationToken);
}
catch (TimeoutException)
{
@@ -926,7 +1062,7 @@ private async Task SendDownloadRequestAsync(DownloadItem do
return response;
}
- private Task SendRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken, bool waitForFullContent)
+ private Task SendRequestAsync(HttpRequestMessage request, bool waitForFullContent, CancellationToken cancellationToken)
{
return Task.Run(() =>
{
@@ -961,49 +1097,13 @@ private Task SendRequestAsync(HttpRequestMessage request, C
});
}
- private string ExecuteTransformation(string pageContent, string transformationName)
- {
- HtmlDocument htmlDocument = new HtmlDocument();
- htmlDocument.LoadHtml(pageContent);
- XslCompiledTransform xslTransform = new XslCompiledTransform();
- xslTransform.Load(Path.Combine(Environment.MirrorsDirectoryPath, transformationName + ".xslt"));
- XmlWriterSettings outputSettings = xslTransform.OutputSettings.Clone();
- outputSettings.OmitXmlDeclaration = true;
- outputSettings.Encoding = new UTF8Encoding(false);
- using (MemoryStream memoryStream = new MemoryStream())
- using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, outputSettings))
- {
- xslTransform.Transform(htmlDocument, xmlWriter);
- string xmlEncodedString = Encoding.UTF8.GetString(memoryStream.ToArray()).Trim();
- return WebUtility.HtmlDecode(xmlEncodedString);
- }
- }
-
- private void AppendCookies(Dictionary existingCookies, Uri uri, string cookieHeader)
- {
- CookieContainer cookieContainer = new CookieContainer();
- cookieContainer.SetCookies(uri, cookieHeader);
- foreach (Cookie cookie in cookieContainer.GetCookies(uri))
- {
- if (!cookie.Expired)
- {
- existingCookies[cookie.Name] = cookie.Value;
- }
- }
- }
-
- private string GenerateCookieHeader(Dictionary cookies)
- {
- return String.Join(";", cookies.Select(cookie => $"{cookie.Key}={cookie.Value}"));
- }
-
private void StartEventPublisherTask()
{
Task.Run(() =>
{
while (!eventQueue.IsCompleted)
{
- DownloaderBatchEventArgs batchEventArgs;
+ DownloadManagerBatchEventArgs batchEventArgs;
try
{
batchEventArgs = eventQueue.Take();
@@ -1012,32 +1112,16 @@ private void StartEventPublisherTask()
{
return;
}
- DownloaderBatchEvent?.Invoke(this, batchEventArgs);
+ DownloadManagerBatchEvent?.Invoke(this, batchEventArgs);
}
});
}
- private HttpClient CreateNewHttpClient(NetworkSettings networkSettings, DownloadSettings downloadSettings)
- {
- WebRequestHandler webRequestHandler = new WebRequestHandler
- {
- Proxy = NetworkUtils.CreateProxy(networkSettings),
- UseProxy = true,
- AllowAutoRedirect = false,
- UseCookies = false,
- ReadWriteTimeout = downloadSettings.Timeout * 1000
- };
- return new HttpClient(webRequestHandler)
- {
- Timeout = Timeout.InfiniteTimeSpan
- };
- }
-
private void SwitchToOfflineMode()
{
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
foreach (DownloadItem downloadingItem in downloadQueue.Where(downloadItem => downloadItem.Status == DownloadItemStatus.DOWNLOADING ||
downloadItem.Status == DownloadItemStatus.RETRY_DELAY))
{
@@ -1056,7 +1140,7 @@ private void SaveDownloadQueue()
{
try
{
- DownloadQueueStorage.SaveDownloadQueue(downloadQueueFilePath, downloadQueue);
+ DownloadManagerQueueStorage.SaveDownloadQueue(downloadQueueFilePath, downloadQueue);
}
catch (Exception exception)
{
@@ -1064,75 +1148,6 @@ private void SaveDownloadQueue()
}
}
- private string GenerateFileName(string directory, string fileNameTemplate, string md5Hash)
- {
- string fileName = fileNameTemplate;
- string filePath;
- string fileExtension = null;
- bool isMd5HashFileName = false;
- try
- {
- filePath = Path.GetFullPath(Path.Combine(directory, fileName));
- }
- catch (PathTooLongException)
- {
- fileExtension = Path.GetExtension(fileNameTemplate);
- fileNameTemplate = md5Hash + fileExtension;
- fileName = fileNameTemplate;
- filePath = Path.Combine(directory, fileName);
- isMd5HashFileName = true;
- }
- string fileNameWithoutExtension = null;
- int counter = 0;
- while (File.Exists(filePath) || File.Exists(filePath + ".part"))
- {
- if (fileNameWithoutExtension == null)
- {
- fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileNameTemplate);
- fileExtension = Path.GetExtension(fileNameTemplate);
- }
- counter++;
- fileName = $"{fileNameWithoutExtension} ({counter}){fileExtension}";
- try
- {
- filePath = Path.GetFullPath(Path.Combine(directory, fileName));
- }
- catch (PathTooLongException)
- {
- if (isMd5HashFileName)
- {
- throw;
- }
- fileExtension = Path.GetExtension(fileNameTemplate);
- fileName = md5Hash + fileExtension;
- filePath = Path.Combine(directory, fileName);
- counter = 0;
- fileNameWithoutExtension = null;
- isMd5HashFileName = true;
- }
- }
- return fileName;
- }
-
- private bool GenerateRedirectUrl(string requestUrl, Uri newLocationUri, out string redirectUrl)
- {
- if (newLocationUri.IsAbsoluteUri)
- {
- redirectUrl = EncodeInvalidUrlCharacters(newLocationUri.ToString());
- }
- else
- {
- redirectUrl = EncodeInvalidUrlCharacters(new Uri(new Uri(requestUrl), newLocationUri).ToString());
- }
- return Uri.IsWellFormedUriString(redirectUrl, UriKind.Absolute);
- }
-
- private string EncodeInvalidUrlCharacters(string url)
- {
- return url.Replace(" ", "%20").Replace("^", "%5E").Replace("`", "%60").Replace("<", "%3C").Replace(">", "%3E").
- Replace("[", "%5B").Replace("]", "%5D").Replace("{", "%7B").Replace("}", "%7D").Replace("|", "%7C");
- }
-
private DownloadItemLogLineEventArgs AddLogLine(DownloadItem downloadItem, DownloadItemLogLineType logLineType, string logLine)
{
lock (downloadQueueLock)
@@ -1140,7 +1155,7 @@ private DownloadItemLogLineEventArgs AddLogLine(DownloadItem downloadItem, Downl
DownloadItemLogLine downloadItemLogLine = new DownloadItemLogLine(logLineType, DateTime.Now, logLine);
int lineIndex = downloadItem.Logs.Count;
downloadItem.Logs.Add(downloadItemLogLine);
- Logger.Debug($"Downloader log line: type = {logLineType}, text = \"{logLine}\".");
+ Logger.Debug($"Download manager log line: type = {logLineType}, text = \"{logLine}\".");
return new DownloadItemLogLineEventArgs(downloadItem.Id, lineIndex, downloadItemLogLine);
}
}
@@ -1149,7 +1164,7 @@ private void ReportLogLine(DownloadItem downloadItem, DownloadItemLogLineType lo
{
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
DownloadItemLogLineEventArgs logLineEventArgs = AddLogLine(downloadItem, logLineType, logLine);
batchEventArgs.Add(logLineEventArgs);
eventQueue.Add(batchEventArgs);
@@ -1160,7 +1175,7 @@ private void ReportChange(DownloadItem downloadItem)
{
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
batchEventArgs.Add(new DownloadItemChangedEventArgs(downloadItem));
eventQueue.Add(batchEventArgs);
}
@@ -1170,7 +1185,7 @@ private void ReportStatusChange(DownloadItem downloadItem, DownloadItemStatus ne
{
lock (downloadQueueLock)
{
- DownloaderBatchEventArgs batchEventArgs = new DownloaderBatchEventArgs();
+ DownloadManagerBatchEventArgs batchEventArgs = new DownloadManagerBatchEventArgs();
DownloadItemLogLineEventArgs logLineEventArgs = AddLogLine(downloadItem, logLineType, logMessage);
batchEventArgs.Add(logLineEventArgs);
downloadItem.Status = newStatus;
diff --git a/LibgenDesktop/Models/Download/DownloaderBatchEventArgs.cs b/LibgenDesktop/Models/Download/DownloadManagerBatchEventArgs.cs
similarity index 91%
rename from LibgenDesktop/Models/Download/DownloaderBatchEventArgs.cs
rename to LibgenDesktop/Models/Download/DownloadManagerBatchEventArgs.cs
index 8b1ad07..d3c7f89 100644
--- a/LibgenDesktop/Models/Download/DownloaderBatchEventArgs.cs
+++ b/LibgenDesktop/Models/Download/DownloadManagerBatchEventArgs.cs
@@ -3,9 +3,9 @@
namespace LibgenDesktop.Models.Download
{
- internal class DownloaderBatchEventArgs : EventArgs
+ internal class DownloadManagerBatchEventArgs : EventArgs
{
- public DownloaderBatchEventArgs()
+ public DownloadManagerBatchEventArgs()
{
BatchEvents = new List();
AddEventCount = 0;
diff --git a/LibgenDesktop/Models/Download/DownloaderEventArgs.cs b/LibgenDesktop/Models/Download/DownloadManagerEventArgs.cs
similarity index 100%
rename from LibgenDesktop/Models/Download/DownloaderEventArgs.cs
rename to LibgenDesktop/Models/Download/DownloadManagerEventArgs.cs
diff --git a/LibgenDesktop/Models/Download/DownloadQueueStorage.cs b/LibgenDesktop/Models/Download/DownloadManagerQueueStorage.cs
similarity index 99%
rename from LibgenDesktop/Models/Download/DownloadQueueStorage.cs
rename to LibgenDesktop/Models/Download/DownloadManagerQueueStorage.cs
index 13b6006..be912bb 100644
--- a/LibgenDesktop/Models/Download/DownloadQueueStorage.cs
+++ b/LibgenDesktop/Models/Download/DownloadManagerQueueStorage.cs
@@ -6,7 +6,7 @@
namespace LibgenDesktop.Models.Download
{
- internal static class DownloadQueueStorage
+ internal static class DownloadManagerQueueStorage
{
internal class StorageDownloadItem
{
diff --git a/LibgenDesktop/Models/Download/DownloadUtils.cs b/LibgenDesktop/Models/Download/DownloadUtils.cs
new file mode 100644
index 0000000..1ebf371
--- /dev/null
+++ b/LibgenDesktop/Models/Download/DownloadUtils.cs
@@ -0,0 +1,263 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Xml;
+using System.Xml.Xsl;
+using HtmlAgilityPack;
+using LibgenDesktop.Common;
+using LibgenDesktop.Models.ProgressArgs;
+using LibgenDesktop.Models.Utils;
+using Environment = LibgenDesktop.Common.Environment;
+
+namespace LibgenDesktop.Models.Download
+{
+ internal static class DownloadUtils
+ {
+ internal enum DownloadResult
+ {
+ COMPLETED = 1,
+ INCOMPLETE,
+ CANCELLED,
+ ERROR
+ }
+
+ internal class DownloadPageResult
+ {
+ public DownloadResult DownloadResult { get; set; }
+ public HttpStatusCode HttpStatusCode { get; set; }
+ public string PageContent { get; set; }
+ }
+
+ public static async Task DownloadPageAsync(HttpClient httpClient, string pageUrl, CancellationToken cancellationToken)
+ {
+ DownloadPageResult result = new DownloadPageResult();
+ Logger.Debug($"Sending a request to {pageUrl}");
+ HttpResponseMessage response;
+ try
+ {
+ response = await httpClient.GetAsync(pageUrl, cancellationToken);
+ }
+ catch (TaskCanceledException)
+ {
+ Logger.Debug("Page download has been cancelled.");
+ result.DownloadResult = DownloadResult.CANCELLED;
+ return result;
+ }
+ catch (Exception exception)
+ {
+ Logger.Exception(exception);
+ result.DownloadResult = DownloadResult.ERROR;
+ return result;
+ }
+ Logger.Debug($"Response status code: {(int)response.StatusCode} {response.StatusCode}.");
+ Logger.Debug("Response headers:", response.Headers.ToString().TrimEnd(), response.Content.Headers.ToString().TrimEnd());
+ result.HttpStatusCode = response.StatusCode;
+ result.PageContent = await response.Content.ReadAsStringAsync();
+ Logger.Debug("Response content:", result.PageContent);
+ result.DownloadResult = DownloadResult.COMPLETED;
+ return result;
+ }
+
+ public static Task DownloadFileAsync(HttpClient httpClient, string fileUrl, string destinationPath, bool resumeDownload,
+ IProgress