From fadf83a50071ffba21db05eceff10c51c18f5fb3 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 23 Feb 2018 12:03:18 +0200 Subject: Machine Studio Update & Publish. Improved user roles & permissions structure. Added permission for version publish. --- .../DataCaptureModule.cs | 2 +- .../Tango.MachineStudio.Stubs/StubsModule.cs | 2 +- .../Tango.MachineStudio.Publisher/MainWindow.xaml | 22 +++++++++++----------- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 10 +++++++++- .../DefaultAuthenticationProvider.cs | 7 ++++++- .../Tango.MachineStudio.UI.csproj | 4 ++++ .../MachineStudioUpdateService.svc.cs | 6 +++--- .../Tango.MachineStudio.UpdateService.csproj | 4 ++-- .../Web.Release.config | 2 +- .../Tango.MachineStudio.Updater/MainWindow.xaml.cs | 5 ++++- 10 files changed, 42 insertions(+), 22 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs index ee650dc13..b138af4f3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/DataCaptureModule.cs @@ -69,7 +69,7 @@ namespace Tango.MachineStudio.DataCapture { get { - return Permissions.RunTechnicianModule; + return Permissions.RunDataCaptureModule; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs index 817c68b49..4dd0bdff1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -41,7 +41,7 @@ namespace Tango.MachineStudio.Stubs /// /// Gets the permission required to see and load this module. /// - public override Permissions Permission => Permissions.RunSynchronizationModule; + public override Permissions Permission => Permissions.RunStubsModule; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml index 9f592ca6d..ab7e503ff 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindow.xaml @@ -26,28 +26,28 @@ - - - Latest Version: + + + Remote Version: - - Current Version: + + Local Version: - + Email: - + - + Password: - + - Comments - + Comments + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs index 2ceb36994..34d2f1b1f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using System.Windows; using Tango.Core.Commands; using Tango.Core.Cryptography; +using Tango.Core.Helpers; using Tango.MachineStudio.Common.Update; using Tango.Settings; using Tango.SharedUI; @@ -121,6 +122,7 @@ namespace Tango.MachineStudio.Publisher Task.Factory.StartNew(() => { IsUpdating = true; + String tempFile = String.Empty; try { @@ -132,7 +134,7 @@ namespace Tango.MachineStudio.Publisher Comments = Comments, }); - String tempFile = Path.Combine(Path.GetTempPath(), response.FileName); + tempFile = Path.Combine(Path.GetTempPath(), response.FileName); using (ZipFile zip = new ZipFile()) { @@ -174,6 +176,11 @@ namespace Tango.MachineStudio.Publisher } } + _client.NotifyUploadCompleted(new UploadCompletedRequest() + { + Token = response.Token, + }); + UpdateVersions(); } catch (Exception ex) @@ -183,6 +190,7 @@ namespace Tango.MachineStudio.Publisher finally { IsUpdating = false; + PathHelper.TryDeleteFile(tempFile); } }); } 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 82aba268d..110e4d148 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -50,7 +50,12 @@ namespace Tango.MachineStudio.UI.Authentication if (user == null) { - throw new AuthenticationException("Login failed for user " + email); + throw new AuthenticationException("Invalid credentials for " + email); + } + + if (!user.HasPermission(Permissions.RunMachineStudio)) + { + throw new AuthenticationException("It seems like you do not have sufficient privileges to run Machine Studio. Please contact your administrator."); } CurrentUser = user; 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 61ea92566..4cfa99a9b 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 @@ -363,6 +363,10 @@ {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common + + {844787ce-f409-4f18-bccc-f3809ecb86f3} + Tango.MachineStudio.Updater + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs index e573a0d77..bf737c7a9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -31,7 +31,7 @@ namespace Tango.MachineStudio.UpdateService private static List _pendingUploads; - MachineStudioUpdateService() + static MachineStudioUpdateService() { _pendingUploads = new List(); } @@ -50,7 +50,7 @@ namespace Tango.MachineStudio.UpdateService var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); - if (user != null) + if (user != null && user.HasPermission(Permissions.RunMachineStudio)) { var latestVersion = db.MachineStudioVersions.FirstOrDefault(); Version currentVersion = Version.Parse(request.Version); @@ -93,7 +93,7 @@ namespace Tango.MachineStudio.UpdateService var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); - if (user != null) + if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) { var latestVersion = db.MachineStudioVersions.FirstOrDefault(); Version currentVersion = Version.Parse(request.Version); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj index c9400b2d1..0b4d78195 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj @@ -26,7 +26,7 @@ true full false - ..\..\Build\Debug\Web\Machine Studio Update Service\ + bin\ DEBUG;TRACE prompt 4 @@ -118,7 +118,7 @@ - True + False True 65206 / diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config index da6e960b8..d2da57796 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config @@ -15,7 +15,7 @@ --> - +