diff --git a/BeWoLauncher/App.config b/BeWoLauncher/App.config index eb846d046..ba86e0a93 100644 --- a/BeWoLauncher/App.config +++ b/BeWoLauncher/App.config @@ -13,19 +13,18 @@ - + - + - diff --git a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs index abc63b3a1..9071ad49e 100644 --- a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs @@ -28,7 +28,7 @@ namespace BeWoLauncher.Logic.Behavior // dlg.ShowDialog(); //} #else - if (ConnectionInformation.Tenant == "demo") + if (SessionInformation.Login.Tenant == "demo") { var dlg = new ConfirmDemoDialog(); dlg.ShowDialog(); @@ -38,7 +38,7 @@ namespace BeWoLauncher.Logic.Behavior LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting(); - if (LauncherPaths.ActualPlanerLocation is object && !CheckForPermissions(LauncherPaths.ActualPlanerLocation)) + if (!string.IsNullOrWhiteSpace(LauncherPaths.ActualPlanerLocation) && !CheckForPermissions(LauncherPaths.ActualPlanerLocation)) { ViewBehavior.ShowFrame(FrameType.NoPermissionInfo); EndWaiting(); @@ -52,7 +52,7 @@ namespace BeWoLauncher.Logic.Behavior } else { - Task.Run(() => DownloadController.StartDownload(EndWaiting)); + Task.Run(() => DownloadController.GetCurrentUpdateplan(EndWaiting)); } } } diff --git a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs index d2b5adbc4..2e9d3d8d6 100644 --- a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs @@ -131,6 +131,7 @@ namespace BeWoLauncher.Logic.Behavior if (CheckForPermissions(install.InstallLocation)) { + DownloadController.InitLogger(); LauncherPaths.SetAndSaveInstallLocation(install.InstallLocation); LauncherAppdataConfig.SetFirstInstallationSuccess(true); ShowFrame(FrameType.InstallProgress); diff --git a/BeWoLauncher/Logic/Controller/DownloadController.cs b/BeWoLauncher/Logic/Controller/DownloadController.cs index f51ea7d84..bddf17f85 100644 --- a/BeWoLauncher/Logic/Controller/DownloadController.cs +++ b/BeWoLauncher/Logic/Controller/DownloadController.cs @@ -5,6 +5,7 @@ using BS.SharedLauncher.Information; using BS.SharedLauncher.Utils; using System; using System.IO; +using System.Windows; namespace BeWoLauncher.Logic.Controller { @@ -16,11 +17,16 @@ namespace BeWoLauncher.Logic.Controller public static long NeededSpace => Manager.UpdatePlanResponse.DownloadSize; static DownloadController() + { + + } + + public static void InitLogger() { GenericTextLogger.Init(LauncherPaths.GetLoggerPath()); } - public static void StartDownload(Action endWaiting = null) + public static void GetCurrentUpdateplan(Action endWaiting = null) { bool not_called = true; @@ -28,6 +34,9 @@ namespace BeWoLauncher.Logic.Controller { Manager = new DownloadManager(); + if (LauncherAppdataConfig.GetFirstInstallationSuccess()) + InitLogger(); + GenericTextLogger.PostImportantInfo("Starting Download Process"); Manager.GetUpdatePlan(); @@ -79,6 +88,7 @@ namespace BeWoLauncher.Logic.Controller public static string UpdateDiskSpace(string path) { FileInfo f = new FileInfo(path); + string drive = System.IO.Path.GetPathRoot(f.FullName); FreeSpace = NonspecificTools.GetTotalFreeSpace(drive); diff --git a/BeWoLauncher/Logic/Controller/ProcessController.cs b/BeWoLauncher/Logic/Controller/ProcessController.cs index 369c1fec4..63f7c356f 100644 --- a/BeWoLauncher/Logic/Controller/ProcessController.cs +++ b/BeWoLauncher/Logic/Controller/ProcessController.cs @@ -20,6 +20,11 @@ namespace BeWoLauncher.Logic.Controller public static bool Running { get; set; } + static ProcessController() + { + Running = true; + } + internal static void CheckForOtherInstance() { string procName = Process.GetCurrentProcess().ProcessName; @@ -69,8 +74,8 @@ namespace BeWoLauncher.Logic.Controller } else { - string message = "Möchten Sie es schließen? Dadurch können nicht gespeicherte Daten verloren gehen."; - string caption = "BeWo Anwendung läuft bereits. "; + string message = "BeWoPlaner Anwendung läuft bereits."; + string caption = "Kann BeWoLauncher nicht starten"; MessageBox.Show(message, caption); @@ -83,8 +88,6 @@ namespace BeWoLauncher.Logic.Controller CheckForOtherInstance(); LauncherServiceFacade.UpdateServerAddresses(); - - Running = true; } internal static void StartLauncherShutdown() diff --git a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs index c23e2c852..dc84340c5 100644 --- a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs @@ -46,7 +46,8 @@ namespace BeWoLauncher.View.Frames { txtLoc.Text = value; - var size2 = DownloadController.UpdateDiskSpace(LauncherPaths.ActualPlanerLocation).Split(' '); + // Login Selection - Aktueller Login Ort in Auswahl + var size2 = DownloadController.UpdateDiskSpace(LauncherPaths.LoginSelectionPlanerLocation).Split(' '); if (size2.Length > 1) { diff --git a/BeWoLauncher/View/LoginView.xaml.cs b/BeWoLauncher/View/LoginView.xaml.cs index 293cf130c..b605f386b 100644 --- a/BeWoLauncher/View/LoginView.xaml.cs +++ b/BeWoLauncher/View/LoginView.xaml.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; +using System.Deployment.Application; using System.IO; using System.Linq; using System.Net; @@ -372,7 +373,7 @@ namespace BeWoLauncher.View ConnectionProfile p = GenerateProfileFromUri(ApplicationDeployment.CurrentDeployment.ActivationUri); if (!String.IsNullOrEmpty(p.Tenant) && !String.IsNullOrEmpty(p.Server)) { - ConnectionInformation.Tenant = p.Tenant; + SessionInformation.Login.Tenant = p.Tenant; if (ProfileList.Count > 0) { diff --git a/DownloadServer/Web.config b/DownloadServer/Web.config index d3e70b22f..5e8b4e961 100644 --- a/DownloadServer/Web.config +++ b/DownloadServer/Web.config @@ -43,25 +43,13 @@ - + - - - - - - - - - - - - @@ -82,7 +70,7 @@ - + diff --git a/Host/Host.csproj.user b/Host/Host.csproj.user index a0002e9f5..769cd8b25 100644 --- a/Host/Host.csproj.user +++ b/Host/Host.csproj.user @@ -3,7 +3,7 @@ BeWo2.0 true - Debug|Any CPU + Release|Any CPU false diff --git a/Service/ServiceContracts/IDownloadBeWoService.cs b/Service/ServiceContracts/IDownloadBeWoService.cs index dfc66d896..f65e68ff0 100644 --- a/Service/ServiceContracts/IDownloadBeWoService.cs +++ b/Service/ServiceContracts/IDownloadBeWoService.cs @@ -17,5 +17,9 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] UpdateFileResponse GetUpdateFile(UpdateFileRequest request); + + //[FaultContract(typeof(BeWoFault))] + //[OperationContract] + //UpdateFileResponse GetUpdateFileStream(UpdateFileRequest request); } } \ No newline at end of file diff --git a/Service/ServiceImplementations/DownloadBeWoServiceImp.cs b/Service/ServiceImplementations/DownloadBeWoServiceImp.cs index d141cfa69..78ce49bd1 100644 --- a/Service/ServiceImplementations/DownloadBeWoServiceImp.cs +++ b/Service/ServiceImplementations/DownloadBeWoServiceImp.cs @@ -42,7 +42,7 @@ namespace BeWo.Service.ServiceImplementations GenericTextLogger.Post("Plan Request erfolreich validiert. Verifiziere Login."); - VerifyLogin(request); + VerifyLogin(request.Login); GenericTextLogger.Post("Login verifiziert. Baue Antwort."); @@ -110,22 +110,18 @@ namespace BeWo.Service.ServiceImplementations return true; } - private void VerifyLogin(UpdatePlanRequest request) => VerifyLogin(request.Login); private void VerifyLogin(LoginDC login) => VerifyLogin(login.Username, login.Password, Tenant, login.Pin, login.ClientID); private void VerifyLogin(string username, string password, string tenant, string pin, string clientid) { - if (!TryVerifyLogin(username, password, tenant, pin, clientid)) - throw new UpdateException("Kann Anmeldung nicht bestätigen"); - } - private bool TryVerifyLogin(string username, string password, string tenant, string pin, string clientid) - { + string server_address = string.Empty; + try { SessionInformation.Login.Username = username; SessionInformation.Login.Password = password; SessionInformation.Login.Tenant = tenant; - var server_address = GetServerFromTenant(); + server_address = GetServerFromTenant(); #if DEBUG server_address = "http://localhost:3777/Host"; @@ -135,14 +131,12 @@ namespace BeWo.Service.ServiceImplementations var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(username, password, pin, clientid, true)); - if (result == BS.SharedLauncher.Enums.UserValidationResult.UserValid) - return true; - - return false; + if (result != BS.SharedLauncher.Enums.UserValidationResult.UserValid) + throw new HideClientUpdateException("Kann Anmeldung nicht bestätigen!"); } catch (Exception e) { - return false; + throw new HideClientUpdateException("Kann Anmeldung nicht bestätigen! ", e); } } @@ -218,6 +212,9 @@ namespace BeWo.Service.ServiceImplementations if (tenant is null) tenant = SessionInformation.Login.Tenant; + if (tenant == "demo") + return null; + try { @@ -229,12 +226,12 @@ namespace BeWo.Service.ServiceImplementations String server = System.Text.Encoding.ASCII.GetString(response); - return server; + return $"https://{server}/service"; } } catch (Exception ex) { - return null; + throw new HideClientUpdateException("Login konnte nicht verifiziert werden.", ex); } } } diff --git a/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs b/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs index ba114d00e..9ad7890f6 100644 --- a/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs +++ b/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs @@ -33,9 +33,15 @@ namespace BeWo.Service.ServiceUtils.Update private static void calculate() { - var path = Path.Combine(getSourceFolderPath(), _Request.UpdateFile.RelativePath); + var relative_path = _Request.UpdateFile.RelativePath; + var path = Path.Combine(getSourceFolderPath(), relative_path); - _Response.FileData = File.ReadAllBytes(path); + var file_data = File.ReadAllBytes(path); + + if (file_data.Length > 512 * 1024 * 1024 - 1) + throw new HideClientUpdateException($"Die angefragte File \"{relative_path}\" überschreitet die maximale Größe von 512 MB."); + + _Response.FileData = file_data; } private static string getSourceFolderPath() @@ -64,7 +70,7 @@ namespace BeWo.Service.ServiceUtils.Update } // User bekommt eigene Daten Feature - throw new NotImplementedException("#479839129"); + throw new HideClientUpdateException("#479839129"); } } } diff --git a/SharedLauncher/Information/GenericTextLogger.cs b/SharedLauncher/Information/GenericTextLogger.cs index 4abd793ee..9ba5ec0a8 100644 --- a/SharedLauncher/Information/GenericTextLogger.cs +++ b/SharedLauncher/Information/GenericTextLogger.cs @@ -10,17 +10,17 @@ namespace BS.SharedLauncher.Information { public static class GenericTextLogger { - private static bool _started; - private static string _LogFileName; private static string _LogFilePath; private static string _Session; static GenericTextLogger() { - _started = false; + Started = false; } + public static bool Started { get; set; } + public static void Init(string folder) { _LogFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; @@ -30,18 +30,19 @@ namespace BS.SharedLauncher.Information _Session = new Random().Next(1, 10000).ToString("0000"); - _started = true; + Started = true; PostWithout(""); } public static void PostWithout(string str) { - File.AppendAllText(_LogFilePath, str + "\n"); + if(Started) + File.AppendAllText(_LogFilePath, str + "\n"); } public static void Post(string message) { - if (!_started) + if (!Started) return; var log = $"[#{_Session} {DateTime.Now.ToString("HH:mm:ss")}]: {message}"; diff --git a/SharedLauncher/Logic/FileController.cs b/SharedLauncher/Logic/FileController.cs index 6e9611ac7..9d41f3d3f 100644 --- a/SharedLauncher/Logic/FileController.cs +++ b/SharedLauncher/Logic/FileController.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows; namespace BS.SharedLauncher.Logic { @@ -174,7 +175,7 @@ namespace BS.SharedLauncher.Logic { } return true; } - catch + catch (Exception e) { if (throwIfFails) throw;