diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index cbb0ec68e..cd4a6971f 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -93,6 +93,9 @@ + + true + False diff --git a/BeWo/MainWindow.xaml b/BeWo/MainWindow.xaml index c747c2c45..39c5a6d77 100644 --- a/BeWo/MainWindow.xaml +++ b/BeWo/MainWindow.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="BeWoPlaner" Height="768" Width="1024" WindowStartupLocation="CenterScreen" WindowState="Maximized" - BorderThickness="1" Closing="MainWindow_OnClosing" Closed="Window_Closed"> + BorderThickness="1" Closing="MainWindow_OnClosing" Closed="Window_Closed" Loaded="Window_Loaded" Activated="Window_Activated" SourceInitialized="Window_SourceInitialized"> diff --git a/BeWo/MainWindow.xaml.cs b/BeWo/MainWindow.xaml.cs index 66524e5dc..cb5cd92e8 100644 --- a/BeWo/MainWindow.xaml.cs +++ b/BeWo/MainWindow.xaml.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Threading; using System.Windows; +using System.Windows.Threading; using BeWo.Core.Config; using BeWo.MultiLanguage; using BS.Shared.Translation; @@ -29,7 +30,7 @@ namespace BeWo private void ShowMainControl() { - + Translator t = new Translator(new ServiceTranslator()); //WebRequest.DefaultWebProxy //System.Net.WebRequest.GetSystemWebProxy() @@ -134,5 +135,35 @@ namespace BeWo { // Environment.ExitCode = 10; } + + bool _shown; + protected override void OnContentRendered(EventArgs e) + { + base.OnContentRendered(e); + + if (_shown) + return; + + _shown = true; + + Dispatcher.BeginInvoke(new Action(() => Activate()), DispatcherPriority.ContextIdle, null); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + + } + + private void Window_Activated(object sender, EventArgs e) + { + + } + + private void Window_SourceInitialized(object sender, EventArgs e) + { + Console.WriteLine("GUI geladen"); + + Thread.Sleep(500); + } } } diff --git a/BeWo/Properties/Resources.Designer.cs b/BeWo/Properties/Resources.Designer.cs index 16aed7ba5..1c308de68 100644 --- a/BeWo/Properties/Resources.Designer.cs +++ b/BeWo/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace BeWo.Properties { // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/BeWo/Properties/Settings.Designer.cs b/BeWo/Properties/Settings.Designer.cs index 9d1e82165..2e2820382 100644 --- a/BeWo/Properties/Settings.Designer.cs +++ b/BeWo/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace BeWo.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.1.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/BeWo/app.config b/BeWo/app.config index 13732b9a4..da18d8e34 100644 --- a/BeWo/app.config +++ b/BeWo/app.config @@ -1,4 +1,4 @@ - + - - + + - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - + + diff --git a/BeWoLauncher/.vs/BeWoLauncher/v15/.suo b/BeWoLauncher/.vs/BeWoLauncher/v15/.suo new file mode 100644 index 000000000..adb6ea2a5 Binary files /dev/null and b/BeWoLauncher/.vs/BeWoLauncher/v15/.suo differ diff --git a/BeWoLauncher/.vs/ProjectSettings.json b/BeWoLauncher/.vs/ProjectSettings.json new file mode 100644 index 000000000..f8b488856 --- /dev/null +++ b/BeWoLauncher/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/BeWoLauncher/.vs/VSWorkspaceState.json b/BeWoLauncher/.vs/VSWorkspaceState.json new file mode 100644 index 000000000..6b6114114 --- /dev/null +++ b/BeWoLauncher/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/BeWoLauncher/.vs/slnx.sqlite b/BeWoLauncher/.vs/slnx.sqlite new file mode 100644 index 000000000..c5b7a9364 Binary files /dev/null and b/BeWoLauncher/.vs/slnx.sqlite differ diff --git a/BeWoLauncher/App.config b/BeWoLauncher/App.config index e520f7975..ddbd19381 100644 --- a/BeWoLauncher/App.config +++ b/BeWoLauncher/App.config @@ -56,6 +56,9 @@ + + False + \ No newline at end of file diff --git a/BeWoLauncher/BeWoLauncher.csproj b/BeWoLauncher/BeWoLauncher.csproj index 3b786249f..a6defc59b 100644 --- a/BeWoLauncher/BeWoLauncher.csproj +++ b/BeWoLauncher/BeWoLauncher.csproj @@ -96,127 +96,163 @@ MSBuild:Compile Designer - + + + + + + + LoginView.xaml + + + ConfirmDemoDialog.xaml - + MessageDialog.xaml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MainPage.xaml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + InfoScreen.xaml - - UpdateInfo1.xaml + + LoadingScreen.xaml - - UpdateInfo2.xaml + + + + + GenericProgressInfo.xaml - - UpdateInfo3.xaml + + BeWoLoginBorder.xaml - - - - + + InstallInfo.xaml + + + UpdateInfo.xaml + + + UninstallInfo.xaml + + + + + + PasswortAenderungsView.xaml - - - 02 UpdatePage.xaml - - + + PopUpWindow.xaml - + MSBuild:Compile Designer - - Designer - MSBuild:Compile - - + MSBuild:Compile Designer - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - + Designer MSBuild:Compile - + 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 + + Designer MSBuild:Compile - + + MSBuild:Compile + Designer + + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + MSBuild:Compile Designer @@ -224,45 +260,41 @@ LauncherApp.xaml Code - - + + EnterTenantDialog.xaml - + ProfileEditView.xaml - - - - - - - - - + + + + + + + + + ExceptionMessageBox.xaml - + 01 LoginPage.xaml - + ProxyLoginView.xaml - + PwVergessenView.xaml - + WaitLayer2.xaml - + LauncherWindow.xaml Code - - Designer - MSBuild:Compile - - + Designer MSBuild:Compile @@ -300,127 +332,127 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -442,5 +474,10 @@ + + + + + \ No newline at end of file diff --git a/BeWoLauncher/LauncherApp.xaml b/BeWoLauncher/LauncherApp.xaml index 796779d36..a360f8211 100644 --- a/BeWoLauncher/LauncherApp.xaml +++ b/BeWoLauncher/LauncherApp.xaml @@ -3,70 +3,18 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:BeWoLauncher" - StartupUri="WindowImp/LauncherWindow.xaml" Exit="Application_Exit"> + xmlns:viewModel="clr-namespace:BeWoLauncher.MVVM.ViewModels" + xmlns:view="clr-namespace:BeWoLauncher.MVVM.View" + StartupUri="View/WindowImp/LauncherWindow.xaml" Exit="Application_Exit"> - + - + + + + diff --git a/BeWoLauncher/LauncherApp.xaml.cs b/BeWoLauncher/LauncherApp.xaml.cs index a2eae9b56..d246f971a 100644 --- a/BeWoLauncher/LauncherApp.xaml.cs +++ b/BeWoLauncher/LauncherApp.xaml.cs @@ -1,8 +1,8 @@ using BeWoLauncher.Components; using BeWoLauncher.Logic; +using BeWoLauncher.Logic.Controller; using BeWoLauncher.ServiceProxy; -using BeWoLauncher.Utils; -using BeWoLauncher.Utils.Update; +using BeWoLauncher.Store; using BeWoLauncher.WindowImp; using BS.SharedLauncher; using BS.SharedLauncher.Information; @@ -34,9 +34,16 @@ namespace BeWoLauncher /// public partial class LauncherApp : Application { + private readonly NavigationStore _navigationStore; + public static string ShortVersion => "3"; public static string Version => "Version 3.0"; + public LauncherApp() + { + _navigationStore = new NavigationStore(); + } + protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); diff --git a/BeWoLauncher/ConnectionProfile.cs b/BeWoLauncher/Logic/ConnectionProfile.cs similarity index 97% rename from BeWoLauncher/ConnectionProfile.cs rename to BeWoLauncher/Logic/ConnectionProfile.cs index b0074e8c2..22f134da6 100644 --- a/BeWoLauncher/ConnectionProfile.cs +++ b/BeWoLauncher/Logic/ConnectionProfile.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BeWoLauncher +namespace BeWoLauncher.Logic { public class ConnectionProfile { diff --git a/BeWoLauncher/Logic/Controller/DownloadController.cs b/BeWoLauncher/Logic/Controller/DownloadController.cs new file mode 100644 index 000000000..7bfd21d98 --- /dev/null +++ b/BeWoLauncher/Logic/Controller/DownloadController.cs @@ -0,0 +1,37 @@ +using BeWoLauncher.Utils.Download; +using BS.SharedLauncher.Update; +using BS.SharedLauncher.Utils; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWoLauncher.Logic.Controller +{ + public static class DownloadController + { + public static DownloadManager Manager { get; set; } + + public static long FreeSpace { get; set; } + public static long NeededSpace => Manager.ResponseInfo.DownloadSize; + + public static void Start() + { + Manager = new DownloadManager(); + } + + public static string UpdateDiskSpace(string path) + { + FileInfo f = new FileInfo(path); + string drive = System.IO.Path.GetPathRoot(f.FullName); + FreeSpace = NonspecificTools.GetTotalFreeSpace(drive); + string txt; + if (FreeSpace >= 0) + return NonspecificTools.SizeSuffix((ulong)FreeSpace); + else + return "error"; + } + } +} diff --git a/BeWoLauncher/Logic/ProcessController.cs b/BeWoLauncher/Logic/Controller/ProcessController.cs similarity index 76% rename from BeWoLauncher/Logic/ProcessController.cs rename to BeWoLauncher/Logic/Controller/ProcessController.cs index a521e91db..865b0f714 100644 --- a/BeWoLauncher/Logic/ProcessController.cs +++ b/BeWoLauncher/Logic/Controller/ProcessController.cs @@ -7,12 +7,12 @@ using System.IO; using System.IO.Pipes; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; -using static BeWoLauncher.Logic.ViewController; -namespace BeWoLauncher.Logic +namespace BeWoLauncher.Logic.Controller { public static class ProcessController { @@ -43,10 +43,16 @@ namespace BeWoLauncher.Logic MessageBox.Show("BeWo Prozess läuft bereits"); StartLauncherShutdown(); } + + Process[] processes2 = Process.GetProcessesByName("BeWoPlaner"); + + if (processes2.Length > 0) + { + MessageBox.Show("BeWo Prozess läuft bereits"); + StartLauncherShutdown(); + } } - - - + internal static void StartLauncherShutdown() { Current.Shutdown(); @@ -65,7 +71,13 @@ namespace BeWoLauncher.Logic { PlanerProcess.StartInfo.Arguments = pipeServer.GetClientHandleAsString(); PlanerProcess.StartInfo.UseShellExecute = false; + PlanerProcess.StartInfo.CreateNoWindow = false; + PlanerProcess.StartInfo.RedirectStandardOutput = true; + PlanerProcess.OutputDataReceived += MessageFromPlanerClient; + PlanerProcess.Start(); + + PlanerProcess.BeginOutputReadLine(); pipeServer.DisposeLocalCopyOfClientHandle(); @@ -87,8 +99,6 @@ namespace BeWoLauncher.Logic } } - - ViewController.LauncherWindow.Hide(); } internal static void KillPlanerProcess() { @@ -110,14 +120,24 @@ namespace BeWoLauncher.Logic if (PlanerProcess.ExitCode == 100) { - CurrentLauncher.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate { - ViewController.ShowPage(LauncherPageType.Login); - ViewController.LauncherWindow.Show(); + CurrentLauncher.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)delegate { + Thread.Sleep(500); + ViewController.RestartView(); }); return; } CurrentLauncher.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)StartLauncherShutdown); } + + private static void MessageFromPlanerClient(object sender, DataReceivedEventArgs args) + { + var data = args.Data; + + if (data == "GUI geladen") + { + ViewController.LauncherWindow.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => ViewController.LauncherWindow.Hide())); + } + } } } diff --git a/BeWoLauncher/Logic/Controller/ViewController.cs b/BeWoLauncher/Logic/Controller/ViewController.cs new file mode 100644 index 000000000..5120f3eb2 --- /dev/null +++ b/BeWoLauncher/Logic/Controller/ViewController.cs @@ -0,0 +1,358 @@ +using BeWoLauncher.Logic.Controller; +using BeWoLauncher.Utils; +using BeWoLauncher.View.Pages; +using BeWoLauncher.WindowImp; +using BS.SharedLauncher.Extensions; +using BS.SharedLauncher.Information; +using BS.SharedLauncher.Logic; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Threading; + +namespace BeWoLauncher.Logic.Controller +{ + public static class ViewController + { + static bool isBeWoLoginBorderPresent = false; + static BeWoLoginBorder BeWoLoginBorder = null; + static LauncherPageType currentPage; + + private static Exception error; + + public enum LauncherPageType + { + Login, + InstallInfo, + InstallProgress, + InstallFailed, + UpdateInfo, + UpdateProgress, + UpdateFailed, + UninstallInfo, + UninstallProgress, + UninstallFailed, + UninstallSuccessful, + LoadingScreen, + NoPermissionInfo + } + + + + public static LauncherWindow LauncherWindow { get; set; } + + public static Dispatcher Dispatcher => LauncherWindow.Dispatcher; + + public static void StartView() + { + ShowPage(LauncherPageType.Login); + } + public static void RestartView() + { + ShowPage(LauncherPageType.Login); + LauncherWindow.Show(); + LauncherWindow.Activate(); + } + + public static void StartWaiting() => LauncherWindow.StartWaiting(); + public static void EndWaiting() => LauncherWindow.EndWaiting(); + + public static bool CheckForPermissions(string path) + { + return FileController.IsDirectoryWritable(path, false); + } + public static void CheckForNewestVersion() + { + Task.Run(() => + { + DownloadController.Start(); + DownloadController.Manager.StartDownloadInfo(); + + Dispatcher.BeginInvoke(DispatcherPriority.Render, + (Action)delegate + { + if (DownloadController.Manager.ResponseInfo.HasSomethingToDo) + { + if (BeWoLocalConfig.GetFirstInstallationSuccess() && + File.Exists(BeWoPaths.GetPlanerExePath())) + { + ShowPage(LauncherPageType.UpdateInfo); + } + else + { + ShowPage(LauncherPageType.InstallInfo); + } + } + else + { + ShowPage(LauncherPageType.LoadingScreen); + } + + EndWaiting(); + }); + }); + } + + public static void InstallationFailed(Exception exception) + { + error = exception; + ShowPage(LauncherPageType.InstallFailed); + } + public static void UpdateFailed(Exception exception) + { + error = exception; + ShowPage(LauncherPageType.UpdateFailed); + } + public static void UninstallFailed(Exception exception) + { + error = exception; + ShowPage(LauncherPageType.UninstallFailed); + } + + public static void CheckForAutoLogin(object sender, EventArgs e) + { + var autologin = bool.TryParse(ConfigurationManager.AppSettings.Get("AutoLogin"), out bool c) && c; + + if (autologin) + if (sender is LoginPage loginPage) + loginPage.ClickLogin(); + } + public static void LoginSuccessful(object sender, EventArgs e) + { + #region confirm demo +#if DEBUG + //if (ConnectionInformation.Tenant == "demo") + //{ + // var dlg = new ConfirmDemoDialog(); + // dlg.ShowDialog(); + //} +#else + if (ConnectionInformation.Tenant == "demo") + { + var dlg = new ConfirmDemoDialog(); + dlg.ShowDialog(); + } +#endif + #endregion + + BeWoPaths.ActualPlanerLocation = BeWoPaths.GetInstallLocationFromSetting(); + + if (BeWoPaths.ActualPlanerLocation is object && !CheckForPermissions(BeWoPaths.ActualPlanerLocation)) + { + ShowPage(LauncherPageType.NoPermissionInfo); + } + else + { + CheckForNewestVersion(); + } + } + + private static UserControl GetNewPage(LauncherPageType type) + { + switch (type) + { + case LauncherPageType.Login: + var login = new LoginPage(); + + login.Loaded += CheckForAutoLogin; + login.LoginSuccessful += LoginSuccessful; + + return login; + + case LauncherPageType.InstallInfo: + var install = new InstallInfo(); + + install.Accept += (s, e) => + { + if (CheckForPermissions(install.InstallLocation)) + { + BeWoPaths.SetAndSaveInstallLocation(install.InstallLocation); + BeWoLocalConfig.SetFirstInstallationSuccess(true); + ShowPage(LauncherPageType.InstallProgress); + } + else + { + ShowPage(LauncherPageType.NoPermissionInfo); + } + }; + install.Abort += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(install); + + case LauncherPageType.InstallProgress: + var installprogress = new InstallProgressInfo(); + + installprogress.InstallSuccessful += (s, e) => + { + BeWoLocalConfig.SetFirstInstallationSuccess(true); + ProcessController.StartPlanerProcess(); + }; + + return GetControlInBorder(installprogress); + + + case LauncherPageType.InstallFailed: + var installError = new InfoScreen(); + + installError.Title = "Installation fehlgeschlagen!"; + installError.Text = error.ToString(); + + installError.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(installError); + + case LauncherPageType.UpdateInfo: + var update = new UpdateInfo(); + + update.Accept += (s, e) => { ShowPage(LauncherPageType.UpdateProgress); }; + update.Abort += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(update); + + + case LauncherPageType.UpdateProgress: + var updateProgress = new UpdateProgressInfo(); + + updateProgress.UpdateSuccessful += (s, e) => { ShowPage(LauncherPageType.LoadingScreen); }; + + return GetControlInBorder(updateProgress); + + + case LauncherPageType.UpdateFailed: + var updateError = new InfoScreen(); + + updateError.Title = "Update fehlgeschlagen!"; + updateError.Text = error.ToString(); + + updateError.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(updateError); + + + case LauncherPageType.UninstallInfo: + var uninstall = new UninstallInfo(); + + uninstall.Accept += (s, e) => { ShowPage(LauncherPageType.UpdateProgress); }; + uninstall.Abort += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(uninstall); + + + case LauncherPageType.UninstallProgress: + var uninstallProgress = new UninstallProgressInfo(); + + uninstallProgress.UninstallSuccessful += (s, e) => { ShowPage(LauncherPageType.UninstallSuccessful); }; + + return GetControlInBorder(uninstallProgress); + + + case LauncherPageType.UninstallFailed: + var uninstallFailed = new InfoScreen(); + + uninstallFailed.Title = "Deinstallation fehlgeschlagen!"; + uninstallFailed.Text = error.ToString(); + + uninstallFailed.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(uninstallFailed); + + + case LauncherPageType.UninstallSuccessful: + var uninstallSuccessful = new InfoScreen(); + + uninstallSuccessful.Title = "Deinstallation erfolgreich!"; + uninstallSuccessful.Text = "Kehre zum Login zurück..."; + uninstallSuccessful.CollapseCopyButton(); + + + uninstallSuccessful.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(uninstallSuccessful); + + + case LauncherPageType.LoadingScreen: + var loading = new LoadingScreen(); + + loading.Loaded += (s, e) => + { + Task.Run(() => ProcessController.StartPlanerProcess()); + }; + + return GetControlInBorder(loading); + + + case LauncherPageType.NoPermissionInfo: + var noper = new InfoScreen(); + + noper.Title = "Keine Rechte auf Speicherort!"; + noper.Text = "Es liegt eine neue Version. Sie besitzen aber nicht die benötigten Rechte, um diese anzuwenden. Bitte wenden Sie sich an Ihren System-Administrator!"; + + noper.Button1Click += (s, e) => { ShowPage(LauncherPageType.Login); }; + + return GetControlInBorder(noper); + } + + throw new NotImplementedException(); + } + private static UserControl GetControlInBorder(UserControl uc) + { + if (isBeWoLoginBorderPresent) + return uc; + + BeWoLoginBorder = new BeWoLoginBorder(); + isBeWoLoginBorderPresent = true; + + BeWoLoginBorder.contentGrid.Children.Clear(); + BeWoLoginBorder.contentGrid.Children.Add(uc); + + return BeWoLoginBorder; + } + private static void ShowPage(LauncherPageType type) + { + bool before = isBeWoLoginBorderPresent; + + var page = GetNewPage(type); + + if (type == LauncherPageType.Login) + { + isBeWoLoginBorderPresent = false; + BeWoLoginBorder = null; + + Dispatcher.BeginInvoke(DispatcherPriority.Render, + (Action)delegate + { + LauncherWindow.SetMainContent(page); + }); + } + else + { + // Neu Laden + if (!before) + { + Dispatcher.BeginInvoke(DispatcherPriority.Render, + (Action)delegate + { + LauncherWindow.SetMainContent(page); + }); + } + // Bereits geladen + else + { + Dispatcher.BeginInvoke(DispatcherPriority.Render, + (Action)delegate + { + BeWoLoginBorder.contentGrid.Children.Clear(); + BeWoLoginBorder.contentGrid.Children.Add(page); + }); + } + } + + currentPage = type; + } + } +} diff --git a/BeWoLauncher/Converter/BoolNullCheckConverter.cs b/BeWoLauncher/Logic/Converter/BoolNullCheckConverter.cs similarity index 100% rename from BeWoLauncher/Converter/BoolNullCheckConverter.cs rename to BeWoLauncher/Logic/Converter/BoolNullCheckConverter.cs diff --git a/BeWoLauncher/Converter/BoolReverseConverter.cs b/BeWoLauncher/Logic/Converter/BoolReverseConverter.cs similarity index 100% rename from BeWoLauncher/Converter/BoolReverseConverter.cs rename to BeWoLauncher/Logic/Converter/BoolReverseConverter.cs diff --git a/BeWoLauncher/Converter/BoolVisibilityConverter.cs b/BeWoLauncher/Logic/Converter/BoolVisibilityConverter.cs similarity index 100% rename from BeWoLauncher/Converter/BoolVisibilityConverter.cs rename to BeWoLauncher/Logic/Converter/BoolVisibilityConverter.cs diff --git a/BeWoLauncher/Converter/BoolVisibilityHiddenConverter.cs b/BeWoLauncher/Logic/Converter/BoolVisibilityHiddenConverter.cs similarity index 100% rename from BeWoLauncher/Converter/BoolVisibilityHiddenConverter.cs rename to BeWoLauncher/Logic/Converter/BoolVisibilityHiddenConverter.cs diff --git a/BeWoLauncher/Converter/BoolVisibilityMultiConverter.cs b/BeWoLauncher/Logic/Converter/BoolVisibilityMultiConverter.cs similarity index 100% rename from BeWoLauncher/Converter/BoolVisibilityMultiConverter.cs rename to BeWoLauncher/Logic/Converter/BoolVisibilityMultiConverter.cs diff --git a/BeWoLauncher/Converter/CollectionCountToBoolConverter.cs b/BeWoLauncher/Logic/Converter/CollectionCountToBoolConverter.cs similarity index 100% rename from BeWoLauncher/Converter/CollectionCountToBoolConverter.cs rename to BeWoLauncher/Logic/Converter/CollectionCountToBoolConverter.cs diff --git a/BeWoLauncher/Converter/CollectionCountToVisibilityConverter.cs b/BeWoLauncher/Logic/Converter/CollectionCountToVisibilityConverter.cs similarity index 100% rename from BeWoLauncher/Converter/CollectionCountToVisibilityConverter.cs rename to BeWoLauncher/Logic/Converter/CollectionCountToVisibilityConverter.cs diff --git a/BeWoLauncher/Converter/DataContract2StringConverter.cs b/BeWoLauncher/Logic/Converter/DataContract2StringConverter.cs similarity index 100% rename from BeWoLauncher/Converter/DataContract2StringConverter.cs rename to BeWoLauncher/Logic/Converter/DataContract2StringConverter.cs diff --git a/BeWoLauncher/Converter/Date2CalendarWeekStringConverter.cs b/BeWoLauncher/Logic/Converter/Date2CalendarWeekStringConverter.cs similarity index 100% rename from BeWoLauncher/Converter/Date2CalendarWeekStringConverter.cs rename to BeWoLauncher/Logic/Converter/Date2CalendarWeekStringConverter.cs diff --git a/BeWoLauncher/Converter/DateConverter.cs b/BeWoLauncher/Logic/Converter/DateConverter.cs similarity index 100% rename from BeWoLauncher/Converter/DateConverter.cs rename to BeWoLauncher/Logic/Converter/DateConverter.cs diff --git a/BeWoLauncher/Converter/DateNullValueToEmptyStringConverter.cs b/BeWoLauncher/Logic/Converter/DateNullValueToEmptyStringConverter.cs similarity index 100% rename from BeWoLauncher/Converter/DateNullValueToEmptyStringConverter.cs rename to BeWoLauncher/Logic/Converter/DateNullValueToEmptyStringConverter.cs diff --git a/BeWoLauncher/Converter/DecimalConverter.cs b/BeWoLauncher/Logic/Converter/DecimalConverter.cs similarity index 100% rename from BeWoLauncher/Converter/DecimalConverter.cs rename to BeWoLauncher/Logic/Converter/DecimalConverter.cs diff --git a/BeWoLauncher/Converter/EnumToDescriptionConverter.cs b/BeWoLauncher/Logic/Converter/EnumToDescriptionConverter.cs similarity index 100% rename from BeWoLauncher/Converter/EnumToDescriptionConverter.cs rename to BeWoLauncher/Logic/Converter/EnumToDescriptionConverter.cs diff --git a/BeWoLauncher/Converter/IListT2DataTableConverter.cs b/BeWoLauncher/Logic/Converter/IListT2DataTableConverter.cs similarity index 100% rename from BeWoLauncher/Converter/IListT2DataTableConverter.cs rename to BeWoLauncher/Logic/Converter/IListT2DataTableConverter.cs diff --git a/BeWoLauncher/Converter/IndexBoolConverter.cs b/BeWoLauncher/Logic/Converter/IndexBoolConverter.cs similarity index 100% rename from BeWoLauncher/Converter/IndexBoolConverter.cs rename to BeWoLauncher/Logic/Converter/IndexBoolConverter.cs diff --git a/BeWoLauncher/Converter/Int2DecimalConverter.cs b/BeWoLauncher/Logic/Converter/Int2DecimalConverter.cs similarity index 100% rename from BeWoLauncher/Converter/Int2DecimalConverter.cs rename to BeWoLauncher/Logic/Converter/Int2DecimalConverter.cs diff --git a/BeWoLauncher/Converter/NullableBoolToBoolConverter.cs b/BeWoLauncher/Logic/Converter/NullableBoolToBoolConverter.cs similarity index 100% rename from BeWoLauncher/Converter/NullableBoolToBoolConverter.cs rename to BeWoLauncher/Logic/Converter/NullableBoolToBoolConverter.cs diff --git a/BeWoLauncher/Converter/ObjectBoolConverter.cs b/BeWoLauncher/Logic/Converter/ObjectBoolConverter.cs similarity index 100% rename from BeWoLauncher/Converter/ObjectBoolConverter.cs rename to BeWoLauncher/Logic/Converter/ObjectBoolConverter.cs diff --git a/BeWoLauncher/Converter/ObjectVisibilityConverter.cs b/BeWoLauncher/Logic/Converter/ObjectVisibilityConverter.cs similarity index 100% rename from BeWoLauncher/Converter/ObjectVisibilityConverter.cs rename to BeWoLauncher/Logic/Converter/ObjectVisibilityConverter.cs diff --git a/BeWoLauncher/Converter/OneWayToSourceSwitch.cs b/BeWoLauncher/Logic/Converter/OneWayToSourceSwitch.cs similarity index 100% rename from BeWoLauncher/Converter/OneWayToSourceSwitch.cs rename to BeWoLauncher/Logic/Converter/OneWayToSourceSwitch.cs diff --git a/BeWoLauncher/Converter/ReverseValueEqualsParamVisibilityConverter.cs b/BeWoLauncher/Logic/Converter/ReverseValueEqualsParamVisibilityConverter.cs similarity index 100% rename from BeWoLauncher/Converter/ReverseValueEqualsParamVisibilityConverter.cs rename to BeWoLauncher/Logic/Converter/ReverseValueEqualsParamVisibilityConverter.cs diff --git a/BeWoLauncher/Converter/StringBrushConverter.cs b/BeWoLauncher/Logic/Converter/StringBrushConverter.cs similarity index 100% rename from BeWoLauncher/Converter/StringBrushConverter.cs rename to BeWoLauncher/Logic/Converter/StringBrushConverter.cs diff --git a/BeWoLauncher/Converter/StringFormatConverter.cs b/BeWoLauncher/Logic/Converter/StringFormatConverter.cs similarity index 100% rename from BeWoLauncher/Converter/StringFormatConverter.cs rename to BeWoLauncher/Logic/Converter/StringFormatConverter.cs diff --git a/BeWoLauncher/Converter/StringFormatMulitConverter.cs b/BeWoLauncher/Logic/Converter/StringFormatMulitConverter.cs similarity index 100% rename from BeWoLauncher/Converter/StringFormatMulitConverter.cs rename to BeWoLauncher/Logic/Converter/StringFormatMulitConverter.cs diff --git a/BeWoLauncher/Converter/StringLengthVisibilityConverter.cs b/BeWoLauncher/Logic/Converter/StringLengthVisibilityConverter.cs similarity index 100% rename from BeWoLauncher/Converter/StringLengthVisibilityConverter.cs rename to BeWoLauncher/Logic/Converter/StringLengthVisibilityConverter.cs diff --git a/BeWoLauncher/Converter/StringLengthVisibilityMultiConverter.cs b/BeWoLauncher/Logic/Converter/StringLengthVisibilityMultiConverter.cs similarity index 100% rename from BeWoLauncher/Converter/StringLengthVisibilityMultiConverter.cs rename to BeWoLauncher/Logic/Converter/StringLengthVisibilityMultiConverter.cs diff --git a/BeWoLauncher/Converter/ValueEqualsParamVisibilityConverter.cs b/BeWoLauncher/Logic/Converter/ValueEqualsParamVisibilityConverter.cs similarity index 100% rename from BeWoLauncher/Converter/ValueEqualsParamVisibilityConverter.cs rename to BeWoLauncher/Logic/Converter/ValueEqualsParamVisibilityConverter.cs diff --git a/BeWoLauncher/Multitenancy/MultitenancyEndpointBehavior.cs b/BeWoLauncher/Logic/Multitenancy/MultitenancyEndpointBehavior.cs similarity index 100% rename from BeWoLauncher/Multitenancy/MultitenancyEndpointBehavior.cs rename to BeWoLauncher/Logic/Multitenancy/MultitenancyEndpointBehavior.cs diff --git a/BeWoLauncher/Multitenancy/MultitenancyHeader.cs b/BeWoLauncher/Logic/Multitenancy/MultitenancyHeader.cs similarity index 100% rename from BeWoLauncher/Multitenancy/MultitenancyHeader.cs rename to BeWoLauncher/Logic/Multitenancy/MultitenancyHeader.cs diff --git a/BeWoLauncher/Multitenancy/MultitenancyInterceptor.cs b/BeWoLauncher/Logic/Multitenancy/MultitenancyInterceptor.cs similarity index 100% rename from BeWoLauncher/Multitenancy/MultitenancyInterceptor.cs rename to BeWoLauncher/Logic/Multitenancy/MultitenancyInterceptor.cs diff --git a/BeWoLauncher/Security/LauncherSecurityHeader.cs b/BeWoLauncher/Logic/Security/LauncherSecurityHeader.cs similarity index 100% rename from BeWoLauncher/Security/LauncherSecurityHeader.cs rename to BeWoLauncher/Logic/Security/LauncherSecurityHeader.cs diff --git a/BeWoLauncher/Security/LauncherSecurityHeaderEndpointBehavior.cs b/BeWoLauncher/Logic/Security/LauncherSecurityHeaderEndpointBehavior.cs similarity index 100% rename from BeWoLauncher/Security/LauncherSecurityHeaderEndpointBehavior.cs rename to BeWoLauncher/Logic/Security/LauncherSecurityHeaderEndpointBehavior.cs diff --git a/BeWoLauncher/Security/LauncherSecurityHeaderInterceptor.cs b/BeWoLauncher/Logic/Security/LauncherSecurityHeaderInterceptor.cs similarity index 100% rename from BeWoLauncher/Security/LauncherSecurityHeaderInterceptor.cs rename to BeWoLauncher/Logic/Security/LauncherSecurityHeaderInterceptor.cs diff --git a/BeWoLauncher/ServiceProxy/LauncherGenerated.cs b/BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs similarity index 95% rename from BeWoLauncher/ServiceProxy/LauncherGenerated.cs rename to BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs index 07bcb7e73..d7c9e0f13 100644 --- a/BeWoLauncher/ServiceProxy/LauncherGenerated.cs +++ b/BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs @@ -332,6 +332,10 @@ namespace BeWoLauncher.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDownloadBeWoService/Download2", ReplyAction="http://tempuri.org/IDownloadBeWoService/Download2Response")] [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IDownloadBeWoService/Download2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] BS.SharedLauncher.DataContract.DownloadPlanerResponseDC Download2(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDownloadBeWoService/DownloadInfo", ReplyAction="http://tempuri.org/IDownloadBeWoService/DownloadInfoResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IDownloadBeWoService/DownloadInfoBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.DataContract.DownloadPlanerResponseInfoDC DownloadInfo(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request); } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] @@ -372,5 +376,10 @@ namespace BeWoLauncher.ServiceProxy { return base.Channel.Download2(request); } + + public BS.SharedLauncher.DataContract.DownloadPlanerResponseInfoDC DownloadInfo(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request) + { + return base.Channel.DownloadInfo(request); + } } } diff --git a/BeWoLauncher/ServiceProxy/LauncherServiceFacade.cs b/BeWoLauncher/Logic/ServiceProxy/LauncherServiceFacade.cs similarity index 100% rename from BeWoLauncher/ServiceProxy/LauncherServiceFacade.cs rename to BeWoLauncher/Logic/ServiceProxy/LauncherServiceFacade.cs diff --git a/BeWoLauncher/Utils/BeWoHelper.cs b/BeWoLauncher/Logic/Utils/BeWoHelper.cs similarity index 86% rename from BeWoLauncher/Utils/BeWoHelper.cs rename to BeWoLauncher/Logic/Utils/BeWoHelper.cs index c6ab11472..2e9263238 100644 --- a/BeWoLauncher/Utils/BeWoHelper.cs +++ b/BeWoLauncher/Logic/Utils/BeWoHelper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Configuration; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; diff --git a/BeWoLauncher/Logic/Utils/BeWoLocalConfig.cs b/BeWoLauncher/Logic/Utils/BeWoLocalConfig.cs new file mode 100644 index 000000000..2683efed2 --- /dev/null +++ b/BeWoLauncher/Logic/Utils/BeWoLocalConfig.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWoLauncher.Utils +{ + public static class BeWoLocalConfig + { + public static string GetInstallLocation() + { + return Properties.Settings.Default.InstallLocation; + } + + public static void SetInstallLocation(string path) + { + Properties.Settings.Default.InstallLocation = path; + Properties.Settings.Default.Save(); + } + + public static bool GetFirstInstallationSuccess() + { + return Properties.Settings.Default.FirstInstallationSuccess; + } + + public static void SetFirstInstallationSuccess(bool b) + { + Properties.Settings.Default.FirstInstallationSuccess = b; + Properties.Settings.Default.Save(); + } + } +} diff --git a/BeWoLauncher/Utils/BeWoPaths.cs b/BeWoLauncher/Logic/Utils/BeWoPaths.cs similarity index 69% rename from BeWoLauncher/Utils/BeWoPaths.cs rename to BeWoLauncher/Logic/Utils/BeWoPaths.cs index 5c89103bf..3d6df0a96 100644 --- a/BeWoLauncher/Utils/BeWoPaths.cs +++ b/BeWoLauncher/Logic/Utils/BeWoPaths.cs @@ -17,7 +17,7 @@ namespace BeWoLauncher.Utils //private static readonly string versionXml = "bewo.version"; public static string LoginSelectionPlanerLocation { get; set; } - public static string ActualPlanerLocation { get; private set; } + public static string ActualPlanerLocation { get; set; } /// /// Holt den Install Ort aus den Properties Settings. @@ -26,41 +26,52 @@ namespace BeWoLauncher.Utils /// public static string GetInstallLocationFromSettingOrDefault() { - var installLocation = Properties.Settings.Default.InstallLocation; + var installLocation = GetInstallLocationFromSetting(); if (string.IsNullOrWhiteSpace(installLocation)) { - installLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data"); + installLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BeWoPathFileConfig.SubDirectory); } return installLocation; } - public static void CheckPathForInstallation(string newLocation) + + public static string GetInstallLocationFromSetting() + { + return BeWoLocalConfig.GetInstallLocation(); + } + + /// + /// + /// + /// + /// Gibt true aus, wenn der Path sich verändert hat. + public static bool ChangePath(string newLocation) { var info = new DirectoryInfo(newLocation); if (LoginSelectionPlanerLocation == newLocation) { - return; + return false; } - if (info.GetDirectories().Any() || info.GetFiles().Any()) - { - MessageBox.Show($"Ordner muss leer sein! Es sind {info.GetDirectories().Count()} Ordner und {info.GetFiles().Count()} Datei(en) enthalten"); - return; - } + //if (newLocation.Exists() && (info.GetDirectories().Any() || info.GetFiles().Any())) + //{ + // MessageBox.Show($"Ordner muss leer sein! Es sind {info.GetDirectories().Count()} Ordner und {info.GetFiles().Count()} Datei(en) enthalten"); + // return false; + //} // Annahme: Ordner ist leer und neuer Ort - LoginSelectionPlanerLocation.ClearFolder(); - LoginSelectionPlanerLocation = newLocation; + + return true; } + public static void SetAndSaveInstallLocation(string path) { ActualPlanerLocation = path; - Properties.Settings.Default.InstallLocation = ActualPlanerLocation; - Properties.Settings.Default.Save(); + BeWoLocalConfig.SetInstallLocation(path); } public static string GetDownloadPath() diff --git a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs new file mode 100644 index 000000000..9e4ad20b1 --- /dev/null +++ b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs @@ -0,0 +1,155 @@ +using BeWoLauncher.ServiceProxy; +using BS.SharedLauncher; +using BS.SharedLauncher.DataContract; +using BS.SharedLauncher.Exceptions; +using BS.SharedLauncher.Extensions; +using BS.SharedLauncher.Information; +using BS.SharedLauncher.Logic; +using BS.SharedLauncher.Update; +using BS.SharedLauncher.Utils; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Xml.Serialization; + +namespace BeWoLauncher.Utils.Download +{ + public class DownloadManager + { + public DownloadPlanerRequestDC Request { get; set; } + public DownloadPlanerResponseInfoDC ResponseInfo { get; set; } + public DownloadPlanerResponseDC Response { get; set; } + public string DownloadZipPath { get; set; } + + public string DownloadFolder => BeWoPaths.GetDownloadPath(); + public string ApplyFolder => BeWoPaths.GetApplyPath(); + + public DownloadManager() + { + Request = null; + ResponseInfo = null; + Response = null; + } + + public void StartDownloadInfo() + { + CreateDownloadRequest(); + + GetDownloadResponseInfo(); + } + + private void CreateDownloadRequest() + { + Request = new DownloadPlanerRequestDC(); + + if (Request.PlanerRootFolderExists = BeWoPaths.ActualPlanerLocation.Exists()) + { + if (Request.DownloadFolderExists = DownloadFolder.Exists()) + if (!(Request.DownloadFolderIsEmpty = DownloadFolder.IsFolderEmpty())) + Request.DownloadedPackages = FileController.LoadInfos(DownloadFolder); + + if (Request.ApplyFolderExists = ApplyFolder.Exists()) + if (!(Request.ApplyFolderIsEmpty = ApplyFolder.IsFolderEmpty())) + { + var files = FileController.GetPlanerFiles(ApplyFolder); + + if (files is object) + files.ForEach(file => file.LoadHash()); + + FileController.TryGetPackageInfo(ApplyFolder, out var package); + + if (package == null) + package = new PlanerPackageInfoDC(); + + package.Files = files.ToPlanerFileInfoDCList(); + + Request.ApplyPackage = package; + } + } + } + + private void GetDownloadResponse() + { + Response = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.Download2(Request)); + } + + private void GetDownloadResponseInfo() + { + ResponseInfo = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.DownloadInfo(Request)); + } + + public void StartDownload(bool skipLock) + { + GetDownloadResponse(); + + if (!Response.HasToDo()) + { + // Macht das Sinn? + // Ne, wahrsch. Fehler + return; + } + + if (Response.HasToDoNewZip()) + { + DownloadFolder.CreateFolder(); + + DownloadFolder.Lock(skipLock); + + DownloadZipPath = FileController.GetNewZipPath(BeWoPaths.GetDownloadPath()); + + FileController.SaveDZip(DownloadZipPath, Response.NewZipData); + FileController.SaveInfo(DownloadZipPath, Response.NewZipInfo); + FileController.SaveInfo(BeWoPaths.GetDownloadPath(), Response.LatestApplicationInfo); + + Response.NewZipData = null; + + DownloadFolder.Unlock(); + } + } + + public void StartApply(bool skiplock, Action apply) + { + ApplyFolder.CreateFolder(); + + ApplyFolder.Lock(skiplock); + + if (Response.HasToDoDownload2Keep()) + { + FileController.ApplyDZip(Response.DownloadFilesToKeep, ApplyFolder, apply); + } + + if (Response.HasToDoNewZip()) + { + FileController.ApplyDZip(DownloadZipPath, ApplyFolder, apply); + } + + if (Response.HasToRemoveFiles) + { + apply(3, null); + + Thread.Sleep(500); + + FileController.RemoveUnsuedFiles(Response.LatestApplicationInfo, ApplyFolder, apply); + } + + DownloadFolder.ClearFolder(); + + ApplyFolder.Unlock(); + } + + public void StartUninstall(Action apply) + { + apply(3, null); + + Thread.Sleep(500); + + FileController.RemoveFiles(BeWoPaths.ActualPlanerLocation); + } + } +} diff --git a/BeWoLauncher/LauncherUtils.cs b/BeWoLauncher/Logic/Utils/LauncherUtils.cs similarity index 100% rename from BeWoLauncher/LauncherUtils.cs rename to BeWoLauncher/Logic/Utils/LauncherUtils.cs diff --git a/BeWoLauncher/Logic/ViewController.cs b/BeWoLauncher/Logic/ViewController.cs deleted file mode 100644 index 9b57d7b88..000000000 --- a/BeWoLauncher/Logic/ViewController.cs +++ /dev/null @@ -1,188 +0,0 @@ -using BeWoLauncher.PageImp; -using BeWoLauncher.Utils; -using BeWoLauncher.WindowImp; -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Controls; -using System.Windows.Threading; - -namespace BeWoLauncher.Logic -{ - public static class ViewController - { - static bool isMainPagePresent = false; - static MainPage MainPage = null; - - public enum LauncherPageType - { - Login, - Update, - UpdateInfo1, - UpdateInfo2, - UpdateInfo3, - } - - public static LauncherWindow LauncherWindow { get; set; } - - public static Dispatcher Dispatcher => LauncherWindow.Dispatcher; - - public static void StartView() - { - //ShowPage(LauncherPageType.Login); - ShowPage(LauncherPageType.UpdateInfo1); - } - - public static void LoginLoaded(object sender, EventArgs e) - { - var autologin = bool.TryParse(ConfigurationManager.AppSettings.Get("AutoLogin"), out bool c) && c; - - if (autologin) - if (sender is LoginPage loginPage) - loginPage.ClickLogin(); - } - public static void LoginSuccessful(object sender, EventArgs e) - { - #region confirm demo -#if DEBUG - //if (ConnectionInformation.Tenant == "demo") - //{ - // var dlg = new ConfirmDemoDialog(); - // dlg.ShowDialog(); - //} -#else - if (ConnectionInformation.Tenant == "demo") - { - var dlg = new ConfirmDemoDialog(); - dlg.ShowDialog(); - } -#endif - #endregion - - BeWoPaths.SetAndSaveInstallLocation(((LoginPage)sender).InstallLocation); - - ShowPage(LauncherPageType.Update); - } - public static void UpdateSuccessful(object sender, EventArgs e) - { - ProcessController.StartPlanerProcess(); - } - public static void UpdateFailed(object sender, EventArgs e) - { - throw new NotImplementedException(); - } - - public static UserControl GetNewPage(LauncherPageType type) - { - if (type == LauncherPageType.Login) - { - var login = new LoginPage(); - - login.Loaded += LoginLoaded; - login.LoginSuccessful += LoginSuccessful; - - return login; - } - else if (type == LauncherPageType.Update) - { - bool showDelay = bool.TryParse(ConfigurationManager.AppSettings.Get("ShowUpdateDelay"), out bool b) && b; - bool forceUpdate = bool.TryParse(ConfigurationManager.AppSettings.Get("ForceUpdate"), out bool c) && c; - - var update = new UpdatePage(showDelay, forceUpdate); - - update.UpdateSuccessful += UpdateSuccessful; - update.UpdateFailed += UpdateFailed; - - return update; - } - else if (type == LauncherPageType.UpdateInfo1) - { var update = new UpdateInfo1(); - - return GetMainPage(update); - } - else if (type == LauncherPageType.UpdateInfo2) - { - var update = new UpdateInfo2(); - - return GetMainPage(update); - } - else if (type == LauncherPageType.UpdateInfo3) - { - var update = new UpdateInfo3(); - - return GetMainPage(update); - } - - throw new NotImplementedException(); - } - - public static UserControl GetMainPage(UserControl uc) - { - if (isMainPagePresent) - return uc; - - MainPage = new MainPage(); - isMainPagePresent = true; - - MainPage.contentGrid.Children.Clear(); - MainPage.contentGrid.Children.Add(uc); - - return MainPage; - } - - public static void ShowPage(LauncherPageType type) - { - bool before = isMainPagePresent; - - var page = GetNewPage(type); - - if(type == LauncherPageType.Login) - { - isMainPagePresent = false; - MainPage = null; - - Dispatcher.BeginInvoke(DispatcherPriority.Normal, - (Action)delegate - { - LauncherWindow.rootGrid.Children.Clear(); - LauncherWindow.rootGrid.Children.Add(page); - }); - } - else if(type == LauncherPageType.Update) - { - - Dispatcher.BeginInvoke(DispatcherPriority.Normal, - (Action)delegate - { - //LauncherWindow.MainPage.contentGrid.Children.Add(page); - }); - } - else - { - // Neu Laden - if(!before) - { - Dispatcher.BeginInvoke(DispatcherPriority.Normal, - (Action)delegate - { - LauncherWindow.rootGrid.Children.Clear(); - LauncherWindow.rootGrid.Children.Add(page); - }); - } - // Bereits geladen - else - { - Dispatcher.BeginInvoke(DispatcherPriority.Normal, - (Action)delegate - { - MainPage.contentGrid.Children.Clear(); - MainPage.contentGrid.Children.Add(page); - }); - } - } - } - } -} diff --git a/BeWoLauncher/PageImp/02 UpdatePage.xaml b/BeWoLauncher/PageImp/02 UpdatePage.xaml deleted file mode 100644 index 7fc91dd2e..000000000 --- a/BeWoLauncher/PageImp/02 UpdatePage.xaml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BeWoLauncher/PageImp/02 UpdatePage.xaml.cs b/BeWoLauncher/PageImp/02 UpdatePage.xaml.cs deleted file mode 100644 index 819fb46ca..000000000 --- a/BeWoLauncher/PageImp/02 UpdatePage.xaml.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Deployment.Application; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using BeWoLauncher.ServiceProxy; -using BeWoLauncher.Utils; -using BeWoLauncher.Utils.Update; -using BS.SharedLauncher; -using BS.SharedLauncher.DataContract; -using BS.SharedLauncher.Information; -using Path = System.IO.Path; - -namespace BeWoLauncher.PageImp -{ - /// - /// Interaktionslogik für UpdateView.xaml - /// - public partial class UpdatePage : UserControl - { - public event EventHandler UpdateSuccessful; - public event EventHandler UpdateFailed; - - private bool _ShowDelay; - private bool _ForceUpdate; - - public UpdatePage(bool showDelay, bool forceUpdate) - { - InitializeComponent(); - - _ShowDelay = showDelay; - _ForceUpdate = forceUpdate; - - //UpdateFileManager.ApplyFileEventHandler += ApplyFile; - //UpdateFileManager.DownloadFileEventHandler += DownloadFile; - } - - public string Message - { - get { return lblMessage.Content as string; } - set { lblMessage.Content = value; } - } - - public string SubMessage - { - get { return lblSubmessage.Content as string; } - set { lblSubmessage.Content = value; } - } - - private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) - { - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo((sender as Hyperlink).NavigateUri.ToString())); - } - - private async void startUpdateAsync() - { - //try - //{ - // Message = "Update wird vorbereitet..."; - // SubMessage = ""; - // UpdatePathManager.GetDownloadDirInfo().ClearFolder(); - // if (_ForceUpdate) - // UpdatePathManager.GetApplyDirInfo().ClearFolder(); - // await showDelay(5000); - - // Message = "Update wird heruntergeladen..."; - // SubMessage = ""; - // await showDelay(1000); - - // //UpdateFileManager.DownloadUpdateSync(); - - // Message = "Update wird installiert..."; - // await showDelay(1000); - - // //await UpdateFileManager.ApplyUpdate(); - - // Message = "Update wurde installiert!"; - // SubMessage = "Starte BeWoPlaner..."; - // await showDelay(1000); - - // //UpdateFileManager.UpdateData = null; - // UpdateSuccessful(this, new EventArgs()); - - // UpdatePathManager.GetDownloadDirInfo().ClearFolder(); - // //UpdateFinished(this, null); - //} - //catch (Exception e) - //{ - // Message = "Update fehlgeschlagen!"; - // SubMessage = string.Empty; - - // throw e; - //} - } - - private async void startUpdateAsync2() - { - var skipLock = bool.TryParse(ConfigurationManager.AppSettings.Get("SkipLock"), out bool c) && c; - - - var manager = new UpdateFileManager(); - - manager.StartUpdate(skipLock); - - try - { - - } - catch (Exception e) - { - Message = "Update fehlgeschlagen!"; - SubMessage = string.Empty; - - throw e; - } - } - - private async Task showDelay(int millisec) - { - if (_ShowDelay) - await Task.Delay(millisec); - } - - private void UserControl_Loaded(object sender, RoutedEventArgs e) - { - double top = (this.ActualHeight - 400) / 3; - this.gridUpdate.Margin = new Thickness(0, top, 0, 0); - - //startUpdate(); - Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)startUpdateAsync2); - } - } -} diff --git a/BeWoLauncher/PageImp/UpdateInfo1.xaml b/BeWoLauncher/PageImp/UpdateInfo1.xaml deleted file mode 100644 index 9c87f345f..000000000 --- a/BeWoLauncher/PageImp/UpdateInfo1.xaml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BeWoLauncher/PageImp/UpdateInfo1.xaml.cs b/BeWoLauncher/PageImp/UpdateInfo1.xaml.cs deleted file mode 100644 index d5b75ea64..000000000 --- a/BeWoLauncher/PageImp/UpdateInfo1.xaml.cs +++ /dev/null @@ -1,59 +0,0 @@ -using BeWoLauncher.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace BeWoLauncher.PageImp -{ - /// - /// Interaktionslogik für UpdateInfo1.xaml - /// - public partial class UpdateInfo1 : UserControl - { - public UpdateInfo1() - { - InitializeComponent(); - } - - public string InstallLocation - { - get - { - return BeWoPaths.LoginSelectionPlanerLocation; - } - set - { - txtLoc.Text = value; - BeWoPaths.LoginSelectionPlanerLocation = value; - } - } - - private void button_installLoc_Click(object sender, RoutedEventArgs rea) - { - // https://stackoverflow.com/questions/11624298/how-to-use-openfiledialog-to-select-a-folder - using (var fbd = new System.Windows.Forms.FolderBrowserDialog()) - { - fbd.SelectedPath = InstallLocation; - - System.Windows.Forms.DialogResult result = fbd.ShowDialog(); - - if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) - { - InstallLocation = fbd.SelectedPath; - //BeWoPaths.ChangeLoginSelectedLocation(fbd.SelectedPath); - } - } - } - } -} diff --git a/BeWoLauncher/Properties/Settings.Designer.cs b/BeWoLauncher/Properties/Settings.Designer.cs index 0fef9d9e3..3dbb00994 100644 --- a/BeWoLauncher/Properties/Settings.Designer.cs +++ b/BeWoLauncher/Properties/Settings.Designer.cs @@ -34,5 +34,17 @@ namespace BeWoLauncher.Properties { this["InstallLocation"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool FirstInstallationSuccess { + get { + return ((bool)(this["FirstInstallationSuccess"])); + } + set { + this["FirstInstallationSuccess"] = value; + } + } } } diff --git a/BeWoLauncher/Properties/Settings.settings b/BeWoLauncher/Properties/Settings.settings index 94532871f..f4fc75103 100644 --- a/BeWoLauncher/Properties/Settings.settings +++ b/BeWoLauncher/Properties/Settings.settings @@ -5,5 +5,8 @@ + + False + \ No newline at end of file diff --git a/BeWoLauncher/OrangeBlack.xaml b/BeWoLauncher/Styles/OrangeBlack.xaml similarity index 98% rename from BeWoLauncher/OrangeBlack.xaml rename to BeWoLauncher/Styles/OrangeBlack.xaml index eba9d6d01..5bbf9aa49 100644 --- a/BeWoLauncher/OrangeBlack.xaml +++ b/BeWoLauncher/Styles/OrangeBlack.xaml @@ -1738,7 +1738,7 @@ - + @@ -1887,7 +1887,7 @@ - + @@ -3960,7 +3960,64 @@ - +