diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
6 files changed, 84 insertions, 7 deletions
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 ccaedb359..9be938fb7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -13,6 +13,8 @@ using System.Data.Entity; using Tango.Transport.Web; using Tango.Settings; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.Core.Helpers; namespace Tango.MachineStudio.UI.Authentication { @@ -50,7 +52,7 @@ namespace Tango.MachineStudio.UI.Authentication /// <param name="password">The password.</param> /// <returns></returns> /// <exception cref="AuthenticationException">Login failed for user " + email</exception> - public User Login(string email, string password) + public AuthenticationLoginResult Login(string email, string password) { var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); @@ -61,6 +63,7 @@ namespace Tango.MachineStudio.UI.Authentication Email = email, Password = password, + Version = AssemblyHelper.GetCurrentAssemblyVersion().ToString(), }).Result; @@ -90,8 +93,16 @@ namespace Tango.MachineStudio.UI.Authentication throw new AuthenticationException("Invalid credentials for " + email); } - CurrentUser = user; - return user; + if (!response.VersionChangeRequired) + { + CurrentUser = user; + } + + return new AuthenticationLoginResult() + { + User = user, + Response = response + }; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Messages/ChangeVersionMessage.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Messages/ChangeVersionMessage.cs new file mode 100644 index 000000000..fc616f359 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Messages/ChangeVersionMessage.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Update; + +namespace Tango.MachineStudio.UI.Messages +{ + public class ChangeVersionMessage + { + public LoginResponse LoginResponse { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 80509e6c0..161177bf1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -383,6 +383,16 @@ namespace Tango.MachineStudio.UI.Notifications } /// <summary> + /// Shows a question message box with an error icon. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> + public bool ShowErrorQuestion(string message) + { + return ShowMessageBox(PackIconKind.CommentAlertOutline, Brushes.DarkOrange, message, true).Value; + } + + /// <summary> /// Pushes the specified task item to the queue. /// </summary> /// <param name="taskItem">The task item.</param> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 4abd115f0..ee10514f2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -144,6 +144,7 @@ </Compile> <Compile Include="Console\ConsoleWindowVM.cs" /> <Compile Include="FirmwareUpgrade\DefaultFirmwareUpgrader.cs" /> + <Compile Include="Messages\ChangeVersionMessage.cs" /> <Compile Include="Messages\ForcedUpdateMessage.cs" /> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> <Compile Include="Notifications\TextInputBoxWindow.xaml.cs"> @@ -609,7 +610,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_UpdateFileVersion="True" BuildVersion_DetectChanges="True" BuildVersion_UseGlobalSettings="False" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file 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 c8e25e2d4..400d2c2f0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -10,11 +10,13 @@ using Tango.BL; using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.Core.Cryptography; +using Tango.Core.DI; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.Messages; using Tango.Settings; using Tango.SharedUI; using Tango.Web; @@ -150,11 +152,26 @@ namespace Tango.MachineStudio.UI.ViewModels await Task.Factory.StartNew(() => { - - _settings.DeploymentSlot = DeploymentSlot; - _authenticationProvider.Login(Email, Password); + var result = _authenticationProvider.Login(Email, Password).Response; + + if (result.VersionChangeRequired) + { + InvokeUI(() => + { + if (_notificationProvider.ShowErrorQuestion($"Your version of Machine Studio is different from the version specified for the selected environment.\nMachine Studio must be changed to version '{result.RequiredVersion}' in order to continue.\nDo you wish to update your local version?")) + { + TangoMessenger.Default.Send(new ChangeVersionMessage() + { + LoginResponse = result, + }); + _navigationManager.NavigateTo(NavigationView.UpdateView); + } + }); + + return; + } _eventLogger.Log(EventTypes.APPLICATION_STARTED, "Application Started!"); 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 60a023071..f671251f7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -158,6 +158,29 @@ namespace Tango.MachineStudio.UI.ViewModels IsRollbackAvailable = File.Exists(GetRollbackFile()); TangoMessenger.Default.Register<Messages.ForcedUpdateMessage>(HandleForcedUpdateMessage); + TangoMessenger.Default.Register<Messages.ChangeVersionMessage>(HandleChangeVersionMessage); + } + + private async void HandleChangeVersionMessage(ChangeVersionMessage msg) + { + ForcedUpdate = true; + InvalidateRelayCommands(); + + Status = UpdateStatus.CheckingForUpdate; + + var client = new MachineStudioUpdateService(); + + DownloadLatestVersionResponse response = await client.DownloadLatestVersion(new DownloadLatestVersionRequest() + { + AccessToken = _authentication.AccessToken, + }); + + _updateInfo = new CheckForUpdatesResponse(); + _updateInfo.BlobAddress = response.BlobAddress; + _updateInfo.Version = response.Version; + LatestVersion = _updateInfo.Version; + + StartUpdate(); } private void HandleForcedUpdateMessage(ForcedUpdateMessage msg) |
