diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-18 16:58:37 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-18 16:58:37 +0200 |
| commit | 473d878e3ae795201223b160fcbc1147e901b038 (patch) | |
| tree | faedd2a3fa181deb297ec2232a171289161738f7 | |
| parent | ccc6add5ea66565453283d7df0f6fbf2324b9264 (diff) | |
| download | Tango-473d878e3ae795201223b160fcbc1147e901b038.tar.gz Tango-473d878e3ae795201223b160fcbc1147e901b038.zip | |
Working on PPC versioning services...
60 files changed, 1020 insertions, 841 deletions
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 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ 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 /// <summary> @@ -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<MachineSetupRequest, MachineSetupResponse>(machineServiceAddress + "/api/PPC/MachineSetup", request); + setup_response = await client.MachineSetup(request); } } catch (Exception ex) 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/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. /// </summary> /// <param name="serialNumber">The serial number.</param> - /// <param name="machineServiceAddress">The machine service address.</param> /// <returns></returns> - Task<MachineUpdateResult> Update(String serialNumber, String machineServiceAddress); + Task<MachineUpdateResult> Update(String serialNumber); /// <summary> /// Performs a machine update using the specified software update package path. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns></returns> - Task<MachineUpdateResult> Update(String fileName); + Task<MachineUpdateResult> UpdateFromTUP(String fileName); /// <summary> /// Checks if any update are available for the specified machine serial number. /// </summary> /// <param name="serialNumber">The serial number.</param> - /// <param name="machineServiceAddress">The machine service address.</param> /// <returns></returns> - Task<CheckForUpdateResponse> CheckForUpdate(String serialNumber, String machineServiceAddress); + Task<CheckForUpdateResponse> CheckForUpdate(String serialNumber); /// <summary> /// Checks whether it is necessary to updates all the "overwrite-able" database tables. /// </summary> /// <param name="serialNumber">The serial number.</param> - /// <param name="machineServiceAddress">The machine service address.</param> /// <returns></returns> - Task<DbCompareResult> UpdateDBCheck(String serialNumber, String machineServiceAddress); + Task<DbCompareResult> UpdateDBCheck(String serialNumber); /// <summary> /// 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 /// <summary> @@ -76,12 +99,14 @@ namespace Tango.PPC.Common.MachineUpdate /// <param name="serialNumber">The serial number.</param> /// <param name="machineServiceAddress">The machine service address.</param> /// <returns></returns> - public async Task<MachineUpdateResult> Update(string serialNumber, string machineServiceAddress) + public async Task<MachineUpdateResult> Update(string serialNumber) { TaskCompletionSource<MachineUpdateResult> result = new TaskCompletionSource<MachineUpdateResult>(); try { + var machineServiceAddress = SettingsManager.Default.GetOrCreate<PPCSettings>().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<DownloadUpdateRequest, DownloadUpdateResponse>(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 /// <param name="serialNumber">The serial number.</param> /// <param name="machineServiceAddress">The machine service address.</param> /// <returns></returns> - public Task<CheckForUpdateResponse> CheckForUpdate(string serialNumber, string machineServiceAddress) + public Task<CheckForUpdateResponse> CheckForUpdate(string serialNumber) { return Task.Factory.StartNew<CheckForUpdateResponse>(() => { + var machineServiceAddress = SettingsManager.Default.GetOrCreate<PPCSettings>().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<CheckForUpdateRequest, CheckForUpdateResponse>(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 /// <param name="serialNumber">The serial number.</param> /// <param name="machineServiceAddress">The machine service address.</param> /// <returns></returns> - public Task<DbCompareResult> UpdateDBCheck(string serialNumber, string machineServiceAddress) + public Task<DbCompareResult> UpdateDBCheck(string serialNumber) { return Task.Factory.StartNew<DbCompareResult>(() => { + var machineServiceAddress = SettingsManager.Default.GetOrCreate<PPCSettings>().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<UpdateDBRequest, UpdateDBResponse>(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 /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns></returns> - public Task<MachineUpdateResult> Update(string fileName) + public Task<MachineUpdateResult> UpdateFromTUP(string fileName) { return Task.Factory.StartNew<MachineUpdateResult>(() => { 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 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL"> + <HintPath>..\..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath> + </Reference> <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> </Reference> @@ -139,19 +142,27 @@ <Compile Include="MachineSetup\MachineSetupManager.cs" /> <Compile Include="MachineSetup\MachineSetupProgress.cs" /> <Compile Include="MachineSetup\MachineSetupResult.cs" /> - <Compile Include="MachineUpdate\CheckForUpdateRequest.cs" /> - <Compile Include="MachineUpdate\CheckForUpdateResponse.cs" /> + <Compile Include="Publish\PPCPublisher.cs" /> + <Compile Include="Publish\PublishOptions.cs" /> + <Compile Include="Publish\PublishProgressEventArgs.cs" /> + <Compile Include="Publish\SequenceItem.cs" /> + <Compile Include="Publish\SynchronizationOptions.cs" /> + <Compile Include="Web\CheckForUpdateRequest.cs" /> + <Compile Include="Web\CheckForUpdateResponse.cs" /> <Compile Include="MachineUpdate\DbCompareResult.cs" /> - <Compile Include="MachineUpdate\DownloadUpdateRequest.cs" /> - <Compile Include="MachineUpdate\DownloadUpdateResponse.cs" /> + <Compile Include="Web\DownloadUpdateRequest.cs" /> + <Compile Include="Web\DownloadUpdateResponse.cs" /> <Compile Include="MachineUpdate\IMachineUpdateManager.cs" /> - <Compile Include="MachineSetup\MachineSetupRequest.cs" /> - <Compile Include="MachineSetup\MachineSetupResponse.cs" /> + <Compile Include="Web\LoginMode.cs" /> + <Compile Include="Web\LoginRequest.cs" /> + <Compile Include="Web\LoginResponse.cs" /> + <Compile Include="Web\MachineSetupRequest.cs" /> + <Compile Include="Web\MachineSetupResponse.cs" /> <Compile Include="MachineUpdate\MachineUpdateProgress.cs" /> <Compile Include="MachineUpdate\MachineUpdateManager.cs" /> <Compile Include="MachineUpdate\MachineUpdateResult.cs" /> - <Compile Include="MachineUpdate\UpdateDBRequest.cs" /> - <Compile Include="MachineUpdate\UpdateDBResponse.cs" /> + <Compile Include="Web\UpdateDBRequest.cs" /> + <Compile Include="Web\UpdateDBResponse.cs" /> <Compile Include="MachineUpdate\UpdatePackageFile.cs" /> <Compile Include="Messages\JobRemovedMessage.cs" /> <Compile Include="Messages\JobSavedMessage.cs" /> @@ -181,16 +192,16 @@ <Compile Include="Storage\DefaultStorageProvider.cs" /> <Compile Include="Storage\IStorageProvider.cs" /> <Compile Include="Threading\IDispatcherProvider.cs" /> - <Compile Include="Update\MachineVersionsRequest.cs" /> - <Compile Include="Update\MachineVersionsResponse.cs" /> - <Compile Include="Update\IPPCUpdateService.cs" /> - <Compile Include="Update\LatestVersionRequest.cs" /> - <Compile Include="Update\LatestVersionResponse.cs" /> - <Compile Include="Update\UploadCompletedResponse.cs" /> - <Compile Include="Update\UploadCompletedRequest.cs" /> - <Compile Include="Update\UploadVersionRequest.cs" /> - <Compile Include="Update\UploadVersionResponse.cs" /> - <Compile Include="Update\PPCUpdateService.cs" /> + <Compile Include="Web\MachineVersionsRequest.cs" /> + <Compile Include="Web\MachineVersionsResponse.cs" /> + <Compile Include="Web\IPPCWebService.cs" /> + <Compile Include="Web\LatestVersionRequest.cs" /> + <Compile Include="Web\LatestVersionResponse.cs" /> + <Compile Include="Web\UploadCompletedResponse.cs" /> + <Compile Include="Web\UploadCompletedRequest.cs" /> + <Compile Include="Web\UploadVersionRequest.cs" /> + <Compile Include="Web\UploadVersionResponse.cs" /> + <Compile Include="Web\PPCWebService.cs" /> <Compile Include="UWF\DefaultUnifiedWriteFilterManager.cs" /> <Compile Include="UWF\IUnifiedWriteFilterManager.cs" /> <Compile Include="WatchDog\WatchDogClient.cs" /> @@ -355,7 +366,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ 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 -{ - /// <summary> - /// Represents an PPC update service for uploading PPC software packages. - /// </summary> - public interface IPPCUpdateService - { - /// <summary> - /// Uploads the version. - /// </summary> - /// <param name="request">The request.</param> - /// <returns></returns> - Task<UploadVersionResponse> UploadVersion(UploadVersionRequest request); - - /// <summary> - /// Notifies the upload completed. - /// </summary> - /// <param name="request">The request.</param> - Task<UploadCompletedResponse> NotifyUploadCompleted(UploadCompletedRequest request); - - /// <summary> - /// Gets the latest version. - /// </summary> - /// <param name="machineVersionGuid">The machine version unique identifier.</param> - /// <returns></returns> - Task<LatestVersionResponse> GetLatestVersion(LatestVersionRequest request); - - /// <summary> - /// Gets the hardware versions. - /// </summary> - /// <param name="request">The request.</param> - /// <returns></returns> - Task<MachineVersionsResponse> GetMachineVersions(); - } -} 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<PPCSettings>().GetMachineServiceAddress() + "/api/PPC/"; - } - - public Task<UploadVersionResponse> UploadVersion(UploadVersionRequest request) - { - return _client.PostJson<UploadVersionRequest, UploadVersionResponse>(GetAddress() + "UploadVersion", request); - } - - public Task<UploadCompletedResponse> NotifyUploadCompleted(UploadCompletedRequest request) - { - return _client.PostJson<UploadCompletedRequest, UploadCompletedResponse>(GetAddress() + "NotifyUploadCompleted", request); - } - - public Task<LatestVersionResponse> GetLatestVersion(LatestVersionRequest request) - { - return _client.PostJson<LatestVersionRequest, LatestVersionResponse>(GetAddress() + "GetLatestVersion", request); - } - - public Task<MachineVersionsResponse> GetMachineVersions() - { - return _client.PostJson<MachineVersionsRequest, MachineVersionsResponse>(GetAddress() + "GetMachineVersions", new MachineVersionsRequest()); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs index cd5789393..8bb8cde54 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs @@ -5,11 +5,10 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineUpdate +namespace Tango.PPC.Common.Web { - public class CheckForUpdateRequest : WebRequestMessage + public class CheckForUpdateRequest : WebRequestSecureMessage { - 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/Web/CheckForUpdateResponse.cs index cbf6c8c64..1d49a535a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/CheckForUpdateResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineUpdate +namespace Tango.PPC.Common.Web { public class CheckForUpdateResponse : WebResponseMessage { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateRequest.cs index 9369a2a94..20d1da3ec 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateRequest.cs @@ -5,10 +5,10 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineUpdate +namespace Tango.PPC.Common.Web { - public class DownloadUpdateRequest : WebRequestMessage + public class DownloadUpdateRequest : WebRequestSecureMessage { - 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/Web/DownloadUpdateResponse.cs index de978ed66..3b09c1525 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/DownloadUpdateResponse.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Tango.Core; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineUpdate +namespace Tango.PPC.Common.Web { public class DownloadUpdateResponse : WebResponseMessage { 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 +{ + /// <summary> + /// Represents an PPC update service for uploading PPC software packages. + /// </summary> + public interface IPPCWebService : IDisposable + { + /// <summary> + /// Gets or sets the environment. + /// </summary> + DeploymentSlot Environment { get; set; } + + /// <summary> + /// Uploads the version. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<UploadVersionResponse> UploadVersion(UploadVersionRequest request); + + /// <summary> + /// Notifies the upload completed. + /// </summary> + /// <param name="request">The request.</param> + Task<UploadCompletedResponse> NotifyUploadCompleted(UploadCompletedRequest request); + + /// <summary> + /// Gets the latest version. + /// </summary> + /// <param name="machineVersionGuid">The machine version unique identifier.</param> + /// <returns></returns> + Task<LatestVersionResponse> GetLatestVersion(LatestVersionRequest request); + + /// <summary> + /// Gets the machine versions. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<MachineVersionsResponse> GetMachineVersions(); + + /// <summary> + /// Checks for available update. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<CheckForUpdateResponse> CheckForUpdate(CheckForUpdateRequest request); + + /// <summary> + /// Gets the version download info for the specified version. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<DownloadUpdateResponse> MachineUpdate(DownloadUpdateRequest request); + + /// <summary> + /// Gets the machine setup information. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<MachineSetupResponse> MachineSetup(MachineSetupRequest request); + + /// <summary> + /// Gets the machine database update information. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<UpdateDBResponse> UpdateDB(UpdateDBRequest request); + + /// <summary> + /// Logins to the PPC service. + /// </summary> + /// <param name="request">The request.</param> + /// <returns></returns> + Task<LoginResponse> Login(LoginRequest request); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionRequest.cs index 6a6dab1b4..400bb315c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionRequest.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { public class LatestVersionRequest : WebRequestMessage { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionResponse.cs index 8e97a8177..d2ed08f7d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/LatestVersionResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/LatestVersionResponse.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { public class LatestVersionResponse : WebResponseMessage { 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/MachineSetup/MachineSetupRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs index 4c8039544..ce8b2f58d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupRequest.cs @@ -5,10 +5,10 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineSetup +namespace Tango.PPC.Common.Web { - public class MachineSetupRequest : WebRequestMessage + public class MachineSetupRequest : WebRequestSecureMessage { - 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/Web/MachineSetupResponse.cs index 5e8885af7..7d142d5f7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Tango.Core; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineSetup +namespace Tango.PPC.Common.Web { public class MachineSetupResponse : WebResponseMessage { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsRequest.cs index bf2d86e70..d5936bc9b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsRequest.cs @@ -5,9 +5,9 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { - public class MachineVersionsRequest : WebRequestMessage + public class MachineVersionsRequest : WebRequestSecureMessage { } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsResponse.cs index ed4ac95c2..8d321f303 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineVersionsResponse.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Tango.BL.Entities; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { public class MachineVersionsResponse : WebResponseMessage { 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<PPCSettings>().DeploymentSlot; + } + + private String GetAddress() + { + return Environment.ToAddress() + "/api/PPC/"; + } + + public Task<UploadVersionResponse> UploadVersion(UploadVersionRequest request) + { + return _client.PostJson<UploadVersionRequest, UploadVersionResponse>(GetAddress() + "UploadVersion", request); + } + + public Task<UploadCompletedResponse> NotifyUploadCompleted(UploadCompletedRequest request) + { + return _client.PostJson<UploadCompletedRequest, UploadCompletedResponse>(GetAddress() + "NotifyUploadCompleted", request); + } + + public Task<LatestVersionResponse> GetLatestVersion(LatestVersionRequest request) + { + return _client.PostJson<LatestVersionRequest, LatestVersionResponse>(GetAddress() + "GetLatestVersion", request); + } + + public Task<MachineVersionsResponse> GetMachineVersions() + { + return _client.PostJson<MachineVersionsRequest, MachineVersionsResponse>(GetAddress() + "GetMachineVersions", new MachineVersionsRequest()); + } + + public Task<CheckForUpdateResponse> CheckForUpdate(CheckForUpdateRequest request) + { + return _client.PostJson<CheckForUpdateRequest, CheckForUpdateResponse>(GetAddress() + "CheckForUpdate", request); + } + + public Task<DownloadUpdateResponse> MachineUpdate(DownloadUpdateRequest request) + { + return _client.PostJson<DownloadUpdateRequest, DownloadUpdateResponse>(GetAddress() + "MachineUpdate", request); + } + + public Task<MachineSetupResponse> MachineSetup(MachineSetupRequest request) + { + return _client.PostJson<MachineSetupRequest, MachineSetupResponse>(GetAddress() + "MachineSetup", request); + } + + public Task<UpdateDBResponse> UpdateDB(UpdateDBRequest request) + { + return _client.PostJson<UpdateDBRequest, UpdateDBResponse>(GetAddress() + "UpdateDB", request); + } + + public Task<LoginResponse> Login(LoginRequest request) + { + return _client.PostJson<LoginRequest, LoginResponse>(GetAddress() + "Login", request); + } + + public void Dispose() + { + _client.Dispose(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs index 1d0caa5a9..4c9714970 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBRequest.cs @@ -5,10 +5,10 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineUpdate +namespace Tango.PPC.Common.Web { - public class UpdateDBRequest : WebRequestMessage + public class UpdateDBRequest : WebRequestSecureMessage { - 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/Web/UpdateDBResponse.cs index 36be14750..b98517e02 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UpdateDBResponse.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Tango.Core; using Tango.Transport.Web; -namespace Tango.PPC.Common.MachineUpdate +namespace Tango.PPC.Common.Web { public class UpdateDBResponse : WebResponseMessage { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedRequest.cs index dab9bcefd..f9674f6c5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedRequest.cs @@ -6,10 +6,10 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { public class UploadCompletedRequest : WebRequestSecureMessage { - + public String Token { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedResponse.cs index 1cce32e7d..231f42db9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadCompletedResponse.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { 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/Web/UploadVersionRequest.cs index 0b496d7be..68643bfe7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionRequest.cs @@ -6,14 +6,10 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { - public class UploadVersionRequest : WebRequestMessage + public class UploadVersionRequest : WebRequestSecureMessage { - public String Email { get; set; } - - public String Password { get; set; } - public String Version { get; set; } public String MachineVersionGuid { get; set; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs index 4543261e7..9a0fc1a5f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadVersionResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/UploadVersionResponse.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Transport.Web; -namespace Tango.PPC.Common.Update +namespace Tango.PPC.Common.Web { public class UploadVersionResponse : WebResponseMessage { 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 @@ <?xml version="1.0" encoding="utf-8"?> <packages> + <package id="CommandLineParser" version="1.9.71" targetFramework="net461" /> <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> <package id="FluentFTP" version="19.1.2" targetFramework="net46" /> <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.config index e8039e63f..e8039e63f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.config diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml index 1f18cae75..0f06af76b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml @@ -1,7 +1,7 @@ -<Application x:Class="Tango.PPC.Publisher.App" +<Application x:Class="Tango.PPC.Publisher.UI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="clr-namespace:Tango.PPC.Publisher" + xmlns:local="clr-namespace:Tango.PPC.Publisher.UI" StartupUri="MainWindow.xaml"> <Application.Resources> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml.cs index 9955d6822..4b857a3af 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/App.xaml.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows; -namespace Tango.PPC.Publisher +namespace Tango.PPC.Publisher.UI { /// <summary> /// Interaction logic for App.xaml diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml index 830c4c585..1bdc062de 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml @@ -1,4 +1,4 @@ -<Window x:Class="Tango.PPC.Publisher.MainWindow" +<Window x:Class="Tango.PPC.Publisher.UI.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" @@ -8,7 +8,7 @@ xmlns:common="clr-namespace:Tango.PPC.Common;assembly=Tango.PPC.Common" xmlns:examiner="clr-namespace:Tango.SQLExaminer;assembly=Tango.SQLExaminer" xmlns:web="clr-namespace:Tango.Web;assembly=Tango.Web" - xmlns:local="clr-namespace:Tango.PPC.Publisher" + xmlns:local="clr-namespace:Tango.PPC.Publisher.UI" mc:Ignorable="d" Title="Tango PPC Publisher" Height="1100" Width="500" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}"> @@ -16,7 +16,18 @@ <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> </Window.Resources> - <Grid> + <Window.Style> + <Style TargetType="Window"> + <Setter Property="Cursor" Value="Arrow"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsBusy}" Value="True"> + <Setter Property="Cursor" Value="Wait"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Window.Style> + + <Grid IsEnabled="{Binding IsFree}"> <DockPanel Margin="10"> <Grid Height="50" DockPanel.Dock="Bottom"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> @@ -31,12 +42,12 @@ <DockPanel Margin="0 40 0 0"> <TextBlock VerticalAlignment="Center" Width="136" DockPanel.Dock="Left">Deployment Slot:</TextBlock> - <ComboBox x:Name="combo" ItemsSource="{Binding Source={x:Type web:DeploymentSlot},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding DeploymentSlot}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Margin="5 0 0 0" /> + <ComboBox x:Name="combo" ItemsSource="{Binding Source={x:Type web:DeploymentSlot},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding Options.Environment}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Margin="5 0 0 0" /> </DockPanel> <DockPanel Margin="0 20 0 0"> <TextBlock VerticalAlignment="Center" Width="136" DockPanel.Dock="Left">Build Configuration:</TextBlock> - <ComboBox Margin="20 0 0 0" SelectedItem="{Binding SelectedBuildConfiguration}" SelectedIndex="0"> + <ComboBox Margin="20 0 0 0" SelectedItem="{Binding Options.BuildConfig}" SelectedIndex="0"> <sys:String>Release</sys:String> <sys:String>Debug</sys:String> </ComboBox> @@ -49,15 +60,15 @@ <TextBlock Margin="0 20 0 0"> <TextBlock> - <Run>Current Version:</Run> - <Run Text="{Binding CurrentVersion}"></Run> + <Run>Local Version:</Run> + <Run Text="{Binding LocalVersion}"></Run> </TextBlock> </TextBlock> <TextBlock Margin="0 20 0 0"> <TextBlock> - <Run>Local Version:</Run> - <Run Text="{Binding LocalVersion}"></Run> + <Run>Remote Version:</Run> + <Run Text="{Binding RemoteVersion}"></Run> </TextBlock> </TextBlock> @@ -90,23 +101,26 @@ <TextBlock Margin="0 20 0 0">Firmware Upgrade Package</TextBlock> <DockPanel Margin="0 5 0 0"> <Button DockPanel.Dock="Right" Margin="10 0 0 0" Command="{Binding FirmwareUpgradePackageBrowseCommand}">BROWSE</Button> - <TextBox IsReadOnly="True" Text="{Binding FirmwareUpgradeFilePath}"></TextBox> + <TextBox IsReadOnly="True" Text="{Binding Options.TfpPath}"></TextBox> </DockPanel> <StackPanel Margin="0 30 0 0"> <TextBlock>Comments</TextBlock> - <TextBox Margin="0 5 0 0" Text="{Binding Comments}" Height="50" AcceptsReturn="True" TextWrapping="Wrap"></TextBox> + <TextBox Margin="0 5 0 0" Text="{Binding Options.Comments}" Height="50" AcceptsReturn="True" TextWrapping="Wrap"></TextBox> <TextBlock>Email</TextBlock> - <TextBox Margin="0 5 0 0" Text="{Binding Email}"></TextBox> + <TextBox Margin="0 5 0 0" Text="{Binding Options.Email}"></TextBox> <TextBlock Margin="0 10 0 0">Password</TextBlock> - <TextBox Margin="0 5 0 0" Text="{Binding Password}"></TextBox> + <TextBox Margin="0 5 0 0" Text="{Binding Options.Password}"></TextBox> </StackPanel> </StackPanel> - <ProgressBar VerticalAlignment="Bottom" Height="15" Margin="0 0 0 10" Maximum="{Binding MaxProgress}" Value="{Binding Progress}"></ProgressBar> + <StackPanel VerticalAlignment="Bottom"> + <TextBlock Text="{Binding PublishArgs.Message}" Foreground="Gray"></TextBlock> + <ProgressBar Height="15" Margin="0 5 0 10" Maximum="{Binding PublishArgs.Total}" Value="{Binding PublishArgs.Progress}"></ProgressBar> + </StackPanel> </Grid> </DockPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs index 610eb40a8..4d062d5af 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml.cs @@ -14,9 +14,10 @@ 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 +namespace Tango.PPC.Publisher.UI { /// <summary> /// Interaction logic for MainWindow.xaml @@ -50,9 +51,9 @@ namespace Tango.PPC.Publisher item.RequiresSerialNumber = File.ReadAllText(dlg.FileName).Contains("'@'"); - if ((DataContext as MainWindowVM).ProvisionSequenceItems.Count > 0) + if ((DataContext as MainWindowVM).Options.Synchronization.ProvisionSequenceItems.Count > 0) { - item.Index = (DataContext as MainWindowVM).ProvisionSequenceItems.Max(x => x.Index + 1); + 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); @@ -82,9 +83,9 @@ namespace Tango.PPC.Publisher item.RequiresSerialNumber = File.ReadAllText(dlg.FileName).Contains("'@'"); - if ((DataContext as MainWindowVM).UpdateSequenceItems.Count > 0) + if ((DataContext as MainWindowVM).Options.Synchronization.UpdateSequenceItems.Count > 0) { - item.Index = (DataContext as MainWindowVM).UpdateSequenceItems.Max(x => x.Index + 1); + 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); 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<MachineVersion> _machineVersions; + public List<MachineVersion> 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<PublisherSettings>(); + 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<CoreSettings>(); + 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/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/AssemblyInfo.cs index 1756d71bc..1756d71bc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/AssemblyInfo.cs diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.Designer.cs index 66912209d..8c15bf2c0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.Designer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // </auto-generated> //------------------------------------------------------------------------------ -namespace Tango.PPC.Publisher.Properties -{ - - +namespace Tango.PPC.Publisher.UI.UI.Properties { + using System; + + /// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> @@ -19,51 +19,43 @@ namespace Tango.PPC.Publisher.Properties // 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + 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() - { + internal Resources() { } - + /// <summary> /// Returns the cached ResourceManager instance used by this class. /// </summary> [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); + 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; } } - + /// <summary> /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.resx b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.resx index af7dbebba..af7dbebba 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Resources.resx +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Resources.resx diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.Designer.cs index 3013d3a3d..984af1fb2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.Designer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // </auto-generated> //------------------------------------------------------------------------------ -namespace Tango.PPC.Publisher.Properties -{ - - +namespace Tango.PPC.Publisher.UI.UI.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 - { - + [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 - { + + 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.UI/Properties/Settings.settings index 033d7a5e9..033d7a5e9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Properties/Settings.settings +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Properties/Settings.settings 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/Tango.PPC.Publisher.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Tango.PPC.Publisher.UI.csproj index c9e5a72d7..6a6b01a46 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/Tango.PPC.Publisher.UI.csproj @@ -6,8 +6,8 @@ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{FABA6A2B-C7EA-4C58-A125-150FA5B4C72F}</ProjectGuid> <OutputType>WinExe</OutputType> - <RootNamespace>Tango.PPC.Publisher</RootNamespace> - <AssemblyName>Tango.PPC.Publisher</AssemblyName> + <RootNamespace>Tango.PPC.Publisher.UI</RootNamespace> + <AssemblyName>Tango.PPC.Publisher.UI</AssemblyName> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> @@ -78,7 +78,6 @@ <SubType>Designer</SubType> </ApplicationDefinition> <Compile Include="PublisherSettings.cs" /> - <Compile Include="SequenceItem.cs" /> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/packages.config index 5ac999495..5ac999495 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/packages.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/packages.config 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<MachineVersion> _machineVersions; - public List<MachineVersion> 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<SequenceItem> _provisionSequenceItems; - public ObservableCollection<SequenceItem> ProvisionSequenceItems - { - get { return _provisionSequenceItems; } - set { _provisionSequenceItems = value; RaisePropertyChangedAuto(); } - } - - private ICollectionView _provisionSequenceItemsView; - public ICollectionView ProvisionSequenceItemsView - { - get { return _provisionSequenceItemsView; } - set { _provisionSequenceItemsView = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection<SequenceItem> _updateSequenceItems; - public ObservableCollection<SequenceItem> 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<PublisherSettings>(); - - SelectedBuildConfiguration = settings.BuildConfiguration; - DeploymentSlot = settings.DeploymentSlot; - - ProvisionSequenceItems = new ObservableCollection<SequenceItem>(settings.ProvisionSequenceItems); - ProvisionSequenceItemsView = CollectionViewSource.GetDefaultView(ProvisionSequenceItems); - ProvisionSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); - - UpdateSequenceItems = new ObservableCollection<SequenceItem>(settings.UpdateSequenceItems); - UpdateSequenceItemsView = CollectionViewSource.GetDefaultView(UpdateSequenceItems); - UpdateSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); - - SettingsManager.Default.GetOrCreate<CoreSettings>(); - 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<PPCSettings>().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<PublisherSettings>(); - 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/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<SequenceItem> ProvisionSequenceItems { get; set; } - - public List<SequenceItem> UpdateSequenceItems { get; set; } - - public String BuildConfiguration { get; set; } - - public DeploymentSlot DeploymentSlot { get; set; } - - public PublisherSettings() - { - ProvisionSequenceItems = new List<SequenceItem>(); - UpdateSequenceItems = new List<SequenceItem>(); - 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.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 @@ <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> 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 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> + </dependentAssembly> + </assemblyBinding> + </runtime> </configuration>
\ 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<PPCPendingUpload> _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<TokenObject> TokensManager { get; set; } #region Constructors static PPCController() { + TokensManager = new TokensManager<TokenObject>(); _pendingUploads = new List<PPCPendingUpload>(); } + 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<WebRequestSecureMessage>(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 @@ <Compile Include="App_Start\BundleConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="Filters\MachineStudioLoginFilter.cs" /> + <Compile Include="Filters\PPCLoginFilter.cs" /> <Compile Include="MachineServiceConfig.cs" /> <Compile Include="Controllers\MachineStudioController.cs" /> <Compile Include="Models\MachineStudioPendingUpload.cs" /> @@ -286,7 +287,6 @@ <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> - <Compile Include="Models\Person.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> |
