From 34b8e42e3c2c3f01c0684476d7a5e70eaee2e4dd Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 14 Dec 2022 12:08:20 +0100 Subject: [PATCH] Testen aufm App5 --- BeWo/BeWoApp.xaml.cs | 26 ++++++-- BeWo/Loader.cs | 5 +- BeWo/MainWindow.xaml.cs | 9 ++- BeWo/ServiceProxy/ServiceFacade.cs | 1 - BeWo/app.config | 6 +- BeWoLauncher/App.config | 2 +- BeWoLauncher/LauncherWindow.xaml | 2 +- BeWoLauncher/LauncherWindow.xaml.cs | 16 +++++ BeWoLauncher/Logic/Behavior/LaunchBehavior.cs | 40 ++++++------- .../Logic/Behavior/ViewSwitchBehavior.cs | 8 +++ .../Logic/Controller/ProcessController.cs | 8 ++- .../Logic/Utils/Download/DownloadManager.cs | 1 + BeWoLauncher/Logic/ViewBuilder.cs | 2 +- BeWoLauncher/View/LoginView.xaml | 2 +- BeWoLauncher/View/LoginView.xaml.cs | 28 +++++---- LauncherHost/Web.config | 2 +- Service/Service.csproj | 1 + Service/ServiceUtils/Paths/ServerFilePaths.cs | 35 +++++------ Service/ServiceUtils/Update/DownloadLogger.cs | 23 ++++++++ .../Update/DownloadPlanerResponseBuilder.cs | 2 +- .../Information/BeWoPathFileConfig.cs | 2 +- .../Information/ConnectionInformation.cs | 59 +++++++++++++------ SharedLauncher/Logic/ZipArchiveBuilder.cs | 19 +++++- 23 files changed, 204 insertions(+), 95 deletions(-) create mode 100644 Service/ServiceUtils/Update/DownloadLogger.cs diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index d686ccb68..b66a7545a 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -540,7 +540,7 @@ namespace BeWo String url = ServerAddress?.ToLower(); #if DEBUG - url = String.Format("http://localhost:3777/Host"); + //url = String.Format("http://localhost:3777/Host"); //return new Uri("https://app4.bewoplaner.de/service"); //url = String.Format("app1.bewoplaner.de/service"); #endif @@ -774,16 +774,32 @@ namespace BeWo { using (StreamReader sr = new StreamReader(pipeClient)) { - string temp = string.Empty; + string temp; + List result = new List(); + var signal = new string[] { "C-137", "C-131"}; - while (!temp.StartsWith("C-137")) + // Warte auf Start + do { temp = sr.ReadLine(); } + while (!temp.StartsWith(signal[0])); - temp = sr.ReadLine(); + result.Add(sr.ReadLine()); + result.Add(sr.ReadLine()); + result.Add(sr.ReadLine()); + result.Add(sr.ReadLine()); + result.Add(sr.ReadLine()); + result.Add(sr.ReadLine()); + result.Add(sr.ReadLine()); - Loader.Load(temp); + do + { + temp = sr.ReadLine(); + } + while (!temp.StartsWith(signal[1])); + + Loader.Load(result.ToArray()); //if (System.Windows.Forms.MessageBox.Show(temp, "(OK to copy)", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) //{ Clipboard.SetText(temp); } diff --git a/BeWo/Loader.cs b/BeWo/Loader.cs index 3f7214307..91b77e4c9 100644 --- a/BeWo/Loader.cs +++ b/BeWo/Loader.cs @@ -28,6 +28,9 @@ namespace BeWo BeWoApp.ShortVersion = version; BeWoApp.Version = "Version " + version; + // var t = MessageBox.Show(BeWoApp.ServerAddress); + // var t1 = MessageBox.Show(BeWoApp.SiteOfOrigin.ToString()); + BeWoApp.LoggedOnUser = ServiceFacade.DoUserServiceSync(s => s.LoadUserByNameAndPassword(BeWoApp.UserName, BeWoApp.UserPassword)); BeWoApp.Mandator = ServiceFacade.DoOperationsServiceSync(s => s.GetMandator()); @@ -37,7 +40,7 @@ namespace BeWo public static void Load(Connection connection) => Load(connection.Username, connection.Password, connection.Servername, connection.Tenant, connection.CoreServerAddress, connection.Version); - public static void Load(string rawInput) + public static void Load(string[] rawInput) => Load(Connection.Parse(rawInput)); } } diff --git a/BeWo/MainWindow.xaml.cs b/BeWo/MainWindow.xaml.cs index acaea0e42..dad6041ef 100644 --- a/BeWo/MainWindow.xaml.cs +++ b/BeWo/MainWindow.xaml.cs @@ -25,7 +25,7 @@ namespace BeWo if (Loader.Loaded) ShowNewWay(); else - ShowOldWay(true); + ShowOldWay(false); } private void ShowNewWay() @@ -47,8 +47,11 @@ namespace BeWo { if (skiplogin) { - Loader.Load("tedemo?undemo?pwdemo?ip?sn1?cs?vr1.0.4.1"); - ShowNewWay(); + throw new NotImplementedException("47845978233134"); + + // Muss hier ggf string anpassen + //Loader.Load("tedemo?undemo?pwdemo?ip?sn1?cs?vr1.0.4.1"); + //ShowNewWay(); } else { diff --git a/BeWo/ServiceProxy/ServiceFacade.cs b/BeWo/ServiceProxy/ServiceFacade.cs index 5abf8c3cc..df28b2d68 100644 --- a/BeWo/ServiceProxy/ServiceFacade.cs +++ b/BeWo/ServiceProxy/ServiceFacade.cs @@ -38,7 +38,6 @@ namespace BeWo.ServiceProxy public static void UpdateServerAddresses(String siteOfOrigin) { - String serverName = siteOfOrigin; var test = serverName.Substring(serverName.Length - 1, 1); if (serverName.Substring(serverName.Length - 1, 1) != "/") diff --git a/BeWo/app.config b/BeWo/app.config index da18d8e34..2bad135a7 100644 --- a/BeWo/app.config +++ b/BeWo/app.config @@ -8,17 +8,17 @@ - + - + - + diff --git a/BeWoLauncher/App.config b/BeWoLauncher/App.config index ddbd19381..bbc6e0aa7 100644 --- a/BeWoLauncher/App.config +++ b/BeWoLauncher/App.config @@ -13,7 +13,7 @@ - + diff --git a/BeWoLauncher/LauncherWindow.xaml b/BeWoLauncher/LauncherWindow.xaml index 1e1ff1339..8f5f7dabf 100644 --- a/BeWoLauncher/LauncherWindow.xaml +++ b/BeWoLauncher/LauncherWindow.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:BeWoLauncher" mc:Ignorable="d" Title="BeWoLauncher" Height="1080" Width="1920" WindowStartupLocation="CenterScreen" WindowState="Maximized" BorderThickness="1" Closing="MainWindow_OnClosing" - Background="{StaticResource LoginBackground}"> + Background="{StaticResource LoginBackground}" KeyDown="Window_KeyDown" KeyUp="Window_KeyUp"> diff --git a/BeWoLauncher/LauncherWindow.xaml.cs b/BeWoLauncher/LauncherWindow.xaml.cs index 302e572b9..2f9c05b6e 100644 --- a/BeWoLauncher/LauncherWindow.xaml.cs +++ b/BeWoLauncher/LauncherWindow.xaml.cs @@ -136,5 +136,21 @@ namespace BeWoLauncher rootGrid.Children.Clear(); rootGrid.Children.Add(main); } + + private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == System.Windows.Input.Key.Delete) + { + ViewController.LaunchBehavior.UninstallMode = true; + } + } + + private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == System.Windows.Input.Key.Delete) + { + ViewController.LaunchBehavior.UninstallMode = false; + } + } } } diff --git a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs index e80e02d32..12ac4cee7 100644 --- a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs @@ -1,19 +1,14 @@ using BeWoLauncher.Logic.Controller; using BeWoLauncher.Logic.Utils; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; using System.Threading.Tasks; -using System.Windows; -using System.Windows.Threading; using static BeWoLauncher.Logic.Controller.ViewController; namespace BeWoLauncher.Logic.Behavior { public class LaunchBehavior { + public bool UninstallMode { get; set; } + public LaunchBehavior() { @@ -46,22 +41,25 @@ namespace BeWoLauncher.Logic.Behavior } else { - Task.Run(() => - { - DownloadController.Start(); - DownloadController.Manager.StartDownloadInfo(); - - if (DownloadController.Manager.ResponseInfo.HasSomethingToDo) + if (UninstallMode) + ViewBehavior.ShowUninstallInfo(); + else + Task.Run(() => { - ViewBehavior.ShowInfo(); - } - else - { - ViewBehavior.ShowLoading(); - } + DownloadController.Start(); + DownloadController.Manager.StartDownloadInfo(); - EndWaiting(); - }); + if (DownloadController.Manager.ResponseInfo.HasSomethingToDo) + { + ViewBehavior.ShowInfo(); + } + else + { + ViewBehavior.ShowLoading(); + } + + EndWaiting(); + }); } } diff --git a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs index 4818a8637..7ea9c4bb6 100644 --- a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs @@ -77,6 +77,14 @@ namespace BeWoLauncher.Logic.Behavior })); } + public void ShowUninstallInfo() + { + ViewController.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => + { + ShowFrame(FrameType.UninstallInfo); + })); + } + public void ShowLoading() { ViewController.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => diff --git a/BeWoLauncher/Logic/Controller/ProcessController.cs b/BeWoLauncher/Logic/Controller/ProcessController.cs index b567b8415..cd8081027 100644 --- a/BeWoLauncher/Logic/Controller/ProcessController.cs +++ b/BeWoLauncher/Logic/Controller/ProcessController.cs @@ -85,8 +85,14 @@ namespace BeWoLauncher.Logic.Controller sw.WriteLine("C-137"); pipeServer.WaitForPipeDrain(); + + foreach (var info in ConnectionInformation.Connection.ToArray()) + { + sw.WriteLine(info); + pipeServer.WaitForPipeDrain(); + } - sw.WriteLine(ConnectionInformation.Connection.ToString()); + sw.WriteLine("C-131"); pipeServer.WaitForPipeDrain(); } } diff --git a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs index e79de62ea..fe683502d 100644 --- a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs +++ b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs @@ -154,6 +154,7 @@ namespace BeWoLauncher.Logic.Utils.Download } private void GetDownloadResponseInfo() { + var t = ConnectionInformation.Tenant; ResponseInfo = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.DownloadInfo(Request)); } } diff --git a/BeWoLauncher/Logic/ViewBuilder.cs b/BeWoLauncher/Logic/ViewBuilder.cs index bcc24457d..7f615f89a 100644 --- a/BeWoLauncher/Logic/ViewBuilder.cs +++ b/BeWoLauncher/Logic/ViewBuilder.cs @@ -129,7 +129,7 @@ namespace BeWoLauncher.Logic { var uninstall = new UninstallInfoFrame(); - uninstall.Accept += ViewBehavior.UpdateStarting; + uninstall.Accept += ViewBehavior.UninstallStarting; uninstall.Abort += ViewBehavior.BackToLogin; return uninstall; diff --git a/BeWoLauncher/View/LoginView.xaml b/BeWoLauncher/View/LoginView.xaml index d531b0366..4566a26ee 100644 --- a/BeWoLauncher/View/LoginView.xaml +++ b/BeWoLauncher/View/LoginView.xaml @@ -18,7 +18,7 @@ - + diff --git a/BeWoLauncher/View/LoginView.xaml.cs b/BeWoLauncher/View/LoginView.xaml.cs index 84bf93ddb..74290d300 100644 --- a/BeWoLauncher/View/LoginView.xaml.cs +++ b/BeWoLauncher/View/LoginView.xaml.cs @@ -37,7 +37,12 @@ namespace BeWoLauncher.View public event EventHandler LoginSuccessful; public event PropertyChangedEventHandler PropertyChanged; - private static String PUB_KEY = "3082010A02820101009CD30CF05AE52E47B7725D3783B3686330EAD735261925E1BDBE35F170922FB7B84B4105ABA99E350858ECB12AC468870BA3E375E4E6F3A76271BA7981601FD7919A9FF3D0786771C8690E9591CFFEE699E9603C48CC7ECA4D7712249D471B5AEBB9EC1E37001C9CAC7BA705EACE4AEBBD41E53698B9CBFD6D3C9668DF232A42900C867467C87FA59AB8526114133F65E98287CBDBFA0E56F68689F3853F9786AFB0DC1AEF6B0D95167DC42BA065B299043675806BAC4AF31B9049782FA2964F2A20252904C674C0D031CD8F31389516BAA833B843F1B11FC3307FA27931133D2D36F8E3FCF2336AB93931C5AFC48D0D1D641633AAFA8429B6D40BC0D87DC3930203010001"; + private static String PUB_KEY_X3 = "3082010A02820101009CD30CF05AE52E47B7725D3783B3686330EAD735261925E1BDBE35F170922FB7B84B4105ABA99E350858ECB12AC468870BA3E375E4E6F3A76271BA7981601FD7919A9FF3D0786771C8690E9591CFFEE699E9603C48CC7ECA4D7712249D471B5AEBB9EC1E37001C9CAC7BA705EACE4AEBBD41E53698B9CBFD6D3C9668DF232A42900C867467C87FA59AB8526114133F65E98287CBDBFA0E56F68689F3853F9786AFB0DC1AEF6B0D95167DC42BA065B299043675806BAC4AF31B9049782FA2964F2A20252904C674C0D031CD8F31389516BAA833B843F1B11FC3307FA27931133D2D36F8E3FCF2336AB93931C5AFC48D0D1D641633AAFA8429B6D40BC0D87DC3930203010001"; + + private static String PUB_KEY_R3 = "3082010A0282010100BB021528CCF6A094D30F12EC8D5592C3F882F199A67A4288A75D26AAB52BB9C54CB1AF8E6BF975C8A3D70F4794145535578C9EA8A23919F5823C42A94E6EF53BC32EDB8DC0B05CF35938E7EDCF69F05A0B1BBEC094242587FA3771B313E71CACE19BEFDBE43B45524596A9C153CE34C852EEB5AEED8FDE6070E2A554ABB66D0E97A540346B2BD3BC66EB66347CFA6B8B8F572999F830175DBA726FFB81C5ADD286583D17C7E709BBF12BF786DCC1DA715DD446E3CCAD25C188BC60677566B3F118F7A25CE653FF3A88B647A5FF1318EA9809773F9D53F9CF01E5F5A6701714AF63A4FF99B3939DDC53A706FE48851DA169AE2575BB13CC5203F5ED51A18BDB150203010001"; + + private static String PUB_KEY_E1 = "04245C2DA22AFD1C4BA65D97732731ACB2A06962EF65E8A6B0F0AC4B9FFF1C0B700FD3982F4DFC0F009B37F074055732972E05EF2A4325A3FB6E342713F64F7E69D302995EEB244792C1249BE6B1218FC12481FC68CC1F69BA58F51922F774C616"; + private readonly Stack _ModalPopUpControls; @@ -55,12 +60,13 @@ namespace BeWoLauncher.View private string GETSERVER_URL = "https://support.bewoplaner.de/api/getserver.php?k={0}&t=1"; private string GETSTATUSMESSAGE_URL = "https://support.bewoplaner.de/api/getstate.php?k={0}&t=1&v={1}"; private string GETNETMESSAGE_URL = "https://support.bewoplaner.de/api/getxmlstate.php?k={0}&t=1"; - + public LoginView() { InitializeComponent(); _ModalPopUpControls = new Stack(); + ViewController.LaunchBehavior.UninstallMode = false; DoTooMuchInitStuffIDontHaveANameForThisMethod(); } @@ -250,6 +256,7 @@ namespace BeWoLauncher.View pwvViewOffen = true; } + private void UIElement_OnKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.P) @@ -260,6 +267,7 @@ namespace BeWoLauncher.View } } } + private void AnimationComplete(object sender, EventArgs e) { double tmp = HeightFrom; @@ -418,7 +426,7 @@ namespace BeWoLauncher.View if (ProfileList.Count > 0) { #if DEBUG - //selectedProfile = ReadSelectedProfile(); + selectedProfile = ReadSelectedProfile(); #else selectedProfile = ReadSelectedProfile(); #endif @@ -493,12 +501,9 @@ namespace BeWoLauncher.View return new ConnectionProfile(pData[0], pData[1], pData[2]); } } - - } } } - } } } @@ -547,21 +552,20 @@ namespace BeWoLauncher.View { try { - if (null == certificate || chain == null) + if (certificate == null || chain == null) return false; - ; + bool chainContainsPk = false; foreach (var element in chain.ChainElements) { String pk = element.Certificate.GetPublicKeyString(); - if (pk == PUB_KEY) + if (pk == PUB_KEY_X3 || pk == PUB_KEY_R3 || pk == PUB_KEY_E1) { chainContainsPk = true; } } - //bool subjectAccepted = Regex.IsMatch(certificate.Subject, @"app[\d]*.bewoplaner.de"); bool subjectAccepted = certificate.Subject.Trim().ToLower().EndsWith(".bewoplaner.de") || certificate.Subject.Trim().ToLower().EndsWith(".ownchat.de"); return chainContainsPk && subjectAccepted; @@ -1150,7 +1154,7 @@ namespace BeWoLauncher.View var t = s.IsUserValid(tempUsername, lPassword, lPIN, "BeWoClient", true); return t; } - catch (Exception) + catch (Exception e) { return UserValidationResult.UnknownError; } @@ -1161,7 +1165,7 @@ namespace BeWoLauncher.View Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate { LoginResult(r, lUserName, lPassword, lPIN); }); }, true); } - catch (Exception) + catch (Exception e) { result = UserValidationResult.UnknownError; } diff --git a/LauncherHost/Web.config b/LauncherHost/Web.config index aeabd639c..82eda0f97 100644 --- a/LauncherHost/Web.config +++ b/LauncherHost/Web.config @@ -94,7 +94,7 @@ - + diff --git a/Service/Service.csproj b/Service/Service.csproj index 474e3e899..4e92203d5 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -477,6 +477,7 @@ + diff --git a/Service/ServiceUtils/Paths/ServerFilePaths.cs b/Service/ServiceUtils/Paths/ServerFilePaths.cs index c418892ab..0cf378a65 100644 --- a/Service/ServiceUtils/Paths/ServerFilePaths.cs +++ b/Service/ServiceUtils/Paths/ServerFilePaths.cs @@ -29,27 +29,11 @@ namespace BeWo.Service.ServiceUtils.Paths private static string _DownloadVersionFilePath; private static string _DownloadFolderPath; + private static string _LogFolderPath; - public static string DownloadVersionFilePath - { - get { - if(_DownloadVersionFilePath is null) - _DownloadVersionFilePath = ConfigurationManager.AppSettings.Get("DownloadVersionFilePath"); - - return _DownloadVersionFilePath; - } - } - - public static string DownloadFolderPath - { - get - { - if (_DownloadFolderPath is null) - _DownloadFolderPath = ConfigurationManager.AppSettings.Get("DownloadFolderPath"); - - return _DownloadFolderPath; - } - } + public static string DownloadVersionFilePath => GetAppSettings(_DownloadVersionFilePath, "DownloadVersionFilePath"); + public static string DownloadFolderPath => GetAppSettings(_DownloadVersionFilePath, "DownloadVersionFilePath"); + public static string LogFolderPath => GetAppSettings(_LogFolderPath, "LogFolderPath"); static ServerFilePaths() { @@ -65,6 +49,15 @@ namespace BeWo.Service.ServiceUtils.Paths public static string GetVersionDefaultFolderPath(string version) => GetVersionTenantFolderPath(version, "default"); public static string GetVersionConfigFilePath() => DownloadVersionFilePath; - //ConfigurationManager.AppSettings.Get("UpdateRootPath"); + + public static string GetLogFolderPath(string tenant) => Path.Combine(LogFolderPath, tenant); + + public static string GetAppSettings(string name, string setting) + { + if (name is null) + name = ConfigurationManager.AppSettings.Get(setting); + + return name; + } } } diff --git a/Service/ServiceUtils/Update/DownloadLogger.cs b/Service/ServiceUtils/Update/DownloadLogger.cs new file mode 100644 index 000000000..8a3e24b7f --- /dev/null +++ b/Service/ServiceUtils/Update/DownloadLogger.cs @@ -0,0 +1,23 @@ +using BeWo.Data; +using BeWo.Service.ServiceUtils.Paths; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Service.ServiceUtils.Update +{ + public static class DownloadLogger + { + //public static string Tenant => MultitenancyOperationContextExt.Current.Tenant; + //public static string Folder => ServerFilePaths.GetLogFolderPath(Tenant); + + //static DownloadLogger() + //{ + // _Started = true; + //} + + //public static string + } +} diff --git a/Service/ServiceUtils/Update/DownloadPlanerResponseBuilder.cs b/Service/ServiceUtils/Update/DownloadPlanerResponseBuilder.cs index 432ddbf3a..2180dce8c 100644 --- a/Service/ServiceUtils/Update/DownloadPlanerResponseBuilder.cs +++ b/Service/ServiceUtils/Update/DownloadPlanerResponseBuilder.cs @@ -109,7 +109,7 @@ namespace BeWo.Service.ServiceUtils.Update if (currentUpdatePackageInfo is object) { - res.NewZipData = ZipArchiveBuilder.CreateZipInMemory(currentUpdatePackageInfo.Files, + res.NewZipData = ZipArchiveBuilder.CreateZipArray(currentUpdatePackageInfo.Files, (file) => file.AbsolutePath, (file) => file.RelativePath); res.NewZipInfo = currentUpdatePackageInfo.ToPlanerPackageInfoDC(); } diff --git a/SharedLauncher/Information/BeWoPathFileConfig.cs b/SharedLauncher/Information/BeWoPathFileConfig.cs index b889a932b..73ecce5c0 100644 --- a/SharedLauncher/Information/BeWoPathFileConfig.cs +++ b/SharedLauncher/Information/BeWoPathFileConfig.cs @@ -15,7 +15,7 @@ namespace BS.SharedLauncher.Information private static readonly string dotbewoinfo = ".bewoinfo"; private static readonly string latestFileName = "latest"; private static readonly string subdir = "BeWoPlaner"; - private static readonly string testForPermission = "bewo.permission"; + private static readonly string testForPermission = "bewo.permission.test"; public static string LockFileName => lockFileName; public static string ZipFormatName => zipName; diff --git a/SharedLauncher/Information/ConnectionInformation.cs b/SharedLauncher/Information/ConnectionInformation.cs index f86f9ce5e..dd019c2da 100644 --- a/SharedLauncher/Information/ConnectionInformation.cs +++ b/SharedLauncher/Information/ConnectionInformation.cs @@ -8,6 +8,8 @@ namespace BS.SharedLauncher.Information { public class Connection { + private const char trennzeichen = '\t'; + public string Tenant { get; set; } public string Username { get; set; } public string Password { get; set; } @@ -23,43 +25,62 @@ namespace BS.SharedLauncher.Information public string ChatServerAddress { get; set; } public string Version { get; set; } - public static Connection Parse(string input) + public static Connection Parse(string[] data) { var connection = new Connection(); - var data = input.Split('?').Select(x => x.Length > 2 ? x.Substring(2) : string.Empty).ToArray(); - connection.Tenant = data[0]; connection.Username = data[1]; connection.Password = data[2]; connection.IpAddress = data[3]; - connection.Servername = data[4]; + connection.CoreServerAddress = data[4]; connection.ChatServerAddress = data[5]; connection.Version = data[6]; return connection; } - public static bool TryParse(string input, out Connection connection) + public string[] ToArray() { - connection = new Connection(); - - try - { - connection = Parse(input); - - return true; - } - catch (Exception) - { - return false; - } + return new string[] { Tenant, Username, Password, IpAddress, "5", ChatServerAddress, Version }; } + //public static bool TryParse(string input, out Connection connection) + //{ + // connection = new Connection(); + + // try + // { + // connection = Parse(input); + + // return true; + // } + // catch (Exception) + // { + // return false; + // } + //} + + //public static bool TryParse(string input, out Connection connection) + //{ + // connection = new Connection(); + + // try + // { + // connection = Parse(input); + + // return true; + // } + // catch (Exception) + // { + // return false; + // } + //} + public override string ToString() { - return - $"te{Tenant}?un{Username}?pw{Password}?ip{IpAddress}?sn{Servername}?cs{ChatServerAddress}?vr{Version}"; + return + $"te{Tenant}{trennzeichen}un{Username}{trennzeichen}pw{Password}{trennzeichen}ip{IpAddress}{trennzeichen}sn{Servername}{trennzeichen}cs{ChatServerAddress}{trennzeichen}vr{Version}"; } } diff --git a/SharedLauncher/Logic/ZipArchiveBuilder.cs b/SharedLauncher/Logic/ZipArchiveBuilder.cs index b5c6f0971..b52f437c1 100644 --- a/SharedLauncher/Logic/ZipArchiveBuilder.cs +++ b/SharedLauncher/Logic/ZipArchiveBuilder.cs @@ -11,8 +11,25 @@ namespace BS.SharedLauncher.Logic { public static class ZipArchiveBuilder { - public static byte[] CreateZipInMemory(List files, Func path, Func zipentryname) + public static MemoryStream CreateZipStream(List files, Func path, Func zipentryname) //(PlanerPackageInfo root) + { + using (var memoryStream = new MemoryStream()) + { + using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) + { + foreach (var file in files) + { + var archiveentry = archive.CreateEntryFromFile(path(file), zipentryname(file)); + } + } + + return memoryStream; + } + } + + public static byte[] CreateZipArray(List files, Func path, Func zipentryname) + //(PlanerPackageInfo root) { byte[] res = null;