From 795444f234f6b45bc83d5c7b28725bd7ebc7ee89 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 24 Dec 2018 17:39:01 +0200 Subject: Working on machine service and machine studio. --- .../Authentication/IAuthenticationProvider.cs | 5 +++ .../Authentication/LoginResponse.cs | 1 + .../Update/CheckForUpdatesRequest.cs | 4 +-- .../Update/CheckForUpdatesResponse.cs | 2 -- .../DefaultAuthenticationProvider.cs | 7 ++++ .../ViewModels/LoadingViewVM.cs | 42 ---------------------- .../ViewModels/MainViewVM.cs | 5 ++- .../ViewModels/UpdateViewVM.cs | 3 +- 8 files changed, 17 insertions(+), 52 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') 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 0c2aa3cb7..785dc1523 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs @@ -12,6 +12,11 @@ namespace Tango.MachineStudio.Common.Authentication /// public interface IAuthenticationProvider { + /// + /// Gets the access token that was retrieved at the last login. + /// + String AccessToken { get; } + /// /// Occurs when the current logged-in user has changed. /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs index 075a5ec10..3da033b9f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/LoginResponse.cs @@ -11,5 +11,6 @@ namespace Tango.MachineStudio.Common.Authentication public class LoginResponse : WebResponseMessage { public DataSource DataSource { get; set; } + public String Token { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs index 11911dd7e..cf06e678d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs @@ -10,9 +10,7 @@ namespace Tango.MachineStudio.Common.Update { public class CheckForUpdatesRequest : WebRequestMessage { - public String Email { get; set; } - - public String Password { get; set; } + public String Token { get; set; } public String Version { get; set; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs index b0577f40b..ae1e958ab 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs @@ -18,8 +18,6 @@ namespace Tango.MachineStudio.Common.Update public String Comments { get; set; } - public bool ForcedUpdate { get; set; } - public String BlobAddress { get; set; } } } 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 450756705..4acc76c25 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -63,6 +63,8 @@ namespace Tango.MachineStudio.UI.Authentication }).Result; + AccessToken = response.Token; + ObservablesContext.OverrideSettingsDataSource(response.DataSource); ObservablesStaticCollections.Instance.Initialize(); @@ -107,5 +109,10 @@ namespace Tango.MachineStudio.UI.Authentication { CurrentUser = null; } + + /// + /// Gets the access token that was retrieved at the last login. + /// + public string AccessToken { get; private set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 6e8d0488b..283ea3637 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -89,48 +89,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - try - { - Status = "Checking for critical updates..."; - - LogManager.Log("Checking for forced update..."); - - var client = new MachineStudioUpdateService(); - - CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() - { - Email = "ForceUpdate", - Password = "ForceUpdate", - Version = ApplicationManager.Version.ToString(), - }).Result; - - if (response.IsUpdateAvailable && response.ForcedUpdate) - { - LogManager.Log("Forced update found, Navigating to update view!"); - - InvokeUI(() => - { - if (_notificationProvider.ShowQuestion("Machine Studio has detected a critical update which must be installed in order for the application to run properly. Do you wish to download and install this update?")) - { - TangoMessenger.Default.Send(new Messages.ForcedUpdateMessage() { UpdateResponse = response }); - _navigationManager.NavigateTo(NavigationView.UpdateView); - } - else - { - ApplicationManager.ShutDown(); - } - - IsLoading = false; - }); - - return; - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error checking for forced update!"); - } - try { Status = "Connecting to Team Foundation Services..."; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index befad162c..818d507ae 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -363,8 +363,7 @@ namespace Tango.MachineStudio.UI.ViewModels CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { - Email = _authenticationProvider.CurrentUser.Email, - Password = _authenticationProvider.CurrentUser.Password, + Token = _authenticationProvider.AccessToken, Version = _applicationManager.Version.ToString(), AcceptBetaRelease = _settings.AcceptBetaRelease, }).Result; @@ -455,7 +454,7 @@ namespace Tango.MachineStudio.UI.ViewModels //Check machine exist on my database first if (x.SelectedMachine.Machine == null) { - _notificationProvider.ShowError( $"The specified machine '{x.SelectedMachine.SerialNumber}' could not be found on the database. Aborting connection."); + _notificationProvider.ShowError($"The specified machine '{x.SelectedMachine.SerialNumber}' could not be found on the database. Aborting connection."); return; } 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 3fec96629..e19dcdbe5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -196,8 +196,7 @@ namespace Tango.MachineStudio.UI.ViewModels CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { - Email = _authentication.CurrentUser.Email, - Password = _authentication.CurrentUser.Password, + Token = _authentication.AccessToken, Version = _application.Version.ToString(), AcceptBetaRelease = settings.AcceptBetaRelease, }).Result; -- cgit v1.3.1