From 6497a7ded592f9a94a15fdc2b3d9a8d9782b651f Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Fri, 7 Jun 2024 13:42:25 +0200 Subject: [PATCH] =?UTF-8?q?Working=20now=20-=20more=20logs=20-=20download?= =?UTF-8?q?=20controller=20+=20manager=20=C3=BCberarbeitet=20-=20Retry=20w?= =?UTF-8?q?ird=20besser=20angezeigt=20-=20Formatierungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeWoLauncher/LauncherWindow.xaml.cs | 4 +- .../Logic/Behavior/ViewSwitchBehavior.cs | 8 ++- .../Logic/Controller/DownloadController.cs | 4 +- .../Logic/Controller/ViewController.cs | 2 + .../Logic/Utils/Download/DownloadManager.cs | 55 +++++++++++++------ .../Logic/Utils/LauncherAppdataConfig.cs | 15 +++++ BeWoLauncher/Logic/Utils/LauncherPaths.cs | 2 +- BeWoLauncher/Logic/ViewBuilder.cs | 10 ++-- BeWoLauncher/View/FrameView.xaml | 8 +-- BeWoLauncher/View/FrameView.xaml.cs | 2 +- BeWoLauncher/View/Frames/InfoFrame.xaml | 2 +- .../View/Frames/ProgressFrame.xaml.cs | 30 +++++++--- BeWoLauncher/View/LoginView.xaml | 8 +-- .../DownloadBeWoServiceImp.cs | 11 ++++ .../LauncherServiceImp.cs | 2 +- .../ServiceUtils/Update/UpdateConfigReader.cs | 2 +- .../Update/UpdatePlanResponseBuilder.cs | 2 +- .../Update/UpdateRequestValidator.cs | 8 +-- .../Update/UpdateServerSessionManager.cs | 6 +- .../DataContract/UpdateFileRequest.cs | 11 +++- .../DataContract/UpdateFileResponse.cs | 3 + .../DataContract/UpdatePlanResponse.cs | 5 +- SharedLauncher/LauncherEnums.cs | 1 + SharedLauncher/SharedLauncher.csproj | 1 + .../Update/DownloadRetryEventArgs.cs | 29 ++++++++++ 25 files changed, 171 insertions(+), 60 deletions(-) create mode 100644 SharedLauncher/Update/DownloadRetryEventArgs.cs diff --git a/BeWoLauncher/LauncherWindow.xaml.cs b/BeWoLauncher/LauncherWindow.xaml.cs index da226357f..ca8805151 100644 --- a/BeWoLauncher/LauncherWindow.xaml.cs +++ b/BeWoLauncher/LauncherWindow.xaml.cs @@ -103,7 +103,7 @@ namespace BeWoLauncher } public void StartWaiting() { - Dispatcher.BeginInvoke(DispatcherPriority.Normal, + Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)delegate { if (_WaitLayer == null) @@ -120,7 +120,7 @@ namespace BeWoLauncher public void EndWaiting() { Dispatcher.BeginInvoke( - DispatcherPriority.Normal, + DispatcherPriority.Render, (Action)delegate { if (_WaitLayer != null) diff --git a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs index e1f2a2660..708018f60 100644 --- a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs @@ -57,7 +57,9 @@ namespace BeWoLauncher.Logic.Behavior public void ShowView(ViewType vt) { - CurrentView = ViewController.ViewBuilder.GetNewView(vt); + var view = ViewController.ViewBuilder.GetNewView(vt); + + CurrentView = view; } public void ShowFrame(FrameType ft) { @@ -129,6 +131,8 @@ namespace BeWoLauncher.Logic.Behavior public void BackToLogin(object sender, EventArgs e) { + StartWaiting(); + ShowView(ViewType.LoginView); } public void LoginSuccessful(object sender, EventArgs e) @@ -174,6 +178,7 @@ namespace BeWoLauncher.Logic.Behavior } public void UpdateSuccess(object sender, EventArgs e) { + LauncherAppdataConfig.SetFirstInstallationSuccess(true); ShowFrame(FrameType.LoadingScreen); } @@ -183,6 +188,7 @@ namespace BeWoLauncher.Logic.Behavior } public void UninstallSuccess(object sender, EventArgs e) { + LauncherAppdataConfig.Reset(); ShowFrame(FrameType.UninstallSuccessful); } } diff --git a/BeWoLauncher/Logic/Controller/DownloadController.cs b/BeWoLauncher/Logic/Controller/DownloadController.cs index 7024b29f8..c2cf66fc5 100644 --- a/BeWoLauncher/Logic/Controller/DownloadController.cs +++ b/BeWoLauncher/Logic/Controller/DownloadController.cs @@ -100,7 +100,7 @@ namespace BeWoLauncher.Logic.Controller GenericTextLogger.Post($"Anfrage wurde erfolgreich verarbeitet. Server gibt Version {client_version} vor."); - if (!response.HasToDo()) + if (!response.HasToDo) can_quick_start = true; return null; @@ -118,6 +118,8 @@ namespace BeWoLauncher.Logic.Controller public static string TryLoadUninstallPlan() { + GenericTextLogger.PostImportantInfo("Starting Uninstall Process"); + try { Manager.GetDeletePlan(); diff --git a/BeWoLauncher/Logic/Controller/ViewController.cs b/BeWoLauncher/Logic/Controller/ViewController.cs index af1e21ff9..efcf4f089 100644 --- a/BeWoLauncher/Logic/Controller/ViewController.cs +++ b/BeWoLauncher/Logic/Controller/ViewController.cs @@ -56,6 +56,8 @@ namespace BeWoLauncher.Logic.Controller ViewBuilder = new ViewBuilder(); } + public static string GetErrorString() => ErrorString ?? Error?.ToString() ?? "unbekannt"; + public static void InitWindow(LauncherWindow window) { if (CurrentWindow is null) diff --git a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs index 34cef8fb6..afc06dbf1 100644 --- a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs +++ b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs @@ -119,24 +119,28 @@ namespace BeWoLauncher.Logic.Utils.Download private void Download() { + var tries_per_file = UpdatePlanResponse.TriesPerFile; + DownloadFolder.CreateFolder(); DownloadFolder.Lock(SkipLock); DownloadFolder.SaveCurrentInfo("current"); - UpdateFileRequest req = new UpdateFileRequest(UpdatePlanResponse.CurrentPackage.Version); + UpdateFileRequest req = new UpdateFileRequest(UpdatePlanResponse); - req.Login = new LoginDC() - { - Username = SessionInformation.Login.Username, - Password = SessionInformation.Login.Password, - CoreServerAddress = SessionInformation.Connection.CoreServerAddress, - Pin = SessionInformation.Login.Pin, - ClientID = SessionInformation.Login.ClientId, - CheckTenant = true, - TempUsername = SessionInformation.Login.TempUsername, - }; + req.SessionId = UpdatePlanResponse.SessionId; + + //req.Login = new LoginDC() + //{ + // Username = SessionInformation.Login.Username, + // Password = SessionInformation.Login.Password, + // CoreServerAddress = SessionInformation.Connection.CoreServerAddress, + // Pin = SessionInformation.Login.Pin, + // ClientID = SessionInformation.Login.ClientId, + // CheckTenant = true, + // TempUsername = SessionInformation.Login.TempUsername, + //}; foreach (var file2request in UpdatePlanResponse.FilesToRequest) { @@ -144,12 +148,16 @@ namespace BeWoLauncher.Logic.Utils.Download UpdateFileResponse response = null; - for (int i = 0; i < 5; i++) + for (int i = 1; i <= tries_per_file; i++) { response = AskForFile(req); if (response is object) break; + + Feedback((int)LauncherProgress.DownloadRetry, new DownloadRetryEventArgs(i + 1, tries_per_file, file2request)); + + Thread.Sleep(500); } if (response is null) @@ -157,14 +165,21 @@ namespace BeWoLauncher.Logic.Utils.Download throw new UpdateException($"file: {file2request.RelativePath} - response null"); } - var download_path = DownloadFolder.Combine(file2request.RelativePath); + if (response.Successful) + { + var download_path = DownloadFolder.Combine(file2request.RelativePath); - Path.GetDirectoryName(download_path).CreateFolder(); - download_path.SaveFile(response.FileData); + Path.GetDirectoryName(download_path).CreateFolder(); + download_path.SaveFile(response.FileData); - var size = NonspecificTools.SizeSuffix((ulong)response.FileData.Length); + var size = NonspecificTools.SizeSuffix((ulong)response.FileData.Length); - Feedback((int)LauncherProgress.DownloadUpdate, new DownloadProgressEventArgs(size, file2request)); + Feedback((int)LauncherProgress.DownloadUpdate, new DownloadProgressEventArgs(size, file2request)); + } + else + { + throw new HideClientUpdateException(response.Error); + } } DownloadFolder.Unlock(SkipLock); @@ -246,7 +261,11 @@ namespace BeWoLauncher.Logic.Utils.Download private UpdateFileResponse AskForFile(UpdateFileRequest request) { - return LauncherServiceFacade.DoDownloadBeWoServiceSyncWithException(x => x.GetUpdateFile(request)); + UpdateFileResponse response; + + response = LauncherServiceFacade.DoDownloadBeWoServiceSyncWithException(x => x.GetUpdateFile(request)); + + return response; } private void GetUpdatePlanResponse() diff --git a/BeWoLauncher/Logic/Utils/LauncherAppdataConfig.cs b/BeWoLauncher/Logic/Utils/LauncherAppdataConfig.cs index d91363dc5..a3768bf3d 100644 --- a/BeWoLauncher/Logic/Utils/LauncherAppdataConfig.cs +++ b/BeWoLauncher/Logic/Utils/LauncherAppdataConfig.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Configuration; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,6 +11,7 @@ namespace BeWoLauncher.Logic.Utils public static class LauncherAppdataConfig { private static string _Location; + private static string _Folder; public static string Location { @@ -17,6 +19,12 @@ namespace BeWoLauncher.Logic.Utils set { _Location = value; } } + public static string Folder + { + get => _Folder ?? (_Folder = Directory.GetParent(Location).FullName); + set { _Folder = value; } + } + public static string GetPlanerLocation() { @@ -65,5 +73,12 @@ namespace BeWoLauncher.Logic.Utils return e.Filename; } } + + public static void Reset() + { + SetFirstInstallationSuccess(false); + SetInstallLocationSetSuccess(false); + SetPlanerLocation(null); + } } } diff --git a/BeWoLauncher/Logic/Utils/LauncherPaths.cs b/BeWoLauncher/Logic/Utils/LauncherPaths.cs index c33c35692..ea0ace528 100644 --- a/BeWoLauncher/Logic/Utils/LauncherPaths.cs +++ b/BeWoLauncher/Logic/Utils/LauncherPaths.cs @@ -83,7 +83,7 @@ namespace BeWoLauncher.Logic.Utils } public static string GetLoggerPath() { - return Path.Combine(new string[] { LauncherAppdataConfig.Location, "log", "update" }); + return Path.Combine(new string[] { LauncherAppdataConfig.Folder, "log", "update" }); } public static string GetDownloadPath() { diff --git a/BeWoLauncher/Logic/ViewBuilder.cs b/BeWoLauncher/Logic/ViewBuilder.cs index 9fc0d7257..57a1c0c44 100644 --- a/BeWoLauncher/Logic/ViewBuilder.cs +++ b/BeWoLauncher/Logic/ViewBuilder.cs @@ -63,7 +63,7 @@ namespace BeWoLauncher.Logic throw new NotImplementedException("ViewBuilder: Frame nicht implementiert"); } - private UserControl getLoginView() + private LoginView getLoginView() { var login = new LoginView(); @@ -113,7 +113,7 @@ namespace BeWoLauncher.Logic var uninstallFailed = new InfoFrame(); uninstallFailed.Title = "Deinstallation fehlgeschlagen!"; - uninstallFailed.Text = Error.ToString(); + uninstallFailed.Text = GetErrorString(); uninstallFailed.Button1Click += ViewBehavior.BackToLogin; @@ -145,7 +145,7 @@ namespace BeWoLauncher.Logic var updateError = new InfoFrame(); updateError.Title = "Update fehlgeschlagen!"; - updateError.Text = Error.ToString(); + updateError.Text = GetErrorString(); updateError.Button1Click += ViewBehavior.BackToLogin; @@ -177,7 +177,7 @@ namespace BeWoLauncher.Logic var installError = new InfoFrame(); installError.Title = "Installation fehlgeschlagen!"; - installError.Text = Error.ToString(); + installError.Text = GetErrorString(); installError.Button1Click += ViewBehavior.BackToLogin; @@ -189,7 +189,7 @@ namespace BeWoLauncher.Logic var genError = new InfoFrame(); genError.Title = "Loader fehlgeschlagen!"; - genError.Text = ErrorString ?? Error.ToString(); + genError.Text = GetErrorString(); genError.Button1Click += ViewBehavior.BackToLogin; diff --git a/BeWoLauncher/View/FrameView.xaml b/BeWoLauncher/View/FrameView.xaml index 98c31b4a3..7ef83abc9 100644 --- a/BeWoLauncher/View/FrameView.xaml +++ b/BeWoLauncher/View/FrameView.xaml @@ -35,7 +35,7 @@ - +