From 473d878e3ae795201223b160fcbc1147e901b038 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 18 Feb 2019 16:58:37 +0200 Subject: Working on PPC versioning services... --- .../Web/LoginResponse.cs | 2 +- .../Tango.MachineStudio.Publisher.UI.csproj | 2 +- .../DefaultAuthenticationProvider.cs | 2 +- .../MachineSetup/MachineSetupManager.cs | 31 +- .../MachineSetup/MachineSetupRequest.cs | 14 - .../MachineSetup/MachineSetupResponse.cs | 28 -- .../MachineUpdate/CheckForUpdateRequest.cs | 15 - .../MachineUpdate/CheckForUpdateResponse.cs | 15 - .../MachineUpdate/DbCompareResult.cs | 1 + .../MachineUpdate/DownloadUpdateRequest.cs | 14 - .../MachineUpdate/DownloadUpdateResponse.cs | 19 - .../MachineUpdate/IMachineUpdateManager.cs | 12 +- .../MachineUpdate/MachineUpdateManager.cs | 62 ++- .../MachineUpdate/UpdateDBRequest.cs | 14 - .../MachineUpdate/UpdateDBResponse.cs | 15 - .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 49 ++- .../Tango.PPC.Common/Update/IPPCUpdateService.cs | 44 --- .../Update/LatestVersionRequest.cs | 15 - .../Update/LatestVersionResponse.cs | 15 - .../Update/MachineVersionsRequest.cs | 14 - .../Update/MachineVersionsResponse.cs | 20 - .../Tango.PPC.Common/Update/PPCUpdateService.cs | 45 --- .../Update/UploadCompletedRequest.cs | 15 - .../Update/UploadCompletedResponse.cs | 15 - .../Update/UploadVersionRequest.cs | 23 -- .../Update/UploadVersionResponse.cs | 17 - .../Tango.PPC.Common/Web/CheckForUpdateRequest.cs | 14 + .../Tango.PPC.Common/Web/CheckForUpdateResponse.cs | 15 + .../Tango.PPC.Common/Web/DownloadUpdateRequest.cs | 14 + .../Tango.PPC.Common/Web/DownloadUpdateResponse.cs | 19 + .../PPC/Tango.PPC.Common/Web/IPPCWebService.cs | 85 ++++ .../Tango.PPC.Common/Web/LatestVersionRequest.cs | 15 + .../Tango.PPC.Common/Web/LatestVersionResponse.cs | 15 + .../PPC/Tango.PPC.Common/Web/LoginMode.cs | 14 + .../PPC/Tango.PPC.Common/Web/LoginRequest.cs | 17 + .../PPC/Tango.PPC.Common/Web/LoginResponse.cs | 14 + .../Tango.PPC.Common/Web/MachineSetupRequest.cs | 14 + .../Tango.PPC.Common/Web/MachineSetupResponse.cs | 28 ++ .../Tango.PPC.Common/Web/MachineVersionsRequest.cs | 14 + .../Web/MachineVersionsResponse.cs | 20 + .../PPC/Tango.PPC.Common/Web/PPCWebService.cs | 79 ++++ .../PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs | 14 + .../PPC/Tango.PPC.Common/Web/UpdateDBResponse.cs | 15 + .../Tango.PPC.Common/Web/UploadCompletedRequest.cs | 15 + .../Web/UploadCompletedResponse.cs | 15 + .../Tango.PPC.Common/Web/UploadVersionRequest.cs | 19 + .../Tango.PPC.Common/Web/UploadVersionResponse.cs | 17 + .../PPC/Tango.PPC.Common/packages.config | 1 + .../PPC/Tango.PPC.Publisher.UI/App.config | 92 +++++ .../PPC/Tango.PPC.Publisher.UI/App.xaml | 9 + .../PPC/Tango.PPC.Publisher.UI/App.xaml.cs | 17 + .../PPC/Tango.PPC.Publisher.UI/MainWindow.xaml | 127 ++++++ .../PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs | 97 +++++ .../PPC/Tango.PPC.Publisher.UI/MainWindowVM.cs | 256 ++++++++++++ .../Properties/AssemblyInfo.cs | 23 ++ .../Properties/Resources.Designer.cs | 63 +++ .../Properties/Resources.resx | 117 ++++++ .../Properties/Settings.Designer.cs | 26 ++ .../Properties/Settings.settings | 7 + .../Tango.PPC.Publisher.UI/PublisherSettings.cs | 22 ++ .../Tango.PPC.Publisher.UI.csproj | 165 ++++++++ .../PPC/Tango.PPC.Publisher.UI/packages.config | 6 + .../PPC/Tango.PPC.Publisher/App.config | 92 ----- .../Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml | 9 - .../PPC/Tango.PPC.Publisher/App.xaml.cs | 17 - .../PPC/Tango.PPC.Publisher/MainWindow.xaml | 113 ------ .../PPC/Tango.PPC.Publisher/MainWindow.xaml.cs | 96 ----- .../PPC/Tango.PPC.Publisher/MainWindowVM.cs | 430 --------------------- .../Tango.PPC.Publisher/Properties/AssemblyInfo.cs | 23 -- .../Properties/Resources.Designer.cs | 71 ---- .../Tango.PPC.Publisher/Properties/Resources.resx | 117 ------ .../Properties/Settings.Designer.cs | 30 -- .../Properties/Settings.settings | 7 - .../PPC/Tango.PPC.Publisher/PublisherSettings.cs | 29 -- .../PPC/Tango.PPC.Publisher/SequenceItem.cs | 63 --- .../Tango.PPC.Publisher/Tango.PPC.Publisher.csproj | 166 -------- .../PPC/Tango.PPC.Publisher/packages.config | 6 - Software/Visual_Studio/PPC/Tango.PPC.UI/App.config | 80 ++++ .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 1 + .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 8 +- .../PPC/Tango.PPC.WatchDog/App.config | 74 +++- .../Tango.Web/Authentication/TokensManager.cs | 2 +- Software/Visual_Studio/Tango.sln | 86 ++--- .../Controllers/MachineStudioController.cs | 4 +- .../Controllers/PPCController.cs | 110 ++++-- .../Tango.MachineService/Filters/PPCLoginFilter.cs | 31 ++ .../Web/Tango.MachineService/Models/Person.cs | 14 - .../Tango.MachineService.csproj | 2 +- 88 files changed, 1939 insertions(+), 1760 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/IPPCWebService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginMode.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/PPCWebService.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.config create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindowVM.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.resx create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.settings create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/PublisherSettings.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Tango.PPC.Publisher.UI.csproj create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/packages.config delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/AssemblyInfo.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.Designer.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.resx delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.Designer.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.settings delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/SequenceItem.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Publisher/packages.config create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Filters/PPCLoginFilter.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/Person.cs diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs index 0379c458b..643e3930d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginResponse.cs @@ -11,7 +11,7 @@ namespace Tango.MachineStudio.Common.Web public class LoginResponse : WebResponseMessage { public DataSource DataSource { get; set; } - public String Token { get; set; } + public String AccessToken { get; set; } public bool VersionChangeRequired { get; set; } public String RequiredVersion { get; set; } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj index dad050b31..f7b753e02 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher.UI/Tango.MachineStudio.Publisher.UI.csproj @@ -174,7 +174,7 @@ - + \ No newline at end of file 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 452b706df..1f9aee937 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -68,7 +68,7 @@ namespace Tango.MachineStudio.UI.Authentication }).Result; - AccessToken = response.Token; + AccessToken = response.AccessToken; if (settings.Environment == MachineStudioSettings.WorkingEnvironment.Remote) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 488206590..b5140e336 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -22,6 +22,7 @@ using Tango.PPC.Common.Connection; using Tango.PPC.Common.OS; using Tango.PPC.Common.RemoteAssistance; using Tango.PPC.Common.UWF; +using Tango.PPC.Common.Web; using Tango.Settings; using Tango.SharedUI.Helpers; using Tango.SQLExaminer; @@ -39,6 +40,7 @@ namespace Tango.PPC.Common.MachineSetup private IRemoteAssistanceProvider _remoteAssistance; private IUnifiedWriteFilterManager _uwf; private IOperationSystemManager _windows_manager; + private String _accessToken; #region Events @@ -80,6 +82,27 @@ namespace Tango.PPC.Common.MachineSetup #endregion + #region Private Methods + + private Task Login(String serialNumber) + { + return Task.Factory.StartNew(() => + { + using (var client = new PPCWebService()) + { + var response = client.Login(new LoginRequest() + { + Mode = LoginMode.Machine, + SerialNumber = serialNumber, + }).Result; + + _accessToken = response.AccessToken; + } + }); + } + + #endregion + #region Public Methods /// @@ -105,16 +128,18 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); + await Login(serialNumber); + MachineSetupRequest request = new MachineSetupRequest(); - request.SerialNumber = serialNumber; + request.AccessToken = _accessToken; MachineSetupResponse setup_response = null; try { - using (var http = new WebTransportClient()) + using (var client = new PPCWebService()) { - setup_response = await http.PostJson(machineServiceAddress + "/api/PPC/MachineSetup", request); + setup_response = await client.MachineSetup(request); } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs deleted file mode 100644 index 4c8039544..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineSetup -{ - public class MachineSetupRequest : WebRequestMessage - { - public String SerialNumber { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs deleted file mode 100644 index 5e8885af7..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineSetup -{ - public class MachineSetupResponse : WebResponseMessage - { - public String Version { get; set; } - - public String BlobAddress { get; set; } - - public DataSource DataSource { get; set; } - - public String OSKey { get; set; } - - public bool SetupActivation { get; set; } - public bool SetupRemoteAssistance { get; set; } - public bool SetupUWF { get; set; } - public bool SetupFirmware { get; set; } - public bool SetupFPGA { get; set; } - public bool IsDemo { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs deleted file mode 100644 index cd5789393..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineUpdate -{ - public class CheckForUpdateRequest : WebRequestMessage - { - public String SerialNumber { get; set; } - public String Version { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs deleted file mode 100644 index cbf6c8c64..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineUpdate -{ - public class CheckForUpdateResponse : WebResponseMessage - { - public bool IsUpdateAvailable { get; set; } - public String Version { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs index fbfc2e08c..3b4f59c9e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DbCompareResult.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.PMR.Synchronization; +using Tango.PPC.Common.Web; namespace Tango.PPC.Common.MachineUpdate { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs deleted file mode 100644 index 9369a2a94..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineUpdate -{ - public class DownloadUpdateRequest : WebRequestMessage - { - public String SerialNumber { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs deleted file mode 100644 index de978ed66..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineUpdate -{ - public class DownloadUpdateResponse : WebResponseMessage - { - public String Version { get; set; } - - public String BlobAddress { get; set; } - - public DataSource DataSource { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs index 08124154b..ffe3f6b5c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.PMR.Synchronization; +using Tango.PPC.Common.Web; namespace Tango.PPC.Common.MachineUpdate { @@ -25,32 +26,29 @@ namespace Tango.PPC.Common.MachineUpdate /// Performs a machine update using the specified serial number and machine service address. /// /// The serial number. - /// The machine service address. /// - Task Update(String serialNumber, String machineServiceAddress); + Task Update(String serialNumber); /// /// Performs a machine update using the specified software update package path. /// /// Name of the file. /// - Task Update(String fileName); + Task UpdateFromTUP(String fileName); /// /// Checks if any update are available for the specified machine serial number. /// /// The serial number. - /// The machine service address. /// - Task CheckForUpdate(String serialNumber, String machineServiceAddress); + Task CheckForUpdate(String serialNumber); /// /// Checks whether it is necessary to updates all the "overwrite-able" database tables. /// /// The serial number. - /// The machine service address. /// - Task UpdateDBCheck(String serialNumber, String machineServiceAddress); + Task UpdateDBCheck(String serialNumber); /// /// Updates all the "overwrite-able" database tables. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 69df627fb..c19208724 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -17,6 +17,7 @@ using Tango.Integration.Operation; using Tango.PMR.Synchronization; using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Web; using Tango.Settings; using Tango.SharedUI.Helpers; using Tango.SQLExaminer; @@ -28,6 +29,7 @@ namespace Tango.PPC.Common.MachineUpdate { private IPPCApplicationManager _app_manager; private IMachineProvider _machineProvider; + private String _accessToken; #region Events @@ -68,6 +70,27 @@ namespace Tango.PPC.Common.MachineUpdate #endregion + #region Private Methods + + private Task Login(String serialNumber) + { + return Task.Factory.StartNew(() => + { + using (var client = new PPCWebService()) + { + var response = client.Login(new LoginRequest() + { + Mode = LoginMode.Machine, + SerialNumber = serialNumber, + }).Result; + + _accessToken = response.AccessToken; + } + }); + } + + #endregion + #region Public Methods /// @@ -76,12 +99,14 @@ namespace Tango.PPC.Common.MachineUpdate /// The serial number. /// The machine service address. /// - public async Task Update(string serialNumber, string machineServiceAddress) + public async Task Update(string serialNumber) { TaskCompletionSource result = new TaskCompletionSource(); try { + var machineServiceAddress = SettingsManager.Default.GetOrCreate().GetMachineServiceAddress(); + LogManager.Log($"Starting machine update for serial number {serialNumber}..."); //Connecting to machine... @@ -106,14 +131,16 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); + await Login(serialNumber); + DownloadUpdateRequest request = new DownloadUpdateRequest(); - request.SerialNumber = serialNumber; + request.AccessToken = _accessToken; DownloadUpdateResponse update_response = null; - using (var http = new WebTransportClient()) + using (var client = new PPCWebService()) { - update_response = await http.PostJson(machineServiceAddress + "/api/PPC/MachineUpdate", request); + update_response = await client.MachineUpdate(request); } LogManager.Log($"Machine update response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -266,22 +293,27 @@ namespace Tango.PPC.Common.MachineUpdate /// The serial number. /// The machine service address. /// - public Task CheckForUpdate(string serialNumber, string machineServiceAddress) + public Task CheckForUpdate(string serialNumber) { return Task.Factory.StartNew(() => { + var machineServiceAddress = SettingsManager.Default.GetOrCreate().GetMachineServiceAddress(); + LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); + + Login(serialNumber).Wait(); + LogManager.Log($"Checking if updates available..."); CheckForUpdateRequest request = new CheckForUpdateRequest(); - request.SerialNumber = serialNumber; + request.AccessToken = _accessToken; request.Version = _app_manager.Version.ToString(); CheckForUpdateResponse update_response = null; - using (var http = new WebTransportClient()) + using (var client = new PPCWebService()) { - update_response = http.PostJson(machineServiceAddress + "/api/PPC/CheckForUpdate", request).Result; + update_response = client.CheckForUpdate(request).Result; } LogManager.Log($"Check for update response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -361,10 +393,12 @@ namespace Tango.PPC.Common.MachineUpdate /// The serial number. /// The machine service address. /// - public Task UpdateDBCheck(string serialNumber, string machineServiceAddress) + public Task UpdateDBCheck(string serialNumber) { return Task.Factory.StartNew(() => { + var machineServiceAddress = SettingsManager.Default.GetOrCreate().GetMachineServiceAddress(); + LogManager.Log($"Checking if database update is required for serial number {serialNumber}..."); LogManager.Log("Looking for OverrideData script on application path..."); @@ -383,14 +417,16 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); + Login(serialNumber).Wait(); + UpdateDBRequest request = new UpdateDBRequest(); - request.SerialNumber = serialNumber; + request.AccessToken = _accessToken; UpdateDBResponse update_response = null; - using (var http = new WebTransportClient()) + using (var client = new PPCWebService()) { - update_response = http.PostJson(machineServiceAddress + "/api/PPC/UpdateDB", request).Result; + update_response = client.UpdateDB(request).Result; } LogManager.Log($"Update DB response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -452,7 +488,7 @@ namespace Tango.PPC.Common.MachineUpdate /// /// Name of the file. /// - public Task Update(string fileName) + public Task UpdateFromTUP(string fileName) { return Task.Factory.StartNew(() => { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs deleted file mode 100644 index 1d0caa5a9..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineUpdate -{ - public class UpdateDBRequest : WebRequestMessage - { - public String SerialNumber { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs deleted file mode 100644 index 36be14750..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.MachineUpdate -{ - public class UpdateDBResponse : WebResponseMessage - { - public DataSource DataSource { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 124e6e276..3b18a6217 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -48,6 +48,9 @@ 4 + + ..\..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll @@ -139,19 +142,27 @@ - - + + + + + + + - - + + - - + + + + + - - + + @@ -181,16 +192,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -355,7 +366,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs deleted file mode 100644 index a16099e7c..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.Text; -using System.Threading.Tasks; -using Tango.PPC.Common.Update; - -namespace Tango.PPC.Common.Update -{ - /// - /// Represents an PPC update service for uploading PPC software packages. - /// - public interface IPPCUpdateService - { - /// - /// Uploads the version. - /// - /// The request. - /// - Task UploadVersion(UploadVersionRequest request); - - /// - /// Notifies the upload completed. - /// - /// The request. - Task NotifyUploadCompleted(UploadCompletedRequest request); - - /// - /// Gets the latest version. - /// - /// The machine version unique identifier. - /// - Task GetLatestVersion(LatestVersionRequest request); - - /// - /// Gets the hardware versions. - /// - /// The request. - /// - Task GetMachineVersions(); - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs deleted file mode 100644 index 6a6dab1b4..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class LatestVersionRequest : WebRequestMessage - { - public String MachineVersionGuid { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs deleted file mode 100644 index 8e97a8177..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class LatestVersionResponse : WebResponseMessage - { - public String Version { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs deleted file mode 100644 index bf2d86e70..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class MachineVersionsRequest : WebRequestMessage - { - - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs deleted file mode 100644 index ed4ac95c2..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class MachineVersionsResponse : WebResponseMessage - { - public List MachineVersions { get; set; } - - public MachineVersionsResponse() - { - MachineVersions = new List(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs deleted file mode 100644 index 5692ccce9..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Settings; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class PPCUpdateService : IPPCUpdateService - { - private WebTransportClient _client; - - public PPCUpdateService() - { - _client = new WebTransportClient(); - } - - private String GetAddress() - { - return SettingsManager.Default.GetOrCreate().GetMachineServiceAddress() + "/api/PPC/"; - } - - public Task UploadVersion(UploadVersionRequest request) - { - return _client.PostJson(GetAddress() + "UploadVersion", request); - } - - public Task NotifyUploadCompleted(UploadCompletedRequest request) - { - return _client.PostJson(GetAddress() + "NotifyUploadCompleted", request); - } - - public Task GetLatestVersion(LatestVersionRequest request) - { - return _client.PostJson(GetAddress() + "GetLatestVersion", request); - } - - public Task GetMachineVersions() - { - return _client.PostJson(GetAddress() + "GetMachineVersions", new MachineVersionsRequest()); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs deleted file mode 100644 index dab9bcefd..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class UploadCompletedRequest : WebRequestSecureMessage - { - - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs deleted file mode 100644 index 1cce32e7d..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class UploadCompletedResponse : WebResponseMessage - { - - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs deleted file mode 100644 index 0b496d7be..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class UploadVersionRequest : WebRequestMessage - { - public String Email { get; set; } - - public String Password { get; set; } - - public String Version { get; set; } - - public String MachineVersionGuid { get; set; } - - public String Comments { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs deleted file mode 100644 index 4543261e7..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using Tango.Transport.Web; - -namespace Tango.PPC.Common.Update -{ - public class UploadVersionResponse : WebResponseMessage - { - public String Token { get; set; } - - public String BlobAddress { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs new file mode 100644 index 000000000..8bb8cde54 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class CheckForUpdateRequest : WebRequestSecureMessage + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs new file mode 100644 index 000000000..1d49a535a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class CheckForUpdateResponse : WebResponseMessage + { + public bool IsUpdateAvailable { get; set; } + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateRequest.cs new file mode 100644 index 000000000..20d1da3ec --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class DownloadUpdateRequest : WebRequestSecureMessage + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateResponse.cs new file mode 100644 index 000000000..3b09c1525 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateResponse.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class DownloadUpdateResponse : WebResponseMessage + { + public String Version { get; set; } + + public String BlobAddress { get; set; } + + public DataSource DataSource { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/IPPCWebService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/IPPCWebService.cs new file mode 100644 index 000000000..6347836a9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/IPPCWebService.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common.Web; +using Tango.Web; + +namespace Tango.PPC.Common.Web +{ + /// + /// Represents an PPC update service for uploading PPC software packages. + /// + public interface IPPCWebService : IDisposable + { + /// + /// Gets or sets the environment. + /// + DeploymentSlot Environment { get; set; } + + /// + /// Uploads the version. + /// + /// The request. + /// + Task UploadVersion(UploadVersionRequest request); + + /// + /// Notifies the upload completed. + /// + /// The request. + Task NotifyUploadCompleted(UploadCompletedRequest request); + + /// + /// Gets the latest version. + /// + /// The machine version unique identifier. + /// + Task GetLatestVersion(LatestVersionRequest request); + + /// + /// Gets the machine versions. + /// + /// The request. + /// + Task GetMachineVersions(); + + /// + /// Checks for available update. + /// + /// The request. + /// + Task CheckForUpdate(CheckForUpdateRequest request); + + /// + /// Gets the version download info for the specified version. + /// + /// The request. + /// + Task MachineUpdate(DownloadUpdateRequest request); + + /// + /// Gets the machine setup information. + /// + /// The request. + /// + Task MachineSetup(MachineSetupRequest request); + + /// + /// Gets the machine database update information. + /// + /// The request. + /// + Task UpdateDB(UpdateDBRequest request); + + /// + /// Logins to the PPC service. + /// + /// The request. + /// + Task Login(LoginRequest request); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionRequest.cs new file mode 100644 index 000000000..400bb315c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class LatestVersionRequest : WebRequestMessage + { + public String MachineVersionGuid { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionResponse.cs new file mode 100644 index 000000000..d2ed08f7d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class LatestVersionResponse : WebResponseMessage + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginMode.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginMode.cs new file mode 100644 index 000000000..01e792ff7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginMode.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Web +{ + public enum LoginMode + { + Machine, + User, + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginRequest.cs new file mode 100644 index 000000000..f8588f6b0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginRequest.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class LoginRequest : WebRequestMessage + { + public LoginMode Mode { get; set; } + public String SerialNumber { get; set; } + public String Email { get; set; } + public String Password { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginResponse.cs new file mode 100644 index 000000000..bf2a1e88e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LoginResponse.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class LoginResponse : WebResponseMessage + { + public String AccessToken { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs new file mode 100644 index 000000000..ce8b2f58d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class MachineSetupRequest : WebRequestSecureMessage + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs new file mode 100644 index 000000000..7d142d5f7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class MachineSetupResponse : WebResponseMessage + { + public String Version { get; set; } + + public String BlobAddress { get; set; } + + public DataSource DataSource { get; set; } + + public String OSKey { get; set; } + + public bool SetupActivation { get; set; } + public bool SetupRemoteAssistance { get; set; } + public bool SetupUWF { get; set; } + public bool SetupFirmware { get; set; } + public bool SetupFPGA { get; set; } + public bool IsDemo { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsRequest.cs new file mode 100644 index 000000000..d5936bc9b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class MachineVersionsRequest : WebRequestSecureMessage + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsResponse.cs new file mode 100644 index 000000000..8d321f303 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsResponse.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class MachineVersionsResponse : WebResponseMessage + { + public List MachineVersions { get; set; } + + public MachineVersionsResponse() + { + MachineVersions = new List(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/PPCWebService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/PPCWebService.cs new file mode 100644 index 000000000..02821e8d4 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/PPCWebService.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; +using Tango.Transport.Web; +using Tango.Web; + +namespace Tango.PPC.Common.Web +{ + public class PPCWebService : IPPCWebService + { + private WebTransportClient _client; + + public DeploymentSlot Environment { get; set; } + + public PPCWebService() + { + _client = new WebTransportClient(); + Environment = SettingsManager.Default.GetOrCreate().DeploymentSlot; + } + + private String GetAddress() + { + return Environment.ToAddress() + "/api/PPC/"; + } + + public Task UploadVersion(UploadVersionRequest request) + { + return _client.PostJson(GetAddress() + "UploadVersion", request); + } + + public Task NotifyUploadCompleted(UploadCompletedRequest request) + { + return _client.PostJson(GetAddress() + "NotifyUploadCompleted", request); + } + + public Task GetLatestVersion(LatestVersionRequest request) + { + return _client.PostJson(GetAddress() + "GetLatestVersion", request); + } + + public Task GetMachineVersions() + { + return _client.PostJson(GetAddress() + "GetMachineVersions", new MachineVersionsRequest()); + } + + public Task CheckForUpdate(CheckForUpdateRequest request) + { + return _client.PostJson(GetAddress() + "CheckForUpdate", request); + } + + public Task MachineUpdate(DownloadUpdateRequest request) + { + return _client.PostJson(GetAddress() + "MachineUpdate", request); + } + + public Task MachineSetup(MachineSetupRequest request) + { + return _client.PostJson(GetAddress() + "MachineSetup", request); + } + + public Task UpdateDB(UpdateDBRequest request) + { + return _client.PostJson(GetAddress() + "UpdateDB", request); + } + + public Task Login(LoginRequest request) + { + return _client.PostJson(GetAddress() + "Login", request); + } + + public void Dispose() + { + _client.Dispose(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs new file mode 100644 index 000000000..4c9714970 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class UpdateDBRequest : WebRequestSecureMessage + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBResponse.cs new file mode 100644 index 000000000..b98517e02 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class UpdateDBResponse : WebResponseMessage + { + public DataSource DataSource { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedRequest.cs new file mode 100644 index 000000000..f9674f6c5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class UploadCompletedRequest : WebRequestSecureMessage + { + public String Token { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedResponse.cs new file mode 100644 index 000000000..231f42db9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class UploadCompletedResponse : WebResponseMessage + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs new file mode 100644 index 000000000..68643bfe7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class UploadVersionRequest : WebRequestSecureMessage + { + public String Version { get; set; } + + public String MachineVersionGuid { get; set; } + + public String Comments { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs new file mode 100644 index 000000000..9a0fc1a5f --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Web +{ + public class UploadVersionResponse : WebResponseMessage + { + public String Token { get; set; } + + public String BlobAddress { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config index c66e795eb..d13fa64fc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config @@ -1,5 +1,6 @@  + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.config new file mode 100644 index 000000000..e8039e63f --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.config @@ -0,0 +1,92 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml new file mode 100644 index 000000000..0f06af76b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml.cs new file mode 100644 index 000000000..4b857a3af --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.PPC.Publisher.UI +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml new file mode 100644 index 000000000..1bdc062de --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + Tango Publish Utility + + + Deployment Slot: + + + + + Build Configuration: + + Release + Debug + + + + + Selected machine version: + + + + + + Local Version: + + + + + + + Remote Version: + + + + + Examiner Provision Sequence Items + + + + + + + + + + + + + Examiner Update Sequence Items + + + + + + + + + + + + + Firmware Upgrade Package + + + + + + + + Comments + + + Email + + + Password + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs new file mode 100644 index 000000000..4d062d5af --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs @@ -0,0 +1,97 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +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; +using Tango.PPC.Common.Publish; +using Tango.SQLExaminer; + +namespace Tango.PPC.Publisher.UI +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + DataContext = new MainWindowVM(); + } + + private void DataGrid_AddingNewItem(object sender, AddingNewItemEventArgs e) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "SQL Examiner Configuration|*.xml"; + if (dlg.ShowDialog().Value) + { + SequenceItem item = new SequenceItem(); + + var config = ExaminerConfiguration.FromFile(dlg.FileName); + + if (config.Maker == "SQL Examiner") + { + item.Type = ExaminerSequenceItemType.Schema; + } + else + { + item.Type = ExaminerSequenceItemType.Data; + } + + item.RequiresSerialNumber = File.ReadAllText(dlg.FileName).Contains("'@'"); + + if ((DataContext as MainWindowVM).Options.Synchronization.ProvisionSequenceItems.Count > 0) + { + item.Index = (DataContext as MainWindowVM).Options.Synchronization.ProvisionSequenceItems.Max(x => x.Index + 1); + } + item.FilePath = dlg.FileName; + item.Name = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName); + + e.NewItem = item; + } + } + + private void DataGrid_AddingNewItem_1(object sender, AddingNewItemEventArgs e) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "SQL Examiner Configuration|*.xml"; + if (dlg.ShowDialog().Value) + { + SequenceItem item = new SequenceItem(); + + var config = ExaminerConfiguration.FromFile(dlg.FileName); + + if (config.Maker == "SQL Examiner") + { + item.Type = ExaminerSequenceItemType.Schema; + } + else + { + item.Type = ExaminerSequenceItemType.Data; + } + + item.RequiresSerialNumber = File.ReadAllText(dlg.FileName).Contains("'@'"); + + if ((DataContext as MainWindowVM).Options.Synchronization.UpdateSequenceItems.Count > 0) + { + item.Index = (DataContext as MainWindowVM).Options.Synchronization.UpdateSequenceItems.Max(x => x.Index + 1); + } + item.FilePath = dlg.FileName; + item.Name = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName); + + e.NewItem = item; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindowVM.cs new file mode 100644 index 000000000..6c7e1d005 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindowVM.cs @@ -0,0 +1,256 @@ +using FluentFTP; +using Ionic.Zip; +using Microsoft.Win32; +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core; +using Tango.Core.Commands; +using Tango.Core.Cryptography; +using Tango.Core.Helpers; +using Tango.Core.IO; +using Tango.PPC.Common; +using Tango.PPC.Common.Publish; +using Tango.PPC.Common.Web; +using Tango.Settings; +using Tango.SharedUI; +using Tango.SQLExaminer; +using Tango.Transport.Web; +using Tango.Web; + +namespace Tango.PPC.Publisher.UI +{ + public class MainWindowVM : ViewModel + { + private IPPCWebService _client; + private PPCPublisher _publisher; + + private PublishOptions _options; + public PublishOptions Options + { + get { return _options; } + set { _options = value; RaisePropertyChangedAuto(); } + } + + private List _machineVersions; + public List MachineVersions + { + get { return _machineVersions; } + set { _machineVersions = value; RaisePropertyChangedAuto(); } + } + + private MachineVersion _selectedMachineVersion; + public MachineVersion SelectedMachineVersion + { + get { return _selectedMachineVersion; } + set { _selectedMachineVersion = value; RaisePropertyChangedAuto(); OnSelectedMachineVersionChanged(); } + } + + private String _localVersion; + public String LocalVersion + { + get { return _localVersion; } + set { _localVersion = value; RaisePropertyChangedAuto(); } + } + + private String _remoteVersion; + public String RemoteVersion + { + get { return _remoteVersion; } + set { _remoteVersion = value; RaisePropertyChangedAuto(); } + } + + private ICollectionView _provisionSequenceItemsView; + public ICollectionView ProvisionSequenceItemsView + { + get { return _provisionSequenceItemsView; } + set { _provisionSequenceItemsView = value; RaisePropertyChangedAuto(); } + } + + private ICollectionView _updateSequenceItemsView; + public ICollectionView UpdateSequenceItemsView + { + get { return _updateSequenceItemsView; } + set { _updateSequenceItemsView = value; RaisePropertyChangedAuto(); } + } + + private PublishProgressEventArgs _publishArgs; + public PublishProgressEventArgs PublishArgs + { + get { return _publishArgs; } + set { _publishArgs = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand PublishCommand { get; set; } + + public RelayCommand CreateTupCommand { get; set; } + + public RelayCommand FirmwareUpgradePackageBrowseCommand { get; set; } + + public MainWindowVM() + { + _client = new PPCWebService(); + + var settings = SettingsManager.Default.GetOrCreate(); + Options = settings.Options; + + _publisher = new PPCPublisher(Options); + _publisher.PublishProgress += _publisher_PublishProgress; + + ProvisionSequenceItemsView = CollectionViewSource.GetDefaultView(Options.Synchronization.ProvisionSequenceItems); + ProvisionSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); + + UpdateSequenceItemsView = CollectionViewSource.GetDefaultView(Options.Synchronization.UpdateSequenceItems); + UpdateSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); + + SettingsManager.Default.GetOrCreate(); + SettingsManager.Default.Save(); + + PublishCommand = new RelayCommand(Publish, () => Options.Email != null && Options.Password != null && Options.Comments != null && LocalVersion != null && RemoteVersion != null && IsFree); + CreateTupCommand = new RelayCommand(PublishTupFile); + FirmwareUpgradePackageBrowseCommand = new RelayCommand(BrowseFirmwareUpgradePackage); + + Options.BasicInfoChanged += (_, __) => InvalidateRelayCommands(); + Options.EnvironmentChanged += async (_, __) => await OnEnvironmentChanged(); + Options.BuidConfigChanged += async (_, __) => await UpdateVersions(); + + Init(); + } + + private void _publisher_PublishProgress(object sender, PublishProgressEventArgs e) + { + PublishArgs = e; + } + + private async void Init() + { + await UpdateAvailableMachineVersions(); + } + + private async Task OnEnvironmentChanged() + { + IsFree = false; + _client.Environment = Options.Environment; + await UpdateAvailableMachineVersions(); + await UpdateVersions(); + IsFree = true; + } + + private async Task UpdateAvailableMachineVersions() + { + IsFree = false; + _machineVersions = (await _client.GetMachineVersions()).MachineVersions; + _selectedMachineVersion = MachineVersions.OrderBy(x => x.Version).LastOrDefault(); + RaisePropertyChanged(nameof(MachineVersions)); + RaisePropertyChanged(nameof(SelectedMachineVersion)); + await OnSelectedMachineVersionChanged(); + IsFree = true; + } + + private async Task UpdateVersions() + { + IsFree = false; + LocalVersion = _publisher.GetLocalVersion(); + if (SelectedMachineVersion != null) + { + RemoteVersion = await _publisher.GetRemoteVersion(SelectedMachineVersion.Guid); + } + InvalidateRelayCommands(); + IsFree = true; + } + + private async Task OnSelectedMachineVersionChanged() + { + if (SelectedMachineVersion != null) Options.MachineVersionGuid = SelectedMachineVersion.Guid; + await UpdateVersions(); + } + + private async void Publish() + { + try + { + IsFree = false; + SettingsManager.Default.Save(); + await _publisher.Publish(); + ShowInfo("Version published successfully."); + } + catch (Exception ex) + { + ShowError(ex.FlattenMessage()); + } + finally + { + IsFree = true; + } + } + + private async void PublishTupFile() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Tango Update Package|*.tup"; + dlg.DefaultExt = ".tup"; + if (dlg.ShowDialog().Value) + { + try + { + IsFree = false; + await _publisher.CreateTupPackage(dlg.FileName); + ShowInfo("Package file created successfully!"); + } + catch (Exception ex) + { + ShowError(ex.Message); + } + finally + { + IsFree = true; + } + } + } + + private void BrowseFirmwareUpgradePackage() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select Tango Firmware Package"; + dlg.Filter = "Tango Firmware Package Files|*.tfp"; + if (dlg.ShowDialog().Value) + { + Options.TfpPath = dlg.FileName; + } + } + + private void ShowError(String error) + { + MessageBox.Show(error, "PPC Publisher", MessageBoxButton.OK, MessageBoxImage.Error); + } + + private void ShowInfo(String message) + { + MessageBox.Show(message, "PPC Publisher", MessageBoxButton.OK, MessageBoxImage.Information); + } + + private bool ShowQuestion(String message) + { + return MessageBox.Show(message, "PPC Publisher", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes; + } + + protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) + { + base.RaisePropertyChangedAuto(caller); + InvalidateRelayCommands(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..1756d71bc --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango PPC Publish Utility")] +[assembly: AssemblyVersion("2.0.9.1657")] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + +//Friends With +[assembly: InternalsVisibleTo("Tango.PPC.UI")] \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.Designer.cs new file mode 100644 index 000000000..8c15bf2c0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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 Tango.PPC.Publisher.UI.UI.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.PPC.Publisher.UI.UI.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [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/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.resx b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/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/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.Designer.cs new file mode 100644 index 000000000..984af1fb2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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 Tango.PPC.Publisher.UI.UI.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.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/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.settings b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/PublisherSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/PublisherSettings.cs new file mode 100644 index 000000000..20c9fb2d1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/PublisherSettings.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; +using Tango.PPC.Common.Publish; +using Tango.Settings; +using Tango.Web; + +namespace Tango.PPC.Publisher.UI +{ + public class PublisherSettings : SettingsBase + { + public PublishOptions Options { get; set; } + + public PublisherSettings() + { + Options = new PublishOptions(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Tango.PPC.Publisher.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Tango.PPC.Publisher.UI.csproj new file mode 100644 index 000000000..6a6b01a46 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Tango.PPC.Publisher.UI.csproj @@ -0,0 +1,165 @@ + + + + + Debug + AnyCPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F} + WinExe + Tango.PPC.Publisher.UI + Tango.PPC.Publisher.UI + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + ..\..\Build\PPC\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + ..\..\Build\PPC\Debug\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\packages\FluentFTP.19.1.2\lib\net45\FluentFTP.dll + + + ..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll + + + + + + + + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {D8F1AD85-526A-4F50-B6DC-D437AF63D8D8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {e1e66ed9-597d-45fa-8048-de90a6930484} + Tango.SQLExaminer + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + + + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} + Tango.PPC.Common + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/packages.config new file mode 100644 index 000000000..5ac999495 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config deleted file mode 100644 index e8039e63f..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config +++ /dev/null @@ -1,92 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml deleted file mode 100644 index 1f18cae75..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml.cs deleted file mode 100644 index 9955d6822..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace Tango.PPC.Publisher -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml deleted file mode 100644 index 830c4c585..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - Tango Publish Utility - - - Deployment Slot: - - - - - Build Configuration: - - Release - Debug - - - - - Selected machine version: - - - - - - Current Version: - - - - - - - Local Version: - - - - - Examiner Provision Sequence Items - - - - - - - - - - - - - Examiner Update Sequence Items - - - - - - - - - - - - - Firmware Upgrade Package - - - - - - - - Comments - - - Email - - - Password - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml.cs deleted file mode 100644 index 610eb40a8..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Microsoft.Win32; -using System; -using System.Collections.Generic; -using System.IO; -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; -using Tango.SQLExaminer; - -namespace Tango.PPC.Publisher -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window - { - public MainWindow() - { - InitializeComponent(); - DataContext = new MainWindowVM(); - } - - private void DataGrid_AddingNewItem(object sender, AddingNewItemEventArgs e) - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Filter = "SQL Examiner Configuration|*.xml"; - if (dlg.ShowDialog().Value) - { - SequenceItem item = new SequenceItem(); - - var config = ExaminerConfiguration.FromFile(dlg.FileName); - - if (config.Maker == "SQL Examiner") - { - item.Type = ExaminerSequenceItemType.Schema; - } - else - { - item.Type = ExaminerSequenceItemType.Data; - } - - item.RequiresSerialNumber = File.ReadAllText(dlg.FileName).Contains("'@'"); - - if ((DataContext as MainWindowVM).ProvisionSequenceItems.Count > 0) - { - item.Index = (DataContext as MainWindowVM).ProvisionSequenceItems.Max(x => x.Index + 1); - } - item.FilePath = dlg.FileName; - item.Name = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName); - - e.NewItem = item; - } - } - - private void DataGrid_AddingNewItem_1(object sender, AddingNewItemEventArgs e) - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Filter = "SQL Examiner Configuration|*.xml"; - if (dlg.ShowDialog().Value) - { - SequenceItem item = new SequenceItem(); - - var config = ExaminerConfiguration.FromFile(dlg.FileName); - - if (config.Maker == "SQL Examiner") - { - item.Type = ExaminerSequenceItemType.Schema; - } - else - { - item.Type = ExaminerSequenceItemType.Data; - } - - item.RequiresSerialNumber = File.ReadAllText(dlg.FileName).Contains("'@'"); - - if ((DataContext as MainWindowVM).UpdateSequenceItems.Count > 0) - { - item.Index = (DataContext as MainWindowVM).UpdateSequenceItems.Max(x => x.Index + 1); - } - item.FilePath = dlg.FileName; - item.Name = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName); - - e.NewItem = item; - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs deleted file mode 100644 index fdaa673ed..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs +++ /dev/null @@ -1,430 +0,0 @@ -using FluentFTP; -using Ionic.Zip; -using Microsoft.Win32; -using Microsoft.WindowsAzure.Storage.Blob; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Data; -using Tango.BL; -using Tango.BL.Entities; -using Tango.Core; -using Tango.Core.Commands; -using Tango.Core.Cryptography; -using Tango.Core.Helpers; -using Tango.Core.IO; -using Tango.PPC.Common; -using Tango.PPC.Common.Update; -using Tango.Settings; -using Tango.SharedUI; -using Tango.SQLExaminer; -using Tango.Transport.Web; -using Tango.Web; - -namespace Tango.PPC.Publisher -{ - public class MainWindowVM : ViewModel - { - private IPPCUpdateService _client; - - private BasicHashGenerator _hashGenerator; - - private List _machineVersions; - public List MachineVersions - { - get { return _machineVersions; } - set { _machineVersions = value; RaisePropertyChangedAuto(); } - } - - private MachineVersion _selectedMachineVersion; - public MachineVersion SelectedMachineVersion - { - get { return _selectedMachineVersion; } - set { _selectedMachineVersion = value; RaisePropertyChangedAuto(); OnSelectedMachineVersionChanged(); } - } - - private String _selectedBuildConfiguration; - public String SelectedBuildConfiguration - { - get { return _selectedBuildConfiguration; } - set { _selectedBuildConfiguration = value; RaisePropertyChangedAuto(); OnSelectedBuildConfigurationChanged(); } - } - - private String _localVersion; - public String LocalVersion - { - get { return _localVersion; } - set { _localVersion = value; RaisePropertyChangedAuto(); } - } - - private String _currentVersion; - public String CurrentVersion - { - get { return _currentVersion; } - set { _currentVersion = value; RaisePropertyChangedAuto(); } - } - - private String _firmwareUpgradeFilePath; - public String FirmwareUpgradeFilePath - { - get { return _firmwareUpgradeFilePath; } - set { _firmwareUpgradeFilePath = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection _provisionSequenceItems; - public ObservableCollection ProvisionSequenceItems - { - get { return _provisionSequenceItems; } - set { _provisionSequenceItems = value; RaisePropertyChangedAuto(); } - } - - private ICollectionView _provisionSequenceItemsView; - public ICollectionView ProvisionSequenceItemsView - { - get { return _provisionSequenceItemsView; } - set { _provisionSequenceItemsView = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection _updateSequenceItems; - public ObservableCollection UpdateSequenceItems - { - get { return _updateSequenceItems; } - set { _updateSequenceItems = value; RaisePropertyChangedAuto(); } - } - - private ICollectionView _updateSequenceItemsView; - public ICollectionView UpdateSequenceItemsView - { - get { return _updateSequenceItemsView; } - set { _updateSequenceItemsView = value; RaisePropertyChangedAuto(); } - } - - - private String _email; - public String Email - { - get { return _email; } - set { _email = value; RaisePropertyChangedAuto(); } - } - - private String _password; - public String Password - { - get { return _password; } - set { _password = value; RaisePropertyChangedAuto(); } - } - - private DeploymentSlot _deplotmentSlot; - public DeploymentSlot DeploymentSlot - { - get { return _deplotmentSlot; } - set { _deplotmentSlot = value; RaisePropertyChangedAuto(); OnDeploymentSlotChanged(); } - } - - private String _comments; - public String Comments - { - get { return _comments; } - set { _comments = value; RaisePropertyChangedAuto(); } - } - - private double _maxProgress; - public double MaxProgress - { - get { return _maxProgress; } - set { _maxProgress = value; RaisePropertyChangedAuto(); } - } - - private double _progress; - public double Progress - { - get { return _progress; } - set { _progress = value; RaisePropertyChangedAuto(); } - } - - private bool _isUpdating; - public bool IsUpdating - { - get { return _isUpdating; } - set { _isUpdating = value; RaisePropertyChangedAuto(); } - } - - public RelayCommand PublishCommand { get; set; } - - public RelayCommand CreateTupCommand { get; set; } - - public RelayCommand FirmwareUpgradePackageBrowseCommand { get; set; } - - public MainWindowVM() - { - _client = new PPCUpdateService(); - - _hashGenerator = new BasicHashGenerator(); - - var settings = SettingsManager.Default.GetOrCreate(); - - SelectedBuildConfiguration = settings.BuildConfiguration; - DeploymentSlot = settings.DeploymentSlot; - - ProvisionSequenceItems = new ObservableCollection(settings.ProvisionSequenceItems); - ProvisionSequenceItemsView = CollectionViewSource.GetDefaultView(ProvisionSequenceItems); - ProvisionSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); - - UpdateSequenceItems = new ObservableCollection(settings.UpdateSequenceItems); - UpdateSequenceItemsView = CollectionViewSource.GetDefaultView(UpdateSequenceItems); - UpdateSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); - - SettingsManager.Default.GetOrCreate(); - SettingsManager.Default.Save(); - - OnSelectedBuildConfigurationChanged(); - - PublishCommand = new RelayCommand(Publish); - CreateTupCommand = new RelayCommand(PublishTupFile); - FirmwareUpgradePackageBrowseCommand = new RelayCommand(BrowseFirmwareUpgradePackage); - } - - private void OnSelectedBuildConfigurationChanged() - { - String _appPath = String.Format(AppDomain.CurrentDomain.BaseDirectory + "..\\{0}", SelectedBuildConfiguration); - LocalVersion = FileVersionInfo.GetVersionInfo(_appPath + "\\Tango.PPC.UI.exe").ProductVersion; - } - - private async void OnSelectedMachineVersionChanged() - { - if (SelectedMachineVersion != null) - { - var response = await _client.GetLatestVersion(new LatestVersionRequest() - { - MachineVersionGuid = SelectedMachineVersion.Guid, - }); - - CurrentVersion = response.Version; - } - } - - private async void OnDeploymentSlotChanged() - { - SettingsManager.Default.GetOrCreate().DeploymentSlot = DeploymentSlot; - SelectedMachineVersion = null; - MachineVersions = (await _client.GetMachineVersions()).MachineVersions; - SelectedMachineVersion = MachineVersions.OrderBy(x => x.Version).LastOrDefault(); - } - - private void Publish() - { - Task.Factory.StartNew(async () => - { - IsUpdating = true; - String tempFile = String.Empty; - - var settings = SettingsManager.Default.GetOrCreate(); - settings.ProvisionSequenceItems = ProvisionSequenceItems.ToList(); - settings.UpdateSequenceItems = UpdateSequenceItems.ToList(); - settings.DeploymentSlot = DeploymentSlot; - settings.BuildConfiguration = SelectedBuildConfiguration; - - settings.Save(); - - try - { - var response = await _client.UploadVersion(new UploadVersionRequest() - { - Comments = Comments, - Email = Email, - Password = _hashGenerator.Encrypt(Password), - Version = LocalVersion, - MachineVersionGuid = SelectedMachineVersion.Guid - }); - - tempFile = TemporaryManager.Default.CreateFile(".zip"); - - CreateTupPackage(tempFile); - - Progress = 0; - MaxProgress = 100; - - using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress, tempFile)) - { - uploader.Progress += (x, e) => - { - InvokeUINow(() => - { - Thread.Sleep(10); - Progress = ((double)e.Current / (double)e.Total) * 100d; - }); - }; - - await uploader.Upload(); - } - - await _client.NotifyUploadCompleted(new UploadCompletedRequest() - { - AccessToken = response.Token, - }); - - Progress = 0; - OnSelectedMachineVersionChanged(); - ShowInfo("Version published successfully!"); - } - catch (Exception ex) - { - ShowError(ex.Message); - } - finally - { - IsUpdating = false; - } - }); - } - - private void PublishTupFile() - { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Filter = "Tango Update Package|*.tup"; - dlg.DefaultExt = ".tup"; - if (dlg.ShowDialog().Value) - { - Task.Factory.StartNew(() => - { - try - { - IsUpdating = true; - CreateTupPackage(dlg.FileName); - Progress = 0; - ShowInfo("Package file created successfully!"); - } - catch (Exception ex) - { - ShowError(ex.Message); - } - finally - { - IsUpdating = false; - } - }); - } - } - - private void BrowseFirmwareUpgradePackage() - { - OpenFileDialog dlg = new OpenFileDialog(); - dlg.Title = "Select Tango Firmware Package"; - dlg.Filter = "Tango Firmware Package Files|*.tfp"; - if (dlg.ShowDialog().Value) - { - FirmwareUpgradeFilePath = dlg.FileName; - } - } - - private void ShowError(String error) - { - MessageBox.Show(error, "PPC Publisher", MessageBoxButton.OK, MessageBoxImage.Error); - } - - private void ShowInfo(String message) - { - MessageBox.Show(message, "PPC Publisher", MessageBoxButton.OK, MessageBoxImage.Information); - } - - private bool ShowQuestion(String message) - { - return MessageBox.Show(message, "PPC Publisher", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes; - } - - private void CreateTupPackage(String filePath) - { - String _appPath = String.Format(AppDomain.CurrentDomain.BaseDirectory + "..\\{0}", SelectedBuildConfiguration); - var tempFile = filePath; - - using (ZipFile zip = new ZipFile()) - { - zip.AddFile(FirmwareUpgradeFilePath, "/"); - - String provision_dir = "Provision Scripts"; - - zip.AddDirectoryByName(provision_dir); - - ExaminerSequenceConfiguration provision_config = new ExaminerSequenceConfiguration(); - - foreach (var item in ProvisionSequenceItems) - { - provision_config.Items.Add(new ExaminerSequenceItem() - { - Direction = item.Direction, - FileName = item.FileName, - Index = item.Index, - Name = item.Name, - Type = item.Type, - RequiresSerialNumber = item.RequiresSerialNumber - }); - - zip.AddFile(item.FilePath, provision_dir); - } - - String provision_config_file = TemporaryManager.Default.CreateFile(".zip"); - provision_config.ToFile(provision_config_file); - - var cf = zip.AddFile(provision_config_file, provision_dir); - cf.FileName = provision_dir + "\\config.xml"; - - - - String update_dir = "Update Scripts"; - - zip.AddDirectoryByName(update_dir); - - ExaminerSequenceConfiguration update_config = new ExaminerSequenceConfiguration(); - - foreach (var item in UpdateSequenceItems) - { - update_config.Items.Add(new ExaminerSequenceItem() - { - Direction = item.Direction, - FileName = item.FileName, - Index = item.Index, - Name = item.Name, - Type = item.Type, - RequiresSerialNumber = item.RequiresSerialNumber - }); - - zip.AddFile(item.FilePath, update_dir); - } - - String update_config_file = TemporaryManager.Default.CreateFile(".zip"); - update_config.ToFile(update_config_file); - - var cuf = zip.AddFile(update_config_file, update_dir); - cuf.FileName = update_dir + "\\config.xml"; - - foreach (var file in Directory.GetFiles(_appPath, "*.*", SearchOption.TopDirectoryOnly)) - { - zip.AddFile(file, "/"); - } - - zip.SaveProgress += (x, e) => - { - MaxProgress = e.EntriesTotal; - Progress = e.EntriesSaved; - }; - - zip.Save(tempFile); - } - } - - protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) - { - base.RaisePropertyChangedAuto(caller); - InvalidateRelayCommands(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/AssemblyInfo.cs deleted file mode 100644 index 1756d71bc..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Tango PPC Publish Utility")] -[assembly: AssemblyVersion("2.0.9.1657")] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - -//Friends With -[assembly: InternalsVisibleTo("Tango.PPC.UI")] \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.Designer.cs deleted file mode 100644 index 66912209d..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 Tango.PPC.Publisher.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [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() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [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("Tango.PPC.Publisher.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [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/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.resx b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.Designer.cs deleted file mode 100644 index 3013d3a3d..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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 Tango.PPC.Publisher.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/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.settings b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs deleted file mode 100644 index de6fe920b..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.PPC.Common; -using Tango.Settings; -using Tango.Web; - -namespace Tango.PPC.Publisher -{ - public class PublisherSettings : SettingsBase - { - public List ProvisionSequenceItems { get; set; } - - public List UpdateSequenceItems { get; set; } - - public String BuildConfiguration { get; set; } - - public DeploymentSlot DeploymentSlot { get; set; } - - public PublisherSettings() - { - ProvisionSequenceItems = new List(); - UpdateSequenceItems = new List(); - BuildConfiguration = "Debug"; - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/SequenceItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/SequenceItem.cs deleted file mode 100644 index a29d626e7..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/SequenceItem.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; -using Tango.SQLExaminer; - -namespace Tango.PPC.Publisher -{ - public class SequenceItem : ExtendedObject - { - private ExaminerSequenceItemType _type; - public ExaminerSequenceItemType Type - { - get { return _type; } - set { _type = value; RaisePropertyChangedAuto(); } - } - - private ExaminerSequenceItemDirection _direction; - public ExaminerSequenceItemDirection Direction - { - get { return _direction; } - set { _direction = value; RaisePropertyChangedAuto(); } - } - - private int _index; - public int Index - { - get { return _index; } - set { _index = value; RaisePropertyChangedAuto(); } - } - - private String _name; - public String Name - { - get { return _name; } - set { _name = value; RaisePropertyChangedAuto(); } - } - - private String _filePath; - public String FilePath - { - get { return _filePath; } - set { _filePath = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(FileName)); } - } - - private bool _requiresSerialNumber; - public bool RequiresSerialNumber - { - get { return _requiresSerialNumber; } - set { _requiresSerialNumber = value; RaisePropertyChangedAuto(); } - } - - - public String FileName - { - get { return Path.GetFileName(FilePath); } - } - - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj deleted file mode 100644 index c9e5a72d7..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj +++ /dev/null @@ -1,166 +0,0 @@ - - - - - Debug - AnyCPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F} - WinExe - Tango.PPC.Publisher - Tango.PPC.Publisher - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - AnyCPU - true - full - false - ..\..\Build\PPC\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - ..\..\Build\PPC\Debug\ - TRACE - prompt - 4 - - - - ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll - - - ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - - ..\..\packages\FluentFTP.19.1.2\lib\net45\FluentFTP.dll - - - ..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll - - - - - - - - - - - - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - - - MSBuild:Compile - Designer - - - GlobalVersionInfo.cs - - - App.xaml - Code - - - MainWindow.xaml - Code - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - {f441feee-322a-4943-b566-110e12fd3b72} - Tango.BL - - - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} - Tango.Core - - - {D8F1AD85-526A-4F50-B6DC-D437AF63D8D8} - Tango.Settings - - - {8491d07b-c1f6-4b62-a412-41b9fd2d6538} - Tango.SharedUI - - - {e1e66ed9-597d-45fa-8048-de90a6930484} - Tango.SQLExaminer - - - {74e700b0-1156-4126-be40-ee450d3c3026} - Tango.Transport - - - {5001990f-977b-48ff-b217-0236a5022ad8} - Tango.Web - - - {0be74eee-22cb-4dba-b896-793b9e1a3ac0} - Tango.PPC.Common - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/packages.config deleted file mode 100644 index 5ac999495..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index 419b55d50..76c4cd552 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -10,6 +10,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs index 48aae2b8f..514a517ff 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -215,6 +215,7 @@ namespace Tango.PPC.UI.ViewModels NavigateTo(MachineSetupView.SetupWelcomeView); Settings.DeploymentSlot = DeploymentSlot; HostAddress = Settings.GetMachineServiceAddress(); + Settings.Save(); }); _operationSystemManager = operationSystemManager; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 2f6199ecb..6046f0300 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -136,7 +136,7 @@ namespace Tango.PPC.UI.ViewModels { IsDbUpdate = false; - var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber, Settings.GetMachineServiceAddress()); + var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber); if (response.IsUpdateAvailable) { @@ -145,7 +145,7 @@ namespace Tango.PPC.UI.ViewModels } else { - _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber, Settings.GetMachineServiceAddress()); + _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber); if (_db_compare_result.RequiresUpdate) { @@ -176,7 +176,7 @@ namespace Tango.PPC.UI.ViewModels try { - _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, Settings.GetMachineServiceAddress()); + _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber); LogManager.Log("Machine update completed."); await NavigateTo(MachineUpdateView.UpdateCompletedView); } @@ -299,7 +299,7 @@ namespace Tango.PPC.UI.ViewModels try { - _update_result = await MachineUpdateManager.Update(fileItem.Path); + _update_result = await MachineUpdateManager.UpdateFromTUP(fileItem.Path); LogManager.Log("Machine update from package completed."); await NavigateTo(MachineUpdateView.UpdateCompletedView); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/App.config b/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/App.config index 731f6de6c..85607e5e8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/App.config @@ -1,6 +1,78 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs b/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs index 4f23c9667..701a87a3c 100644 --- a/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs +++ b/Software/Visual_Studio/Tango.Web/Authentication/TokensManager.cs @@ -28,7 +28,7 @@ namespace Tango.Web.Authentication return _tokens.ContainsKey(token); } - public T GetUserID(String token) + public T GetTokenObject(String token) { if (!_tokens.ContainsKey(token)) { diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index f898277f3..f8eb5e42e 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -206,8 +206,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.CSV", "Tango.CSV\Tang EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.SQLExaminer", "Tango.SQLExaminer\Tango.SQLExaminer.csproj", "{E1E66ED9-597D-45FA-8048-DE90A6930484}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Publisher", "PPC\Tango.PPC.Publisher\Tango.PPC.Publisher.csproj", "{FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Updater", "PPC\Tango.PPC.Updater\Tango.PPC.Updater.csproj", "{D0E71A4D-9EEA-4F07-983F-EEB4416C587F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.EventsTypesGenerator", "Utilities\Tango.EventsTypesGenerator\Tango.EventsTypesGenerator.csproj", "{0BDA9B52-9879-4C5E-84E3-81D00B75DACC}" @@ -260,6 +258,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Publish EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Publisher.UI", "MachineStudio\Tango.MachineStudio.Publisher.UI\Tango.MachineStudio.Publisher.UI.csproj", "{E711CD86-89C1-432C-9C60-BFF30BBBFB3A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Publisher.UI", "PPC\Tango.PPC.Publisher.UI\Tango.PPC.Publisher.UI.csproj", "{FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -3607,46 +3607,6 @@ Global {E1E66ED9-597D-45FA-8048-DE90A6930484}.Release|x64.Build.0 = Release|Any CPU {E1E66ED9-597D-45FA-8048-DE90A6930484}.Release|x86.ActiveCfg = Release|Any CPU {E1E66ED9-597D-45FA-8048-DE90A6930484}.Release|x86.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|Any CPU.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM64.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x64.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x64.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x86.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x86.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM64.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x64.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x64.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x86.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x86.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x64.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x86.Build.0 = Debug|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|Any CPU.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM64.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM64.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x64.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x64.Build.0 = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x86.ActiveCfg = Release|Any CPU - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x86.Build.0 = Release|Any CPU {D0E71A4D-9EEA-4F07-983F-EEB4416C587F}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU {D0E71A4D-9EEA-4F07-983F-EEB4416C587F}.AppVeyor|Any CPU.Build.0 = Release|Any CPU {D0E71A4D-9EEA-4F07-983F-EEB4416C587F}.AppVeyor|ARM.ActiveCfg = Release|Any CPU @@ -4637,6 +4597,46 @@ Global {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x64.Build.0 = Release|Any CPU {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x86.ActiveCfg = Release|Any CPU {E711CD86-89C1-432C-9C60-BFF30BBBFB3A}.Release|x86.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x64.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.AppVeyor|x86.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|ARM64.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x64.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x64.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x86.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Debug|x86.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|Any CPU.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM64.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|ARM64.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x64.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x64.Build.0 = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x86.ActiveCfg = Release|Any CPU + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4697,7 +4697,6 @@ Global {0440A135-0DF0-4232-AB3C-98B9283123B3} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {808E47B6-BAA7-4D23-83CB-40C53DC4B38A} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {91B70E9B-66A7-4873-AE10-400E71CF404F} = {0048447D-1D94-4E60-9DAD-7349C777CB4E} - {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} {D0E71A4D-9EEA-4F07-983F-EEB4416C587F} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} {0BDA9B52-9879-4C5E-84E3-81D00B75DACC} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {D0186AC0-0FCF-4D3B-9619-54812B6E524B} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} @@ -4719,6 +4718,7 @@ Global {25D7CC4D-A11C-4065-A797-4A1944F636C0} = {AD8721D6-D728-4D58-A0D8-BE2E3FF7A9BC} {6F924F92-611B-41CF-A6E6-443E69D4CA83} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} {E711CD86-89C1-432C-9C60-BFF30BBBFB3A} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} + {FABA6A2B-C7EA-4C58-A125-150FA5B4C72F} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution BuildVersion_UseGlobalSettings = False diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index b2e3aa150..142980fdd 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -150,7 +150,7 @@ namespace Tango.MachineService.Controllers db.UsersRoles.ToList(); db.RolesPermissions.ToList(); - String userID = TokensManager.GetUserID(request.AccessToken); + String userID = TokensManager.GetTokenObject(request.AccessToken); var user = db.Users.SingleOrDefault(x => x.Guid == userID); @@ -347,7 +347,7 @@ namespace Tango.MachineService.Controllers Password = request.Password, }, - Token = TokensManager.CreateNew(user.Guid), + AccessToken = TokensManager.CreateNew(user.Guid), VersionChangeRequired = versionChangeRequired, RequiredVersion = requiredVersion, }; diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 603517caa..af861923c 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -13,32 +13,51 @@ using Tango.Core; using Tango.Core.DB; using Tango.Logging; using Tango.MachineService.Models; -using Tango.PPC.Common.MachineSetup; -using Tango.PPC.Common.MachineUpdate; -using Tango.PPC.Common.Update; +using Tango.PPC.Common.Web; using Tango.Web.Controllers; using Tango.Web.Helpers; using Tango.Web.SMO; using Tango.Web.Storage; using System.Data.Entity; +using Tango.Web.Authentication; +using Tango.Web.ActiveDirectory; +using Tango.Core.Cryptography; +using Tango.MachineService.Filters; namespace Tango.MachineService.Controllers { public class PPCController : JsonController { private static List _pendingUploads; + private ActiveDirectoryManager _ad_manager; + + public class TokenObject + { + public LoginMode Mode { get; set; } + public String UserGuid { get; set; } + public String MachineGuid { get; set; } + } + + public static TokensManager TokensManager { get; set; } #region Constructors static PPCController() { + TokensManager = new TokensManager(); _pendingUploads = new List(); } + public PPCController() + { + _ad_manager = new ActiveDirectoryManager(); + } + #endregion #region Setup & Update + [PPCLoginFilter] [HttpPost] public MachineSetupResponse MachineSetup(MachineSetupRequest request) { @@ -49,9 +68,9 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { db.Configuration.LazyLoadingEnabled = false; - String serial_number = request.SerialNumber; + String machine_guid = TokensManager.GetTokenObject(request.AccessToken).MachineGuid; - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); + var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid); if (machine == null) { @@ -112,6 +131,7 @@ namespace Tango.MachineService.Controllers return response; } + [PPCLoginFilter] [HttpPost] public DownloadUpdateResponse MachineUpdate(DownloadUpdateRequest request) { @@ -120,9 +140,9 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { db.Configuration.LazyLoadingEnabled = false; - String serial_number = request.SerialNumber; + String machine_guid = TokensManager.GetTokenObject(request.AccessToken).MachineGuid; - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); + var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid); if (machine == null) { @@ -170,6 +190,7 @@ namespace Tango.MachineService.Controllers return response; } + [PPCLoginFilter] [HttpPost] public CheckForUpdateResponse CheckForUpdate(CheckForUpdateRequest request) { @@ -177,9 +198,9 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - db.Configuration.LazyLoadingEnabled = false; + String machine_guid = TokensManager.GetTokenObject(request.AccessToken).MachineGuid; - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == request.SerialNumber); + var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid); if (machine == null) { @@ -201,6 +222,7 @@ namespace Tango.MachineService.Controllers return response; } + [PPCLoginFilter] [HttpPost] public UpdateDBResponse UpdateDB(UpdateDBRequest request) { @@ -208,10 +230,10 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - db.Configuration.LazyLoadingEnabled = false; - String serial_number = request.SerialNumber; - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); + String machine_guid = TokensManager.GetTokenObject(request.AccessToken).MachineGuid; + + var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid); if (machine == null) { @@ -274,6 +296,7 @@ namespace Tango.MachineService.Controllers return response; } + [PPCLoginFilter] [HttpPost] public UploadVersionResponse UploadVersion(UploadVersionRequest request) { @@ -287,7 +310,9 @@ namespace Tango.MachineService.Controllers db.UsersRoles.ToList(); db.RolesPermissions.ToList(); - var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + var user_guid = TokensManager.GetTokenObject(request.AccessToken).UserGuid; + + var user = db.Users.SingleOrDefault(x => x.Guid == user_guid); if (user != null && user.HasPermission(Permissions.PublishPPCVersions)) { @@ -339,10 +364,11 @@ namespace Tango.MachineService.Controllers return response; } + [PPCLoginFilter] [HttpPost] public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) { - PPCPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.AccessToken); + PPCPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); if (upload != null) { @@ -382,20 +408,58 @@ namespace Tango.MachineService.Controllers } } - #endregion - [HttpPost] - public Machine PersonTest(Person p) + public LoginResponse Login(LoginRequest request) { - using (var db = ObservablesContextHelper.CreateContext()) + LoginResponse response = new LoginResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - var machine = new MachineBuilder(db) - .Set(x => x.SerialNumber == "1111") - .WithOrganization() - .WithConfiguration().Build(); + if (request.Mode == LoginMode.User) + { + var authResult = _ad_manager.ValidateUserCredentials(request.Email, request.Password); + + if (!_ad_manager.CanUserAccessCurrentEnvironment(request.Email)) + { + throw new AuthenticationException($"You do not have permissions to access the {MachineServiceConfig.DEPLOYMENT_SLOT.ToDescription()} environment."); + } - return machine; + BasicHashGenerator hash = new BasicHashGenerator(); + String pass = hash.Encrypt(request.Password); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == pass); + + if (user == null) + { + throw new AuthenticationException("Domain user found but the database entry validation failed."); + } + + response.AccessToken = TokensManager.CreateNew(new TokenObject() + { + Mode = LoginMode.User, + UserGuid = user.Guid, + }); + } + else if (request.Mode == LoginMode.Machine) + { + var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == request.SerialNumber); + + if (machine == null) + { + throw new AuthenticationException("Invalid serial number."); + } + + response.AccessToken = TokensManager.CreateNew(new TokenObject() + { + Mode = LoginMode.Machine, + UserGuid = machine.Guid, + }); + } } + + return response; } + + #endregion } } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Filters/PPCLoginFilter.cs b/Software/Visual_Studio/Web/Tango.MachineService/Filters/PPCLoginFilter.cs new file mode 100644 index 000000000..45c436ef7 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Filters/PPCLoginFilter.cs @@ -0,0 +1,31 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Web; +using System.Web.Http; +using System.Web.Http.Controllers; +using System.Web.Http.Filters; +using Tango.Transport.Web; + +namespace Tango.MachineService.Filters +{ + public class PPCLoginFilter : ActionFilterAttribute + { + public override void OnActionExecuting(HttpActionContext actionContext) + { + var json = actionContext.Request.Content.ReadAsStringAsync().Result; + WebRequestSecureMessage msg = JsonConvert.DeserializeObject(json); + + if (!Controllers.PPCController.TokensManager.Exists(msg.AccessToken)) + { + throw new HttpResponseException(actionContext.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new AuthenticationException("Invalid Token."))); + } + + base.OnActionExecuting(actionContext); + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/Person.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/Person.cs deleted file mode 100644 index c54d44e8f..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Models/Person.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Tango.MachineService.Models -{ - public class Person - { - public String FirstName { get; set; } - - public String LastName { get; set; } - } -} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index ab3215f6b..44351869b 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -276,6 +276,7 @@ + @@ -286,7 +287,6 @@ Global.asax - -- cgit v1.3.1