From 7b22fc549089ea11a90486bcef0afbaba4efe3fa Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 26 Sep 2019 19:29:21 +0300 Subject: Fixed issue with BypassVersionCheck not loading modules. Added ForceVersionUpdate setting. --- .../Authentication/IAuthenticationProvider.cs | 7 ++++--- .../MachineStudioSettings.cs | 5 +++++ .../DefaultAuthenticationProvider.cs | 23 +++++++++++++++------- .../ViewModels/LoginViewVM.cs | 2 +- .../ViewModels/UpdateViewVM.cs | 2 +- .../Tango.MachineStudio.Updater/MainWindow.xaml.cs | 6 +++++- 6 files changed, 32 insertions(+), 13 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs index 4958cb0f4..74969fd27 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs @@ -4,13 +4,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.MachineStudio.Common.Web; -namespace Tango.MachineStudio.Common.Authentication +namespace Tango.MachineStudio.Common.Authentication { /// /// Represents the Machine Studio user authentication provider responsible for the current logged-in user. /// - public interface IAuthenticationProvider + public interface IAuthenticationProvider { /// /// Occurs when the current logged-in user has changed. @@ -28,7 +29,7 @@ namespace Tango.MachineStudio.Common.Authentication /// The email. /// The password. /// - AuthenticationLoginResult Login(String email, String password); + AuthenticationLoginResult Login(String email, String password, bool bypassVersionCheck = false); /// /// Logs-out the current logged-in user. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index 219b6faf0..781e034e8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -114,6 +114,11 @@ namespace Tango.MachineStudio.Common /// public bool ByPassEnvironmentVersionCheck { get; set; } + /// + /// Gets or sets a value indicating whether to force the application version update. + /// + public bool ForceVersionUpdate { get; set; } + /// /// Gets or sets a value indicating whether to enable database entity caching. /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index 2de61fd75..7fe1ae36a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -66,12 +66,19 @@ namespace Tango.MachineStudio.UI.Authentication /// The password. /// /// Login failed for user " + email - public AuthenticationLoginResult Login(string email, string password) + public AuthenticationLoginResult Login(string email, string password, bool bypassVersionCheck = false) { var settings = SettingsManager.Default.GetOrCreate(); _client.Environment = settings.DeploymentSlot; + var appVersion = AssemblyHelper.GetCurrentAssemblyVersion().ToString(); + + if (settings.ForceVersionUpdate) + { + appVersion = "1.0.0.0"; + } + LoginResponse response = null; try @@ -81,7 +88,7 @@ namespace Tango.MachineStudio.UI.Authentication Email = email, Password = password, - Version = AssemblyHelper.GetCurrentAssemblyVersion().ToString(), + Version = appVersion, }).Result; } @@ -90,12 +97,17 @@ namespace Tango.MachineStudio.UI.Authentication throw new AggregateException(new AuthenticationException("Error logging in to machine service."), ex); } + if (bypassVersionCheck) + { + response.VersionChangeRequired = false; + } + if (settings.Environment == MachineStudioSettings.WorkingEnvironment.Remote) { ObservablesContext.OverrideSettingsDataSource(response.DataSource); } - if (response.VersionChangeRequired) + if (response.VersionChangeRequired && !bypassVersionCheck) { return new AuthenticationLoginResult() { @@ -121,10 +133,7 @@ namespace Tango.MachineStudio.UI.Authentication throw new AuthenticationException("Invalid credentials for " + email); } - if (!response.VersionChangeRequired) - { - CurrentUser = user; - } + CurrentUser = user; return new AuthenticationLoginResult() { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index c181d7b9d..cf34764d9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -158,7 +158,7 @@ namespace Tango.MachineStudio.UI.ViewModels { _settings.DeploymentSlot = DeploymentSlot; - LoginResponse result = _authenticationProvider.Login(Email, Password).Response; + LoginResponse result = _authenticationProvider.Login(Email, Password, _settings.ByPassEnvironmentVersionCheck).Response; if (result.VersionChangeRequired && !_settings.ByPassEnvironmentVersionCheck) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index c40f91005..4a94322fb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -218,7 +218,7 @@ namespace Tango.MachineStudio.UI.ViewModels CheckForUpdatesResponse response = _machineStudioWebClient.CheckForUpdates(new CheckForUpdatesRequest() { - Version = _application.Version.ToString(), + Version = settings.ForceVersionUpdate ? "1.0.0.0" : _application.Version.ToString(), }).Result; if (response.IsUpdateAvailable) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs index c636e3125..8ac3d7c71 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/MainWindow.xaml.cs @@ -143,7 +143,11 @@ namespace Tango.MachineStudio.Updater if (appProcess != null) { tries++; - appProcess.Kill(); + try + { + appProcess.Kill(); + } + catch { } try { -- cgit v1.3.1