Skip to content

Commit

Permalink
Update-import, synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
libgenapps committed Jan 15, 2018
1 parent 9785ff9 commit 6159a9d
Show file tree
Hide file tree
Showing 61 changed files with 2,591 additions and 590 deletions.
6 changes: 3 additions & 3 deletions LibgenDesktop.Setup/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>

<supportedRuntime version="v2.0.50727"/></startup>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
4 changes: 3 additions & 1 deletion LibgenDesktop.Setup/AppFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ public static string[] GetFileList(bool is64Bit)
return new[]
{
Constants.MAIN_EXECUTABLE_NAME,
"System.ValueTuple.dll",
"Newtonsoft.Json.dll",
"SharpCompress.dll",
"MaterialDesignThemes.Wpf.dll",
"MaterialDesignColors.dll",
"Dragablz.dll",
"System.Data.SQLite.dll",
(is64Bit ? "x64" : "x86") + @"\SQLite.Interop.dll"
(is64Bit ? "x64" : "x86") + @"\SQLite.Interop.dll",
"mirrors.config"
};
}
}
Expand Down
6 changes: 2 additions & 4 deletions LibgenDesktop.Setup/AppSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void Build64BitSetupPackage()
private static void BuildSetupPackage(bool is64Bit, string projectGuid)
{
string productTitle = String.Format(Constants.PRODUCT_TITLE_FORMAT, is64Bit ? 64 : 32);
string shortcutTitle = String.Format(Constants.SHORTCUT_TITLE_FORMAT, is64Bit ? 64 : 32);
string normalizedCurrentVersion = Constants.CURRENT_VERSION.Count(c => c == '.') > 1 ? Constants.CURRENT_VERSION : Constants.CURRENT_VERSION + ".0";
string installerFileName = String.Format(Constants.INSTALLER_FILE_NAME_FORMAT, is64Bit ? 64 : 32);
Project project = new Project(productTitle, new Dir(@"%ProgramFiles%\Libgen Desktop"));
Expand All @@ -33,7 +34,7 @@ private static void BuildSetupPackage(bool is64Bit, string projectGuid)
{
file.Shortcuts = new[]
{
new FileShortcut(productTitle, "%ProgramMenu%")
new FileShortcut(shortcutTitle, "%ProgramMenu%")
};
}
targetDirectory.AddFile(file);
Expand Down Expand Up @@ -65,10 +66,7 @@ private static void BuildSetupPackage(bool is64Bit, string projectGuid)
project.CustomUI = new DialogSequence()
.On(NativeDialogs.WelcomeDlg, Buttons.Next, new ShowDialog(NativeDialogs.InstallDirDlg))
.On(NativeDialogs.InstallDirDlg, Buttons.Back, new ShowDialog(NativeDialogs.WelcomeDlg));
project.PreserveTempFiles = false;
project.PreserveDbgFiles = false;
project.BuildMsi(installerFileName);
Utils.DeleteTempFiles("*.wixobj", "*.wixpdb", "*.wxs");
Utils.MoveFile($"{installerFileName}.msi", @"..\Release");
}
}
Expand Down
3 changes: 2 additions & 1 deletion LibgenDesktop.Setup/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
{
internal static class Constants
{
public const string CURRENT_VERSION = "0.8";
public const string CURRENT_VERSION = "0.9";
public const string PRODUCT_TITLE_FORMAT = "Libgen Desktop " + CURRENT_VERSION + " ({0}-bit)";
public const string SHORTCUT_TITLE_FORMAT = "Libgen Desktop ({0}-bit)";
public const string PRODUCT_COMPANY = "Libgen Apps";
public const string INSTALLER_FILE_NAME_FORMAT = "LibgenDesktop Setup ({0}-bit)";
public const string PORTABLE_PACKAGE_FILE_NAME_FORMAT = "LibgenDesktop Portable ({0}-bit).zip";
Expand Down
45 changes: 22 additions & 23 deletions LibgenDesktop.Setup/LibgenDesktop.Setup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>bin\Debug x86\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -44,10 +44,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BootstrapperCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.5.0.0\lib\BootstrapperCore.dll</HintPath>
<HintPath>..\packages\WixSharp.bin.1.6.0.0\lib\BootstrapperCore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.5.0.0\lib\Microsoft.Deployment.WindowsInstaller.dll</HintPath>
<HintPath>..\packages\WixSharp.bin.1.6.0.0\lib\Microsoft.Deployment.WindowsInstaller.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpCompress, Version=0.19.2.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.19.2\lib\net35\SharpCompress.dll</HintPath>
Expand All @@ -58,14 +60,14 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WixSharp, Version=1.5.0.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.5.0.0\lib\WixSharp.dll</HintPath>
<Reference Include="WixSharp, Version=1.6.0.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.6.0.0\lib\WixSharp.dll</HintPath>
</Reference>
<Reference Include="WixSharp.Msi, Version=1.5.0.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.5.0.0\lib\WixSharp.Msi.dll</HintPath>
<Reference Include="WixSharp.Msi, Version=1.6.0.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.6.0.0\lib\WixSharp.Msi.dll</HintPath>
</Reference>
<Reference Include="WixSharp.UI, Version=1.5.0.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.5.0.0\lib\WixSharp.UI.dll</HintPath>
<Reference Include="WixSharp.UI, Version=1.6.0.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.6.0.0\lib\WixSharp.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -78,28 +80,25 @@
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<!-- <ItemGroup>
<PackageReference Include="WixSharp">
<Version>1.4.8.0</Version>
</PackageReference>
</ItemGroup> -->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\WixSharp.1.5.0.0\build\WixSharp.targets" Condition="Exists('..\packages\WixSharp.1.5.0.0\build\WixSharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\WixSharp.1.5.0.0\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.1.5.0.0\build\WixSharp.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<UsingTask AssemblyFile="$(SolutionDir)packages\WixSharp.1.5.0.0\build\SetEnvVar.dll" TaskName="SetEnvVar" />
<Import Project="..\packages\WixSharp.1.6.0.0\build\WixSharp.targets" Condition="Exists('..\packages\WixSharp.1.6.0.0\build\WixSharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\WixSharp.1.6.0.0\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.1.6.0.0\build\WixSharp.targets'))" />
</Target>
<UsingTask AssemblyFile="$(SolutionDir)packages\WixSharp.1.6.0.0\build\SetEnvVar.dll" TaskName="SetEnvVar" />
</Project>
4 changes: 2 additions & 2 deletions LibgenDesktop.Setup/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpCompress" version="0.19.2" targetFramework="net35" />
<package id="WixSharp" version="1.5.0.0" targetFramework="net35" />
<package id="WixSharp.bin" version="1.5.0.0" targetFramework="net35" />
<package id="WixSharp" version="1.6.0.0" targetFramework="net35" />
<package id="WixSharp.bin" version="1.6.0.0" targetFramework="net35" />
</packages>
9 changes: 8 additions & 1 deletion LibgenDesktop/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
internal static class Constants
{
public const string CURRENT_VERSION = "0.9";
public const string CURRENT_DATABASE_VERSION = "0.7";

public const string APP_SETTINGS_FILE_NAME = "libgen.config";
Expand Down Expand Up @@ -47,6 +48,9 @@ internal static class Constants
public const int SETTINGS_WINDOW_DEFAULT_HEIGHT = 450;
public const int SETTINGS_WINDOW_MIN_WIDTH = 650;
public const int SETTINGS_WINDOW_MIN_HEIGHT = 450;
public const int SYNCHRONIZATION_WINDOW_MIN_WIDTH = 500;
public const int SYNCHRONIZATION_WINDOW_MIN_HEIGHT = 400;
public const int MESSAGE_BOX_WINDOW_WIDTH = 500;

public const string DEFAULT_DATABASE_FILE_NAME = "libgen.db";
public const int DEFAULT_MAIN_WINDOW_WIDTH = 1000;
Expand Down Expand Up @@ -82,6 +86,9 @@ internal static class Constants
public const int DEFAULT_MAXIMUM_SEARCH_RESULT_COUNT = 50000;

public const int SEARCH_REPORT_PROGRESS_BATCH_SIZE = 2000;
public const int INSERT_TRANSACTION_BATCH = 500;
public const int DATABASE_TRANSACTION_BATCH = 500;

public const string JSON_API_URL = "http://gen.lib.rus.ec/json.php";
public const string USER_AGENT = "LibgenDesktop/" + CURRENT_VERSION;
}
}
2 changes: 1 addition & 1 deletion LibgenDesktop/Infrastructure/IWindowContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LibgenDesktop.Infrastructure
{
internal interface IWindowContext
public interface IWindowContext
{
object DataContext { get; }

Expand Down
4 changes: 3 additions & 1 deletion LibgenDesktop/Infrastructure/RegisteredWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ internal enum WindowKey
ERROR_WINDOW,
IMPORT_WINDOW,
CREATE_DATABASE_WINDOW,
SETTINGS_WINDOW
SETTINGS_WINDOW,
SYNCHRONIZATION_WINDOW
}

internal class RegisteredWindow
Expand Down Expand Up @@ -44,6 +45,7 @@ static RegisteredWindows()
RegisterWindow(WindowKey.IMPORT_WINDOW, typeof(ImportWindow), typeof(ImportWindowViewModel));
RegisterWindow(WindowKey.CREATE_DATABASE_WINDOW, typeof(CreateDatabaseWindow), typeof(CreateDatabaseViewModel));
RegisterWindow(WindowKey.SETTINGS_WINDOW, typeof(SettingsWindow), typeof(SettingsWindowViewModel));
RegisterWindow(WindowKey.SYNCHRONIZATION_WINDOW, typeof(SynchronizationWindow), typeof(SynchronizationWindowViewModel));
}

public static Dictionary<WindowKey, RegisteredWindow> AllWindows { get; }
Expand Down
29 changes: 27 additions & 2 deletions LibgenDesktop/Infrastructure/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Threading;
using Microsoft.Win32;

namespace LibgenDesktop.Infrastructure
Expand Down Expand Up @@ -85,9 +86,33 @@ public static IWindowContext GetWindowContext(object viewModel)
return createdWindowContexts.FirstOrDefault(windowContext => ReferenceEquals(windowContext.DataContext, viewModel));
}

public static void ShowMessageBox(string title, string text)
public static void ExecuteActionInBackground(Action action)
{
MessageBox.Show(text, title);
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, action);
}

