diff --git a/.gitignore b/.gitignore index 02cfcaa3e..dc85c3122 100644 --- a/.gitignore +++ b/.gitignore @@ -570,4 +570,10 @@ obj /SharedLauncher/bin /SharedLauncher/obj /BeWoLauncher/bin -/BeWoLauncher/obj \ No newline at end of file +/BeWoLauncher/obj +/UnitTests/bin +/UnitTests/obj +/DownloadServer/bin +/DownloadServer/obj +/BeWoTest/bin +/BeWoTest/obj diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index b66a7545a..2ff6ce89b 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -10,6 +10,7 @@ using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; +using BS.SharedLauncher.Information; using ChatController.HauptKlassen; using DevExpress.Xpf.Core; using DevExpress.Xpf.Grid; @@ -537,39 +538,7 @@ namespace BeWo { get { - String url = ServerAddress?.ToLower(); - -#if DEBUG - //url = String.Format("http://localhost:3777/Host"); - //return new Uri("https://app4.bewoplaner.de/service"); - //url = String.Format("app1.bewoplaner.de/service"); -#endif - - if (url.IndexOf("localhost") < 0) - { - int i; - - - if (Int32.TryParse(url, out i)) - url = "app" + url; - - if (url.IndexOf('.') < 0) - { - url += ".bewoplaner.de"; - } - - //if (url.IndexOf("/service45") < 0) - //{ - // url += "/service45"; - //} - if (url.IndexOf("/service") < 0) - { - url += "/service"; - } - - return new Uri(String.Format("https://{0}", url)); - } - return new Uri(url); + return new Uri(SessionInformation.Connection.CoreServerAddressExact); } } @@ -764,52 +733,11 @@ namespace BeWo FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); var args = e.Args; - - //args = new string[] { "tedemo?undemo?pwdemo?ip?sn1?cs" }; - try + + if (args.Length > 0) { - if (args.Length > 0) - { - using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0])) - { - using (StreamReader sr = new StreamReader(pipeClient)) - { - string temp; - List result = new List(); - var signal = new string[] { "C-137", "C-131"}; - - // Warte auf Start - do - { - temp = sr.ReadLine(); - } - while (!temp.StartsWith(signal[0])); - - 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()); - - 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); } - } - } - } - } - catch (Exception ex) - { - MessageBox.Show(ex.ToString()); + SessionInformation.LoadPipe(args[0]); + Loader.Load(); } } @@ -1109,7 +1037,7 @@ namespace BeWo tenant = "5473568546"; #endif - var login = new Login(tenant, serverUrl => + var login = new ChatController.HauptKlassen.Login(tenant, serverUrl => { if (!string.IsNullOrWhiteSpace(serverUrl)) { diff --git a/BeWo/Loader.cs b/BeWo/Loader.cs index 91b77e4c9..f7a707c69 100644 --- a/BeWo/Loader.cs +++ b/BeWo/Loader.cs @@ -2,9 +2,9 @@ using BS.SharedLauncher.Information; using System; using System.Collections.Generic; +using System.IO; +using System.IO.Pipes; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; namespace BeWo @@ -17,30 +17,21 @@ namespace BeWo { Loaded = false; } - - public static void Load(string username, string password, string servername, string tenant, string coreserveraddress, string version) + + public static void Load() { - BeWoApp.UserName = username; - BeWoApp.UserPassword = password; - BeWoApp.ServerName = servername; - BeWoApp.Tenant = tenant; - BeWoApp.ServerAddress = coreserveraddress; - BeWoApp.ShortVersion = version; - BeWoApp.Version = "Version " + version; - - // var t = MessageBox.Show(BeWoApp.ServerAddress); - // var t1 = MessageBox.Show(BeWoApp.SiteOfOrigin.ToString()); + BeWoApp.UserName = SessionInformation.Login.Username; + BeWoApp.UserPassword = SessionInformation.Login.Password; + BeWoApp.ServerName = SessionInformation.Connection.Servername; + BeWoApp.Tenant = SessionInformation.Login.Tenant; + BeWoApp.ServerAddress = SessionInformation.Connection.CoreServerAddress; + BeWoApp.ShortVersion = SessionInformation.Session.Version; + BeWoApp.Version = "Version " + SessionInformation.Session.Version; BeWoApp.LoggedOnUser = ServiceFacade.DoUserServiceSync(s => s.LoadUserByNameAndPassword(BeWoApp.UserName, BeWoApp.UserPassword)); BeWoApp.Mandator = ServiceFacade.DoOperationsServiceSync(s => s.GetMandator()); Loaded = true; } - - 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) - => Load(Connection.Parse(rawInput)); } } diff --git a/BeWo/MainWindow.xaml.cs b/BeWo/MainWindow.xaml.cs index dad6041ef..83ca3a7ba 100644 --- a/BeWo/MainWindow.xaml.cs +++ b/BeWo/MainWindow.xaml.cs @@ -25,7 +25,8 @@ namespace BeWo if (Loader.Loaded) ShowNewWay(); else - ShowOldWay(false); + // ShowOldWay(false); + throw new Exception("Loader failed"); } private void ShowNewWay() diff --git a/BeWoLauncher/App.config b/BeWoLauncher/App.config index bbc6e0aa7..ddbd19381 100644 --- a/BeWoLauncher/App.config +++ b/BeWoLauncher/App.config @@ -13,7 +13,7 @@ - + diff --git a/BeWoLauncher/BeWoLauncher.csproj b/BeWoLauncher/BeWoLauncher.csproj index fbfaf7511..ae35b12a9 100644 --- a/BeWoLauncher/BeWoLauncher.csproj +++ b/BeWoLauncher/BeWoLauncher.csproj @@ -145,11 +145,8 @@ LoadingFrame.xaml - - - - - GenericProgressFrame.xaml + + ProgressFrame.xaml FrameView.xaml @@ -217,7 +214,7 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer @@ -311,7 +308,6 @@ ResXFileCodeGenerator Resources.Designer.cs - SettingsSingleFileGenerator diff --git a/BeWoLauncher/BeWoLauncher_TemporaryKey.pfx b/BeWoLauncher/BeWoLauncher_TemporaryKey.pfx deleted file mode 100644 index 5a575a88e..000000000 Binary files a/BeWoLauncher/BeWoLauncher_TemporaryKey.pfx and /dev/null differ diff --git a/BeWoLauncher/LauncherApp.xaml.cs b/BeWoLauncher/LauncherApp.xaml.cs index 034822460..37515ed1d 100644 --- a/BeWoLauncher/LauncherApp.xaml.cs +++ b/BeWoLauncher/LauncherApp.xaml.cs @@ -48,11 +48,7 @@ namespace BeWoLauncher base.OnStartup(e); - ProcessController.CheckForOtherInstance(); - - // Update Server Adresses - ConnectionInformation.LauncherServerAddress = ConnectionInformation.LauncherServerAddressOrigin.ToString(); - LauncherServiceFacade.UpdateServerAddresses(ConnectionInformation.LauncherServerAddress); + ProcessController.StartLauncher(); Dispatcher.UnhandledException += (s, ex) => diff --git a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs index e4849e8c3..63d4eea1c 100644 --- a/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/LaunchBehavior.cs @@ -1,6 +1,7 @@ using BeWoLauncher.Components; using BeWoLauncher.Logic.Controller; using BeWoLauncher.Logic.Utils; +using BS.SharedLauncher.Extensions; using BS.SharedLauncher.Information; using System; using System.Threading.Tasks; @@ -52,9 +53,9 @@ namespace BeWoLauncher.Logic.Behavior try { DownloadController.Start(); - DownloadController.Manager.StartDownloadInfo(); + DownloadController.Manager.GetUpdatePlan(); - if (DownloadController.Manager.ResponseInfo.HasSomethingToDo) + if (DownloadController.Manager.UpdatePlanResponse.HasToDo()) { ViewBehavior.ShowInfo(); } diff --git a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs index cf589467b..4904ee431 100644 --- a/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs +++ b/BeWoLauncher/Logic/Behavior/ViewSwitchBehavior.cs @@ -2,6 +2,7 @@ using BeWoLauncher.Logic.Utils; using BeWoLauncher.View; using BeWoLauncher.View.Frames; +using BS.SharedLauncher.Enums; using System; using System.IO; using System.Threading.Tasks; @@ -15,6 +16,7 @@ namespace BeWoLauncher.Logic.Behavior { private UserControl _currentView; private FrameBase _currentFrame; + private LauncherMode _currentLauncherMode; private UserControl CurrentView { @@ -32,7 +34,8 @@ namespace BeWoLauncher.Logic.Behavior } private FrameBase CurrentFrame { - get => _currentFrame; set + get => _currentFrame; + set { _currentFrame = value; @@ -131,11 +134,18 @@ namespace BeWoLauncher.Logic.Behavior LauncherAppdataConfig.SetFirstInstallationSuccess(true); ShowFrame(FrameType.LoadingScreen); } - public void InstallationFailed(Exception exception) + public void InstallFailed(object sender, EventArgs e) { - Error = exception; ShowFrame(FrameType.InstallFailed); } + public void UpdateFailed(object sender, EventArgs e) + { + ShowFrame(FrameType.UpdateFailed); + } + public void UninstallFailed(object sender, EventArgs e) + { + ShowFrame(FrameType.UninstallFailed); + } public void UpdateStarting(object sender, EventArgs e) { @@ -145,11 +155,6 @@ namespace BeWoLauncher.Logic.Behavior { ShowFrame(FrameType.LoadingScreen); } - public void UpdateFailed(Exception exception) - { - Error = exception; - ShowFrame(FrameType.UpdateFailed); - } public void UninstallStarting(object sender, EventArgs e) { @@ -159,10 +164,5 @@ namespace BeWoLauncher.Logic.Behavior { ShowFrame(FrameType.UninstallSuccessful); } - public void UninstallFailed(Exception exception) - { - Error = exception; - ShowFrame(FrameType.UninstallFailed); - } } } diff --git a/BeWoLauncher/Logic/Controller/DownloadController.cs b/BeWoLauncher/Logic/Controller/DownloadController.cs index 139b0fa85..6ff041aeb 100644 --- a/BeWoLauncher/Logic/Controller/DownloadController.cs +++ b/BeWoLauncher/Logic/Controller/DownloadController.cs @@ -1,4 +1,6 @@ -using BeWoLauncher.Logic.Utils.Download; +using BeWoLauncher.Logic.Utils; +using BeWoLauncher.Logic.Utils.Download; +using BS.SharedLauncher.Information; using BS.SharedLauncher.Utils; using System.IO; @@ -9,11 +11,13 @@ namespace BeWoLauncher.Logic.Controller public static DownloadManager Manager { get; set; } public static long FreeSpace { get; set; } - public static long NeededSpace => Manager.ResponseInfo.DownloadSize; + public static long NeededSpace => Manager.UpdatePlanResponse.DownloadSize; public static void Start() { Manager = new DownloadManager(); + + DownloadLogger.Init(LauncherPaths.GetLoggerPath()); } public static string UpdateDiskSpace(string path) diff --git a/BeWoLauncher/Logic/Controller/ProcessController.cs b/BeWoLauncher/Logic/Controller/ProcessController.cs index cd8081027..9fed8fdd4 100644 --- a/BeWoLauncher/Logic/Controller/ProcessController.cs +++ b/BeWoLauncher/Logic/Controller/ProcessController.cs @@ -1,4 +1,5 @@ using BeWoLauncher.Logic.Utils; +using BeWoLauncher.ServiceProxy; using BS.SharedLauncher.Information; using System; using System.Diagnostics; @@ -49,6 +50,17 @@ namespace BeWoLauncher.Logic.Controller } } + internal static void StartLauncher() + { + CheckForOtherInstance(); + + // Update Server Adresses + //ConnectionInformation.DownloadServerAddress = ConnectionInformation.DownloadServerAddressExact.ToString(); + //ConnectionInformation.CoreServerAddress = ConnectionInformation.CoreServerAddress.ToString(); + + LauncherServiceFacade.UpdateServerAddresses(SessionInformation.Connection.DownloadServerAddressExact, SessionInformation.Connection.CoreServerAddressExact); + } + internal static void StartLauncherShutdown() { Current.Shutdown(); @@ -72,6 +84,7 @@ namespace BeWoLauncher.Logic.Controller PlanerProcess.OutputDataReceived += MessageFromPlanerClient; PlanerProcess.Start(); + DownloadLogger.Post2($"Launcher Start: {PlanerProcess.StartInfo.FileName}"); PlanerProcess.BeginOutputReadLine(); @@ -81,19 +94,17 @@ namespace BeWoLauncher.Logic.Controller { using (StreamWriter sw = new StreamWriter(pipeServer)) { + var signal = new string[] { "C-137", "C-131" }; + sw.AutoFlush = true; - - sw.WriteLine("C-137"); - pipeServer.WaitForPipeDrain(); - foreach (var info in ConnectionInformation.Connection.ToArray()) - { - sw.WriteLine(info); - pipeServer.WaitForPipeDrain(); - } + SendInfo(sw, signal[0], pipeServer); - sw.WriteLine("C-131"); - pipeServer.WaitForPipeDrain(); + SessionInformation.Connection.ToList().ForEach(info => SendInfo(sw, info, pipeServer)); + SessionInformation.Login.ToList().ForEach(info => SendInfo(sw, info, pipeServer)); + SessionInformation.Session.ToList().ForEach(info => SendInfo(sw, info, pipeServer)); + + SendInfo(sw, signal[1], pipeServer); } } catch (IOException ex) @@ -102,6 +113,11 @@ namespace BeWoLauncher.Logic.Controller } } } + internal static void SendInfo(StreamWriter sw, string info, AnonymousPipeServerStream pipe) + { + sw.WriteLine(info); + pipe.WaitForPipeDrain(); + } internal static void KillPlanerProcess() { foreach (var process in Process.GetProcesses()) diff --git a/BeWoLauncher/Logic/Multitenancy/MultitenancyInterceptor.cs b/BeWoLauncher/Logic/Multitenancy/MultitenancyInterceptor.cs index 075b61c14..cc05087b0 100644 --- a/BeWoLauncher/Logic/Multitenancy/MultitenancyInterceptor.cs +++ b/BeWoLauncher/Logic/Multitenancy/MultitenancyInterceptor.cs @@ -14,7 +14,7 @@ namespace BeWoLauncher.Multitenancy public object BeforeSendRequest(ref Message request, IClientChannel channel) { - request.Headers.Add(new MultitenancyHeader { Tenant = ConnectionInformation.Tenant }); + request.Headers.Add(new MultitenancyHeader { Tenant = SessionInformation.Login.Tenant }); return null; } } diff --git a/BeWoLauncher/Logic/Security/LauncherSecurityHeaderInterceptor.cs b/BeWoLauncher/Logic/Security/LauncherSecurityHeaderInterceptor.cs index 9629a7419..8c0e49527 100644 --- a/BeWoLauncher/Logic/Security/LauncherSecurityHeaderInterceptor.cs +++ b/BeWoLauncher/Logic/Security/LauncherSecurityHeaderInterceptor.cs @@ -15,7 +15,7 @@ namespace BeWoLauncher.Security public object BeforeSendRequest(ref Message request, IClientChannel channel) { - request.Headers.Add(new LauncherSecurityHeader { Username = ConnectionInformation.Username, Password = ConnectionInformation.Password }); + request.Headers.Add(new LauncherSecurityHeader { Username = SessionInformation.Login.Username, Password = SessionInformation.Login.Password }); return null; } } diff --git a/BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs b/BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs index d7c9e0f13..0b2a8cd65 100644 --- a/BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs +++ b/BeWoLauncher/Logic/ServiceProxy/LauncherGenerated.cs @@ -11,26 +11,26 @@ namespace BeWoLauncher.ServiceProxy { using System.Runtime.Serialization; - - + + [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + [System.Runtime.Serialization.DataContractAttribute(Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] public partial class BeWoFault : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged { - + private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - + private BeWoLauncher.ServiceProxy.BeWoFaultType FaultTypeField; - + private string InnerExceptionMessageField; - + private string InnerExceptionStackTraceField; - + private string MessageField; - + private string StackTraceField; - + public System.Runtime.Serialization.ExtensionDataObject ExtensionData { get @@ -42,7 +42,7 @@ namespace BeWoLauncher.ServiceProxy this.extensionDataField = value; } } - + [System.Runtime.Serialization.DataMemberAttribute()] public BeWoLauncher.ServiceProxy.BeWoFaultType FaultType { @@ -59,7 +59,7 @@ namespace BeWoLauncher.ServiceProxy } } } - + [System.Runtime.Serialization.DataMemberAttribute()] public string InnerExceptionMessage { @@ -76,7 +76,7 @@ namespace BeWoLauncher.ServiceProxy } } } - + [System.Runtime.Serialization.DataMemberAttribute()] public string InnerExceptionStackTrace { @@ -93,7 +93,7 @@ namespace BeWoLauncher.ServiceProxy } } } - + [System.Runtime.Serialization.DataMemberAttribute()] public string Message { @@ -110,7 +110,7 @@ namespace BeWoLauncher.ServiceProxy } } } - + [System.Runtime.Serialization.DataMemberAttribute()] public string StackTrace { @@ -127,9 +127,9 @@ namespace BeWoLauncher.ServiceProxy } } } - + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - + protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; @@ -139,247 +139,265 @@ namespace BeWoLauncher.ServiceProxy } } } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFaultType", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + [System.Runtime.Serialization.DataContractAttribute(Name = "BeWoFaultType", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] public enum BeWoFaultType : int { - + [System.Runtime.Serialization.EnumMemberAttribute()] Unknown = 0, - + [System.Runtime.Serialization.EnumMemberAttribute()] Concurrency = 1, - + [System.Runtime.Serialization.EnumMemberAttribute()] DeleteNotPossible = 2, - + [System.Runtime.Serialization.EnumMemberAttribute()] LoginNameTaken = 3, - + [System.Runtime.Serialization.EnumMemberAttribute()] CustomWithoutDetails = 4, } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWoLauncher.ServiceProxy.ILauncherService")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName = "BeWoLauncher.ServiceProxy.ILauncherService")] public interface ILauncherService { - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/IsUserValid", ReplyAction="http://tempuri.org/ILauncherService/IsUserValidResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/IsUserValidBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/IsUserValid", ReplyAction = "http://tempuri.org/ILauncherService/IsUserValidResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/IsUserValidBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetTenantResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/ResetTenant", ReplyAction = "http://tempuri.org/ILauncherService/ResetTenantResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/ResetTenantBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] void ResetTenant(string tenant); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetAllTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetAllTenantResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetAllTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/ResetAllTenant", ReplyAction = "http://tempuri.org/ILauncherService/ResetAllTenantResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/ResetAllTenantBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] void ResetAllTenant(); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/GetEmailForUserName", ReplyAction="http://tempuri.org/ILauncherService/GetEmailForUserNameResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/GetEmailForUserNameBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/GetEmailForUserName", ReplyAction = "http://tempuri.org/ILauncherService/GetEmailForUserNameResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/GetEmailForUserNameBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword", ReplyAction="http://tempuri.org/ILauncherService/CheckPasswordResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/CheckPassword", ReplyAction = "http://tempuri.org/ILauncherService/CheckPasswordResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/CheckPasswordBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword2", ReplyAction="http://tempuri.org/ILauncherService/CheckPassword2Response")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPassword2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/CheckPassword2", ReplyAction = "http://tempuri.org/ILauncherService/CheckPassword2Response")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/CheckPassword2BeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ChangePassword", ReplyAction="http://tempuri.org/ILauncherService/ChangePasswordResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ChangePasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/ChangePassword", ReplyAction = "http://tempuri.org/ILauncherService/ChangePasswordResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/ChangePasswordBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] long ChangePassword(string pUserName, string pOldPassword, string pNewPassword); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetPasswordInfo", ReplyAction="http://tempuri.org/ILauncherService/ResetPasswordInfoResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetPasswordInfoBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ILauncherService/ResetPasswordInfo", ReplyAction = "http://tempuri.org/ILauncherService/ResetPasswordInfoResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/ILauncherService/ResetPasswordInfoBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] void ResetPasswordInfo(string pUserName, string pPassword); } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public interface ILauncherServiceChannel : BeWoLauncher.ServiceProxy.ILauncherService, System.ServiceModel.IClientChannel { } - + [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public partial class LauncherServiceClient : System.ServiceModel.ClientBase, BeWoLauncher.ServiceProxy.ILauncherService { - + public LauncherServiceClient() { } - - public LauncherServiceClient(string endpointConfigurationName) : + + public LauncherServiceClient(string endpointConfigurationName) : base(endpointConfigurationName) { } - - public LauncherServiceClient(string endpointConfigurationName, string remoteAddress) : + + public LauncherServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } - - public LauncherServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + + public LauncherServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { } - - public LauncherServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + + public LauncherServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { } - + public BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant) { return base.Channel.IsUserValid(pUserName, pPassword, pPIN, clientId, checkTenant); } - + public void ResetTenant(string tenant) { base.Channel.ResetTenant(tenant); } - + public void ResetAllTenant() { base.Channel.ResetAllTenant(); } - + public bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName) { return base.Channel.GetEmailForUserName(out email, pUserName, serverName); } - + public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword) { return base.Channel.CheckPassword(userOid, pOldPassword, pNewPassword); } - + public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword) { return base.Channel.CheckPassword2(username, pOldPassword, pNewPassword); } - + public long ChangePassword(string pUserName, string pOldPassword, string pNewPassword) { return base.Channel.ChangePassword(pUserName, pOldPassword, pNewPassword); } - + public void ResetPasswordInfo(string pUserName, string pPassword) { base.Channel.ResetPasswordInfo(pUserName, pPassword); } } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWoLauncher.ServiceProxy.IEnumTranslationService")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName = "BeWoLauncher.ServiceProxy.IEnumTranslationService")] public interface IEnumTranslationService { - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEnumTranslationService/GetTranslation", ReplyAction="http://tempuri.org/IEnumTranslationService/GetTranslationResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IEnumTranslationService/GetTranslationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IEnumTranslationService/GetTranslation", ReplyAction = "http://tempuri.org/IEnumTranslationService/GetTranslationResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/IEnumTranslationService/GetTranslationBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] string GetTranslation(string e, short value); } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public interface IEnumTranslationServiceChannel : BeWoLauncher.ServiceProxy.IEnumTranslationService, System.ServiceModel.IClientChannel { } - + [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public partial class EnumTranslationServiceClient : System.ServiceModel.ClientBase, BeWoLauncher.ServiceProxy.IEnumTranslationService { - + public EnumTranslationServiceClient() { } - - public EnumTranslationServiceClient(string endpointConfigurationName) : + + public EnumTranslationServiceClient(string endpointConfigurationName) : base(endpointConfigurationName) { } - - public EnumTranslationServiceClient(string endpointConfigurationName, string remoteAddress) : + + public EnumTranslationServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } - - public EnumTranslationServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + + public EnumTranslationServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { } - - public EnumTranslationServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + + public EnumTranslationServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { } - + public string GetTranslation(string e, short value) { return base.Channel.GetTranslation(e, value); } } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWoLauncher.ServiceProxy.IDownloadBeWoService")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName = "BeWoLauncher.ServiceProxy.IDownloadBeWoService")] public interface IDownloadBeWoService { - - [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.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.UpdateFileResponse Download2(BS.SharedLauncher.DataContract.UpdatePlanRequest 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.UpdatePlanResponse DownloadInfo(BS.SharedLauncher.DataContract.UpdatePlanRequest request); + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IDownloadBeWoService/GetUpdatePlan", ReplyAction = "http://tempuri.org/IDownloadBeWoService/GetUpdatePlanResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/IDownloadBeWoService/GetUpdatePlanBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.DataContract.UpdatePlanResponse GetUpdatePlan(BS.SharedLauncher.DataContract.UpdatePlanRequest request); + + [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IDownloadBeWoService/GetUpdateFile", ReplyAction = "http://tempuri.org/IDownloadBeWoService/GetUpdateFileResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action = "http://tempuri.org/IDownloadBeWoService/GetUpdateFileBeWoFaultFault", Name = "BeWoFault", Namespace = "http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.DataContract.UpdateFileResponse GetUpdateFile(BS.SharedLauncher.DataContract.UpdateFileRequest request); } - + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public interface IDownloadBeWoServiceChannel : BeWoLauncher.ServiceProxy.IDownloadBeWoService, System.ServiceModel.IClientChannel { } - + [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public partial class DownloadBeWoServiceClient : System.ServiceModel.ClientBase, BeWoLauncher.ServiceProxy.IDownloadBeWoService { - + public DownloadBeWoServiceClient() { } - - public DownloadBeWoServiceClient(string endpointConfigurationName) : + + public DownloadBeWoServiceClient(string endpointConfigurationName) : base(endpointConfigurationName) { } - - public DownloadBeWoServiceClient(string endpointConfigurationName, string remoteAddress) : + + public DownloadBeWoServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } - - public DownloadBeWoServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + + public DownloadBeWoServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { } - - public DownloadBeWoServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + + public DownloadBeWoServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { } - - public BS.SharedLauncher.DataContract.DownloadPlanerResponseDC Download2(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request) + + public BS.SharedLauncher.DataContract.UpdateFileResponse Download2(BS.SharedLauncher.DataContract.UpdatePlanRequest request) { return base.Channel.Download2(request); } - - public BS.SharedLauncher.DataContract.DownloadPlanerResponseInfoDC DownloadInfo(BS.SharedLauncher.DataContract.DownloadPlanerRequestDC request) + + public BS.SharedLauncher.DataContract.UpdatePlanResponse DownloadInfo(BS.SharedLauncher.DataContract.UpdatePlanRequest request) { return base.Channel.DownloadInfo(request); } + + public BS.SharedLauncher.DataContract.UpdatePlanResponse GetUpdatePlan(BS.SharedLauncher.DataContract.UpdatePlanRequest request) + { + return base.Channel.GetUpdatePlan(request); + } + + public BS.SharedLauncher.DataContract.UpdateFileResponse GetUpdateFile(BS.SharedLauncher.DataContract.UpdateFileRequest request) + { + return base.Channel.GetUpdateFile(request); + } } } diff --git a/BeWoLauncher/Logic/ServiceProxy/LauncherServiceFacade.cs b/BeWoLauncher/Logic/ServiceProxy/LauncherServiceFacade.cs index 4ed1571ab..12ad742b8 100644 --- a/BeWoLauncher/Logic/ServiceProxy/LauncherServiceFacade.cs +++ b/BeWoLauncher/Logic/ServiceProxy/LauncherServiceFacade.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ServiceModel; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; - -using BeWoLauncher.Multitenancy; +using BeWoLauncher.Multitenancy; using BeWoLauncher.Security; -using BS.SharedLauncher.Information; +using System; +using System.Collections.Generic; +using System.ServiceModel; +using System.Threading; +using System.Windows; namespace BeWoLauncher.ServiceProxy { @@ -20,18 +15,21 @@ namespace BeWoLauncher.ServiceProxy private static Dictionary _EndpointAddresses; private static readonly Dictionary _ProxyCache; - private static int _RunningAsyncs; - - public static void UpdateServerAddresses(string siteOfOrigin) + private static readonly int _RunningAsyncs; + + public static void UpdateServerAddresses(string launcher, string main) { - var serverName = siteOfOrigin; + var serverName = launcher; + var serverName2 = main; if (serverName.Substring(serverName.Length - 1, 1) != "/") serverName += "/"; + if (serverName2.Substring(serverName2.Length - 1, 1) != "/") + serverName2 += "/"; _EndpointAddresses = new Dictionary { - { typeof(ILauncherService), new EndpointAddress(serverName + "LauncherService.svc") }, - { typeof(IEnumTranslationService), new EndpointAddress(serverName + "EnumTranslationService.svc") }, + { typeof(ILauncherService), new EndpointAddress(serverName2 + "LauncherService.svc") }, + { typeof(IEnumTranslationService), new EndpointAddress(serverName2 + "EnumTranslationService.svc") }, { typeof(IDownloadBeWoService), new EndpointAddress(serverName + "DownloadBeWoService.svc") } }; } diff --git a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs index 553ef6e12..af73ba4b8 100644 --- a/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs +++ b/BeWoLauncher/Logic/Utils/Download/DownloadManager.cs @@ -10,6 +10,7 @@ using BS.SharedLauncher.Update; using BS.SharedLauncher.Utils; using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.IO.Compression; using System.Linq; @@ -23,144 +24,189 @@ namespace BeWoLauncher.Logic.Utils.Download { public class DownloadManager { - public DownloadPlanerRequestDC Request { get; set; } - public DownloadPlanerResponseInfoDC ResponseInfo { get; set; } - public DownloadPlanerResponseDC Response { get; set; } + public UpdatePlanRequest UpdatePlanRequest { get; set; } + public UpdatePlanResponse UpdatePlanResponse { get; set; } + public string RootFolder => LauncherPaths.GetRootPath(); public string DownloadFolder => LauncherPaths.GetDownloadPath(); public string ApplyFolder => LauncherPaths.GetApplyPath(); + public bool SkipLock { get; set; } + public Action Feedback { get; set; } + + public int FilesToDownloadCount => UpdatePlanResponse.FilesToRequest?.Count ?? 0; + public int FilesToApplyCount => FilesToDownloadCount + (UpdatePlanResponse.FilesToApply?.Count ?? 0); + public int FilesToDeleteInApplyCount => UpdatePlanResponse.FilesToDeleteInApply?.Count ?? 0; + public int FilesToProcessTotal => FilesToDownloadCount + FilesToApplyCount + FilesToDeleteInApplyCount; + public DownloadManager() { - Request = null; - ResponseInfo = null; - Response = null; + } - public void StartDownloadInfo() + public void GetUpdatePlan() { - CreateDownloadRequest(); + CreateUpdatePlanRequest(); - GetDownloadResponseInfo(); + GetUpdatePlanResponse(); - ConnectionInformation.Version = ResponseInfo.Version; + SessionInformation.Session.Version = UpdatePlanResponse.CurrentPackage.Version; } - public void StartDownload(bool skipLock, Action download) - { - GetDownloadResponse(); - if (!Response.HasToDo()) + public void StartProcess(BackgroundWorker worker) + { + var report = new Action((progress, waitms) => { - // Macht das Sinn? - // Ne, wahrsch. Fehler - throw new NotImplementedException("#45419873274"); + worker.ReportProgress((int)progress); + Thread.Sleep(waitms); + }); + + report(LauncherProgress.ProgressStart, 1000); - return; + if (FilesToDownloadCount > 0) + { + report(LauncherProgress.DownloadStart, 500); + + Download(); + + report(LauncherProgress.DownloadFinish, 1000); } - if (Response.HasToDoNewZip()) + if (FilesToApplyCount > 0) { - DownloadFolder.CreateFolder(); + report(LauncherProgress.ApplyStart, 500); - DownloadFolder.Lock(skipLock); + Apply(); - LauncherPaths.CurrentDownloadZipLocation = FileController.GetNewZipPath(LauncherPaths.GetDownloadPath()); - - //FileController.SaveDZipStream(LauncherPaths.CurrentDownloadZipLocation, Response.NewZipStream, Response.NewZipData.LongLength, download); - FileController.SaveDZip(LauncherPaths.CurrentDownloadZipLocation, Response.NewZipData); - FileController.SaveInfo(LauncherPaths.CurrentDownloadZipLocation, Response.NewZipInfo); - FileController.SaveInfo(LauncherPaths.GetRootPath().Combine("latest"), Response.LatestApplicationInfo); - - Response.NewZipData = null; - - DownloadFolder.Unlock(); + report(LauncherProgress.ApplyFinished, 1000); } + + if (FilesToDeleteInApplyCount > 0) + { + report(LauncherProgress.DeleteStart, 500); + + Delete(); + + report(LauncherProgress.DeleteFinished, 1000); + } + + report(LauncherProgress.CleanupStart, 500); + + Cleanup(); + + report(LauncherProgress.CleanupFinished, 1000); + + // report(LauncherProgress.ProgressEnd, 500); } - public void StartApply(bool skiplock, Action apply) + + public void Download() + { + DownloadFolder.CreateFolder(); + + DownloadFolder.Lock(SkipLock); + + DownloadFolder.SaveCurrentInfo("current"); + + UpdateFileRequest req = new UpdateFileRequest(UpdatePlanResponse.CurrentPackage.Version); + foreach (var file2request in UpdatePlanResponse.FilesToRequest) + { + req.UpdateFile = file2request; + + var res = AskForFile(req); + + var download_path = DownloadFolder.Combine(file2request.RelativePath); + + Path.GetDirectoryName(download_path).CreateFolder(); + download_path.SaveFile(res.FileData); + + var size = NonspecificTools.SizeSuffix((ulong)res.FileData.Length); + + Feedback((int)LauncherProgress.DownloadUpdate, new DownloadProgressEventArgs(size, file2request)); + } + + DownloadFolder.Unlock(); + } + public void Apply() { ApplyFolder.CreateFolder(); - ApplyFolder.Lock(skiplock); + ApplyFolder.Lock(SkipLock); - if (Response.HasToDoDownload2Keep()) - { - FileController.ApplyDZip(Response.DownloadFilesToKeep, ApplyFolder, apply); - } + if (UpdatePlanResponse.FilesToApply is object) + UpdatePlanResponse.FilesToApply.ForEach(ApplyFile); + + if (UpdatePlanResponse.FilesToRequest is object) + UpdatePlanResponse.FilesToRequest.ForEach(ApplyFile); - if (Response.HasToDoNewZip()) + ApplyFolder.SaveCurrentInfo("current"); + } + public void ApplyFile(UpdateFileDC file2apply) + { + var apply_path = ApplyFolder.Combine(file2apply.RelativePath); + var download_path = DownloadFolder.Combine(file2apply.RelativePath); + + Path.GetDirectoryName(apply_path).CreateFolder(); + download_path.CopyFileTo(apply_path); + + Feedback((int)LauncherProgress.ApplyUpdate, new ApplyFileEventArgs(file2apply.RelativePath)); + } + public void Delete() + { + foreach (var file2delete in UpdatePlanResponse.FilesToDeleteInApply) { - FileController.ApplyDZip(LauncherPaths.CurrentDownloadZipLocation, ApplyFolder, apply); + var delete_path = ApplyFolder.Combine(file2delete.RelativePath); + + delete_path.DeleteFile(); + + Feedback((int)LauncherProgress.DeleteUpdate, file2delete.RelativePath); } } - public void StartCleanup(Action feedback) + public void Cleanup() { - if (Response.HasToRemoveFiles) - { - StartRemoveFiles(feedback, Response.LatestApplicationInfo); - } + ApplyFolder.DeleteEmptyDirectories(); DownloadFolder.ClearFolder(); ApplyFolder.Unlock(); - - Thread.Sleep(1000); } - public void StartUninstall(Action feedback) + + private void CreateUpdatePlanRequest() { - var t = new PlanerPackageInfoDC() + UpdatePlanRequest = new UpdatePlanRequest(); + + if (UpdatePlanRequest.PlanerRootFolderExists = LauncherPaths.ActualPlanerLocation.Exists()) { - Files = new List() - }; + if (UpdatePlanRequest.DownloadFolderExists = DownloadFolder.Exists()) + if (!(UpdatePlanRequest.DownloadFolderIsEmpty = DownloadFolder.IsFolderEmpty())) + UpdatePlanRequest.DownloadedFiles = FileController.GetDownloadedFiles(DownloadFolder); - StartRemoveFiles(feedback, t); - } - - private void StartRemoveFiles(Action feedback, PlanerPackageInfoDC newPackage) - { - feedback((int)LauncherProgress.DeleteStart, null); - - Thread.Sleep(500); - - FileController.RemoveUnsuedFiles(newPackage, ApplyFolder, feedback); - } - - private void CreateDownloadRequest() - { - Request = new DownloadPlanerRequestDC(); - - if (Request.PlanerRootFolderExists = LauncherPaths.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; - } + if (UpdatePlanRequest.ApplyFolderExists = ApplyFolder.Exists()) + if (!(UpdatePlanRequest.ApplyFolderIsEmpty = ApplyFolder.IsFolderEmpty())) + UpdatePlanRequest.ApplyPackage = FileController.GetApplyPackage(ApplyFolder); } + + UpdatePlanRequest.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, + }; } - private void GetDownloadResponse() + + private UpdateFileResponse AskForFile(UpdateFileRequest request) { - Response = LauncherServiceFacade.DoDownloadBeWoServiceSync(x => x.Download2(Request)); + return LauncherServiceFacade.DoDownloadBeWoServiceSyncWithException(x => x.GetUpdateFile(request)); } - private void GetDownloadResponseInfo() + + private void GetUpdatePlanResponse() { - var t = ConnectionInformation.Tenant; - ResponseInfo = LauncherServiceFacade.DoDownloadBeWoServiceSyncWithException(x => x.DownloadInfo(Request)); + UpdatePlanResponse = LauncherServiceFacade.DoDownloadBeWoServiceSyncWithException(x => x.GetUpdatePlan(UpdatePlanRequest)); + + // UpdatePlanResponse.FilesToApply.AddRange(UpdatePlanResponse.FilesToRequest); } } } diff --git a/BeWoLauncher/Logic/Utils/LauncherPaths.cs b/BeWoLauncher/Logic/Utils/LauncherPaths.cs index 29f13a7ee..ac145715e 100644 --- a/BeWoLauncher/Logic/Utils/LauncherPaths.cs +++ b/BeWoLauncher/Logic/Utils/LauncherPaths.cs @@ -1,5 +1,7 @@ -using BS.SharedLauncher.Extensions; +using BeWoLauncher.Logic.Controller; +using BS.SharedLauncher.Extensions; using BS.SharedLauncher.Information; +using BS.SharedLauncher.Logic; using System; using System.Collections.Generic; using System.IO; @@ -19,8 +21,6 @@ namespace BeWoLauncher.Logic.Utils public static string LoginSelectionPlanerLocation { get; set; } public static string ActualPlanerLocation { get; set; } - public static string CurrentDownloadZipLocation { get; set; } - /// /// Holt den Install Ort aus den Properties Settings. /// Sollte dieser nicht verfügbar sein, wird als default - "CurrentBaseDir"/BeWoPlaner - verwendet @@ -81,6 +81,10 @@ namespace BeWoLauncher.Logic.Utils { return ActualPlanerLocation; } + public static string GetLoggerPath() + { + return Path.Combine(new string[] { GetRootPath(), "log" }); + } public static string GetDownloadPath() { return Path.Combine(new string[] { GetRootPath(), "download" }); @@ -94,13 +98,30 @@ namespace BeWoLauncher.Logic.Utils { return Path.Combine(GetApplyPath(), GetPlanerExeName()); } - public static string GetApplyPackagePath() + + public static void SaveCurrentInfo(this string path, string file) { - return Path.Combine(GetApplyPath(), BeWoPathFileConfig.LatestBeWoInfo); + FileController.SaveInfo(path.Combine(file), DownloadController.Manager.UpdatePlanResponse.CurrentPackage); } - public static string GetDownloadPackagePath() + + public static void SaveFile(this string path, byte[] data) { - return Path.Combine(GetDownloadPath(), BeWoPathFileConfig.LatestBeWoInfo); + FileController.SaveFile(path, data); + } + + public static void CopyFileTo(this string source, string destination) + { + FileController.CopyFile(source, destination); + } + + public static void DeleteFile(this string file) + { + FileController.DeleteFile(file); + } + + public static void DeleteEmptyDirectories(this string dir) + { + FileController.DeleteEmptyDirectories(dir); } } } \ No newline at end of file diff --git a/BeWoLauncher/Logic/ViewBuilder.cs b/BeWoLauncher/Logic/ViewBuilder.cs index 018f0a772..b9c41357a 100644 --- a/BeWoLauncher/Logic/ViewBuilder.cs +++ b/BeWoLauncher/Logic/ViewBuilder.cs @@ -2,6 +2,7 @@ using BeWoLauncher.Logic.Controller; using BeWoLauncher.View; using BeWoLauncher.View.Frames; +using BS.SharedLauncher.Enums; using System; using System.Threading.Tasks; using System.Windows.Controls; @@ -120,11 +121,12 @@ namespace BeWoLauncher.Logic private FrameBase getUninstallProgressFrame() { - var uninstallProgress = new UninstallProgressInfoFrame(); + var progress = new ProgressFrame(LauncherMode.Update); - uninstallProgress.UninstallSuccessful += ViewBehavior.UninstallSuccess; + progress.Successful += ViewBehavior.UninstallSuccess; + progress.Exception += ViewBehavior.UninstallFailed; - return uninstallProgress; + return progress; } private FrameBase getUninstallInfoFrame() @@ -151,11 +153,12 @@ namespace BeWoLauncher.Logic private FrameBase getUpdateProgressFrame() { - var updateProgress = new UpdateProgressInfoFrame(); + var progress = new ProgressFrame(LauncherMode.Update); - updateProgress.UpdateSuccessful += ViewBehavior.UpdateSuccess; + progress.Successful += ViewBehavior.UpdateSuccess; + progress.Exception += ViewBehavior.UpdateFailed; - return updateProgress; + return progress; } private FrameBase getUpdateInfoFrame() @@ -194,11 +197,12 @@ namespace BeWoLauncher.Logic private FrameBase getInstallProgressFrame() { - var installprogress = new InstallProgressInfoFrame(); + var progress = new ProgressFrame(LauncherMode.Install); - installprogress.InstallSuccessful += ViewBehavior.InstallSuccesss; + progress.Successful += ViewBehavior.InstallSuccesss; + progress.Exception += ViewBehavior.InstallFailed; - return installprogress; + return progress; } private FrameBase getInstallInfoFrame() diff --git a/BeWoLauncher/ServiceProxy/LauncherGenerated.cs b/BeWoLauncher/ServiceProxy/LauncherGenerated.cs new file mode 100644 index 000000000..f096a7629 --- /dev/null +++ b/BeWoLauncher/ServiceProxy/LauncherGenerated.cs @@ -0,0 +1,403 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace BeWoLauncher.ServiceProxy +{ + using System.Runtime.Serialization; + + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + public partial class BeWoFault : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged + { + + private System.Runtime.Serialization.ExtensionDataObject extensionDataField; + + private BeWoLauncher.ServiceProxy.BeWoFaultType FaultTypeField; + + private string InnerExceptionMessageField; + + private string InnerExceptionStackTraceField; + + private string MessageField; + + private string StackTraceField; + + public System.Runtime.Serialization.ExtensionDataObject ExtensionData + { + get + { + return this.extensionDataField; + } + set + { + this.extensionDataField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public BeWoLauncher.ServiceProxy.BeWoFaultType FaultType + { + get + { + return this.FaultTypeField; + } + set + { + if ((this.FaultTypeField.Equals(value) != true)) + { + this.FaultTypeField = value; + this.RaisePropertyChanged("FaultType"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string InnerExceptionMessage + { + get + { + return this.InnerExceptionMessageField; + } + set + { + if ((object.ReferenceEquals(this.InnerExceptionMessageField, value) != true)) + { + this.InnerExceptionMessageField = value; + this.RaisePropertyChanged("InnerExceptionMessage"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string InnerExceptionStackTrace + { + get + { + return this.InnerExceptionStackTraceField; + } + set + { + if ((object.ReferenceEquals(this.InnerExceptionStackTraceField, value) != true)) + { + this.InnerExceptionStackTraceField = value; + this.RaisePropertyChanged("InnerExceptionStackTrace"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Message + { + get + { + return this.MessageField; + } + set + { + if ((object.ReferenceEquals(this.MessageField, value) != true)) + { + this.MessageField = value; + this.RaisePropertyChanged("Message"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string StackTrace + { + get + { + return this.StackTraceField; + } + set + { + if ((object.ReferenceEquals(this.StackTraceField, value) != true)) + { + this.StackTraceField = value; + this.RaisePropertyChanged("StackTrace"); + } + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) + { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) + { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFaultType", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + public enum BeWoFaultType : int + { + + [System.Runtime.Serialization.EnumMemberAttribute()] + Unknown = 0, + + [System.Runtime.Serialization.EnumMemberAttribute()] + Concurrency = 1, + + [System.Runtime.Serialization.EnumMemberAttribute()] + DeleteNotPossible = 2, + + [System.Runtime.Serialization.EnumMemberAttribute()] + LoginNameTaken = 3, + + [System.Runtime.Serialization.EnumMemberAttribute()] + CustomWithoutDetails = 4, + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWoLauncher.ServiceProxy.ILauncherService")] + public interface ILauncherService + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/IsUserValid", ReplyAction="http://tempuri.org/ILauncherService/IsUserValidResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/IsUserValidBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetTenantResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void ResetTenant(string tenant); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetAllTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetAllTenantResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetAllTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void ResetAllTenant(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/GetEmailForUserName", ReplyAction="http://tempuri.org/ILauncherService/GetEmailForUserNameResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/GetEmailForUserNameBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword", ReplyAction="http://tempuri.org/ILauncherService/CheckPasswordResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword2", ReplyAction="http://tempuri.org/ILauncherService/CheckPassword2Response")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPassword2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ChangePassword", ReplyAction="http://tempuri.org/ILauncherService/ChangePasswordResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ChangePasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + long ChangePassword(string pUserName, string pOldPassword, string pNewPassword); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetPasswordInfo", ReplyAction="http://tempuri.org/ILauncherService/ResetPasswordInfoResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetPasswordInfoBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void ResetPasswordInfo(string pUserName, string pPassword); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface ILauncherServiceChannel : BeWoLauncher.ServiceProxy.ILauncherService, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class LauncherServiceClient : System.ServiceModel.ClientBase, BeWoLauncher.ServiceProxy.ILauncherService + { + + public LauncherServiceClient() + { + } + + public LauncherServiceClient(string endpointConfigurationName) : + base(endpointConfigurationName) + { + } + + public LauncherServiceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public LauncherServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public LauncherServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant) + { + return base.Channel.IsUserValid(pUserName, pPassword, pPIN, clientId, checkTenant); + } + + public void ResetTenant(string tenant) + { + base.Channel.ResetTenant(tenant); + } + + public void ResetAllTenant() + { + base.Channel.ResetAllTenant(); + } + + public bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName) + { + return base.Channel.GetEmailForUserName(out email, pUserName, serverName); + } + + public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword) + { + return base.Channel.CheckPassword(userOid, pOldPassword, pNewPassword); + } + + public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword) + { + return base.Channel.CheckPassword2(username, pOldPassword, pNewPassword); + } + + public long ChangePassword(string pUserName, string pOldPassword, string pNewPassword) + { + return base.Channel.ChangePassword(pUserName, pOldPassword, pNewPassword); + } + + public void ResetPasswordInfo(string pUserName, string pPassword) + { + base.Channel.ResetPasswordInfo(pUserName, pPassword); + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWoLauncher.ServiceProxy.IEnumTranslationService")] + public interface IEnumTranslationService + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IEnumTranslationService/GetTranslation", ReplyAction="http://tempuri.org/IEnumTranslationService/GetTranslationResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IEnumTranslationService/GetTranslationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + string GetTranslation(string e, short value); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface IEnumTranslationServiceChannel : BeWoLauncher.ServiceProxy.IEnumTranslationService, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class EnumTranslationServiceClient : System.ServiceModel.ClientBase, BeWoLauncher.ServiceProxy.IEnumTranslationService + { + + public EnumTranslationServiceClient() + { + } + + public EnumTranslationServiceClient(string endpointConfigurationName) : + base(endpointConfigurationName) + { + } + + public EnumTranslationServiceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public EnumTranslationServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public EnumTranslationServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public string GetTranslation(string e, short value) + { + return base.Channel.GetTranslation(e, value); + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWoLauncher.ServiceProxy.IDownloadBeWoService")] + public interface IDownloadBeWoService + { + + [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.UpdateFileResponse Download2(BS.SharedLauncher.DataContract.UpdateRequest 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.UpdateResponse DownloadInfo(BS.SharedLauncher.DataContract.UpdateRequest request); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDownloadBeWoService/GetUpdatePlan", ReplyAction="http://tempuri.org/IDownloadBeWoService/GetUpdatePlanResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IDownloadBeWoService/GetUpdatePlanBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.DataContract.UpdateResponse GetUpdatePlan(BS.SharedLauncher.DataContract.UpdateRequest request); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDownloadBeWoService/GetUpdateFile", ReplyAction="http://tempuri.org/IDownloadBeWoService/GetUpdateFileResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWoLauncher.ServiceProxy.BeWoFault), Action="http://tempuri.org/IDownloadBeWoService/GetUpdateFileBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.DataContract.UpdateFileResponse GetUpdateFile(BS.SharedLauncher.DataContract.UpdateFileRequest request); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface IDownloadBeWoServiceChannel : BeWoLauncher.ServiceProxy.IDownloadBeWoService, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class DownloadBeWoServiceClient : System.ServiceModel.ClientBase, BeWoLauncher.ServiceProxy.IDownloadBeWoService + { + + public DownloadBeWoServiceClient() + { + } + + public DownloadBeWoServiceClient(string endpointConfigurationName) : + base(endpointConfigurationName) + { + } + + public DownloadBeWoServiceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public DownloadBeWoServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public DownloadBeWoServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public BS.SharedLauncher.DataContract.UpdateFileResponse Download2(BS.SharedLauncher.DataContract.UpdateRequest request) + { + return base.Channel.Download2(request); + } + + public BS.SharedLauncher.DataContract.UpdateResponse DownloadInfo(BS.SharedLauncher.DataContract.UpdateRequest request) + { + return base.Channel.DownloadInfo(request); + } + + public BS.SharedLauncher.DataContract.UpdateResponse GetUpdatePlan(BS.SharedLauncher.DataContract.UpdateRequest request) + { + return base.Channel.GetUpdatePlan(request); + } + + public BS.SharedLauncher.DataContract.UpdateFileResponse GetUpdateFile(BS.SharedLauncher.DataContract.UpdateFileRequest request) + { + return base.Channel.GetUpdateFile(request); + } + } +} diff --git a/BeWoLauncher/View/Components/MessageDialog.xaml.cs b/BeWoLauncher/View/Components/MessageDialog.xaml.cs index 7188a8ddb..2fcce003c 100644 --- a/BeWoLauncher/View/Components/MessageDialog.xaml.cs +++ b/BeWoLauncher/View/Components/MessageDialog.xaml.cs @@ -105,7 +105,7 @@ namespace BeWoLauncher.Components private void OkayButton_OnClick(object sender, RoutedEventArgs e) { - LauncherServiceFacade.DoLauncherServiceAsync(u => u.IsUserValid(ConnectionInformation.Username, PasswordBox.Password, null, null, false), result => + LauncherServiceFacade.DoLauncherServiceAsync(u => u.IsUserValid(SessionInformation.Login.Username, PasswordBox.Password, null, null, false), result => { if(result == UserValidationResult.UserValid) { diff --git a/BeWoLauncher/View/Components/PasswortAenderungsView.xaml.cs b/BeWoLauncher/View/Components/PasswortAenderungsView.xaml.cs index 395ace7ba..f158e3b5e 100644 --- a/BeWoLauncher/View/Components/PasswortAenderungsView.xaml.cs +++ b/BeWoLauncher/View/Components/PasswortAenderungsView.xaml.cs @@ -70,7 +70,7 @@ namespace BeWoLauncher.Components var lOld = AltesPwBox.Password; var lNew = NeuesPwBox.Password; - LauncherServiceFacade.DoLauncherServiceAsync(x => x.CheckPassword2(ConnectionInformation.Username, lOld, lNew), + LauncherServiceFacade.DoLauncherServiceAsync(x => x.CheckPassword2(SessionInformation.Login.Username, lOld, lNew), result => CheckPasswordResult(result, lOld, lNew), true); } @@ -78,9 +78,9 @@ namespace BeWoLauncher.Components { if (result == PasswordValidationResult.Succesful) { - LauncherServiceFacade.DoLauncherServiceSync(x => x.ChangePassword(ConnectionInformation.Username, oldPassword, newPassword)); + LauncherServiceFacade.DoLauncherServiceSync(x => x.ChangePassword(SessionInformation.Login.Username, oldPassword, newPassword)); - ConnectionInformation.Password = newPassword; + SessionInformation.Login.Password = newPassword; Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)PopUp.Close); } diff --git a/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs b/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs deleted file mode 100644 index b2fc0f763..000000000 --- a/BeWoLauncher/View/Frames/GenericProgressFrame.xaml.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.ComponentModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media.Animation; - -namespace BeWoLauncher.View.Frames -{ - /// - /// Interaktionslogik für UpdateView.xaml - /// - public abstract partial class GenericProgressInfo : FrameBase - { - private static TimeSpan duration = TimeSpan.FromSeconds(1); - - public readonly BackgroundWorker Worker = new BackgroundWorker(); - - private int lastStep = -1; - - public GenericProgressInfo() - { - InitializeComponent(); - - proBar1.IsIndeterminate = false; - proBar1.Minimum = 0; - proBar1.Maximum = 100; - - proBar2.IsIndeterminate = false; - proBar2.Minimum = 0; - - Loaded += (s, e) => Start(); - } - - 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; } - } - - public abstract void Start(); - - public void Bar1Activate() => proBar1.IsIndeterminate = false; - public void Bar1Deactivate() => proBar1.IsIndeterminate = true; - public void Bar1SetLimit(int max) => proBar1.Maximum = max; - public void Bar1MakeStep() => proBar1.Value++; - public void Bar1Hide() => proBar1.Visibility = Visibility.Collapsed; - public void Bar1Show() => proBar1.Visibility = Visibility.Visible; - - public void Bar2Activate() => proBar2.IsIndeterminate = false; - public void Bar2Deactivate() => proBar2.IsIndeterminate = true; - public void Bar2SetLimit(int max) => proBar2.Maximum = max; - public void Bar2MakeStep(int step) - { - if (step > lastStep) - { - lastStep = step; - 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/InfoFrame.xaml b/BeWoLauncher/View/Frames/InfoFrame.xaml index e46e1c8d1..e82888b24 100644 --- a/BeWoLauncher/View/Frames/InfoFrame.xaml +++ b/BeWoLauncher/View/Frames/InfoFrame.xaml @@ -9,12 +9,15 @@ - - + + + Hier könnte ihre Fehlermeldung stehen! + + diff --git a/BeWoLauncher/View/Frames/InfoFrame.xaml.cs b/BeWoLauncher/View/Frames/InfoFrame.xaml.cs index a23a79ae0..37ddb3978 100644 --- a/BeWoLauncher/View/Frames/InfoFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/InfoFrame.xaml.cs @@ -35,8 +35,8 @@ namespace BeWoLauncher.View.Frames public string Text { - get => txtField.Content as string; - set => txtField.Content = value; + get => txtField2.Text; + set => txtField2.Text = value; } public void CollapseCopyButton() => btnCopy.Visibility = Visibility.Collapsed; diff --git a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml index ecc9f136d..dba8bed7e 100644 --- a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml +++ b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml @@ -45,12 +45,6 @@ - - - - - - diff --git a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs index d3d7ca4db..c23e2c852 100644 --- a/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/InstallInfoFrame.xaml.cs @@ -23,20 +23,12 @@ namespace BeWoLauncher.View.Frames InstallLocation = LauncherPaths.GetInstallLocationFromSettingOrDefault(); - var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize).Split(' '); + var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.UpdatePlanResponse.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; - - lblcountalready.Visibility = Visibility.Hidden; - lblcountalreadytxt.Visibility = Visibility.Hidden; - lblcountnew.Visibility = Visibility.Hidden; - lblcountnewtxt.Visibility = Visibility.Hidden; + lblversion.Content = DownloadController.Manager.UpdatePlanResponse.CurrentPackage.Version; } public string InstallLocation diff --git a/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs b/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs deleted file mode 100644 index 639c8bfcc..000000000 --- a/BeWoLauncher/View/Frames/InstallProgressInfoFrame.cs +++ /dev/null @@ -1,183 +0,0 @@ -using BeWoLauncher.Logic.Controller; -using BeWoLauncher.Logic.Utils.Download; -using BS.SharedLauncher.Enums; -using BS.SharedLauncher.Update; -using System; -using System.ComponentModel; -using System.Configuration; -using System.Threading; - -namespace BeWoLauncher.View.Frames -{ - public class InstallProgressInfoFrame : GenericProgressInfo - { - public event EventHandler InstallSuccessful; - - public DownloadManager Manager => DownloadController.Manager; - - public InstallProgressInfoFrame() : base() - { - Bar1SetLimit(Manager.ResponseInfo.FileCount); - Bar1Hide(); - - Bar2SetLimit(100); - } - - public override void Start() - { - var skipLock = bool.TryParse(ConfigurationManager.AppSettings.Get("SkipLock"), out bool c) && c; - - Worker.DoWork += worker_DoWork; - Worker.ProgressChanged += worker_ProgressChanged; - Worker.RunWorkerCompleted += worker_completed; - - Worker.WorkerReportsProgress = true; - - Worker.RunWorkerAsync(skipLock); - } - - void worker_DoWork(object sender, DoWorkEventArgs e) - { - bool skipLock = (bool)e.Argument; - - BackgroundWorker worker = sender as BackgroundWorker; - - // UI: 0 - worker.ReportProgress((int)LauncherProgress.ProgressStart); - - // Wait - Thread.Sleep(1000); - - // UI: 1 - worker.ReportProgress((int)LauncherProgress.DownloadStart); - - // Wait - Thread.Sleep(500); - - // Process: 2 - DownloadController.Manager.StartDownload(skipLock, worker.ReportProgress); - - // UI: 3 - worker.ReportProgress((int)LauncherProgress.DownloadFinish); - - // Wait - Thread.Sleep(1000); - - // UI: 4 - worker.ReportProgress((int)LauncherProgress.ApplyStart); - - // Wait - Thread.Sleep(500); - - // Process: 5 - DownloadController.Manager.StartApply(skipLock, worker.ReportProgress); - - // UI: 6 - worker.ReportProgress((int)LauncherProgress.ApplyFinished); - - // Wait - Thread.Sleep(1000); - - // Process: 7, Wait, 8 - DownloadController.Manager.StartCleanup(worker.ReportProgress); - - // UI: 9 - worker.ReportProgress((int)LauncherProgress.DeleteFinished); - - // Wait - Thread.Sleep(500); - - // UI: 10 - worker.ReportProgress((int)LauncherProgress.ProgressEnd); - } - - private void worker_completed(object sender, RunWorkerCompletedEventArgs e) - { - if (e.Error != null) - { - ViewController.ViewBehavior.InstallationFailed(e.Error); - } - else - { - InstallSuccessful.Invoke(this, new EventArgs()); - } - } - - private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - var progress = (LauncherProgress)e.ProgressPercentage; - var obj = e.UserState; - - switch (progress) - { - case LauncherProgress.ProgressStart: - Message = "Installation wird vorbereitet..."; - SubMessage = "Lade benötigte Pakete herunter..."; - break; - - case LauncherProgress.DownloadStart: - Message = "Download startet..."; - SubMessage = ""; - Bar1Show(); - Bar1Deactivate(); - Bar2SetPercent(10); - break; - - case LauncherProgress.DownloadUpdate: - throw new NotImplementedException("#fd42398"); - var args = obj as DownloadProgressEventArgs; - SubMessage = $"{args.Progress.ToString("0.##")}% fertig"; - break; - - case LauncherProgress.DownloadFinish: - Message = "Download abgeschlossen!"; - SubMessage = ""; - Bar2SetPercent(40); - break; - - case LauncherProgress.ApplyStart: - Message = "Füge Pakete hinzu..."; - SubMessage = ""; - Bar1Activate(); - break; - - case LauncherProgress.ApplyUpdate: - var args2 = obj as ApplyFileEventArgs; - SubMessage = $"{args2.Name} wurde erfolgreich von \n{args2.AbsolutePath} hinzugefügt!"; - Bar1MakeStep(); - break; - - case LauncherProgress.ApplyFinished: - Message = "Hinzufügen abgeschlossen!"; - SubMessage = ""; - Bar2SetPercent(80); - Bar1Deactivate(); - break; - - case LauncherProgress.DeleteStart: - Message = "Ungebrauchte Datei(en) gefunden."; - SubMessage = ""; - break; - case LauncherProgress.DeleteUpdate: - var args3 = obj as string; - SubMessage = $"{args3} wurde entfernt!"; - break; - - case LauncherProgress.DeleteFinished: - Message = "Säuberung abgeschlossen!"; - SubMessage = ""; - Bar2SetPercent(95); - Bar1Deactivate(); - break; - - case LauncherProgress.ProgressEnd: - Message = "Installation abgeschlossen!"; - SubMessage = ""; - Bar2Fill(); - break; - default: - break; - } - } - } -} diff --git a/BeWoLauncher/View/Frames/GenericProgressFrame.xaml b/BeWoLauncher/View/Frames/ProgressFrame.xaml similarity index 91% rename from BeWoLauncher/View/Frames/GenericProgressFrame.xaml rename to BeWoLauncher/View/Frames/ProgressFrame.xaml index ed7c96d63..c1c426bdc 100644 --- a/BeWoLauncher/View/Frames/GenericProgressFrame.xaml +++ b/BeWoLauncher/View/Frames/ProgressFrame.xaml @@ -1,5 +1,5 @@  - + diff --git a/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs b/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs new file mode 100644 index 000000000..ac1a86671 --- /dev/null +++ b/BeWoLauncher/View/Frames/ProgressFrame.xaml.cs @@ -0,0 +1,237 @@ +using BeWoLauncher.Logic.Controller; +using BS.SharedLauncher.Enums; +using BS.SharedLauncher.Update; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media.Animation; + +namespace BeWoLauncher.View.Frames +{ + /// + /// Interaktionslogik für UpdateView.xaml + /// + public partial class ProgressFrame : FrameBase + { + private static TimeSpan duration = TimeSpan.FromSeconds(1); + + private int lastStep = -1; + + private string[][] keywords = new string[][] + { + new string[]{"Installation", "Ungebrauchte Datei(en) gefunden." }, + new string[]{"Update", "Ungebrauchte Datei(en) gefunden."}, + new string[]{"Deinstallation", "Deinstallation startet..."}, + }; + private int keyword_mode; + + public readonly BackgroundWorker Worker = new BackgroundWorker(); + public event EventHandler Successful; + public event EventHandler Exception; + + public LauncherMode LauncherMode { get; set; } + + public ProgressFrame(LauncherMode mode) + { + InitializeComponent(); + + proBar1.IsIndeterminate = false; + proBar1.Minimum = 0; + proBar1.Maximum = 100; + + proBar2.IsIndeterminate = false; + proBar2.Minimum = 0; + proBar2.Maximum = DownloadController.Manager.FilesToProcessTotal; + + LauncherMode = mode; + + keyword_mode = (int)mode; + + Loaded += (s, e) => Start(); + } + + private string getKeyword(int pos) => keywords[keyword_mode][pos]; + + 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; } + } + + public void Start() + { + var skipLock = bool.TryParse(ConfigurationManager.AppSettings.Get("SkipLock"), out bool c) && c; + + Worker.DoWork += worker_DoWork; + Worker.ProgressChanged += worker_ProgressChanged; + Worker.RunWorkerCompleted += worker_completed; + + Worker.WorkerReportsProgress = true; + + Worker.RunWorkerAsync(skipLock); + } + + void worker_DoWork(object sender, DoWorkEventArgs e) + { + var skipLock = (bool)e.Argument; + var worker = sender as BackgroundWorker; + + DownloadController.Manager.SkipLock = skipLock; + DownloadController.Manager.Feedback = worker.ReportProgress; + + DownloadController.Manager.StartProcess(worker); + } + + private void worker_completed(object sender, RunWorkerCompletedEventArgs e) + { + if (e.Error != null) + { + ViewController.Error = e.Error; + + Exception.Invoke(this, new EventArgs()); + } + else + { + Successful.Invoke(this, new EventArgs()); + } + } + + private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + var progress = (LauncherProgress)e.ProgressPercentage; + var obj = e.UserState; + + switch (progress) + { + case LauncherProgress.ProgressStart: + Message = $"{getKeyword(0)} wird vorbereitet..."; + SubMessage = ""; + Bar2Activate(); + break; + + case LauncherProgress.DownloadStart: + Message = "Download startet..."; + SubMessage = ""; + Bar1Show(); + Bar1Activate(); + Bar1Reset(); + Bar1SetLimit(DownloadController.Manager.FilesToDownloadCount); + break; + + case LauncherProgress.DownloadUpdate: + var args = obj as DownloadProgressEventArgs; + Message = "Download wird ausgeführt..."; + SubMessage = $"{args.File.RelativePath} ({args.Size})\n wurde heruntergeladen..."; + Bar1MakeStep(); + Bar2MakeStep(); + break; + + case LauncherProgress.DownloadFinish: + Message = "Download abgeschlossen!"; + SubMessage = ""; + Bar1Hide(); + break; + + case LauncherProgress.ApplyStart: + Message = "Füge Pakete hinzu..."; + SubMessage = ""; + Bar1Show(); + Bar1Activate(); + Bar1Reset(); + Bar1SetLimit(DownloadController.Manager.FilesToApplyCount); + break; + + case LauncherProgress.ApplyUpdate: + var args2 = obj as ApplyFileEventArgs; + SubMessage = $"{args2.RelativePath}\n wurde installiert..."; + Bar1MakeStep(); + Bar2MakeStep(); + break; + + case LauncherProgress.ApplyFinished: + Message = "Hinzufügen abgeschlossen!"; + SubMessage = ""; + Bar1Hide(); + break; + + case LauncherProgress.DeleteStart: + Message = getKeyword(1); + SubMessage = ""; + Bar1Show(); + Bar1Activate(); + Bar1Reset(); + Bar1SetLimit(DownloadController.Manager.FilesToDeleteInApplyCount); + break; + case LauncherProgress.DeleteUpdate: + var args3 = obj as string; + SubMessage = $"{args3}\n wurde entfernt!"; + Bar1MakeStep(); + Bar2MakeStep(); + break; + + case LauncherProgress.DeleteFinished: + Message = "Säuberung abgeschlossen!"; + SubMessage = ""; + Bar1Hide(); + break; + + case LauncherProgress.CleanupStart: + Message = "Räume hier noch eben auf..."; + SubMessage = ""; + Bar1Show(); + Bar1Deactivate(); + break; + + case LauncherProgress.CleanupUpdate: + break; + + case LauncherProgress.CleanupFinished: + Message = "Blitze blank..."; + SubMessage = ""; + break; + + case LauncherProgress.ProgressEnd: + Message = $"{getKeyword(0)} abgeschlossen!"; + SubMessage = ""; + Bar2Fill(); + break; + default: + break; + } + } + + #region a + public void Bar1Activate() => proBar1.IsIndeterminate = false; + public void Bar1Deactivate() => proBar1.IsIndeterminate = true; + public void Bar1SetLimit(int max) => proBar1.Maximum = max; + public void Bar1Reset() => proBar1.Value = 0; + public void Bar1MakeStep() => proBar1.Value++; + public void Bar1Hide() => proBar1.Visibility = Visibility.Hidden; + public void Bar1Show() => proBar1.Visibility = Visibility.Visible; + + public void Bar2Activate() => proBar2.IsIndeterminate = false; + public void Bar2Deactivate() => proBar2.IsIndeterminate = true; + public void Bar2SetLimit(int max) => proBar2.Maximum = max; + public void Bar2MakeStep() => proBar2.Value++; + public void Bar2MakeStep(int val) => proBar2.Value += val; + public void Bar2Fill() => proBar2.Value = proBar2.Maximum; + public void Bar2Hide() => proBar2.Visibility = Visibility.Hidden; + public void Bar2Show() => proBar2.Visibility = Visibility.Visible; + + public void Bar2SetPercent(double percentage) + { + DoubleAnimation animation = new DoubleAnimation(percentage, duration); + proBar2.BeginAnimation(ProgressBar.ValueProperty, animation); + } + #endregion + } +} diff --git a/BeWoLauncher/View/Frames/UninstallProgressInfoFrame.cs b/BeWoLauncher/View/Frames/UninstallProgressInfoFrame.cs deleted file mode 100644 index fac42c630..000000000 --- a/BeWoLauncher/View/Frames/UninstallProgressInfoFrame.cs +++ /dev/null @@ -1,69 +0,0 @@ -using BeWoLauncher.Logic.Controller; -using BS.SharedLauncher.Update; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace BeWoLauncher.View.Frames -{ - public class UninstallProgressInfoFrame : GenericProgressInfo - { - public event EventHandler UninstallSuccessful; - - public UninstallProgressInfoFrame() - { - Bar1Deactivate(); - Bar2Hide(); - } - - public override void Start() - { - Worker.DoWork += worker_DoWork; - Worker.ProgressChanged += worker_ProgressChanged; - Worker.RunWorkerCompleted += worker_completed; - - Worker.WorkerReportsProgress = true; - - Worker.RunWorkerAsync(); - } - - void worker_DoWork(object sender, DoWorkEventArgs e) - { - BackgroundWorker worker = sender as BackgroundWorker; - - DownloadController.Manager.StartUninstall(worker.ReportProgress); - } - - private void worker_completed(object sender, RunWorkerCompletedEventArgs e) - { - if (e.Error != null) - { - ViewController.ViewBehavior.UninstallFailed(e.Error); - } - else - { - UninstallSuccessful.Invoke(this, new EventArgs()); - } - } - - private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - if (e.ProgressPercentage == 3) - { - Bar1Deactivate(); - - Message = "Alte Dateien werden entfernt."; - SubMessage = ""; - } - else if (e.ProgressPercentage == 4) - { - var args = e.UserState as string; - SubMessage = $"{args} wurde entfernt!"; - } - } - } -} diff --git a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml index 55a6e1565..95a2b0c54 100644 --- a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml +++ b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml @@ -47,14 +47,6 @@ - - - - - - - - diff --git a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs index 1910c2d6d..fc2cb2cd9 100644 --- a/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs +++ b/BeWoLauncher/View/Frames/UpdateInfoFrame.xaml.cs @@ -33,7 +33,7 @@ namespace BeWoLauncher.View.Frames LauncherPaths.ActualPlanerLocation = LauncherPaths.GetInstallLocationFromSetting(); - var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.ResponseInfo.DownloadSize).Split(' '); + var size = NonspecificTools.SizeSuffix((ulong)DownloadController.Manager.UpdatePlanResponse.DownloadSize).Split(' '); lblErforderlich.Content = size[0]; lblErforderlichSize.Content = size[1]; @@ -50,22 +50,8 @@ namespace BeWoLauncher.View.Frames lblVerfuegbar.Content = size2[0] ?? "error#87"; lblVerfuegbarSize.Content = string.Empty; } - - var total = DownloadController.Manager.ResponseInfo.FileCount; - var download = DownloadController.Manager.ResponseInfo.NewFileCount; - var already = total - download; - - lblcountnew.Content = $"{download}"; - lblcountalready.Content = $"{already}"; - lblversion.Content = DownloadController.Manager.ResponseInfo.Version; - - lblcountalready.Visibility = Visibility.Hidden; - lblcountalreadytxt.Visibility = Visibility.Hidden; - lblcountnew.Visibility = Visibility.Hidden; - lblcountnewtxt.Visibility = Visibility.Hidden; - - lblfound.Visibility = already == 0 ? Visibility.Hidden : Visibility.Visible; + lblversion.Content = DownloadController.Manager.UpdatePlanResponse.CurrentPackage.Version; } private void Button_Click(object sender, RoutedEventArgs e) diff --git a/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs b/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs deleted file mode 100644 index 4a9004803..000000000 --- a/BeWoLauncher/View/Frames/UpdateProgressInfoFrame.cs +++ /dev/null @@ -1,183 +0,0 @@ -using BeWoLauncher.Logic.Controller; -using BeWoLauncher.Logic.Utils.Download; -using BS.SharedLauncher.Enums; -using BS.SharedLauncher.Update; -using System; -using System.ComponentModel; -using System.Configuration; -using System.Threading; - -namespace BeWoLauncher.View.Frames -{ - public class UpdateProgressInfoFrame : GenericProgressInfo - { - public event EventHandler UpdateSuccessful; - - public DownloadManager Manager => DownloadController.Manager; - - public UpdateProgressInfoFrame() - { - Bar1SetLimit(Manager.ResponseInfo.FileCount); - Bar1Hide(); - - Bar2SetLimit(100); - } - - public override void Start() - { - var skipLock = bool.TryParse(ConfigurationManager.AppSettings.Get("SkipLock"), out bool c) && c; - - Worker.DoWork += worker_DoWork; - Worker.ProgressChanged += worker_ProgressChanged; - Worker.RunWorkerCompleted += worker_completed; - - Worker.WorkerReportsProgress = true; - - Worker.RunWorkerAsync(skipLock); - } - - void worker_DoWork(object sender, DoWorkEventArgs e) - { - bool skipLock = (bool)e.Argument; - - BackgroundWorker worker = sender as BackgroundWorker; - - // UI: 0 - worker.ReportProgress((int)LauncherProgress.ProgressStart); - - // Wait - Thread.Sleep(1000); - - // UI: 1 - worker.ReportProgress((int)LauncherProgress.DownloadStart); - - // Wait - Thread.Sleep(500); - - // Process: 2 - DownloadController.Manager.StartDownload(skipLock, worker.ReportProgress); - - // UI: 3 - worker.ReportProgress((int)LauncherProgress.DownloadFinish); - - // Wait - Thread.Sleep(1000); - - // UI: 4 - worker.ReportProgress((int)LauncherProgress.ApplyStart); - - // Wait - Thread.Sleep(500); - - // Process: 5 - DownloadController.Manager.StartApply(skipLock, worker.ReportProgress); - - // UI: 6 - worker.ReportProgress((int)LauncherProgress.ApplyFinished); - - // Wait - Thread.Sleep(1000); - - // Process: 7, Wait, 8 - DownloadController.Manager.StartCleanup(worker.ReportProgress); - - // UI: 9 - worker.ReportProgress((int)LauncherProgress.DeleteFinished); - - // Wait - Thread.Sleep(500); - - // UI: 10 - worker.ReportProgress((int)LauncherProgress.ProgressEnd); - } - - private void worker_completed(object sender, RunWorkerCompletedEventArgs e) - { - if (e.Error != null) - { - ViewController.ViewBehavior.UpdateFailed(e.Error); - } - else - { - UpdateSuccessful.Invoke(this, new EventArgs()); - } - } - - private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - var progress = (LauncherProgress)e.ProgressPercentage; - var obj = e.UserState; - - switch (progress) - { - case LauncherProgress.ProgressStart: - Message = "Update wird vorbereitet..."; - SubMessage = "Lade benötigte Pakete herunter..."; - break; - - case LauncherProgress.DownloadStart: - Message = "Download startet..."; - SubMessage = ""; - Bar1Show(); - Bar1Deactivate(); - Bar2SetPercent(5); - break; - - case LauncherProgress.DownloadUpdate: - throw new NotImplementedException("#fd42398"); - var args = obj as DownloadProgressEventArgs; - SubMessage = $"{args.Progress.ToString("0.##")}% fertig"; - break; - - case LauncherProgress.DownloadFinish: - Message = "Download abgeschlossen!"; - SubMessage = ""; - Bar2SetPercent(40); - break; - - case LauncherProgress.ApplyStart: - Message = "Füge Pakete hinzu..."; - SubMessage = ""; - Bar1Activate(); - break; - - case LauncherProgress.ApplyUpdate: - var args2 = obj as ApplyFileEventArgs; - SubMessage = $"{args2.Name} wurde erfolgreich von \n{args2.AbsolutePath} hinzugefügt!"; - Bar1MakeStep(); - break; - - case LauncherProgress.ApplyFinished: - Message = "Hinzufügen abgeschlossen!"; - SubMessage = ""; - Bar2SetPercent(80); - Bar1Deactivate(); - break; - - case LauncherProgress.DeleteStart: - Message = "Ungebrauchte Datei(en) gefunden."; - SubMessage = ""; - break; - case LauncherProgress.DeleteUpdate: - var args3 = obj as string; - SubMessage = $"{args3} wurde entfernt!"; - break; - - case LauncherProgress.DeleteFinished: - Message = "Säuberung abgeschlossen!"; - SubMessage = ""; - Bar2SetPercent(95); - Bar1Deactivate(); - break; - - case LauncherProgress.ProgressEnd: - Message = "Installation abgeschlossen!"; - SubMessage = ""; - Bar2Fill(); - break; - default: - break; - } - } - } -} diff --git a/BeWoLauncher/View/LoginView.xaml.cs b/BeWoLauncher/View/LoginView.xaml.cs index 6bb6cd0df..cf5fe7352 100644 --- a/BeWoLauncher/View/LoginView.xaml.cs +++ b/BeWoLauncher/View/LoginView.xaml.cs @@ -12,7 +12,6 @@ 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; @@ -61,7 +60,7 @@ 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(); @@ -113,19 +112,19 @@ namespace BeWoLauncher.View private void button_login_Click(object sender, RoutedEventArgs e) { - if (!String.IsNullOrEmpty(ConnectionInformation.ProxyName)) + if (!String.IsNullOrEmpty(SessionInformation.Connection.ProxyName)) { var webProxy = WebProxy.GetDefaultProxy(); webProxy.UseDefaultCredentials = true; - System.Net.WebRequest.DefaultWebProxy = new WebProxy(ConnectionInformation.ProxyName, true); + System.Net.WebRequest.DefaultWebProxy = new WebProxy(SessionInformation.Connection.ProxyName, true); - if (String.IsNullOrEmpty(ConnectionInformation.ProxyUsername)) + if (String.IsNullOrEmpty(SessionInformation.Connection.ProxyUsername)) { WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials; } else { - WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(ConnectionInformation.ProxyUsername, ConnectionInformation.ProxyPassword); + WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(SessionInformation.Connection.ProxyUsername, SessionInformation.Connection.ProxyPassword); } } @@ -168,18 +167,17 @@ namespace BeWoLauncher.View ViewController.StartWaiting(); - string lUserName = TextBox_Username.Text; - string lPassword = PasswordBox_Password.Password; - string lPIN = PINTextBox.Text; - string lTenant = ConnectionInformation.Tenant; + SessionInformation.Login.Username = TextBox_Username.Text; + SessionInformation.Login.Password = PasswordBox_Password.Password; + SessionInformation.Login.Pin = PINTextBox.Text; - if (!String.IsNullOrEmpty(lPIN)) + if (!String.IsNullOrEmpty(SessionInformation.Login.Pin)) { - lPIN += "_" + System.Environment.MachineName; + SessionInformation.Login.Pin += "_" + System.Environment.MachineName; } - Action action = Login; - action.BeginInvoke(lUserName, lPassword, lTenant, lPIN, cb => { }, null); + Action action = Login; + action.BeginInvoke(cb => { }, null); } } private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) @@ -358,12 +356,12 @@ namespace BeWoLauncher.View string v1, v2; paramDic.TryGetValue("k", out v1); paramDic.TryGetValue("s", out v2); - ConnectionInformation.Tenant = v1; - ConnectionInformation.ServerName = v2; + SessionInformation.Login.Tenant = v1; + SessionInformation.Connection.Servername = v2; if (ProfileList.Count > 0) - ProfileList.Insert(0, new ConnectionProfile(v1, v2, ConnectionInformation.Tenant)); + ProfileList.Insert(0, new ConnectionProfile(v1, v2, SessionInformation.Login.Tenant)); else - ProfileList.Add(new ConnectionProfile(v1, v2, ConnectionInformation.Tenant)); + ProfileList.Add(new ConnectionProfile(v1, v2, SessionInformation.Login.Tenant)); SaveProfileListToFile(); #else if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.ActivationUri != null) @@ -460,19 +458,19 @@ namespace BeWoLauncher.View ChangeServerAndTenant(profileSelectionComboBox.SelectedItem as ConnectionProfile); - if (!String.IsNullOrEmpty(ConnectionInformation.ProxyName)) + if (!String.IsNullOrEmpty(SessionInformation.Connection.ProxyName)) { var webProxy = WebProxy.GetDefaultProxy(); webProxy.UseDefaultCredentials = true; - System.Net.WebRequest.DefaultWebProxy = new WebProxy(ConnectionInformation.ProxyName, true); + System.Net.WebRequest.DefaultWebProxy = new WebProxy(SessionInformation.Connection.ProxyName, true); - if (String.IsNullOrEmpty(ConnectionInformation.ProxyUsername)) + if (String.IsNullOrEmpty(SessionInformation.Connection.ProxyUsername)) { WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials; } else { - WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(ConnectionInformation.ProxyUsername, ConnectionInformation.ProxyPassword); + WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(SessionInformation.Connection.ProxyUsername, SessionInformation.Connection.ProxyPassword); } } } @@ -629,14 +627,14 @@ namespace BeWoLauncher.View { Uri path = new Uri(adminUrl); - ConnectionInformation.IpAddress = Encoding.UTF8.GetString(wc.DownloadData(path)); + SessionInformation.Connection.IpAddress = Encoding.UTF8.GetString(wc.DownloadData(path)); } } } catch (Exception) { - ConnectionInformation.IpAddress = String.Empty; + SessionInformation.Connection.IpAddress = String.Empty; } } private string GetAdminUrl() @@ -706,11 +704,11 @@ namespace BeWoLauncher.View file.Close(); - ConnectionInformation.ProxyName = datai[0]; - ConnectionInformation.ProxyUsername = datai[1]; - ConnectionInformation.ProxyPassword = datai[2]; + SessionInformation.Connection.ProxyName = datai[0]; + SessionInformation.Connection.ProxyUsername = datai[1]; + SessionInformation.Connection.ProxyPassword = datai[2]; - proxyTextBox.Text = ConnectionInformation.ProxyName; + proxyTextBox.Text = SessionInformation.Connection.ProxyName; } catch (IOException) @@ -847,11 +845,16 @@ namespace BeWoLauncher.View SaveProfileListToFile(); } - ConnectionInformation.Tenant = profile.Tenant; - ConnectionInformation.ServerName = GetNumericServerName(profile.Server); - ConnectionInformation.LauncherServerAddress = profile.Server; + SessionInformation.Login.Tenant = profile.Tenant; + SessionInformation.Connection.Servername = GetNumericServerName(profile.Server); + SessionInformation.Connection.CoreServerAddress = profile.Server; + SessionInformation.Connection.DownloadServerAddress = profile.Server; #if DEBUG + + SessionInformation.Connection.DownloadServerAddress = SessionInformation.GetDebugConnection(1); + SessionInformation.Connection.CoreServerAddress = SessionInformation.GetDebugConnection(2); + //CB ZUM TESTEN //ConnectionInformation.Tenant = "9876543210"; //ConnectionInformation.ServerName = "4"; @@ -1010,20 +1013,20 @@ namespace BeWoLauncher.View return true; #endif } - private void Login(String lUserName, String lPassword, String lTenant, String lPIN) + private void Login() { try { //1. Versuch - UserValidationResult result = TryLogin(lUserName, lPassword, lPIN); + UserValidationResult result = TryLogin(); //2. Versuch if (result == UserValidationResult.UnknownError) { - LauncherServiceFacade.DoLauncherServiceAsync(op => op.ResetTenant(lTenant), + LauncherServiceFacade.DoLauncherServiceAsync(op => op.ResetTenant(SessionInformation.Login.Tenant), delegate { - result = TryLogin(lUserName, lPassword, lPIN); + result = TryLogin(); if (result == UserValidationResult.UnknownError) { @@ -1031,7 +1034,7 @@ namespace BeWoLauncher.View LauncherServiceFacade.DoLauncherServiceAsync(op => op.ResetAllTenant(), delegate { - result = TryLogin(lUserName, lPassword, lPIN); + result = TryLogin(); if (result == UserValidationResult.UnknownError) { @@ -1059,14 +1062,14 @@ namespace BeWoLauncher.View this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate { ViewController.EndWaiting(); - MessageBox.Show("Die Kundennummer '" + lTenant + "' ist ungültig.", "Fehler bei der Anmeldung", MessageBoxButton.OK, MessageBoxImage.Exclamation); + MessageBox.Show("Die Kundennummer '" + SessionInformation.Login.Tenant + "' ist ungültig.", "Fehler bei der Anmeldung", MessageBoxButton.OK, MessageBoxImage.Exclamation); }); } - String pin = lPIN; + String pin = SessionInformation.Login.Pin; - if (!String.IsNullOrEmpty(lPIN) && lPIN.IndexOf('_') >= 0) + if (!String.IsNullOrEmpty(SessionInformation.Login.Pin) && SessionInformation.Login.Pin.IndexOf('_') >= 0) { - pin = lPIN.Substring(0, lPIN.IndexOf('_')); + pin = SessionInformation.Login.Pin.Substring(0, SessionInformation.Login.Pin.IndexOf('_')); } if (result == UserValidationResult.IncorrectPin) @@ -1115,13 +1118,12 @@ namespace BeWoLauncher.View LauncherApp.ShowError(ex); //MessageBox.Show(ex.Message); } } - private UserValidationResult TryLogin(string lUserName, string lPassword, string lPIN = "") + private UserValidationResult TryLogin() { UserValidationResult? result = null; - if (!string.IsNullOrEmpty(lUserName) && !string.IsNullOrEmpty(lPassword)) + if (!string.IsNullOrEmpty(SessionInformation.Login.Username) && !string.IsNullOrEmpty(SessionInformation.Login.Password)) { - String tempUsername = lUserName; String version = "unbekannt"; String clr = "unbekannt"; var bewoVersion = LauncherApp.Version; @@ -1145,14 +1147,17 @@ namespace BeWoLauncher.View } - tempUsername = String.Format("{0}//Version={1};CLRVersion={2};BeWoVersion={3};IsNet45OrNewer={4}", lUserName, version, clr, bewoVersion, isNet45OrNewer); + SessionInformation.Login.TempUsername = + $"{SessionInformation.Login.Username}" + + $"//Version={version};CLRVersion={clr};BeWoVersion={bewoVersion};IsNet45OrNewer={isNet45OrNewer}"; try { LauncherServiceFacade.DoLauncherServiceAsync(s => { try { - var t = s.IsUserValid(tempUsername, lPassword, lPIN, "BeWoClient", true); + SessionInformation.Login.ClientId = "BeWoClient"; + var t = s.IsUserValid(SessionInformation.Login.TempUsername, SessionInformation.Login.Password, SessionInformation.Login.Pin, SessionInformation.Login.ClientId, true); return t; } catch (Exception e) @@ -1163,7 +1168,7 @@ namespace BeWoLauncher.View r => { result = r; - Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate { LoginResult(r, lUserName, lPassword, lPIN); }); + Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate { LoginResult(r); }); }, true); } catch (Exception e) @@ -1184,13 +1189,10 @@ namespace BeWoLauncher.View return result.Value; } - private void LoginResult(UserValidationResult result, String lUserName, String lPassword, String lPIN = "") + private void LoginResult(UserValidationResult result) { if (result == UserValidationResult.UserValid) { - ConnectionInformation.Username = lUserName; - ConnectionInformation.Password = lPassword; - LoginSuccessful.Invoke(this, new EventArgs()); } else if (result == UserValidationResult.PasswordExpired) @@ -1205,9 +1207,6 @@ namespace BeWoLauncher.View if (!window.Abbruch) { - ConnectionInformation.Username = lUserName; - ConnectionInformation.Password = lPassword; - LoginSuccessful.Invoke(this, new EventArgs()); } }); diff --git a/BeWoOhneReports.sln b/BeWoOhneReports.sln index 6df300f17..b029612d0 100644 --- a/BeWoOhneReports.sln +++ b/BeWoOhneReports.sln @@ -31,10 +31,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatController", "..\Chat\C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeWoLauncher", "BeWoLauncher\BeWoLauncher.csproj", "{E3BA193A-A64F-4CE6-91BE-F54E551797BE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LauncherHost", "LauncherHost\LauncherHost.csproj", "{18019E8C-C6DA-4B1B-9C2B-908BC14911AB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DownloadServer", "DownloadServer\DownloadServer.csproj", "{18019E8C-C6DA-4B1B-9C2B-908BC14911AB}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedLauncher", "SharedLauncher\SharedLauncher.csproj", "{EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CA77E4CE-37D5-489D-9009-ACC75DFC421E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeWoTest", "BeWoTest\BeWoTest.csproj", "{767ACFAF-D6ED-4DFD-AC49-0990F23B2239}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{825B9513-40EF-48C1-A354-9D4503A3FA74}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -173,6 +179,30 @@ Global {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Any CPU.Build.0 = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|.NET.ActiveCfg = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|.NET.Build.0 = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Any CPU.Build.0 = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|.NET.ActiveCfg = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|.NET.Build.0 = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Any CPU.ActiveCfg = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Any CPU.Build.0 = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|.NET.ActiveCfg = Debug|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|.NET.Build.0 = Debug|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|.NET.ActiveCfg = Release|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|.NET.Build.0 = Release|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Any CPU.Build.0 = Release|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {825B9513-40EF-48C1-A354-9D4503A3FA74}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -188,6 +218,7 @@ Global {8A83C4DC-A0B1-4A51-AE1D-366D7A05B298} = {E7543C39-A44C-40C9-82C9-E7FAA2D9A852} {E3BA193A-A64F-4CE6-91BE-F54E551797BE} = {E7543C39-A44C-40C9-82C9-E7FAA2D9A852} {18019E8C-C6DA-4B1B-9C2B-908BC14911AB} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A} + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239} = {CA77E4CE-37D5-489D-9009-ACC75DFC421E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {5352BE53-F2FD-442F-85A8-4157599AA153} diff --git a/BeWoTest/App.config b/BeWoTest/App.config new file mode 100644 index 000000000..8e1564635 --- /dev/null +++ b/BeWoTest/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/BeWoTest/App.xaml b/BeWoTest/App.xaml new file mode 100644 index 000000000..18bc591a4 --- /dev/null +++ b/BeWoTest/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/BeWoTest/App.xaml.cs b/BeWoTest/App.xaml.cs new file mode 100644 index 000000000..36acbfa16 --- /dev/null +++ b/BeWoTest/App.xaml.cs @@ -0,0 +1,22 @@ +using BS.SharedLauncher.Information; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace BeWoTest +{ + /// + /// Interaktionslogik für "App.xaml" + /// + public partial class App : Application + { + protected override void OnStartup(StartupEventArgs e) + { + SessionInformation.LoadPipe(e.Args[0]); + } + } +} diff --git a/BeWoTest/BeWoTest.csproj b/BeWoTest/BeWoTest.csproj new file mode 100644 index 000000000..468cac3c2 --- /dev/null +++ b/BeWoTest/BeWoTest.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {767ACFAF-D6ED-4DFD-AC49-0990F23B2239} + WinExe + BeWoTest + BeWoPlaner + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {EFE05C79-E0DD-4311-8B90-A8DA7EBDF36F} + SharedLauncher + + + + \ No newline at end of file diff --git a/BeWoTest/MainWindow.xaml b/BeWoTest/MainWindow.xaml new file mode 100644 index 000000000..b1179c36c --- /dev/null +++ b/BeWoTest/MainWindow.xaml @@ -0,0 +1,16 @@ + + + + + adafsafdssssssssssssssssssssssssssssssssgfddddddddddddddddddddddfkjaghuiareghuirgheaurighbireuahgiuaerhgiuaerghhergaihhgaressssssssssssasdf + + + + diff --git a/BeWoTest/MainWindow.xaml.cs b/BeWoTest/MainWindow.xaml.cs new file mode 100644 index 000000000..6f1bac2ee --- /dev/null +++ b/BeWoTest/MainWindow.xaml.cs @@ -0,0 +1,33 @@ +using BS.SharedLauncher.Information; +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 BeWoTest +{ + /// + /// Interaktionslogik für MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + + testtxt.Text = SessionInformation.ToString(); + + Console.WriteLine("GUI geladen"); + } + } +} diff --git a/BeWoTest/Properties/AssemblyInfo.cs b/BeWoTest/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..165eca48e --- /dev/null +++ b/BeWoTest/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("BeWoTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BeWoTest")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie +//ImCodeVerwendeteKultur in der .csproj-Datei +//in einer fest. Wenn Sie in den Quelldateien beispielsweise Deutsch +//(Deutschland) verwenden, legen Sie auf \"de-DE\" fest. Heben Sie dann die Auskommentierung +//des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile, +//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher + //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird, + // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.) + ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs + //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird, + // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.) +)] + + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/BeWoTest/Properties/Resources.Designer.cs b/BeWoTest/Properties/Resources.Designer.cs new file mode 100644 index 000000000..f152c10f2 --- /dev/null +++ b/BeWoTest/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion: 4.0.30319.42000 +// +// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn +// der Code neu generiert wird. +// +//------------------------------------------------------------------------------ + +namespace BeWoTest.Properties +{ + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder-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 Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BeWoTest.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/BeWoTest/Properties/Resources.resx b/BeWoTest/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/BeWoTest/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeWoTest/Properties/Settings.Designer.cs b/BeWoTest/Properties/Settings.Designer.cs new file mode 100644 index 000000000..bb4981e3c --- /dev/null +++ b/BeWoTest/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace BeWoTest.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/BeWoTest/Properties/Settings.settings b/BeWoTest/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/BeWoTest/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/LauncherHost/DownloadBeWoService.svc b/DownloadServer/DownloadBeWoService.svc similarity index 100% rename from LauncherHost/DownloadBeWoService.svc rename to DownloadServer/DownloadBeWoService.svc diff --git a/LauncherHost/LauncherHost.csproj b/DownloadServer/DownloadServer.csproj similarity index 95% rename from LauncherHost/LauncherHost.csproj rename to DownloadServer/DownloadServer.csproj index 2c079e930..a40ffbf81 100644 --- a/LauncherHost/LauncherHost.csproj +++ b/DownloadServer/DownloadServer.csproj @@ -12,12 +12,13 @@ {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties - LauncherHost - LauncherHost + DownloadServer + DownloadServer v4.7.2 true - + + @@ -78,9 +79,7 @@ - - Designer @@ -108,6 +107,10 @@ {094331c3-ecee-4c89-bbfd-4c9ded89f0ef} Service + + {efe05c79-e0dd-4311-8b90-a8da7ebdf36f} + SharedLauncher + diff --git a/LauncherHost/LauncherHost.csproj.user b/DownloadServer/DownloadServer.csproj.user similarity index 96% rename from LauncherHost/LauncherHost.csproj.user rename to DownloadServer/DownloadServer.csproj.user index f95380675..eac4167e7 100644 --- a/LauncherHost/LauncherHost.csproj.user +++ b/DownloadServer/DownloadServer.csproj.user @@ -3,7 +3,8 @@ true - + + diff --git a/DownloadServer/DownloadServerServiceReferences.bat b/DownloadServer/DownloadServerServiceReferences.bat new file mode 100644 index 000000000..2d8fa49ad --- /dev/null +++ b/DownloadServer/DownloadServerServiceReferences.bat @@ -0,0 +1 @@ +svcutil.exe /noConfig /edb /n:*,DownloadServer.ServiceProxy /out:ServiceProxy\DownloadGenerated.cs /ct:System.Collections.Generic.List`1 /r:..\SharedLauncher\bin\Debug\BS.SharedLauncher.dll http://localhost:3777/Host/LauncherService.svc?wsdl \ No newline at end of file diff --git a/LauncherHost/Multitenancy/Symbol Edit.png b/DownloadServer/Multitenancy/Symbol Edit.png similarity index 100% rename from LauncherHost/Multitenancy/Symbol Edit.png rename to DownloadServer/Multitenancy/Symbol Edit.png diff --git a/LauncherHost/Multitenancy/debug.config b/DownloadServer/Multitenancy/debug.config similarity index 100% rename from LauncherHost/Multitenancy/debug.config rename to DownloadServer/Multitenancy/debug.config diff --git a/LauncherHost/Multitenancy/debugMsSQL.config b/DownloadServer/Multitenancy/debugMsSQL.config similarity index 100% rename from LauncherHost/Multitenancy/debugMsSQL.config rename to DownloadServer/Multitenancy/debugMsSQL.config diff --git a/LauncherHost/Multitenancy/debugMySQL.config b/DownloadServer/Multitenancy/debugMySQL.config similarity index 100% rename from LauncherHost/Multitenancy/debugMySQL.config rename to DownloadServer/Multitenancy/debugMySQL.config diff --git a/LauncherHost/Multitenancy/demo.config b/DownloadServer/Multitenancy/demo.config similarity index 100% rename from LauncherHost/Multitenancy/demo.config rename to DownloadServer/Multitenancy/demo.config diff --git a/LauncherHost/Properties/AssemblyInfo.cs b/DownloadServer/Properties/AssemblyInfo.cs similarity index 100% rename from LauncherHost/Properties/AssemblyInfo.cs rename to DownloadServer/Properties/AssemblyInfo.cs diff --git a/LauncherHost/Web.Debug.config b/DownloadServer/Web.Debug.config similarity index 100% rename from LauncherHost/Web.Debug.config rename to DownloadServer/Web.Debug.config diff --git a/LauncherHost/Web.Release.config b/DownloadServer/Web.Release.config similarity index 100% rename from LauncherHost/Web.Release.config rename to DownloadServer/Web.Release.config diff --git a/LauncherHost/Web.config b/DownloadServer/Web.config similarity index 87% rename from LauncherHost/Web.config rename to DownloadServer/Web.config index 96e9fb899..c49cca32b 100644 --- a/LauncherHost/Web.config +++ b/DownloadServer/Web.config @@ -44,17 +44,24 @@ + + + + + + + @@ -74,6 +81,9 @@ + + + @@ -86,14 +96,6 @@ - - - - - - diff --git a/LauncherHost/packages.config b/DownloadServer/packages.config similarity index 100% rename from LauncherHost/packages.config rename to DownloadServer/packages.config diff --git a/LauncherHost/EnumTranslationService.svc b/Host/EnumTranslationService.svc similarity index 100% rename from LauncherHost/EnumTranslationService.svc rename to Host/EnumTranslationService.svc diff --git a/Host/Host.csproj b/Host/Host.csproj index 6cc7736e6..8833d7521 100644 --- a/Host/Host.csproj +++ b/Host/Host.csproj @@ -21,7 +21,8 @@ true - + + @@ -196,6 +197,8 @@ + + diff --git a/Host/Host.csproj.user b/Host/Host.csproj.user index 7eda74d9d..d4f1ce7a0 100644 --- a/Host/Host.csproj.user +++ b/Host/Host.csproj.user @@ -5,7 +5,8 @@ true Debug|Any CPU - + + diff --git a/LauncherHost/LauncherService.svc b/Host/LauncherService.svc similarity index 100% rename from LauncherHost/LauncherService.svc rename to Host/LauncherService.svc diff --git a/Host/Web.config b/Host/Web.config index 45b154b59..0ec77dd6d 100644 --- a/Host/Web.config +++ b/Host/Web.config @@ -156,6 +156,12 @@ + + + + + + diff --git a/Service/Multitenancy/DMultitenancyEndpointBehavior.cs b/Service/Multitenancy/DMultitenancyEndpointBehavior.cs new file mode 100644 index 000000000..5def827ca --- /dev/null +++ b/Service/Multitenancy/DMultitenancyEndpointBehavior.cs @@ -0,0 +1,28 @@ +using System; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; +using System.ServiceModel.Dispatcher; + +namespace BeWo.Service.Multitenancy +{ + public class DMultitenancyEndpointBehavior : IEndpointBehavior + { + public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) + { + } + + public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) + { + clientRuntime.MessageInspectors.Add(new DMultitenancyInterceptor()); + } + + public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) + { + throw new NotImplementedException("This is a client behavior only"); + } + + public void Validate(ServiceEndpoint endpoint) + { + } + } +} \ No newline at end of file diff --git a/Service/Multitenancy/DMultitenancyHeader.cs b/Service/Multitenancy/DMultitenancyHeader.cs new file mode 100644 index 000000000..6186a9160 --- /dev/null +++ b/Service/Multitenancy/DMultitenancyHeader.cs @@ -0,0 +1,39 @@ +using System.ServiceModel.Channels; +using System.Xml; + +namespace BeWo.Service.Multitenancy +{ + public class DMultitenancyHeader : MessageHeader + { + public override bool MustUnderstand + { + get + { + return false; + } + } + + public override string Name + { + get + { + return "Multitenancy"; + } + } + + public override string Namespace + { + get + { + return "http://beyondsoft.de/Multitenancy.xsd"; + } + } + + public string Tenant { get; set; } + + protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion) + { + writer.WriteElementString("Tenant", this.Tenant); + } + } +} \ No newline at end of file diff --git a/Service/Multitenancy/DMultitenancyInterceptor.cs b/Service/Multitenancy/DMultitenancyInterceptor.cs new file mode 100644 index 000000000..766a6d193 --- /dev/null +++ b/Service/Multitenancy/DMultitenancyInterceptor.cs @@ -0,0 +1,21 @@ +using BS.SharedLauncher; +using BS.SharedLauncher.Information; +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.ServiceModel.Dispatcher; + +namespace BeWo.Service.Multitenancy +{ + public class DMultitenancyInterceptor : IClientMessageInspector + { + public void AfterReceiveReply(ref Message reply, object correlationState) + { + } + + public object BeforeSendRequest(ref Message request, IClientChannel channel) + { + request.Headers.Add(new DMultitenancyHeader { Tenant = SessionInformation.Login.Tenant }); + return null; + } + } +} \ No newline at end of file diff --git a/Service/Service.csproj b/Service/Service.csproj index 4e92203d5..234e2a7a3 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -393,9 +393,12 @@ + + + @@ -476,10 +479,12 @@ + + - - + + diff --git a/Service/ServiceContracts/IDownloadBeWoService.cs b/Service/ServiceContracts/IDownloadBeWoService.cs index ecfd9daf9..e9afdcc51 100644 --- a/Service/ServiceContracts/IDownloadBeWoService.cs +++ b/Service/ServiceContracts/IDownloadBeWoService.cs @@ -12,10 +12,18 @@ namespace BeWo.Service.ServiceContracts { [FaultContract(typeof(BeWoFault))] [OperationContract] - DownloadPlanerResponseDC Download2(DownloadPlanerRequestDC request); + UpdateFileResponse Download2(UpdatePlanRequest request); [FaultContract(typeof(BeWoFault))] [OperationContract] - DownloadPlanerResponseInfoDC DownloadInfo(DownloadPlanerRequestDC request); + UpdatePlanResponse DownloadInfo(UpdatePlanRequest request); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + UpdatePlanResponse GetUpdatePlan(UpdatePlanRequest request); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + UpdateFileResponse GetUpdateFile(UpdateFileRequest request); } } \ No newline at end of file diff --git a/Service/ServiceImplementations/DownloadBeWoServiceImp.cs b/Service/ServiceImplementations/DownloadBeWoServiceImp.cs index e98f37bdc..25e41b202 100644 --- a/Service/ServiceImplementations/DownloadBeWoServiceImp.cs +++ b/Service/ServiceImplementations/DownloadBeWoServiceImp.cs @@ -8,12 +8,14 @@ using System.ServiceModel; using System.Xml; using BeWo.Data; using BeWo.Service.ServiceContracts; +using BeWo.Service.ServiceProxy; using BeWo.Service.ServiceUtils.Paths; using BeWo.Service.ServiceUtils.Update; using BS.SharedLauncher.DataContract; using BS.SharedLauncher.Enums; using BS.SharedLauncher.Exceptions; using BS.SharedLauncher.Extensions; +using BS.SharedLauncher.Information; using BS.SharedLauncher.Logic; using BS.SharedLauncher.Update; @@ -24,23 +26,29 @@ namespace BeWo.Service.ServiceImplementations { public string Tenant => MultitenancyOperationContextExt.Current.Tenant; - public DownloadPlanerResponseDC Download2(DownloadPlanerRequestDC request) + public UpdateFileResponse Download2(UpdatePlanRequest request) + { + return null; + } + public UpdatePlanResponse DownloadInfo(UpdatePlanRequest request) + { + return null; + } + + + public UpdatePlanResponse GetUpdatePlan(UpdatePlanRequest request) { try { - DownloadPlanerResponseBuilder builder = new DownloadPlanerResponseBuilder(request); + if (!isUpdatePlanRequestValid(request)) + throw new InvalidUpdatePlanRequestException(); - builder.Calculate(Tenant); + if (!VerifyLogin(request)) + throw new InvalidUpdatePlanRequestException("Login konnte nicht aufm Download Server verifiziert werden."); - if (!request.ApplyFolderIsEmpty) - if (request.ApplyPackage is object) - builder.Substract(request.ApplyPackage.ToPlanerPackageInfo()); + var response = UpdatePlanResponseBuilder.GetUpdatePlanResponse(request, Tenant); - if (!request.DownloadFolderIsEmpty) - if (request.DownloadedPackages is object) - builder.AnalyseDownload(request.DownloadedPackages.ToDictionary(pair => pair.Key, pair => pair.Value.ToPlanerPackageInfo())); - - return builder.CreateResponse(request); + return response; } catch (UpdateException update) { @@ -48,35 +56,20 @@ namespace BeWo.Service.ServiceImplementations } catch (Exception ex) { - throw new UpdateException("Update - Download - Exception", ex); + throw new UpdateException("Update - GetUpdatePlan - Exception", ex); } } - public DownloadPlanerResponseInfoDC DownloadInfo(DownloadPlanerRequestDC request) + public UpdateFileResponse GetUpdateFile(UpdateFileRequest request) { try { - var responseInfo = new DownloadPlanerResponseInfoDC(); + if (!isUpdateFileRequestValid(request)) + throw new InvalidUpdateFileRequestException(); + + var response = UpdateFileResponseBuilder.GetUpdateFileResponse(request, Tenant); - var response = Download2(request); - - responseInfo.DownloadSize = response.NewZipData?.LongLength ?? 0; - responseInfo.FileCount = 0; - - if (response.DownloadFilesToKeep is object) - responseInfo.FileCount += response.DownloadFilesToKeep.Sum(kv => kv.Value.Count); - - if (response.NewZipInfo is object) - { - responseInfo.FileCount += response.NewZipInfo.Files.Count; - responseInfo.NewFileCount = response.NewZipInfo.Files.Count; - } - - responseInfo.HasSomethingToDo = response.HasToDo(); - - responseInfo.Version = response.LatestApplicationInfo.Version; - - return responseInfo; + return response; } catch (UpdateException update) { @@ -84,8 +77,38 @@ namespace BeWo.Service.ServiceImplementations } catch (Exception ex) { - throw new UpdateException("Update - DownloadInfo - Exception", ex); + throw new UpdateException("Update - GetUpdateFile - Exception", ex); } } + + private bool VerifyLogin(UpdatePlanRequest request) + { + SessionInformation.Login.Username = request.Login.Username; + SessionInformation.Login.Password = request.Login.Password; + SessionInformation.Login.Tenant = Tenant; + + ServiceFacade.UpdateServerAddresses(request.Login.CoreServerAddress); + + var result = ServiceFacade.DoLauncherServiceSync(x => x.IsUserValid(request.Login.TempUsername, request.Login.Password, request.Login.Pin, request.Login.ClientID, true)); + + if (result == UserValidationResult.UserValid) + return true; + + return false; + } + + private bool isUpdatePlanRequestValid(UpdatePlanRequest request) + { + return true; + } + + private bool isUpdateFileRequestValid(UpdateFileRequest request) + { + // Check for Login + // Check for Correct Version + // Check for File Permissions + + return true; + } } } \ No newline at end of file diff --git a/Service/ServiceImplementations/LauncherServiceImp.cs b/Service/ServiceImplementations/LauncherServiceImp.cs index d0f26a114..924f23c94 100644 --- a/Service/ServiceImplementations/LauncherServiceImp.cs +++ b/Service/ServiceImplementations/LauncherServiceImp.cs @@ -139,7 +139,7 @@ namespace BeWo.Service.ServiceImplementations { try { - var user = DAOFactory.UserDAO.FindUserByLoginName(ConnectionInformation.Username); + var user = DAOFactory.UserDAO.FindUserByLoginName(SessionInformation.Login.Username); var version = (new UserServiceImp()).ChangePassword(pUserName, user.Version.Value, pOldPassword, pNewPassword); @@ -156,7 +156,7 @@ namespace BeWo.Service.ServiceImplementations { try { - var user = DAOFactory.UserDAO.FindUserByLoginName(ConnectionInformation.Username); + var user = DAOFactory.UserDAO.FindUserByLoginName(SessionInformation.Login.Username); user.ResetPasswordInfos.ForEach(f => f.HasToChangePW = false); diff --git a/Service/ServiceImplementations/UserServiceImp.cs b/Service/ServiceImplementations/UserServiceImp.cs index adfab87f2..a3a1c6e5f 100644 --- a/Service/ServiceImplementations/UserServiceImp.cs +++ b/Service/ServiceImplementations/UserServiceImp.cs @@ -47,8 +47,6 @@ namespace BeWo.Service.ServiceImplementations { allowChange = true; } - - } if (allowChange) diff --git a/Service/ServiceProxy/ServiceFacade.cs b/Service/ServiceProxy/ServiceFacade.cs new file mode 100644 index 000000000..de6c79c76 --- /dev/null +++ b/Service/ServiceProxy/ServiceFacade.cs @@ -0,0 +1,116 @@ +using BeWo.Service.Multitenancy; +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Service.ServiceProxy +{ + public class ServiceFacade + { + public static object _Lock = string.Empty; + + private static Dictionary _EndpointAddresses; + private static readonly Dictionary _ProxyCache; + + private static int _RunningAsyncs; + + public static void UpdateServerAddresses(string main) + { + var serverName2 = main; + if (serverName2.Substring(serverName2.Length - 1, 1) != "/") + serverName2 += "/"; + + _EndpointAddresses = new Dictionary + { + { typeof(ILauncherService), new EndpointAddress(serverName2 + "LauncherService.svc") } + }; + } + + static ServiceFacade() + { + _ProxyCache = new Dictionary(); + } + + public static void DoLauncherServiceSync(Action pAction) + { + try + { + pAction.Invoke(GetInstance()); + } + catch (Exception e) + { + // if (HandleServiceProxyException(e)) + // throw e; + throw e; + } + } + public static T DoLauncherServiceSync(Func pFunc) + { + try + { + return pFunc.Invoke(GetInstance()); + } + catch (Exception e) + { + throw e; + } + return default(T); + } + + private static TInterface GetInstance() + where TClient : ClientBase, TInterface, new() + where TInterface : class + { + TClient lClient = null; + if (_ProxyCache.ContainsKey(typeof(TClient))) + { + lClient = (TClient)_ProxyCache[typeof(TClient)]; + + if (lClient.State == CommunicationState.Closing || lClient.State == CommunicationState.Closed || lClient.State == CommunicationState.Faulted) + { + if (lClient.State == CommunicationState.Faulted) + { + lClient.Abort(); + } + + lClient = null; + _ProxyCache.Remove(typeof(TClient)); + } + } + + if (lClient != null) + {// EndpointAddresses aktualisieren + if (!lClient.Endpoint.Address.Equals(_EndpointAddresses[typeof(TInterface)])) + { + if (lClient.State == CommunicationState.Opened) + lClient.Close(); + + if (_ProxyCache.ContainsKey(typeof(TClient))) + _ProxyCache.Remove(typeof(TClient)); + lClient = null; + } + } + + if (lClient == null) + { + lClient = new TClient(); + + if (!_ProxyCache.ContainsKey(lClient.GetType())) + { + _ProxyCache.Add(typeof(TClient), lClient); + } + + + // lClient.Endpoint.Behaviors.Add(new DownloadSecurityHeaderEndpointBehavior()); + lClient.Endpoint.Behaviors.Add(new DMultitenancyEndpointBehavior()); + + lClient.Endpoint.Address = _EndpointAddresses[typeof(TInterface)]; + } + + return lClient; + } + } +} diff --git a/Service/ServiceProxy/ServiceGenerated.cs b/Service/ServiceProxy/ServiceGenerated.cs new file mode 100644 index 000000000..4ac27d37c --- /dev/null +++ b/Service/ServiceProxy/ServiceGenerated.cs @@ -0,0 +1,276 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace BeWo.Service.ServiceProxy +{ + using System.Runtime.Serialization; + + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + public partial class BeWoFault : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged + { + + private System.Runtime.Serialization.ExtensionDataObject extensionDataField; + + private BeWo.Service.ServiceProxy.BeWoFaultType FaultTypeField; + + private string InnerExceptionMessageField; + + private string InnerExceptionStackTraceField; + + private string MessageField; + + private string StackTraceField; + + public System.Runtime.Serialization.ExtensionDataObject ExtensionData + { + get + { + return this.extensionDataField; + } + set + { + this.extensionDataField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public BeWo.Service.ServiceProxy.BeWoFaultType FaultType + { + get + { + return this.FaultTypeField; + } + set + { + if ((this.FaultTypeField.Equals(value) != true)) + { + this.FaultTypeField = value; + this.RaisePropertyChanged("FaultType"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string InnerExceptionMessage + { + get + { + return this.InnerExceptionMessageField; + } + set + { + if ((object.ReferenceEquals(this.InnerExceptionMessageField, value) != true)) + { + this.InnerExceptionMessageField = value; + this.RaisePropertyChanged("InnerExceptionMessage"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string InnerExceptionStackTrace + { + get + { + return this.InnerExceptionStackTraceField; + } + set + { + if ((object.ReferenceEquals(this.InnerExceptionStackTraceField, value) != true)) + { + this.InnerExceptionStackTraceField = value; + this.RaisePropertyChanged("InnerExceptionStackTrace"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Message + { + get + { + return this.MessageField; + } + set + { + if ((object.ReferenceEquals(this.MessageField, value) != true)) + { + this.MessageField = value; + this.RaisePropertyChanged("Message"); + } + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string StackTrace + { + get + { + return this.StackTraceField; + } + set + { + if ((object.ReferenceEquals(this.StackTraceField, value) != true)) + { + this.StackTraceField = value; + this.RaisePropertyChanged("StackTrace"); + } + } + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) + { + System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; + if ((propertyChanged != null)) + { + propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] + [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFaultType", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + public enum BeWoFaultType : int + { + + [System.Runtime.Serialization.EnumMemberAttribute()] + Unknown = 0, + + [System.Runtime.Serialization.EnumMemberAttribute()] + Concurrency = 1, + + [System.Runtime.Serialization.EnumMemberAttribute()] + DeleteNotPossible = 2, + + [System.Runtime.Serialization.EnumMemberAttribute()] + LoginNameTaken = 3, + + [System.Runtime.Serialization.EnumMemberAttribute()] + CustomWithoutDetails = 4, + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWo.Service.ServiceProxy.ILauncherService")] + public interface ILauncherService + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/IsUserValid", ReplyAction="http://tempuri.org/ILauncherService/IsUserValidResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/IsUserValidBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetTenantResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void ResetTenant(string tenant); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetAllTenant", ReplyAction="http://tempuri.org/ILauncherService/ResetAllTenantResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetAllTenantBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void ResetAllTenant(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/GetEmailForUserName", ReplyAction="http://tempuri.org/ILauncherService/GetEmailForUserNameResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/GetEmailForUserNameBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword", ReplyAction="http://tempuri.org/ILauncherService/CheckPasswordResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/CheckPassword2", ReplyAction="http://tempuri.org/ILauncherService/CheckPassword2Response")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/CheckPassword2BeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ChangePassword", ReplyAction="http://tempuri.org/ILauncherService/ChangePasswordResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ChangePasswordBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + long ChangePassword(string pUserName, string pOldPassword, string pNewPassword); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILauncherService/ResetPasswordInfo", ReplyAction="http://tempuri.org/ILauncherService/ResetPasswordInfoResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.Service.ServiceProxy.BeWoFault), Action="http://tempuri.org/ILauncherService/ResetPasswordInfoBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void ResetPasswordInfo(string pUserName, string pPassword); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public interface ILauncherServiceChannel : BeWo.Service.ServiceProxy.ILauncherService, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + public partial class LauncherServiceClient : System.ServiceModel.ClientBase, BeWo.Service.ServiceProxy.ILauncherService + { + + public LauncherServiceClient() + { + } + + public LauncherServiceClient(string endpointConfigurationName) : + base(endpointConfigurationName) + { + } + + public LauncherServiceClient(string endpointConfigurationName, string remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public LauncherServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : + base(endpointConfigurationName, remoteAddress) + { + } + + public LauncherServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public BS.SharedLauncher.Enums.UserValidationResult IsUserValid(string pUserName, string pPassword, string pPIN, string clientId, bool checkTenant) + { + return base.Channel.IsUserValid(pUserName, pPassword, pPIN, clientId, checkTenant); + } + + public void ResetTenant(string tenant) + { + base.Channel.ResetTenant(tenant); + } + + public void ResetAllTenant() + { + base.Channel.ResetAllTenant(); + } + + public bool GetEmailForUserName(out string email, string pUserName, System.Uri serverName) + { + return base.Channel.GetEmailForUserName(out email, pUserName, serverName); + } + + public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword(long userOid, string pOldPassword, string pNewPassword) + { + return base.Channel.CheckPassword(userOid, pOldPassword, pNewPassword); + } + + public BS.SharedLauncher.Enums.PasswordValidationResult CheckPassword2(string username, string pOldPassword, string pNewPassword) + { + return base.Channel.CheckPassword2(username, pOldPassword, pNewPassword); + } + + public long ChangePassword(string pUserName, string pOldPassword, string pNewPassword) + { + return base.Channel.ChangePassword(pUserName, pOldPassword, pNewPassword); + } + + public void ResetPasswordInfo(string pUserName, string pPassword) + { + base.Channel.ResetPasswordInfo(pUserName, pPassword); + } + } +} diff --git a/Service/ServiceReferences.bat b/Service/ServiceReferences.bat new file mode 100644 index 000000000..19f6e697a --- /dev/null +++ b/Service/ServiceReferences.bat @@ -0,0 +1 @@ +svcutil.exe /noConfig /edb /n:*,BeWo.Service.ServiceProxy /out:ServiceProxy\ServiceGenerated.cs /ct:System.Collections.Generic.List`1 /r:..\SharedLauncher\bin\Debug\BS.SharedLauncher.dll http://localhost:3777/Host/LauncherService.svc?wsdl \ No newline at end of file diff --git a/Service/ServiceUtils/Paths/ServerFilePaths.cs b/Service/ServiceUtils/Paths/ServerFilePaths.cs index eff05b45a..eeafffc6b 100644 --- a/Service/ServiceUtils/Paths/ServerFilePaths.cs +++ b/Service/ServiceUtils/Paths/ServerFilePaths.cs @@ -40,8 +40,8 @@ namespace BeWo.Service.ServiceUtils.Paths } - public static string GetSpecialTenantFolderPath() => Path.Combine(DownloadFolderPath, "overridetenant"); - public static string GetOverrideTenantFolderPath(string tenant) => Path.Combine(GetSpecialTenantFolderPath(), tenant); + public static string GetOverrideTenantFolderPath() => Path.Combine(DownloadFolderPath, "overridetenant"); + public static string GetOverrideTenantFolderPath(string tenant) => Path.Combine(GetOverrideTenantFolderPath(), tenant); public static string GetVersionFolderPath() => Path.Combine(DownloadFolderPath, "version"); public static string GetVersionFolderPath(string version) => Path.Combine(GetVersionFolderPath(), version); diff --git a/Service/ServiceUtils/Update/DownloadLogger.cs b/Service/ServiceUtils/Update/DownloadLogger.cs deleted file mode 100644 index 8a3e24b7f..000000000 --- a/Service/ServiceUtils/Update/DownloadLogger.cs +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 88af9e978..000000000 --- a/Service/ServiceUtils/Update/DownloadPlanerResponseBuilder.cs +++ /dev/null @@ -1,146 +0,0 @@ -using BeWo.Service.ServiceUtils.Paths; -using BS.SharedLauncher.DataContract; -using BS.SharedLauncher.Exceptions; -using BS.SharedLauncher.Extensions; -using BS.SharedLauncher.Logic; -using BS.SharedLauncher.Update; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BeWo.Service.ServiceUtils.Update -{ - public class DownloadPlanerResponseBuilder - { - private PlanerPackageInfo currentUpdatePackageInfo; - private PlanerPackageInfo latestUpdatePackageInfo; - private Dictionary> downloadFilesToKeep; - - public DownloadPlanerResponseBuilder(DownloadPlanerRequestDC req) - { - currentUpdatePackageInfo = null; - latestUpdatePackageInfo = null; - downloadFilesToKeep = null; - } - - public PlanerPackageInfo CurrentUpdatePackageInfo => currentUpdatePackageInfo; - public PlanerPackageInfo FullUpdatePackageInfo => latestUpdatePackageInfo; - - public void Calculate(string tenant) - { - PlanerPackageInfo root = new PlanerPackageInfo(); - UpdateConfigReader reader = new UpdateConfigReader(ServerFilePaths.GetVersionConfigFilePath(), tenant); - - root.DefaultVersion = reader.GetDefaultVersion(); - root.TenantVersion = reader.GetSpecificVersion(); - - string version = root.Version; - - // Setze Basis - root.InitFiles(getVersionDefaultFiles(version)); - - // Überschreibe mit Version-Tenant Daten - root.OverrideFiles(getVersionTenantFiles(version, tenant)); - - // Überschreibe mit Special-Tenant Daten - root.OverrideFiles(getSpecialTenantFiles(tenant)); - - // Lade Hash Werte - root.LoadHash(); - - latestUpdatePackageInfo = root; - currentUpdatePackageInfo = root.Copy(); - } - public void Substract(PlanerPackageInfo applyPackage) - { - currentUpdatePackageInfo.SubstractFiles(applyPackage.Files); - } - public void AnalyseDownload(Dictionary zip2info) - { - downloadFilesToKeep = new Dictionary>(); - - foreach (var z2i in zip2info) - { - bool found = false; - - for (int i = currentUpdatePackageInfo.Files.Count - 1; i >= 0; i--) - //foreach (var file in currentUpdatePackageInfo.Files) - { - var file = currentUpdatePackageInfo.Files[i]; - - if (z2i.Value.ContainsPlanerFile(file.RelativePath, file.Checksum)) - { - if (!found) - { - found = true; - downloadFilesToKeep.Add(z2i.Key, new List()); - } - - downloadFilesToKeep[z2i.Key].Add(file.RelativePath); - - currentUpdatePackageInfo.RemoveFileAt(i); - } - } - } - } - public void Compress() - { - if (downloadFilesToKeep != null && !downloadFilesToKeep.Any()) - downloadFilesToKeep = null; - - if (currentUpdatePackageInfo != null && !currentUpdatePackageInfo.AnyFile()) - currentUpdatePackageInfo = null; - } - - public DownloadPlanerResponseDC CreateResponse(DownloadPlanerRequestDC request) - { - var res = new DownloadPlanerResponseDC(); - - Compress(); - - res.LatestApplicationInfo = latestUpdatePackageInfo.ToPlanerPackageInfoDC(); - - if (downloadFilesToKeep is object) - { - res.DownloadFilesToKeep = downloadFilesToKeep; - } - - if (currentUpdatePackageInfo is object) - { - res.NewZipData = ZipArchiveBuilder.CreateZipArray(currentUpdatePackageInfo.Files, - (file) => file.AbsolutePath, (file) => file.RelativePath); - res.NewZipInfo = currentUpdatePackageInfo.ToPlanerPackageInfoDC(); - //res.NewZipStream = ZipArchiveBuilder.CreateZipStream(currentUpdatePackageInfo.Files, - // (file) => file.AbsolutePath, (file) => file.RelativePath); - //res.NewZipStreamLength = res.NewZipStream.Length; - } - - res.HasToRemoveFiles = request.ApplyPackage?.Files?.Any(x => !res.LatestApplicationInfo.Files.Any(y => x.EqualsFile(y))) ?? false; - - - - return res; - } - - private List getVersionDefaultFiles(string version) => getPlanerFiles(ServerFilePaths.GetVersionDefaultFolderPath(version), false); - private List getVersionTenantFiles(string version, string tenant) => getPlanerFiles(ServerFilePaths.GetVersionTenantFolderPath(version, tenant), true); - private List getSpecialTenantFiles(string tenant) => getPlanerFiles(ServerFilePaths.GetOverrideTenantFolderPath(tenant), true); - - private List getPlanerFiles(string path, bool ignore) - { - if (!Directory.Exists(path)) { - if (ignore) - return new List(); - else - throw new ServerConfigException($"{path} konnte nicht gefunden werden"); - } - var res = FileController.GetPlanerFiles(path); - - //res.ForEach(x => x.Source = source); - return res; - } - } -} diff --git a/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs b/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs new file mode 100644 index 000000000..680e3bc07 --- /dev/null +++ b/Service/ServiceUtils/Update/UpdateFileResponseBuilder.cs @@ -0,0 +1,104 @@ +using BeWo.Service.ServiceUtils.Paths; +using BS.SharedLauncher.DataContract; +using BS.SharedLauncher.Exceptions; +using BS.SharedLauncher.Extensions; +using BS.SharedLauncher.Logic; +using BS.SharedLauncher.Update; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Service.ServiceUtils.Update +{ + public static class UpdateFileResponseBuilder + { + private static string _Version; + private static string _Tenant; + + private static UpdateFileRequest _Request; + private static UpdateFileResponse _Response; + + public static UpdateFileResponse GetUpdateFileResponse(UpdateFileRequest request, string tenant) + { + _Response = new UpdateFileResponse(); + _Tenant = tenant; + _Request = request; + _Version = request.Version; + + calculate(); + + return _Response; + } + + private static void calculate() + { + var path = Path.Combine(getSourceFolderPath(), _Request.UpdateFile.RelativePath); + + _Response.FileData = File.ReadAllBytes(path); + } + + private static string getSourceFolderPath() + { + switch (_Request.UpdateFile.Source) + { + case BS.SharedLauncher.Enums.UpdateFileSource.Invalid: + throw new UpdateException("Invalid UpdateFileSource"); + + case BS.SharedLauncher.Enums.UpdateFileSource.VersionDefault: + return ServerFilePaths.GetVersionDefaultFolderPath(_Version); + + case BS.SharedLauncher.Enums.UpdateFileSource.VersionTenant: + return ServerFilePaths.GetVersionTenantFolderPath(_Version, _Tenant); + + case BS.SharedLauncher.Enums.UpdateFileSource.VersionUser: + break; + + case BS.SharedLauncher.Enums.UpdateFileSource.OverrideTenant: + return ServerFilePaths.GetOverrideTenantFolderPath(_Tenant); + + case BS.SharedLauncher.Enums.UpdateFileSource.OverrideUser: + break; + default: + break; + } + + // User bekommt eigene Daten Feature + throw new NotImplementedException("#479839129"); + } + + //public static UpdateResponse GetUpdatePlanResponse(UpdateRequest request, string tenant) + //{ + // var reader = new UpdateConfigReader(ServerFilePaths.GetVersionConfigFilePath(), tenant); + + // _Tenant = tenant; + // _Request = request; + // _Response = new UpdateResponse + // { + // CurrentPackage = new PlanerPackageInfoDC + // { + // DefaultVersion = reader.GetDefaultVersion(), + // TenantVersion = reader.GetSpecificVersion() + // } + // }; + + // _Version = _Response.CurrentPackage.Version; + + // // Lädt komplettes Paket ohne Hash + // CalcFullPackage(); + + // // Lade Hash Werte + // _Response.CurrentPackage.LoadHash(); + + // CalcFilesToRequest(); + + // CalcFilesToDeleteInApply(); + + // CalcFilesToIgnoreInDownload(); + + // return _Response; + //} + } +} diff --git a/Service/ServiceUtils/Update/UpdatePlanResponseBuilder.cs b/Service/ServiceUtils/Update/UpdatePlanResponseBuilder.cs new file mode 100644 index 000000000..4abd1edd6 --- /dev/null +++ b/Service/ServiceUtils/Update/UpdatePlanResponseBuilder.cs @@ -0,0 +1,166 @@ +using BeWo.Service.ServiceUtils.Paths; +using BS.SharedLauncher.DataContract; +using BS.SharedLauncher.Enums; +using BS.SharedLauncher.Exceptions; +using BS.SharedLauncher.Extensions; +using BS.SharedLauncher.Information; +using BS.SharedLauncher.Logic; +using BS.SharedLauncher.Update; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Service.ServiceUtils.Update +{ + public static class UpdatePlanResponseBuilder + { + private static UpdatePlanRequest _Request; + private static UpdatePlanResponse _Response; + + private static string _Version; + private static string _Tenant; + + public static UpdatePlanResponse GetUpdatePlanResponse(UpdatePlanRequest request, string tenant) + { + var reader = new UpdateConfigReader(ServerFilePaths.GetVersionConfigFilePath(), tenant); + + _Tenant = tenant; + _Request = request; + _Response = new UpdatePlanResponse + { + CurrentPackage = new UpdatePlanDC + { + DefaultVersion = reader.GetDefaultVersion(), + TenantVersion = reader.GetSpecificVersion() + } + }; + + _Version = _Response.CurrentPackage.Version; + + // Lädt komplettes Paket ohne Hash + CalcFullPackage(); + + // Lade Hash Werte + _Response.CurrentPackage.LoadHash(); + + CalcFilesToRequest(); + + if (!_Request.ApplyFolderIsEmpty) + CalcFilesToDeleteInApply(); + + if (!_Request.DownloadFolderIsEmpty) + CalcFilesToApplyInDownload(); + + CalcDownloadSize(); + + return _Response; + } + + private static void CalcFullPackage() + { + // Setze Basis + _Response.CurrentPackage.InitFiles(getVersionDefaultFiles(_Version)); + + // Überschreibe mit Version-Tenant Daten + _Response.CurrentPackage.OverrideOrAddFiles(getVersionTenantFiles(_Version, _Tenant)); + + // Überschreibe mit Special-Tenant Daten + _Response.CurrentPackage.OverrideOrAddFiles(getSpecialTenantFiles(_Tenant)); + } + + private static void CalcFilesToRequest() + { + foreach (var file in _Response.CurrentPackage.Files) + { + // Bereits installiert + if (_Request.ApplyPackage?.ContainsPlanerFileWithHash(file) ?? false) + continue; + + // Bereits heruntergeladen + if (_Request.DownloadedFiles?.ContainsPlanerFileWithHash(file) ?? false) + continue; + + if (_Response.FilesToRequest is null) + _Response.FilesToRequest = new List(); + + _Response.FilesToRequest.Add(file); + } + } + + private static void CalcFilesToDeleteInApply() + { + foreach (var file in _Request.ApplyPackage.Files) + { + // Datei wird gebraucht + if (_Response.CurrentPackage.ContainsPlanerFile(file)) + continue; + + if (_Response.FilesToDeleteInApply is null) + _Response.FilesToDeleteInApply = new List(); + + _Response.FilesToDeleteInApply.Add(file); + } + } + + private static void CalcFilesToApplyInDownload() + { + foreach (var file in _Request.DownloadedFiles) + { + // Datei wird gebraucht + if (!_Response.CurrentPackage.ContainsPlanerFile(file)) + continue; + + if (_Response.FilesToApply is null) + _Response.FilesToApply = new List(); + + _Response.FilesToApply.Add(file); + } + } + + private static void CalcDownloadSize() + { + if (_Response.FilesToRequest is null || !_Response.FilesToRequest.Any()) + return; + + long count = 0; + foreach (var file in _Response.FilesToRequest) + { + var fi = new FileInfo(file.AbsolutePath); + + count += fi.Length; + } + + _Response.DownloadSize = count; + } + + private static List getVersionDefaultFiles(string version) => getPlanerFiles(ServerFilePaths.GetVersionDefaultFolderPath(version), UpdateFileSource.VersionDefault, false); + private static List getVersionTenantFiles(string version, string tenant) => getPlanerFiles(ServerFilePaths.GetVersionTenantFolderPath(version, tenant), UpdateFileSource.VersionTenant, true); + private static List getSpecialTenantFiles(string tenant) => getPlanerFiles(ServerFilePaths.GetOverrideTenantFolderPath(tenant), UpdateFileSource.OverrideTenant, true); + + private static List getPlanerFiles(string path, UpdateFileSource source, bool ignoreOnError) + { + if (!Directory.Exists(path)) { + if (ignoreOnError) + return new List(); + else + throw new ServerConfigException($"{path} konnte nicht gefunden werden"); + } + var res = FileController.GetPlanerFiles(path, true, ignorePlanerFile); + + res.ForEach(x => x.Source = source); + + return res; + } + + private static bool ignorePlanerFile(UpdateFileDC update) + { + if (update.GetExtensionType() == ".xml") + return true; + + return false; + } + } +} diff --git a/Service/SvcUtil.exe b/Service/SvcUtil.exe new file mode 100644 index 000000000..c81ea03b1 Binary files /dev/null and b/Service/SvcUtil.exe differ diff --git a/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs b/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs deleted file mode 100644 index c88ac36a6..000000000 --- a/SharedLauncher/DataContract/DownloadPlanerResponseDC.cs +++ /dev/null @@ -1,49 +0,0 @@ -using BS.SharedLauncher.Update; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Serialization; - -namespace BS.SharedLauncher.DataContract -{ - [DataContract] - public class DownloadPlanerResponseDC - { - public DownloadPlanerResponseDC() - { - DownloadFilesToKeep = null; - HasToRemoveFiles = false; - } - - [DataMember] - public bool HasToRemoveFiles { get; set; } - - [DataMember] - public byte[] NewZipData { get; set; } - - [DataMember] - public Stream NewZipStream { get; set; } - - [DataMember] - public long NewZipStreamLength { get; set; } - - /// - /// Nur neue Dateien - /// - [DataMember] - public PlanerPackageInfoDC NewZipInfo { get; set; } - - /// - /// Alle Dateien aus der letzten Version - /// - [DataMember] - public PlanerPackageInfoDC LatestApplicationInfo { get; set; } - - [DataMember] - public Dictionary> DownloadFilesToKeep { get; set; } - } -} diff --git a/SharedLauncher/DataContract/LoginDC.cs b/SharedLauncher/DataContract/LoginDC.cs new file mode 100644 index 000000000..369f5d68f --- /dev/null +++ b/SharedLauncher/DataContract/LoginDC.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.DataContract +{ + [DataContract] + public class LoginDC + { + [DataMember] + public string Username { get; set; } + + [DataMember] + public string TempUsername { get; set; } + + [DataMember] + public string Password { get; set; } + + [DataMember] + public string CoreServerAddress { get; set; } + + [DataMember] + public string Pin { get; set; } + + [DataMember] + public string ClientID { get; set; } + + [DataMember] + public bool CheckTenant { get; set; } + } +} diff --git a/SharedLauncher/DataContract/PlanerFileInfoDC.cs b/SharedLauncher/DataContract/PlanerFileInfoDC.cs deleted file mode 100644 index 1b09625d0..000000000 --- a/SharedLauncher/DataContract/PlanerFileInfoDC.cs +++ /dev/null @@ -1,26 +0,0 @@ -using BS.SharedLauncher.Enums; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Serialization; - -namespace BS.SharedLauncher.DataContract -{ - [DebuggerDisplay("{RelativePath} ({Checksum})")] - [DataContract, Serializable()] - public class PlanerFileInfoDC - { - [DataMember, XmlAttribute] - public string Name { get; set; } - - [DataMember, XmlAttribute] - public string RelativePath { get; set; } - - [DataMember, XmlAttribute] - public string Checksum { get; set; } - } -} diff --git a/SharedLauncher/DataContract/UpdateFileDC.cs b/SharedLauncher/DataContract/UpdateFileDC.cs new file mode 100644 index 000000000..9a7a3a0d0 --- /dev/null +++ b/SharedLauncher/DataContract/UpdateFileDC.cs @@ -0,0 +1,50 @@ +using BS.SharedLauncher.Enums; +using BS.SharedLauncher.Utils; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace BS.SharedLauncher.DataContract +{ + [DebuggerDisplay("{RelativePath} ({Checksum})")] + [DataContract, Serializable()] + public class UpdateFileDC + { + public UpdateFileDC() + { + + } + + public UpdateFileDC(FileInfo fileInfo, string relativeTo) : base() + { + Name = fileInfo.Name; + AbsolutePath = fileInfo.FullName; + RelativePath = PathUtils.MakeRelativePath(relativeTo, fileInfo.FullName); + Size = fileInfo.Length; + } + + [DataMember, XmlAttribute] + public string Name { get; set; } + + [XmlIgnore] + public string AbsolutePath { get; set; } + + [DataMember, XmlAttribute] + public string RelativePath { get; set; } + + [DataMember, XmlAttribute] + public UpdateFileSource Source { get; set; } + + [DataMember, XmlAttribute] + public string Checksum { get; set; } + + [DataMember, XmlAttribute] + public long Size { get; set; } + } +} diff --git a/SharedLauncher/DataContract/UpdateFileRequest.cs b/SharedLauncher/DataContract/UpdateFileRequest.cs new file mode 100644 index 000000000..de926eb3d --- /dev/null +++ b/SharedLauncher/DataContract/UpdateFileRequest.cs @@ -0,0 +1,32 @@ +using BS.SharedLauncher.Update; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace BS.SharedLauncher.DataContract +{ + [DataContract] + public class UpdateFileRequest + { + public UpdateFileRequest() + { + + } + + public UpdateFileRequest(string version) : base() + { + Version = version; + } + + [DataMember] + public string Version { get; set; } + + [DataMember] + public UpdateFileDC UpdateFile { get; set; } + } +} diff --git a/SharedLauncher/DataContract/UpdateFileResponse.cs b/SharedLauncher/DataContract/UpdateFileResponse.cs new file mode 100644 index 000000000..0525f4ba9 --- /dev/null +++ b/SharedLauncher/DataContract/UpdateFileResponse.cs @@ -0,0 +1,24 @@ +using BS.SharedLauncher.Update; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace BS.SharedLauncher.DataContract +{ + [DataContract] + public class UpdateFileResponse + { + public UpdateFileResponse() + { + + } + + [DataMember] + public byte[] FileData { get; set; } + } +} diff --git a/SharedLauncher/DataContract/PlanerPackageInfoDC.cs b/SharedLauncher/DataContract/UpdatePlanDC.cs similarity index 83% rename from SharedLauncher/DataContract/PlanerPackageInfoDC.cs rename to SharedLauncher/DataContract/UpdatePlanDC.cs index 8213d5031..7b121a5df 100644 --- a/SharedLauncher/DataContract/PlanerPackageInfoDC.cs +++ b/SharedLauncher/DataContract/UpdatePlanDC.cs @@ -9,10 +9,10 @@ using System.Xml.Serialization; namespace BS.SharedLauncher.DataContract { [DataContract, XmlRoot("Package"), Serializable()] - public class PlanerPackageInfoDC + public class UpdatePlanDC { - [DataMember] - public List Files { get; set; } + [DataMember, XmlIgnore] + public List Files { get; set; } [DataMember] public DateTime Created { get; set; } diff --git a/SharedLauncher/DataContract/DownloadPlanerRequestDC.cs b/SharedLauncher/DataContract/UpdatePlanRequest.cs similarity index 79% rename from SharedLauncher/DataContract/DownloadPlanerRequestDC.cs rename to SharedLauncher/DataContract/UpdatePlanRequest.cs index 224300699..9da9b5d55 100644 --- a/SharedLauncher/DataContract/DownloadPlanerRequestDC.cs +++ b/SharedLauncher/DataContract/UpdatePlanRequest.cs @@ -10,9 +10,9 @@ namespace BS.SharedLauncher.DataContract { //[DebuggerDisplay("{InternalName} ({FileVersion})")] [DataContract] - public class DownloadPlanerRequestDC + public class UpdatePlanRequest { - public DownloadPlanerRequestDC() + public UpdatePlanRequest() { PlanerRootFolderExists = false; DownloadFolderExists = false; @@ -37,9 +37,12 @@ namespace BS.SharedLauncher.DataContract public bool ApplyFolderIsEmpty { get; set; } [DataMember] - public Dictionary DownloadedPackages { get; set; } + public List DownloadedFiles { get; set; } [DataMember] - public PlanerPackageInfoDC ApplyPackage { get; set; } + public UpdatePlanDC ApplyPackage { get; set; } + + [DataMember] + public LoginDC Login { get; set; } } } diff --git a/SharedLauncher/DataContract/DownloadPlanerResponseInfoDC.cs b/SharedLauncher/DataContract/UpdatePlanResponse.cs similarity index 58% rename from SharedLauncher/DataContract/DownloadPlanerResponseInfoDC.cs rename to SharedLauncher/DataContract/UpdatePlanResponse.cs index a047c3680..0273dfe4c 100644 --- a/SharedLauncher/DataContract/DownloadPlanerResponseInfoDC.cs +++ b/SharedLauncher/DataContract/UpdatePlanResponse.cs @@ -10,29 +10,26 @@ using System.Xml.Serialization; namespace BS.SharedLauncher.DataContract { [DataContract] - public class DownloadPlanerResponseInfoDC + public class UpdatePlanResponse { - public DownloadPlanerResponseInfoDC() + public UpdatePlanResponse() { } [DataMember] - public string Version { get; set; } + public UpdatePlanDC CurrentPackage { get; set; } + [DataMember] + public List FilesToRequest { get; set; } + + [DataMember] + public List FilesToApply { get; set; } + + [DataMember] + public List FilesToDeleteInApply { get; set; } + [DataMember] public long DownloadSize { get; set; } - - [DataMember] - public long TotalSize { get; set; } - - [DataMember] - public int FileCount { get; set; } - - [DataMember] - public int NewFileCount { get; set; } - - [DataMember] - public bool HasSomethingToDo { get; set; } } } diff --git a/SharedLauncher/Exceptions/InvalidUpdateFileRequestException.cs b/SharedLauncher/Exceptions/InvalidUpdateFileRequestException.cs new file mode 100644 index 000000000..cdf6425f9 --- /dev/null +++ b/SharedLauncher/Exceptions/InvalidUpdateFileRequestException.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Exceptions +{ + public class InvalidUpdateFileRequestException : UpdateException + { + public InvalidUpdateFileRequestException() + { + } + + public InvalidUpdateFileRequestException(string message) : base(message) + { + } + + public InvalidUpdateFileRequestException(string message, Exception innerException) : base(message, innerException) + { + } + } +} diff --git a/SharedLauncher/Exceptions/InvalidUpdatePlanRequestException.cs b/SharedLauncher/Exceptions/InvalidUpdatePlanRequestException.cs new file mode 100644 index 000000000..e565b85ab --- /dev/null +++ b/SharedLauncher/Exceptions/InvalidUpdatePlanRequestException.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Exceptions +{ + public class InvalidUpdatePlanRequestException : UpdateException + { + public InvalidUpdatePlanRequestException() + { + } + + public InvalidUpdatePlanRequestException(string message) : base(message) + { + } + + public InvalidUpdatePlanRequestException(string message, Exception innerException) : base(message, innerException) + { + } + } +} diff --git a/SharedLauncher/Extensions/DownloadPlanerResponseExtension.cs b/SharedLauncher/Extensions/DownloadPlanerResponseExtension.cs deleted file mode 100644 index 313cf4e0c..000000000 --- a/SharedLauncher/Extensions/DownloadPlanerResponseExtension.cs +++ /dev/null @@ -1,27 +0,0 @@ -using BS.SharedLauncher.DataContract; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BS.SharedLauncher.Extensions -{ - public static class DownloadPlanerResponseExtension - { - public static bool HasToDo(this DownloadPlanerResponseDC response) - { - return response.HasToDoDownload2Keep() || response.HasToDoNewZip() || response.HasToRemoveFiles; - } - - public static bool HasToDoDownload2Keep(this DownloadPlanerResponseDC response) - { - return response.DownloadFilesToKeep is object; - } - - public static bool HasToDoNewZip(this DownloadPlanerResponseDC response) - { - return response.NewZipInfo is object; - } - } -} diff --git a/SharedLauncher/Extensions/PathExtensions.cs b/SharedLauncher/Extensions/PathExtensions.cs index 140a5cde7..144ead075 100644 --- a/SharedLauncher/Extensions/PathExtensions.cs +++ b/SharedLauncher/Extensions/PathExtensions.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BS.SharedLauncher.Information; +using BS.SharedLauncher.Logic; namespace BS.SharedLauncher.Extensions { diff --git a/SharedLauncher/Extensions/PlanerFileExtension.cs b/SharedLauncher/Extensions/PlanerFileExtension.cs index 97cdb0a4b..18570f9af 100644 --- a/SharedLauncher/Extensions/PlanerFileExtension.cs +++ b/SharedLauncher/Extensions/PlanerFileExtension.cs @@ -13,22 +13,16 @@ namespace BS.SharedLauncher.Extensions { public static class PlanerFileExtension { - public static List ToPlanerFileInfoDCList(this List planerFileInfos) => planerFileInfos.Select(x => new PlanerFileInfoDC() + public static bool ContainsPlanerFile(this List files, UpdateFileDC file2) { - Checksum = x.Checksum, - Name = x.Name, - RelativePath = x.RelativePath - }).ToList(); - public static List ToPlanerFileInfoList(this List planerFileInfos) => planerFileInfos.Select(x => new PlanerFileInfo() + return files.FirstOrDefault(file => file.RelativePath == file2.RelativePath) is object; + } + public static bool ContainsPlanerFileWithHash(this List files, UpdateFileDC file2) { - Checksum = x.Checksum, - Name = x.Name, - RelativePath = x.RelativePath - }).ToList(); - - public static void LoadHash(this PlanerFileInfo planerFileInfo) + return files.FirstOrDefault(file => file.RelativePath == file2.RelativePath && file.Checksum == file2.Checksum) is object; + } + public static void LoadHash(this UpdateFileDC planerFileInfo) { - //FileData = File.ReadAllBytes(AbsolutePath); using (var md5 = MD5.Create()) { using (var stream = File.OpenRead(planerFileInfo.AbsolutePath)) @@ -38,44 +32,52 @@ namespace BS.SharedLauncher.Extensions } } - public static void Copy(this PlanerFileInfo info) => new PlanerFileInfo() + public static void Copy(this UpdateFileDC info) => new UpdateFileDC() { Name = info.Name, AbsolutePath = info.AbsolutePath, Checksum = info.Checksum, RelativePath = info.RelativePath }; + public static bool EqualsFile(this UpdateFileDC file, UpdateFileDC file2) + { + return (file.Checksum == file2.Checksum) && + (file.RelativePath == file2.RelativePath) && + (file.Name == file2.Name); + } + public static string GetExtensionType(this UpdateFileDC file) + { + return Path.GetExtension(file.AbsolutePath); + } + public static bool IsLockFile(this UpdateFileDC file) + { + return file.Name == BeWoPathFileConfig.LockFileName; + } + public static bool IsPackageInfo(this UpdateFileDC file) + { + return file.GetExtensionType() == BeWoPathFileConfig.DotBeWoInfo; + } + public static bool IgnoreFile(this UpdateFileDC file) + { + // Lock File Ignorieren + if (file.IsLockFile()) + return true; - public static bool EqualsFile(this PlanerFileInfo file, PlanerFileInfo file2) - { - return (file.Checksum == file2.Checksum) && - (file.RelativePath == file2.RelativePath) && - (file.Name == file2.Name); - } - public static bool EqualsFile(this PlanerFileInfoDC file, PlanerFileInfoDC file2) - { - return (file.Checksum == file2.Checksum) && - (file.RelativePath == file2.RelativePath) && - (file.Name == file2.Name); - } - public static bool EqualsFile(this PlanerFileInfo file, PlanerFileInfoDC file2) - { - return (file.Checksum == file2.Checksum) && - (file.RelativePath == file2.RelativePath) && - (file.Name == file2.Name); - } - public static bool EqualsFile(this PlanerFileInfoDC file, PlanerFileInfo file2) - { - return (file.Checksum == file2.Checksum) && - (file.RelativePath == file2.RelativePath) && - (file.Name == file2.Name); + // Package Info Ignorieren + if (file.IsPackageInfo()) + return true; + + return false; } - public static bool IgnoreToRemove(this PlanerFileInfo file) + public static bool IgnoreToRemove(this UpdateFileDC file) { if (file.Name == BeWoPathFileConfig.LockFileName) return true; + if (file.GetExtensionType() == BeWoPathFileConfig.DotBeWoInfo) + return true; + return false; } } diff --git a/SharedLauncher/Extensions/PlanerPackageExtension.cs b/SharedLauncher/Extensions/PlanerPackageExtension.cs index 54fa46eb3..8d4667501 100644 --- a/SharedLauncher/Extensions/PlanerPackageExtension.cs +++ b/SharedLauncher/Extensions/PlanerPackageExtension.cs @@ -10,26 +10,15 @@ namespace BS.SharedLauncher.Extensions { public static class PlanerPackageExtension { - public static PlanerPackageInfoDC ToPlanerPackageInfoDC(this PlanerPackageInfo planerFileInfo) => new PlanerPackageInfoDC() + public static bool ContainsPlanerFile(this UpdatePlanDC planerPackageInfo, UpdateFileDC file2) { - Created = planerFileInfo.Created, - DefaultVersion = planerFileInfo.DefaultVersion, - Files = planerFileInfo.Files.ToPlanerFileInfoDCList(), - TenantVersion = planerFileInfo.TenantVersion - }; - public static PlanerPackageInfo ToPlanerPackageInfo(this PlanerPackageInfoDC planerFileInfo) => new PlanerPackageInfo() - { - Created = planerFileInfo.Created, - DefaultVersion = planerFileInfo.DefaultVersion, - Files = planerFileInfo.Files.ToPlanerFileInfoList(), - TenantVersion = planerFileInfo.TenantVersion - }; - - public static bool ContainsPlanerFile(this PlanerPackageInfo planerPackageInfo, string rel, string checksum) - { - return planerPackageInfo.Files.FirstOrDefault(file => file.RelativePath == rel && file.Checksum == checksum) is object; + return planerPackageInfo.Files.FirstOrDefault(file => file.RelativePath == file2.RelativePath) is object; } - public static bool AnyFile(this PlanerPackageInfo planerPackageInfo) + public static bool ContainsPlanerFileWithHash(this UpdatePlanDC planerPackageInfo, UpdateFileDC file2) + { + return planerPackageInfo.Files.FirstOrDefault(file => file.RelativePath == file2.RelativePath && file.Checksum == file2.Checksum) is object; + } + public static bool AnyFile(this UpdatePlanDC planerPackageInfo) { if (planerPackageInfo.Files is null) return false; @@ -37,25 +26,25 @@ namespace BS.SharedLauncher.Extensions return planerPackageInfo.Files.Any(); } - public static PlanerFileInfo FindPlanerFile(this PlanerPackageInfo planerFileInfo, string relative) + public static UpdateFileDC FindPlanerFile(this UpdatePlanDC planerFileInfo, string relative) { return planerFileInfo.Files.Find(x => x.RelativePath == relative); } - public static PlanerFileInfo FirstOrDefaultPlanerFile(this PlanerPackageInfo planerFileInfo, string relative) + public static UpdateFileDC FirstOrDefaultPlanerFile(this UpdatePlanDC planerFileInfo, string relative) { return planerFileInfo.Files.FirstOrDefault(x => x.RelativePath == relative); } - public static PlanerFileInfo FirstOrDefaultPlanerFile(this PlanerPackageInfo planerFileInfo, PlanerFileInfo file) + public static UpdateFileDC FirstOrDefaultPlanerFile(this UpdatePlanDC planerFileInfo, UpdateFileDC file) { return planerFileInfo.Files.FirstOrDefault(x => x.EqualsFile(file)); } - public static void InitFiles(this PlanerPackageInfo planerFileInfo, List files) + public static void InitFiles(this UpdatePlanDC planerFileInfo, List files) { - planerFileInfo.Files = new List(); + planerFileInfo.Files = new List(); planerFileInfo.Files.AddRange(files); } - private static void OverrideFile(this PlanerPackageInfo planerFileInfo, PlanerFileInfo newFile) + private static void OverrideOrAddFile(this UpdatePlanDC planerFileInfo, UpdateFileDC newFile) { var oldFile = planerFileInfo.FirstOrDefaultPlanerFile(newFile.RelativePath); @@ -65,44 +54,32 @@ namespace BS.SharedLauncher.Extensions planerFileInfo.Files.Add(newFile); //oldFile.Source = newFile.Source; } - public static void OverrideFiles(this PlanerPackageInfo planerFileInfo, List files) + public static void OverrideOrAddFiles(this UpdatePlanDC planerFileInfo, List files) { - files.ForEach(x => planerFileInfo.OverrideFile(x)); + files.ForEach(x => planerFileInfo.OverrideOrAddFile(x)); } - public static void TryRemoveFile(this PlanerPackageInfo planerFileInfo, PlanerFileInfo file) + public static void TryRemoveFile(this UpdatePlanDC planerFileInfo, UpdateFileDC file) { var minuend = planerFileInfo.FirstOrDefaultPlanerFile(file); - if (minuend is PlanerFileInfo) + if (minuend is UpdateFileDC) { planerFileInfo.RemoveFile(minuend); } } - public static void RemoveFile(this PlanerPackageInfo planerFileInfo, PlanerFileInfo file) + public static void RemoveFile(this UpdatePlanDC planerFileInfo, UpdateFileDC file) { planerFileInfo.Files.Remove(file); } - public static void RemoveFileAt(this PlanerPackageInfo planerFileInfo, int index) + public static void RemoveFileAt(this UpdatePlanDC planerFileInfo, int index) { planerFileInfo.Files.RemoveAt(index); } - public static void SubstractFiles(this PlanerPackageInfo planerPackageInfo, List files) + public static void SubstractFiles(this UpdatePlanDC planerPackageInfo, List files) { files.ForEach(f => planerPackageInfo.TryRemoveFile(f)); } - public static void LoadHash(this PlanerPackageInfo planer) => planer.Files.ForEach(file => file.LoadHash()); - public static PlanerPackageInfo Copy(this PlanerPackageInfo pp) => new PlanerPackageInfo() - { - Created = pp.Created, - DefaultVersion = pp.DefaultVersion, - TenantVersion = pp.TenantVersion, - Files = pp.Files.Select(file => file.Copy()).ToList() - }; - - public static void Apply(this PlanerPackageInfo planer) - { - - } + public static void LoadHash(this UpdatePlanDC planer) => planer.Files.ForEach(file => file.LoadHash()); } } diff --git a/SharedLauncher/Extensions/UpdateResponseExtension.cs b/SharedLauncher/Extensions/UpdateResponseExtension.cs new file mode 100644 index 000000000..c7468079d --- /dev/null +++ b/SharedLauncher/Extensions/UpdateResponseExtension.cs @@ -0,0 +1,32 @@ +using BS.SharedLauncher.DataContract; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Extensions +{ + public static class UpdateResponseExtension + { + public static bool HasToDo(this UpdatePlanResponse response) + { + return response.HasToRequestFiles() || response.HasToApplyFiles() || response.HasToDeleteFilesInApply(); + } + + public static bool HasToRequestFiles(this UpdatePlanResponse response) + { + return response.FilesToRequest is object; + } + + public static bool HasToApplyFiles(this UpdatePlanResponse response) + { + return response.FilesToApply is object; + } + + public static bool HasToDeleteFilesInApply(this UpdatePlanResponse response) + { + return response.FilesToDeleteInApply is object; + } + } +} diff --git a/SharedLauncher/Information/BeWoPathFileConfig.cs b/SharedLauncher/Information/BeWoPathFileConfig.cs index 73ecce5c0..53c72f856 100644 --- a/SharedLauncher/Information/BeWoPathFileConfig.cs +++ b/SharedLauncher/Information/BeWoPathFileConfig.cs @@ -11,14 +11,12 @@ namespace BS.SharedLauncher.Information public static class BeWoPathFileConfig { private static readonly string lockFileName = "_lock"; - private static readonly string zipName = "bewo{0}.zip"; - private static readonly string dotbewoinfo = ".bewoinfo"; + private static readonly string dotbewoinfo = ".bewoplan"; private static readonly string latestFileName = "latest"; private static readonly string subdir = "BeWoPlaner"; private static readonly string testForPermission = "bewo.permission.test"; public static string LockFileName => lockFileName; - public static string ZipFormatName => zipName; public static string DotBeWoInfo => dotbewoinfo; public static string LatestBeWoInfo => latestFileName + DotBeWoInfo; public static string SubDirectory => subdir; diff --git a/SharedLauncher/Information/Connection.cs b/SharedLauncher/Information/Connection.cs new file mode 100644 index 000000000..0b0df6f92 --- /dev/null +++ b/SharedLauncher/Information/Connection.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Information +{ + public class Connection + { + private const char trennzeichen = '\t'; + + public string ProxyName { get; set; } + public string ProxyPassword { get; set; } + public string ProxyUsername { get; set; } + + public string IpAddress { get; set; } + public string DownloadServerAddress { get; set; } + public string Servername { get; set; } + + public string CoreServerAddress { get; set; } + public string ChatServerAddress { get; set; } + + public int Length => ToList().Count; + + public static Connection Parse(List data) + { + var connection = new Connection(); + var c = 0; + + connection.ProxyName = data[c++]; + connection.ProxyPassword = data[c++]; + connection.ProxyUsername = data[c++]; + + connection.IpAddress = data[c++]; + connection.DownloadServerAddress = data[c++]; + connection.Servername = data[c++]; + + connection.CoreServerAddress = data[c++]; + connection.ChatServerAddress = data[c++]; + + return connection; + } + + public List ToList() + { + return new List { ProxyName, ProxyPassword, ProxyUsername, + IpAddress, DownloadServerAddress, Servername, + CoreServerAddress, ChatServerAddress}; + } + + public string DownloadServerAddressExact + { + get + { + String url = DownloadServerAddress?.ToLower(); + + // Localhost + if (url.IndexOf("localhost") >= 0) + return new Uri(url).ToString(); + + // Just Number + if (int.TryParse(url, out int i)) + url = "app" + url; + + // Kein Https + if (url.IndexOf("https://") < 0) + url = "https://" + url; + + // Kein Punkt + if (url.IndexOf('.') < 0) + url += ".bewoplaner.de"; + + // Kein Slash + if (url.IndexOf("/download") < 0) + url += "/download"; + + return new Uri(url).ToString(); + } + } + + public string CoreServerAddressExact + { + get + { + String url = CoreServerAddress?.ToLower(); + + // Localhost + if (url.IndexOf("localhost") >= 0) + return new Uri(url).ToString(); + + // Just Number + if (int.TryParse(url, out int i)) + url = "app" + url; + + // Kein Https + if (url.IndexOf("https://") < 0) + url = "https://" + url; + + // Kein Punkt + if (url.IndexOf('.') < 0) + url += ".bewoplaner.de"; + + // Kein Slash + if (url.IndexOf("/service") < 0) + url += "/service"; + + return new Uri(url).ToString(); + } + } + } +} diff --git a/SharedLauncher/Information/ConnectionInformation.cs b/SharedLauncher/Information/ConnectionInformation.cs deleted file mode 100644 index 309ad7fb6..000000000 --- a/SharedLauncher/Information/ConnectionInformation.cs +++ /dev/null @@ -1,246 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -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; } - - public string ProxyName { get; set; } - public string ProxyPassword { get; set; } - public string ProxyUsername { get; set; } - - public string IpAddress{ get; set; } - public string LauncherServerAddress { get; set; } - 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[] data) - { - var connection = new Connection(); - - connection.Tenant = data[0]; - connection.Username = data[1]; - connection.Password = data[2]; - connection.IpAddress = data[3]; - connection.CoreServerAddress = data[4]; - connection.ChatServerAddress = data[5]; - connection.Version = data[6]; - - return connection; - } - - public string[] ToArray() - { - return new string[] { "demo", "demo", "demo", IpAddress, ConnectionInformation.CoreServerAddressOrigin.ToString(), 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}{trennzeichen}un{Username}{trennzeichen}pw{Password}{trennzeichen}ip{IpAddress}{trennzeichen}sn{Servername}{trennzeichen}cs{ChatServerAddress}{trennzeichen}vr{Version}"; - } - } - - public static class ConnectionInformation - { - private static Connection connection; - - public static Connection Connection - { - get - { - if (connection is null) - connection = new Connection(); - - return connection; - } - } - public static string ProxyName - { - get { return Connection.ProxyName; } - set { Connection.ProxyName = value; } - } - - public static string ProxyPassword - { - get { return Connection.ProxyPassword; } - set { Connection.ProxyPassword = value; } - } - - public static string ProxyUsername - { - get { return Connection.ProxyUsername; } - set { Connection.ProxyUsername = value; } - } - - public static string ChatServerAddress - { - get { return Connection.ChatServerAddress; } - set { Connection.ChatServerAddress = value; } - } - - public static string CoreServerAddress - { - get { return Connection.CoreServerAddress; } - set { Connection.CoreServerAddress = value; } - } - - public static string IpAddress - { - get { return Connection.IpAddress; } - set { Connection.IpAddress = value; } - } - - public static string Password - { - get { return Connection.Password; } - set { Connection.Password = value; } - } - - public static string ServerName - { - get { return Connection.Servername; } - set { Connection.Servername = value; } - } - - public static string Tenant - { - get { return Connection.Tenant; } - set { Connection.Tenant = value; } - } - - public static string Username - { - get { return Connection.Username; } - set { Connection.Username = value; } - } - - public static string Version - { - get { return Connection.Version; } - set { Connection.Version = value; } - } - - public static string LauncherServerAddress - { - get { return Connection.LauncherServerAddress; } - set - { - Connection.LauncherServerAddress = value; - //LauncherServiceFacade.UpdateServerAddresses(LauncherServerAddressOrigin.ToString()); - } - } - - public static Uri LauncherServerAddressOrigin - { - get - { - String url = Connection.LauncherServerAddress?.ToLower(); - -#if DEBUG - //url = String.Format("http://localhost:3778"); - return new Uri("https://app5.bewoplaner.de/launcher"); - //url = String.Format("app1.bewoplaner.de/service"); -#endif - - if (url.IndexOf("localhost") < 0) - { - if (int.TryParse(url, out int i)) - url = "app" + url; - - if (url.IndexOf('.') < 0) - { - url += ".bewoplaner.de"; - } - - if (url.IndexOf("/service") < 0) - { - url += "/service"; - } - - return new Uri(string.Format("https://{0}", url)); - } - return new Uri(url); - } - } - - public static Uri CoreServerAddressOrigin - { - get - { - String url = Connection.CoreServerAddress?.ToLower(); -#if DEBUG - url = String.Format("http://localhost:3777/Host"); - //return new Uri("https://app4.bewoplaner.de/servicesbd"); - //url = String.Format("app1.bewoplaner.de/service"); -#endif - - if (url.IndexOf("localhost") < 0) - { - if (Int32.TryParse(url, out int i)) - url = "app" + url; - - if (url.IndexOf('.') < 0) - { - url += ".bewoplaner.de"; - } - - //if (url.IndexOf("/service45") < 0) - //{ - // url += "/service45"; - //} - if (url.IndexOf("/servicesbd") < 0) - { - url += "/servicesbd"; - } - - return new Uri(string.Format("https://{0}", url)); - } - return new Uri(url); - } - } - } -} diff --git a/SharedLauncher/Information/DownloadLogger.cs b/SharedLauncher/Information/DownloadLogger.cs new file mode 100644 index 000000000..446df1ab5 --- /dev/null +++ b/SharedLauncher/Information/DownloadLogger.cs @@ -0,0 +1,59 @@ +using BS.SharedLauncher.Extensions; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Information +{ + public static class DownloadLogger + { + private static bool _started; + + private static string _LogFileName; + private static string _LogFilePath; + private static string _folder; + + public static string LogFilePath => _LogFilePath; + + static DownloadLogger() + { + _started = false; + } + + public static void Init(string folder) + { + _LogFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; + _LogFilePath = folder.Combine(_LogFileName); + + folder.CreateFolder(); + + _started = true; + + Post3(); + Post2("Starting Download Logger..."); + Post3(); + } + + public static void Post(string message) + { + if (!_started) + return; + + var log = $"[{DateTime.Now.ToString("HH:mm:ss")}]: {message}\n"; + File.AppendAllText(_LogFilePath, log); + } + + public static void Post2(string message) + { + Post("--->>> " + message); + } + + public static void Post3() + { + Post("-----------------------------------"); + } + } +} diff --git a/SharedLauncher/Information/Login.cs b/SharedLauncher/Information/Login.cs new file mode 100644 index 000000000..1b9d4d39a --- /dev/null +++ b/SharedLauncher/Information/Login.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Information +{ + public class Login + { + public string Tenant { get; set; } + public string Username { get; set; } + public string TempUsername { get; set; } + public string Password { get; set; } + + public string CoreServerAddress { get; set; } + public string Pin { get; set; } + public string ClientId { get; set; } + + public int Length => ToList().Count; + + public static Login Parse(List data) + { + var login = new Login(); + var c = 0; + + login.Tenant = data[c++]; + login.Username = data[c++]; + login.TempUsername = data[c++]; + login.Password = data[c++]; + + login.CoreServerAddress = data[c++]; + login.Pin = data[c++]; + login.ClientId = data[c++]; + + return login; + } + + public List ToList() + { + return new List { Tenant, Username, TempUsername, Password, + CoreServerAddress, Pin, ClientId}; + } + } +} diff --git a/SharedLauncher/Information/Session.cs b/SharedLauncher/Information/Session.cs new file mode 100644 index 000000000..57ececd79 --- /dev/null +++ b/SharedLauncher/Information/Session.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.SharedLauncher.Information +{ + public class Session + { + public string Version { get; set; } + + public int Length => ToList().Count; + + public static Session Parse(List data) + { + var session = new Session(); + var c = 0; + + session.Version = data[c++]; + + return session; + } + + public List ToList() + { + return new List { Version }; + } + } +} diff --git a/SharedLauncher/Information/SessionInformation.cs b/SharedLauncher/Information/SessionInformation.cs new file mode 100644 index 000000000..ee4f38250 --- /dev/null +++ b/SharedLauncher/Information/SessionInformation.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Pipes; +using System.Linq; + +namespace BS.SharedLauncher.Information +{ + public static class SessionInformation + { + private static Connection connection; + private static Login login; + private static Session session; + + public static string GetDebugConnection(int i) + { + if (i == 1) + { + // Download Server + + return "http://localhost:3778"; + //return "https://localhost:44367/"; + //return "https://app5.bewoplaner.de"; + } + if (i == 2) + { + // Core Server + + return "http://localhost:3777/Host/"; + //return "https://localhost:44308/Host/"; + //return "https://app5.bewoplaner.de"; + } + throw new Exception(); + } + + public static Connection Connection + { + get + { + if (connection is null) + { + connection = new Connection(); + Loaded = true; + } + + return connection; + } + } + public static Session Session + { + get + { + if (session is null) + { + session = new Session(); + Loaded = true; + } + + return session; + } + } + public static Login Login + { + get + { + if (login is null) + { + login = new Login(); + Loaded = true; + } + + return login; + } + } + + public static bool Loaded { get; set; } + + static SessionInformation() + { + Loaded = false; + } + + public static void Load(List connection, List login, List session) + { + Init( + BS.SharedLauncher.Information.Connection.Parse(connection), + BS.SharedLauncher.Information.Login.Parse(login), + BS.SharedLauncher.Information.Session.Parse(session)); + } + public static void Init(Connection pconnection, Login plogin, Session psession) + { + //if (Loaded) + // throw new Exception(SessionInformation.ToString()); + + connection = pconnection; + login = plogin; + session = psession; + + Loaded = true; + } + + public static void LoadPipe(string pipe) + { + try + { + using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipe)) + { + using (StreamReader sr = new StreamReader(pipeClient)) + { + string temp; + List result = new List(); + var signal = new string[] { "C-137", "C-131" }; + + // Warte auf Start + do + { + temp = sr.ReadLine(); + } + while (!temp.StartsWith(signal[0])); + + var connection = (from x in Enumerable.Range(0, Connection.Length) select sr.ReadLine()).ToList(); + var login = (from x in Enumerable.Range(0, Login.Length) select sr.ReadLine()).ToList(); + var session = (from x in Enumerable.Range(0, Session.Length) select sr.ReadLine()).ToList(); + + do + { + temp = sr.ReadLine(); + } + while (!temp.StartsWith(signal[1])); + + Load(connection, login, session); + } + } + } + catch (Exception ex) + { + throw ex; + } + } + + public static string ToString() + { + return $"c:{string.Join(",", connection.ToList())} l:{string.Join(",", login.ToList())} s:{string.Join(",", session.ToList())}"; + } + } +} diff --git a/SharedLauncher/LauncherEnums.cs b/SharedLauncher/LauncherEnums.cs index 1a0e2c40b..ceba34d1f 100644 --- a/SharedLauncher/LauncherEnums.cs +++ b/SharedLauncher/LauncherEnums.cs @@ -51,39 +51,26 @@ namespace BS.SharedLauncher.Enums DeleteStart = 7, DeleteUpdate = 8, DeleteFinished = 9, - ProgressEnd = 10, + CleanupStart = 10, + CleanupUpdate = 11, + CleanupFinished = 12, + ProgressEnd = 13, } - //public enum PlanerUpdateSource - //{ - // Invalid = 0, - // Version = 1, - // VersionTenant = 2, - // OverrideTenant = 3 + public enum LauncherMode + { + Install = 0, + Update = 1, + Uninstall = 2 + } - // ///// - // ///// Aus der neusten Version / Default Case - // ///// - // //NewestVersion = 1, - - // ///// - // ///// Durch spezieller Version in version.config - // ///// - // //SpecialVersion = 2, - - // ///// - // ///// Aus der neusten Version aus dem Version-Kunden-Ordner - // ///// - // //NewestVersionTenant = 3, - - // ///// - // ///// Aus der speziellen Version aus dem Version-Kunden-Ordner - // ///// - // //SpecialVersionTenant = 4, - - // ///// - // ///// Aus dem Kunden-Ordner - // ///// - // //SpecialTenant = 5 - //} + public enum UpdateFileSource + { + Invalid = 0, + VersionDefault = 1, + VersionTenant = 2, + VersionUser = 3, + OverrideTenant = 4, + OverrideUser = 5 + } } diff --git a/SharedLauncher/Logic/FileController.cs b/SharedLauncher/Logic/FileController.cs index 8adedd92d..3f7a8a5bf 100644 --- a/SharedLauncher/Logic/FileController.cs +++ b/SharedLauncher/Logic/FileController.cs @@ -16,196 +16,77 @@ namespace BS.SharedLauncher.Logic { public static class FileController { - private static string ZipFormatName => BeWoPathFileConfig.ZipFormatName; private static string DotBeWoInfo => BeWoPathFileConfig.DotBeWoInfo; - - public static string GetDZipPath(string root, int number) => Path.Combine(root, string.Format(ZipFormatName, getFileNumberCountString(number))); - public static string GetDZipInfoPath(string root, int number) => GetDZipPath(root, number) + DotBeWoInfo; - public static void ApplyDZip(Dictionary> zip2keepfiles, string destinationfolder, Action apply) + public static List GetDownloadedFiles(string downloadFolder) { - foreach (var pair in zip2keepfiles) - { - ApplyDZip(pair.Key, destinationfolder, pair.Value.Contains, apply); - } + return GetPlanerFiles(downloadFolder, true, null); } - public static void ApplyDZip(string zipfilepath, string destinationfolder, Action apply) - => ApplyDZip(zipfilepath, destinationfolder, (s) => true, apply); - private static void ApplyDZip(string zipfilepath, string destinationfolder, Func isValidFunc, Action apply) + public static UpdatePlanDC GetApplyPackage(string applyFolder) { - using (ZipArchive archive = ZipFile.OpenRead(zipfilepath)) - { - foreach (ZipArchiveEntry entry in archive.Entries) - { - if (isValidFunc(entry.FullName)) - { - var path = destinationfolder.Combine(entry.FullName); - Directory.CreateDirectory(Path.GetDirectoryName(path)); - entry.ExtractToFile(path, true); - apply((int)LauncherProgress.ApplyUpdate, new ApplyFileEventArgs(entry.FullName, path)); - Thread.Sleep(100); - } - } - } + TryGetPackageInfo(applyFolder, out var package); + + if (package == null) + package = new UpdatePlanDC(); + + package.Files = GetPlanerFiles(applyFolder, true, null); + + return package; } - - public static void RemoveUnsuedFiles(PlanerPackageInfoDC latestApplicationInfo, string applyFolder, Action status) - { - foreach (var file in GetPlanerFiles(applyFolder)) - { - file.LoadHash(); - if (latestApplicationInfo.Files.Any(late => late.EqualsFile(file))) - continue; - - if (file.IgnoreToRemove()) - continue; - - File.Delete(file.AbsolutePath); - status((int)LauncherProgress.DeleteUpdate, file); - } - } - - public static List GetValidDZipPaths(string path) - { - var res = new List(); - - var dir = new DirectoryInfo(path); - var files = dir.GetFiles("*.zip"); - - foreach (var file in files) - { - if (file.FullName.IsDZipValid()) - res.Add(file.FullName); - } - - return res; - } - public static string GetNewZipPath(string root) - { - int i = 0; - string temp = string.Empty; - - do - { - temp = GetDZipPath(root, i++); - - } while (temp.IsDZipValidAndDeleteIfNot()); - - return temp; - } - - public static void SaveDZipStream(string path, Stream filebytestream, long length, Action download) - { - long startlength = 0; - FileInfo finfo = new FileInfo(path); - if (finfo.Exists) - startlength = finfo.Length; // If File exists, - // we need to send the Start length to the server - - using (FileStream writeStream = - new System.IO.FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) - { - int chunkSize = 2048; - byte[] buffer = new byte[chunkSize]; - - do - { - int bytesRead = filebytestream.Read(buffer, 0, chunkSize); - if (bytesRead == 0) break; - - writeStream.Write(buffer, 0, bytesRead); - - download(11, new DownloadProgressEventArgs(writeStream.Position * 100 / length)); - } - while (true); - - writeStream.Close(); - } - filebytestream.Dispose(); - } - public static void SaveDZip(string path, byte[] data) - { - File.WriteAllBytes(path, data); - } - public static void SaveInfo(string path, T t) - where T : class - { - File.WriteAllText(path.WithInfoExtension(), XmlConverter.Serialize(t)); - } - public static void DeleteInfo(string path) - { - File.Delete(path.WithInfoExtension()); - } - public static PlanerPackageInfoDC LoadInfo(string filepath) + public static UpdatePlanDC LoadPackageInfo(string filepath) { filepath = filepath.WithInfoExtension(); var xml = File.ReadAllText(filepath); - var obj = XmlConverter.Deserialize(xml); + var obj = XmlConverter.Deserialize(xml); return obj; } - - public static bool TryGetPackageInfo(string filepath, out PlanerPackageInfoDC planerPackageInfoDC) + public static bool TryGetPackageInfo(string filepath, out UpdatePlanDC planerPackageInfoDC) { planerPackageInfoDC = null; try { - planerPackageInfoDC = LoadInfo(filepath); + planerPackageInfoDC = LoadPackageInfo(filepath); } catch (Exception) { return false; } + return true; } - public static Dictionary LoadInfos(string rootfolder) + + #region file + public static void SaveFile(string path, byte[] data) { - var allDZips = GetValidDZipPaths(rootfolder); - - if (allDZips is null || !allDZips.Any()) - return null; - - return allDZips.ToDictionary(dzip => dzip, dzip => LoadInfo(dzip)); - - // Detailed Debug Section - //var res = new Dictionary(); - - //foreach (var dzip in allDZips) - //{ - // res.Add(dzip, GetPackageInfo(dzip)); - //} - - //return res; + File.WriteAllBytes(path, data); + DownloadLogger.Post($"Save File: {path}"); } - public static List GetPlanerFiles(string path) + public static void CopyFile(string source, string destination) { - var res = new List(); - - // Sollte der Path ohne / enden, wird der unterordner mit angegeben - // Deshalb manuell hinzufügen, falls nicht vorhanden - - if (!path.EndsWith(Path.DirectorySeparatorChar.ToString())) - path += Path.DirectorySeparatorChar; - - getPlanerFilesRecursive(new DirectoryInfo(path), path, ref res); - return res; + File.Copy(source, destination, true); + DownloadLogger.Post($"Copy File: {source} -> {destination}"); } - - public static bool IsDZipValidAndDeleteIfNot(this string path) + public static void DeleteFile(string source) { - if (path.IsDZipValid()) - return true; - - new FileInfo(path).Delete(); - new FileInfo(path + BeWoPathFileConfig.DotBeWoInfo).Delete(); - - return false; + File.Delete(source); + DownloadLogger.Post($"Delete File: {source}"); } - public static bool IsDZipValid(this string path) + #endregion + + #region info + public static void SaveInfo(string path, T t) + where T : class { - return path.Exists() && (path + BeWoPathFileConfig.DotBeWoInfo).Exists(); + File.WriteAllText(path.WithInfoExtension(), XmlConverter.Serialize(t)); + DownloadLogger.Post($"Info Save: {path}"); + } + public static void DeleteInfo(string path) + { + File.Delete(path.WithInfoExtension()); + DownloadLogger.Post($"Info delete: {path}"); } public static string WithInfoExtension(this string path) { @@ -214,28 +95,69 @@ namespace BS.SharedLauncher.Logic return path + DotBeWoInfo; } + #endregion - private static void getPlanerFilesRecursive(DirectoryInfo directoryInfo, string relativeTo, ref List files) + public static void DeleteEmptyDirectories(string path) + { + // Witzige Sache: Generiert mit chat.openai.com/chat + // Recursive function to delete empty directories + // Get all subdirectories in the specified path + string[] subdirectories = Directory.GetDirectories(path); + + // Loop through each subdirectory + foreach (string subdirectory in subdirectories) + { + // Call the recursive function to delete empty directories in the subdirectory + DeleteEmptyDirectories(subdirectory); + + // Check if the subdirectory is empty + if (IsDirectoryEmpty(subdirectory)) + { + // If the subdirectory is empty, delete it + Directory.Delete(subdirectory); + DownloadLogger.Post($"Deleted empty directory: {subdirectory}"); + } + } + } + + public static List GetPlanerFiles(string path, bool hash, Func skipFile) + { + var files = new List(); + + // Sollte der Path ohne / enden, wird der unterordner mit angegeben + // Deshalb manuell hinzufügen, falls nicht vorhanden + + if (!path.EndsWith(Path.DirectorySeparatorChar.ToString())) + path += Path.DirectorySeparatorChar; + + GetPlanerFilesRecursive(new DirectoryInfo(path), path, ref files, hash, skipFile); + + return files; + } + public static void GetPlanerFilesRecursive(DirectoryInfo directoryInfo, string relativeTo, ref List files, bool load_hash, Func skipFile) { foreach (var item in directoryInfo.GetDirectories()) { - getPlanerFilesRecursive(item, relativeTo, ref files); + GetPlanerFilesRecursive(item, relativeTo, ref files, load_hash, skipFile); } foreach (var item in directoryInfo.GetFiles()) { - var file = new PlanerFileInfo(item, relativeTo); + var file = new UpdateFileDC(item, relativeTo); + if (file.IgnoreFile()) + continue; + + if (skipFile is object && skipFile(file)) + continue; + + if (load_hash) + file.LoadHash(); + files.Add(file); } } - private static string getFileNumberCountString(int i) - { - if (i == 0) - return string.Empty; - return $"({i})"; - } - + public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false) { try @@ -260,5 +182,9 @@ namespace BS.SharedLauncher.Logic return false; } } + private static bool IsDirectoryEmpty(string path) + { + return !Directory.EnumerateFileSystemEntries(path).Any(); + } } } diff --git a/SharedLauncher/SharedLauncher.csproj b/SharedLauncher/SharedLauncher.csproj index 32749c241..0f93921e5 100644 --- a/SharedLauncher/SharedLauncher.csproj +++ b/SharedLauncher/SharedLauncher.csproj @@ -49,27 +49,33 @@ - - - - - + + + + + + + + + - + + + + + - + - - diff --git a/SharedLauncher/Update/ApplyFileEventArgs.cs b/SharedLauncher/Update/ApplyFileEventArgs.cs index 86d454cf4..4653e30be 100644 --- a/SharedLauncher/Update/ApplyFileEventArgs.cs +++ b/SharedLauncher/Update/ApplyFileEventArgs.cs @@ -8,13 +8,11 @@ namespace BS.SharedLauncher.Update { public class ApplyFileEventArgs : EventArgs { - public string Name { get; set; } - public string AbsolutePath { get; set; } + public string RelativePath { get; set; } - public ApplyFileEventArgs(string name, string path) + public ApplyFileEventArgs(string name) { - Name = name; - AbsolutePath = path; + RelativePath = name; } } } diff --git a/SharedLauncher/Update/DownloadProgressEventArgs.cs b/SharedLauncher/Update/DownloadProgressEventArgs.cs index 6157994ae..a56124a96 100644 --- a/SharedLauncher/Update/DownloadProgressEventArgs.cs +++ b/SharedLauncher/Update/DownloadProgressEventArgs.cs @@ -1,4 +1,5 @@ -using System; +using BS.SharedLauncher.DataContract; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,11 +9,13 @@ namespace BS.SharedLauncher.Update { public class DownloadProgressEventArgs : EventArgs { - public double Progress { get; set; } + public string Size { get; set; } + public UpdateFileDC File { get; set; } - public DownloadProgressEventArgs(double progress) + public DownloadProgressEventArgs(string size, UpdateFileDC file) { - Progress = progress; + Size = size; + File = file; } } } diff --git a/SharedLauncher/Update/PlanerFileInfo.cs b/SharedLauncher/Update/PlanerFileInfo.cs deleted file mode 100644 index 15d57d53d..000000000 --- a/SharedLauncher/Update/PlanerFileInfo.cs +++ /dev/null @@ -1,45 +0,0 @@ -using BS.SharedLauncher.Utils; -using BS.SharedLauncher.Enums; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Security.Cryptography; -using BS.SharedLauncher.Update; -using System.Diagnostics; - -namespace BS.SharedLauncher.Update -{ - [DebuggerDisplay("{AbsolutePath}")] - public class PlanerFileInfo - { - public string Name { get; set; } - public string AbsolutePath { get; set; } - public string RelativePath { get; set; } - public string Checksum { get; set; } - - public PlanerFileInfo() - { - } - - public PlanerFileInfo(FileInfo fileInfo, string relativeTo) : this() - { - Name = fileInfo.Name; - AbsolutePath = fileInfo.FullName; - RelativePath = PathUtils.MakeRelativePath(relativeTo, fileInfo.FullName); - } - - public PlanerFileInfo Copy() - { - return new PlanerFileInfo() - { - Name = Name, - AbsolutePath = AbsolutePath, - RelativePath = RelativePath, - Checksum = Checksum - }; - } - } -} diff --git a/SharedLauncher/Update/PlanerPackageInfo.cs b/SharedLauncher/Update/PlanerPackageInfo.cs deleted file mode 100644 index 64a3ec8ad..000000000 --- a/SharedLauncher/Update/PlanerPackageInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using BS.SharedLauncher.Enums; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Linq; -using System.Xml.Serialization; - -namespace BS.SharedLauncher.Update -{ - public class PlanerPackageInfo - { - public List Files { get; set; } - public DateTime Created { get; set; } - public string DefaultVersion { get; set; } - public string TenantVersion { get; set; } - - public PlanerPackageInfo() - { - DefaultVersion = null; - TenantVersion = null; - } - - public string Version => TenantVersion ?? DefaultVersion; - } -} diff --git a/UnitTests/SharedLauncherTests.cs b/UnitTests/SharedLauncherTests.cs new file mode 100644 index 000000000..d7c39fe2e --- /dev/null +++ b/UnitTests/SharedLauncherTests.cs @@ -0,0 +1,33 @@ +using BS.SharedLauncher.Information; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace UnitTests +{ + [TestClass] + public class SharedLauncherTests + { + [TestMethod] + public void TestLoginLength() + { + var login = new Login(); + + Assert.AreEqual(login.Length, 7); + } + + [TestMethod] + public void TestConnectionLength() + { + var conn = new Connection(); + + Assert.AreEqual(conn.Length, 8); + } + + [TestMethod] + public void TestSessionLength() + { + var session = new Session(); + + Assert.AreEqual(session.Length, 1); + } + } +} diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj new file mode 100644 index 000000000..aa0327a5d --- /dev/null +++ b/UnitTests/UnitTests.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + +