diff --git a/BeWo/Loader.cs b/BeWo/Loader.cs index f2873c55c..aaf935c59 100644 --- a/BeWo/Loader.cs +++ b/BeWo/Loader.cs @@ -17,13 +17,15 @@ namespace BeWo Loaded = false; } - public static void Load(string username, string password, string servername, string tenant, string coreserveraddress) + public static void Load(string username, string password, string servername, string tenant, string coreserveraddress, string version) { BeWoApp.UserName = username; BeWoApp.UserPassword = password; BeWoApp.ServerName = servername; BeWoApp.Tenant = tenant; BeWoApp.ServerAddress = coreserveraddress; + BeWoApp.ShortVersion = version; + BeWoApp.Version = "Version " + version; BeWoApp.LoggedOnUser = ServiceFacade.DoUserServiceSync(s => s.LoadUserByNameAndPassword(BeWoApp.UserName, BeWoApp.UserPassword)); BeWoApp.Mandator = ServiceFacade.DoOperationsServiceSync(s => s.GetMandator()); @@ -32,7 +34,7 @@ namespace BeWo } public static void Load(Connection connection) - => Load(connection.Username, connection.Password, connection.Servername, connection.Tenant, connection.CoreServerAddress); + => Load(connection.Username, connection.Password, connection.Servername, connection.Tenant, connection.CoreServerAddress, connection.Version); public static void Load(string rawInput) => Load(Connection.Parse(rawInput)); diff --git a/BeWoLauncher/BeWoLauncher.csproj b/BeWoLauncher/BeWoLauncher.csproj index 043d7ae0a..9b3b32b6b 100644 --- a/BeWoLauncher/BeWoLauncher.csproj +++ b/BeWoLauncher/BeWoLauncher.csproj @@ -67,6 +67,9 @@ true + + False + diff --git a/BeWoLauncher/Logic/Controller/ViewController.cs b/BeWoLauncher/Logic/Controller/ViewController.cs index 71668aa2e..8d7292cb4 100644 --- a/BeWoLauncher/Logic/Controller/ViewController.cs +++ b/BeWoLauncher/Logic/Controller/ViewController.cs @@ -172,6 +172,7 @@ namespace BeWoLauncher.Logic.Controller if (BeWoPaths.ActualPlanerLocation is object && !CheckForPermissions(BeWoPaths.ActualPlanerLocation)) { ShowPage(LauncherPageType.NoPermissionInfo); + EndWaiting(); } else { @@ -217,7 +218,7 @@ namespace BeWoLauncher.Logic.Controller installprogress.InstallSuccessful += (s, e) => { BeWoLocalConfig.SetFirstInstallationSuccess(true); - ProcessController.StartPlanerProcess(); + ShowPage(LauncherPageType.LoadingScreen); }; return GetControlInFrameView(installprogress); @@ -348,14 +349,22 @@ namespace BeWoLauncher.Logic.Controller { var page = GetNewPage(type); - if (type == LauncherPageType.Login) + if (page is LoginView login) { - CurrentView = page; + CurrentView = login; + } + else if (page is FrameView frameview) + { + CurrentView = frameview; } else if(page is FrameBase frame) { CurrentFrame = frame; } + else + { + throw new NotImplementedException("Page Error 1063"); + } } } } diff --git a/BeWoLauncher/Logic/Utils/BeWoPaths.cs b/BeWoLauncher/Logic/Utils/BeWoPaths.cs index 3d6df0a96..8701a9ee5 100644 --- a/BeWoLauncher/Logic/Utils/BeWoPaths.cs +++ b/BeWoLauncher/Logic/Utils/BeWoPaths.cs @@ -74,13 +74,18 @@ namespace BeWoLauncher.Utils BeWoLocalConfig.SetInstallLocation(path); } + public static string GetRootPath() + { + return ActualPlanerLocation; + } + public static string GetDownloadPath() { - return Path.Combine(new string[] { ActualPlanerLocation, "download" }); + return Path.Combine(new string[] { GetRootPath(), "download" }); } public static string GetApplyPath() { - return Path.Combine(new string[] { ActualPlanerLocation, "apply" }); + return Path.Combine(new string[] { GetRootPath(), "apply" }); } public static string GetPlanerExeName() => planerExeName; public static string GetPlanerExePath() diff --git a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs index ba5dd3d6b..d342544ae 100644 --- a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs +++ b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs @@ -42,6 +42,8 @@ namespace BeWoLauncher.Utils.Download CreateDownloadRequest(); GetDownloadResponseInfo(); + + ConnectionInformation.Version = ResponseInfo.Version; } private void CreateDownloadRequest() @@ -105,7 +107,7 @@ namespace BeWoLauncher.Utils.Download FileController.SaveDZip(DownloadZipPath, Response.NewZipData); FileController.SaveInfo(DownloadZipPath, Response.NewZipInfo); - FileController.SaveInfo(BeWoPaths.GetDownloadPath(), Response.LatestApplicationInfo); + FileController.SaveInfo(BeWoPaths.GetRootPath().Combine("latest"), Response.LatestApplicationInfo); Response.NewZipData = null; @@ -141,6 +143,10 @@ namespace BeWoLauncher.Utils.Download DownloadFolder.ClearFolder(); ApplyFolder.Unlock(); + + apply(5, null); + + Thread.Sleep(1000); } public void StartUninstall(Action apply) diff --git a/BeWoLauncher/View/FrameView.xaml.cs b/BeWoLauncher/View/FrameView.xaml.cs index 662e70e40..62246d688 100644 --- a/BeWoLauncher/View/FrameView.xaml.cs +++ b/BeWoLauncher/View/FrameView.xaml.cs @@ -54,6 +54,7 @@ namespace BeWoLauncher.View public void SetFrame(FrameBase uc) { + ClearFrame(); contentGrid.Children.Add(uc); } diff --git a/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs b/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs index 84a3fb603..3d37ad7af 100644 --- a/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -36,6 +37,8 @@ namespace BeWoLauncher.View.Frames /// public abstract partial class GenericProgressInfo : FrameBase { + private static TimeSpan duration = TimeSpan.FromSeconds(1); + public readonly BackgroundWorker Worker = new BackgroundWorker(); private int lastStep = -1; @@ -48,7 +51,7 @@ namespace BeWoLauncher.View.Frames proBar1.Minimum = 0; proBar1.Maximum = 100; - proBar2.IsIndeterminate = true; + proBar2.IsIndeterminate = false; proBar2.Minimum = 0; Loaded += (s, e) => Start(); @@ -85,7 +88,14 @@ namespace BeWoLauncher.View.Frames proBar2.Value++; } } + public void Bar2Fill() => proBar2.Value = proBar2.Maximum; public void Bar2Hide() => proBar2.Visibility = Visibility.Collapsed; public void Bar2Show() => proBar2.Visibility = Visibility.Visible; + + public void Bar2SetPercent(double percentage) + { + DoubleAnimation animation = new DoubleAnimation(percentage, duration); + proBar2.BeginAnimation(ProgressBar.ValueProperty, animation); + } } } diff --git a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml index feb75db1f..c761cdf86 100644 --- a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml +++ b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml @@ -17,25 +17,41 @@ Startmenüverknüpfung erstellen --> - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - + + + + + + + + + + diff --git a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs index e6e29eda0..9d3e77359 100644 --- a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs @@ -37,8 +37,14 @@ namespace BeWoLauncher.View.Frames InstallLocation = BeWoPaths.GetInstallLocationFromSettingOrDefault(); - lblErforderlich.Content = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize); - lblcount.Content = $"{DownloadController.Manager.ResponseInfo.NewFileCount} (T:{DownloadController.Manager.ResponseInfo.FileCount})"; + var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize).Split(' '); + + lblErforderlich.Content = size[0]; + lblErforderlichSize.Content = size[1]; + + lblcountnew.Content = $"{DownloadController.Manager.ResponseInfo.NewFileCount}"; + lblcountalready.Content = $"{DownloadController.Manager.ResponseInfo.FileCount - DownloadController.Manager.ResponseInfo.NewFileCount}"; + lblversion.Content = DownloadController.Manager.ResponseInfo.Version; } @@ -50,13 +56,25 @@ namespace BeWoLauncher.View.Frames } set { + if (!endPathWithSubDir(value)) + value = Path.Combine(value, BeWoPathFileConfig.SubDirectory); + if (BeWoPaths.ChangePath(value)) { - if (!endPathWithSubDir(value)) - value = Path.Combine(value, BeWoPathFileConfig.SubDirectory); - txtLoc.Text = value; - lblVerfuegbar.Content = DownloadController.UpdateDiskSpace(value); + + var size2 = DownloadController.UpdateDiskSpace(BeWoPaths.ActualPlanerLocation).Split(' '); + + if (size2.Length > 1) + { + lblVerfuegbar.Content = size2[0]; + lblVerfuegbarSize.Content = size2[1]; + } + else + { + lblVerfuegbar.Content = size2[0] ?? "error#87"; + lblVerfuegbarSize.Content = string.Empty; + } } } } diff --git a/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs b/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs index 70b51086e..ea6e86405 100644 --- a/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs +++ b/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs @@ -17,8 +17,7 @@ namespace BeWoLauncher.View.Frames public class InstallProgressInfoFrame : GenericProgressInfo { public event EventHandler InstallSuccessful; - public event EventHandler InstallFailed; - + public DownloadManager Manager => DownloadController.Manager; public InstallProgressInfoFrame() : base() @@ -52,10 +51,15 @@ namespace BeWoLauncher.View.Frames Thread.Sleep(1000); DownloadController.Manager.StartDownload(skipLock); - worker.ReportProgress(1); + + worker.ReportProgress(10); Thread.Sleep(1000); + worker.ReportProgress(1); + + Thread.Sleep(500); + DownloadController.Manager.StartApply(skipLock, worker.ReportProgress); } @@ -67,59 +71,70 @@ namespace BeWoLauncher.View.Frames } else { - Message = "BeWoPlaner wurde erfolgreich installiert!"; - SubMessage = "Starte BeWo..."; - - Thread.Sleep(500); - InstallSuccessful.Invoke(this, new EventArgs()); } } private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) { - Bar2SetLimit(5); + Bar2SetLimit(100); if (e.ProgressPercentage == 0) { + // Download begonnen + Message = "Installation wird vorbereitet..."; SubMessage = "Lade benötigte Pakete herunter..."; + } + else if (e.ProgressPercentage == 10) + { + // Download fertig - Bar2MakeStep(e.ProgressPercentage); + Message = "Download abgeschlossen!"; + SubMessage = ""; + + Bar2SetPercent(30); } else if (e.ProgressPercentage == 1) { + // Installation beginnen + Message = "Installiere Pakete..."; SubMessage = ""; Bar1Activate(); - - Bar2MakeStep(e.ProgressPercentage); } else if (e.ProgressPercentage == 2) { + // Installation Fortschritt + var args = e.UserState as FileEventArgs; SubMessage = $"{args.Name} wurde erfolgreich von {args.AbsolutePath} installiert!"; Bar1MakeStep(); - - Bar2MakeStep(e.ProgressPercentage); } else if (e.ProgressPercentage == 3) { + // Löschen begonnen + Bar1Deactivate(); Message = "Alte Dateien werden entfernt."; SubMessage = ""; - Bar2MakeStep(e.ProgressPercentage); + Bar2SetPercent(75); } else if (e.ProgressPercentage == 4) { + // Löschen Fortschrittt + var args = e.UserState as string; SubMessage = $"{args} wurde entfernt!"; - - Bar2MakeStep(e.ProgressPercentage); + } + else if (e.ProgressPercentage == 5) + { + // Fertig mitm Löschen + Bar2Fill(); } } } diff --git a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml index 60fd59c63..386e8125c 100644 --- a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml +++ b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml @@ -16,25 +16,41 @@ Startmenüverknüpfung erstellen --> - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - + + - - - - + + + + + + + + + + + + + + diff --git a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs index 68480b8da..aa1a9f204 100644 --- a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs @@ -33,9 +33,27 @@ namespace BeWoLauncher.View.Frames BeWoPaths.ActualPlanerLocation = BeWoPaths.GetInstallLocationFromSetting(); - lblErforderlich.Content = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize); - lblcount.Content = $"{DownloadController.Manager.ResponseInfo.NewFileCount} (T:{DownloadController.Manager.ResponseInfo.FileCount})"; - lblVerfuegbar.Content = DownloadController.UpdateDiskSpace(BeWoPaths.ActualPlanerLocation); + var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize).Split(' '); + + lblErforderlich.Content = size[0]; + lblErforderlichSize.Content = size[1]; + + var size2 = DownloadController.UpdateDiskSpace(BeWoPaths.ActualPlanerLocation).Split(' '); + + if(size2.Length > 1) + { + lblVerfuegbar.Content = size2[0]; + lblVerfuegbarSize.Content = size2[1]; + } + else + { + lblVerfuegbar.Content = size2[0] ?? "error#87"; + lblVerfuegbarSize.Content = string.Empty; + } + + lblcountnew.Content = $"{DownloadController.Manager.ResponseInfo.NewFileCount}"; + lblcountalready.Content = $"{DownloadController.Manager.ResponseInfo.FileCount - DownloadController.Manager.ResponseInfo.NewFileCount}"; + lblversion.Content = DownloadController.Manager.ResponseInfo.Version; } diff --git a/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs b/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs index cc3ebf3df..72e0cf355 100644 --- a/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs +++ b/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs @@ -51,10 +51,15 @@ namespace BeWoLauncher.View.Frames Thread.Sleep(1000); DownloadController.Manager.StartDownload(skipLock); - worker.ReportProgress(1); + + worker.ReportProgress(10); Thread.Sleep(1000); + worker.ReportProgress(1); + + Thread.Sleep(500); + DownloadController.Manager.StartApply(skipLock, worker.ReportProgress); } @@ -66,57 +71,71 @@ namespace BeWoLauncher.View.Frames } else { - Message = "BeWoPlaner wurde erfolgreich aktualisiert!"; - SubMessage = "Starte BeWo..."; - - Thread.Sleep(500); - UpdateSuccessful.Invoke(this, new EventArgs()); } } private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) { - Bar2SetLimit(5); + Bar2SetLimit(100); if (e.ProgressPercentage == 0) { + // Download begonnen + Message = "Update wird vorbereitet..."; SubMessage = "Lade benötigte Pakete herunter..."; + } + else if (e.ProgressPercentage == 10) + { + // Download fertig - Bar2MakeStep(e.ProgressPercentage); + Message = "Download abgeschlossen!"; + SubMessage = ""; + + Bar2SetPercent(30); } else if (e.ProgressPercentage == 1) { + // Installation beginnen + Message = "Aktualisiere Pakete..."; SubMessage = ""; Bar1Activate(); - Bar2MakeStep(e.ProgressPercentage); } else if (e.ProgressPercentage == 2) { + // Installation Fortschritt + var args = e.UserState as FileEventArgs; SubMessage = $"{args.Name} wurde erfolgreich von {args.AbsolutePath} installiert!"; Bar1MakeStep(); - Bar2MakeStep(e.ProgressPercentage); } else if (e.ProgressPercentage == 3) { - Bar2Deactivate(); + // Löschen begonnen + + Bar1Deactivate(); Message = "Alte Dateien werden entfernt."; SubMessage = ""; - Bar2MakeStep(e.ProgressPercentage); + Bar2SetPercent(75); } else if (e.ProgressPercentage == 4) { + // Löschen Fortschrittt + var args = e.UserState as string; SubMessage = $"{args} wurde entfernt!"; + } + else if (e.ProgressPercentage == 5) + { + // Fertig mitm Löschen - Bar2MakeStep(e.ProgressPercentage); + Bar2Fill(); } } } diff --git a/Host/Web.config b/Host/Web.config index 83b9553aa..45b154b59 100644 --- a/Host/Web.config +++ b/Host/Web.config @@ -105,7 +105,7 @@ - + diff --git a/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs b/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs index d80da3e6f..000c63f0c 100644 --- a/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs +++ b/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs @@ -24,9 +24,15 @@ namespace BS.SharedLauncher.DataContract [DataMember] public byte[] NewZipData { get; set; } + /// + /// Nur neue Dateien + /// [DataMember] public PlanerPackageInfoDC NewZipInfo { get; set; } + /// + /// Alle Dateien aus der letzten Version + /// [DataMember] public PlanerPackageInfoDC LatestApplicationInfo { get; set; } diff --git a/SharedLauncher/Information/ConnectionInformation.cs b/SharedLauncher/Information/ConnectionInformation.cs index 481ce949b..b1f2ec365 100644 --- a/SharedLauncher/Information/ConnectionInformation.cs +++ b/SharedLauncher/Information/ConnectionInformation.cs @@ -17,6 +17,7 @@ namespace BS.SharedLauncher.Information public string Servername { get; set; } public string CoreServerAddress { get; set; } public string ChatServerAddress { get; set; } + public string Version { get; set; } public static Connection Parse(string input) { @@ -30,6 +31,7 @@ namespace BS.SharedLauncher.Information connection.IpAddress = data[3]; connection.Servername = data[4]; connection.ChatServerAddress = data[5]; + connection.Version = data[6]; return connection; } @@ -53,7 +55,7 @@ namespace BS.SharedLauncher.Information public override string ToString() { return - $"te{Tenant}?un{Username}?pw{Password}?ip{IpAddress}?sn{Servername}?cs{ChatServerAddress}"; + $"te{Tenant}?un{Username}?pw{Password}?ip{IpAddress}?sn{Servername}?cs{ChatServerAddress}?vr{Version}"; } } @@ -114,6 +116,12 @@ namespace BS.SharedLauncher.Information set { Connection.Username = value; } } + public static string Version + { + get { return Connection.Version; } + set { Connection.Version = value; } + } + public static string LauncherServerAddress { get { return Connection.LauncherServerAddress; } diff --git a/SharedLauncher/Logic/FileController.cs b/SharedLauncher/Logic/FileController.cs index daa9ff677..4d9380c79 100644 --- a/SharedLauncher/Logic/FileController.cs +++ b/SharedLauncher/Logic/FileController.cs @@ -106,6 +106,10 @@ namespace BS.SharedLauncher.Logic { File.WriteAllText(path.WithInfoExtension(), XmlConverter.Serialize(t)); } + public static void DeleteInfo(string path) + { + File.Delete(path.WithInfoExtension()); + } public static PlanerPackageInfoDC LoadInfo(string filepath) { filepath = filepath.WithInfoExtension(); @@ -210,6 +214,7 @@ namespace BS.SharedLauncher.Logic { try { + Directory.CreateDirectory(dirPath); using (FileStream fs = File.Create( Path.Combine( dirPath,