public static void ShowMessageBox(string title, string text, IWindowContext parentWindowContext = null)
{
if (parentWindowContext != null)
{
MessageBox.Show((parentWindowContext as WindowContext)?.Window, text, title);
}
else
{
MessageBox.Show(text, title);
}
}

public static bool ShowPrompt(string title, string text, IWindowContext parentWindowContext = null)
{
if (parentWindowContext != null)
{
return MessageBox.Show((parentWindowContext as WindowContext)?.Window, text, title, MessageBoxButton.YesNo) == MessageBoxResult.Yes;
}
else
{
return MessageBox.Show(text, title, MessageBoxButton.YesNo) == MessageBoxResult.Yes;
}
}

public static OpenFileDialogResult ShowOpenFileDialog(OpenFileDialogParameters openFileDialogParameters)
Expand Down
48 changes: 45 additions & 3 deletions LibgenDesktop/LibgenDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dragablz">
<HintPath>..\packages\Dragablz.0.0.3.197\lib\net45\Dragablz.dll</HintPath>
Expand Down Expand Up @@ -75,6 +78,9 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -110,21 +116,33 @@
<Compile Include="Models\Database\SearchQueryParser.cs" />
<Compile Include="Models\Entities\DatabaseMetadata.cs" />
<Compile Include="Models\Entities\FictionBook.cs" />
<Compile Include="Models\Entities\LibgenObject.cs" />
<Compile Include="Models\Entities\SciMagArticle.cs" />
<Compile Include="Models\Import\FictionImporter.cs" />
<Compile Include="Models\Import\SciMagImporter.cs" />
<Compile Include="Models\JsonApi\JsonApiClient.cs" />
<Compile Include="Models\JsonApi\JsonApiNonFictionBook.cs" />
<Compile Include="Models\ProgressArgs\ImportCreateIndexProgress.cs" />
<Compile Include="Models\ProgressArgs\ImportObjectsProgress.cs" />
<Compile Include="Models\ProgressArgs\ImportSearchTableDefinitionProgress.cs" />
<Compile Include="Models\ProgressArgs\ImportTableDefinitionFoundProgress.cs" />
<Compile Include="Models\ProgressArgs\JsonApiDownloadProgress.cs" />
<Compile Include="Models\ProgressArgs\SearchProgress.cs" />
<Compile Include="Models\Settings\Mirrors.cs" />
<Compile Include="Models\Settings\MirrorStorage.cs" />
<Compile Include="Models\SqlDump\ColumnDefinition.cs" />
<Compile Include="Models\SqlDump\ColumnType.cs" />
<Compile Include="Models\Import\Importer.cs" />
<Compile Include="Models\Import\NonFictionImporter.cs" />
<Compile Include="Models\SqlDump\ParsedTableDefinition.cs" />
<Compile Include="Models\SqlDump\SqlDumpReader.cs" />
<Compile Include="Models\SqlDump\TableDefinition.cs" />
<Compile Include="Models\SqlDump\TableDefinitions.cs" />
<Compile Include="Models\SqlDump\TableType.cs" />
<Compile Include="Models\Utils\UrlGenerator.cs" />
<Compile Include="ViewModels\FictionDetailsTabViewModel.cs" />
<Compile Include="ViewModels\ProgressLogItemViewModel.cs" />
<Compile Include="ViewModels\SynchronizationWindowViewModel.cs" />
<Compile Include="ViewModels\NonFictionDetailsTabViewModel.cs" />
<Compile Include="ViewModels\SciMagDetailsTabViewModel.cs" />
<Compile Include="ViewModels\SciMagDetailsWindowViewModel.cs" />
Expand All @@ -148,6 +166,12 @@
<DependentUpon>CloseTabButton.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\TabControl.cs" />
<Compile Include="Views\MessageBoxWindow.xaml.cs">
<DependentUpon>MessageBoxWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SynchronizationWindow.xaml.cs">
<DependentUpon>SynchronizationWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SciMagDetailsWindow.xaml.cs">
<DependentUpon>SciMagDetailsWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -222,6 +246,22 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\MessageBoxWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Styles\MessageBoxWindowStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Styles\SynchronizationWindowStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SynchronizationWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SciMagDetailsWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -276,9 +316,7 @@
<Compile Include="Models\MainModel.cs" />
<Compile Include="Models\Settings\AppSettings.cs" />
<Compile Include="Models\Settings\SettingsStorage.cs" />
<Compile Include="Models\Utils\AsyncBookCollection.cs" />
<Compile Include="Models\Utils\Formatters.cs" />
<Compile Include="Models\Utils\RangeCollection.cs" />
<Compile Include="ViewModels\MainWindowViewModel.cs" />
<Compile Include="ViewModels\ViewModel.cs" />
<Compile Include="Views\MainWindow.xaml.cs">
Expand Down Expand Up @@ -412,12 +450,16 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<EmbeddedResource Include="Resources\default_mirrors.config" />
<ContentWithTargetPath Include="Resources\mirrors.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>mirrors.config</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
Loading

0 comments on commit 6159a9d

Please sign in to comment.