From 6240aad18f5dc54d4e29bf2d39f49ef1ba39742f Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 10 Dec 2018 12:59:22 +0200 Subject: Added array support for stubsexec. Improved PPC update & setup. --- .../PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs') 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 16b1c05bc..84987d705 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -102,6 +102,17 @@ namespace Tango.PPC.UI.ViewModels set { _state = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private String _failedError; + /// + /// Gets or sets the setup failed error. + /// + public String FailedError + { + get { return _failedError; } + set { _failedError = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -281,6 +292,7 @@ namespace Tango.PPC.UI.ViewModels catch (Exception ex) { LogManager.Log(ex, "Machine setup failed."); + FailedError = ex.FlattenMessage(); State = MachineSetupStates.Failed; await NavigateTo(MachineSetupView.SetupFailedView); } -- cgit v1.3.1 From 2f85568170b4c11c6c5876b7fac9e662a004d47f Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 24 Dec 2018 19:01:11 +0200 Subject: Implemented PPC time zone modification ! --- Software/Graphics/time-zone.png | Bin 0 -> 8892 bytes .../MachineSetup/MachineSetupManager.cs | 8 +- .../OS/DefaultOperationSystemManager.cs | 115 +++++++++++++++++++++ .../OS/DefaultWindowsActivationManager.cs | 90 ---------------- .../Tango.PPC.Common/OS/IOperationSystemManager.cs | 47 +++++++++ .../OS/IWindowsActivationManager.cs | 33 ------ .../PPC/Tango.PPC.Common/PPCSettings.cs | 2 +- .../PPC/Tango.PPC.Common/PPCViewModel.cs | 1 - .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 6 +- .../PPC/Tango.PPC.UI/Images/time-zone.png | Bin 0 -> 8892 bytes .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 3 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 4 +- .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 33 +++++- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 13 +++ 14 files changed, 218 insertions(+), 137 deletions(-) create mode 100644 Software/Graphics/time-zone.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IWindowsActivationManager.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs') diff --git a/Software/Graphics/time-zone.png b/Software/Graphics/time-zone.png new file mode 100644 index 000000000..10b5d996c Binary files /dev/null and b/Software/Graphics/time-zone.png differ 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 b8638b158..488206590 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -38,7 +38,7 @@ namespace Tango.PPC.Common.MachineSetup { private IRemoteAssistanceProvider _remoteAssistance; private IUnifiedWriteFilterManager _uwf; - private IWindowsActivationManager _windows_activation_manager; + private IOperationSystemManager _windows_manager; #region Events @@ -71,11 +71,11 @@ namespace Tango.PPC.Common.MachineSetup /// Initializes a new instance of the class. /// /// The remote assistance. - public MachineSetupManager(IRemoteAssistanceProvider remoteAssistance, IUnifiedWriteFilterManager unifiedWriterFilterManager, IWindowsActivationManager windowsActivationManager) + public MachineSetupManager(IRemoteAssistanceProvider remoteAssistance, IUnifiedWriteFilterManager unifiedWriterFilterManager, IOperationSystemManager operationSystemManager) { _remoteAssistance = remoteAssistance; _uwf = unifiedWriterFilterManager; - _windows_activation_manager = windowsActivationManager; + _windows_manager = operationSystemManager; } #endregion @@ -140,7 +140,7 @@ namespace Tango.PPC.Common.MachineSetup { LogManager.Log("Activating windows license..."); UpdateProgress("Activating operation system license", "Activating..."); - await _windows_activation_manager.Activate(setup_response.OSKey); + await _windows_manager.Activate(setup_response.OSKey); } if (setup_response.SetupRemoteAssistance) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs new file mode 100644 index 000000000..5e6b9c156 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common.Scripting; + +namespace Tango.PPC.Common.OS +{ + using System.Collections.ObjectModel; + using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h + + /// + /// Represents the default windows activation manager. + /// + /// + public class DefaultOperationSystemManager : IOperationSystemManager + { + #region Win32 + + private enum SL_GENUINE_STATE + { + SL_GEN_STATE_IS_GENUINE = 0, + SL_GEN_STATE_INVALID_LICENSE = 1, + SL_GEN_STATE_TAMPERED = 2, + SL_GEN_STATE_OFFLINE = 3, + SL_GEN_STATE_LAST = 4 + } + + [DllImportAttribute("Slwga.dll", EntryPoint = "SLIsGenuineLocal", CharSet = CharSet.None, ExactSpelling = false, SetLastError = false, PreserveSig = true, CallingConvention = CallingConvention.Winapi, BestFitMapping = false, ThrowOnUnmappableChar = false)] + [PreserveSigAttribute()] + private static extern uint SLIsGenuineLocal(ref SLID slid, [In, Out] ref SL_GENUINE_STATE genuineState, IntPtr val3); + + #endregion + + /// + /// Determines whether the OS is activated. + /// + /// + public Task IsActivated() + { + return Task.Factory.StartNew(() => + { + Guid ApplicationID = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f"); //Application ID GUID http://technet.microsoft.com/en-us/library/dd772270.aspx + SLID windowsSlid = (Guid)ApplicationID; + try + { + SL_GENUINE_STATE genuineState = SL_GENUINE_STATE.SL_GEN_STATE_LAST; + uint ResultInt = SLIsGenuineLocal(ref windowsSlid, ref genuineState, IntPtr.Zero); + if (ResultInt == 0) + { + return (genuineState == SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE); + } + else + { + throw new InvalidOperationException("An error occurred while trying to get the OS activation status."); + } + + } + catch (Exception ex) + { + throw ex; + } + }); + } + + /// + /// Activates the OS using the specified activation key. + /// + /// The activation key. + /// + public async Task Activate(string activationKey) + { + CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); + await command.Run(); + + if (!await IsActivated()) + { + throw new ApplicationException("The activation was completed but activation status returned a false response."); + } + } + + /// + /// Deactivates the OS license. + /// + /// + /// + public Task Deactivate() + { + throw new NotImplementedException("Deactivating windows license is not supported."); + } + + /// + /// Gets the available time zones. + /// + /// + public ReadOnlyCollection GetAvailableTimeZones() + { + return TimeZoneInfo.GetSystemTimeZones(); + } + + /// + /// Changes the operation system time zone. + /// + /// The time zone. + /// + public async Task ChangeTimeZone(TimeZoneInfo timeZone) + { + CmdCommand cmd = new CmdCommand("tzutil", $"/s \"{timeZone.StandardName}\""); + await cmd.Run(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs deleted file mode 100644 index 610328bc2..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Management; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using Tango.PPC.Common.Scripting; - -namespace Tango.PPC.Common.OS -{ - using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h - - /// - /// Represents the default windows activation manager. - /// - /// - public class DefaultWindowsActivationManager : IWindowsActivationManager - { - private enum SL_GENUINE_STATE - { - SL_GEN_STATE_IS_GENUINE = 0, - SL_GEN_STATE_INVALID_LICENSE = 1, - SL_GEN_STATE_TAMPERED = 2, - SL_GEN_STATE_OFFLINE = 3, - SL_GEN_STATE_LAST = 4 - } - - [DllImportAttribute("Slwga.dll", EntryPoint = "SLIsGenuineLocal", CharSet = CharSet.None, ExactSpelling = false, SetLastError = false, PreserveSig = true, CallingConvention = CallingConvention.Winapi, BestFitMapping = false, ThrowOnUnmappableChar = false)] - [PreserveSigAttribute()] - private static extern uint SLIsGenuineLocal(ref SLID slid, [In, Out] ref SL_GENUINE_STATE genuineState, IntPtr val3); - - /// - /// Determines whether the OS is activated. - /// - /// - public Task IsActivated() - { - return Task.Factory.StartNew(() => - { - Guid ApplicationID = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f"); //Application ID GUID http://technet.microsoft.com/en-us/library/dd772270.aspx - SLID windowsSlid = (Guid)ApplicationID; - try - { - SL_GENUINE_STATE genuineState = SL_GENUINE_STATE.SL_GEN_STATE_LAST; - uint ResultInt = SLIsGenuineLocal(ref windowsSlid, ref genuineState, IntPtr.Zero); - if (ResultInt == 0) - { - return (genuineState == SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE); - } - else - { - throw new InvalidOperationException("An error occurred while trying to get the OS activation status."); - } - - } - catch (Exception ex) - { - throw ex; - } - }); - } - - /// - /// Activates the OS using the specified activation key. - /// - /// The activation key. - /// - public async Task Activate(string activationKey) - { - CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); - await command.Run(); - - if (!await IsActivated()) - { - throw new ApplicationException("The activation was completed but activation status returned a false response."); - } - } - - /// - /// Deactivates the OS license. - /// - /// - /// - public Task Deactivate() - { - throw new NotImplementedException("Deactivating windows license is not supported."); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs new file mode 100644 index 000000000..d7898d174 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.OS +{ + /// + /// Represents a windows license activation manager. + /// + public interface IOperationSystemManager + { + /// + /// Determines whether the OS is activated. + /// + /// + Task IsActivated(); + + /// + /// Activates the OS using the specified activation key. + /// + /// The activation key. + /// + Task Activate(String activationKey); + + /// + /// Deactivates the OS license. + /// + /// + Task Deactivate(); + + /// + /// Gets the available time zones. + /// + /// + ReadOnlyCollection GetAvailableTimeZones(); + + /// + /// Changes the operation system time zone. + /// + /// The time zone. + /// + Task ChangeTimeZone(TimeZoneInfo timeZone); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IWindowsActivationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IWindowsActivationManager.cs deleted file mode 100644 index 2fc79e5bb..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IWindowsActivationManager.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Common.OS -{ - /// - /// Represents a windows license activation manager. - /// - public interface IWindowsActivationManager - { - /// - /// Determines whether the OS is activated. - /// - /// - Task IsActivated(); - - /// - /// Activates the OS using the specified activation key. - /// - /// The activation key. - /// - Task Activate(String activationKey); - - /// - /// Deactivates the OS license. - /// - /// - Task Deactivate(); - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index d6fa39af0..8413e5a4f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -77,7 +77,7 @@ namespace Tango.PPC.Common { MachineScanningTimeoutSeconds = 20; LoggingCategories = new List(); - MachineServiceAddress = "http://machineservice.twine-srv.com/"; + MachineServiceAddress = "https://machineservice.twine-srv.com/"; EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index 289683855..b9a0d8483 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -109,7 +109,6 @@ namespace Tango.PPC.Common [TangoInject] public IEventLogger EventLogger { get; set; } - private PPCSettings _settings; /// /// Gets the main PPC settings. 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 790f69ff8..c8c6575a5 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 @@ -167,8 +167,8 @@ MessageNotificationItemView.xaml - - + + @@ -344,7 +344,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png new file mode 100644 index 000000000..10b5d996c Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/time-zone.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 836878152..5fe3ae2bb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -409,6 +409,7 @@ Tango.ColorLib.dll PreserveNewest + @@ -485,7 +486,7 @@ del "$(TargetDir)firmware_package.tfp" - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 80154bc3f..444fd70b9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -68,7 +68,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); - TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); TangoIOC.Default.Register(new DefaultDispatcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register(); @@ -89,7 +89,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); + TangoIOC.Default.Register(); //TangoIOC.Default.Register(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); 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 84987d705..7b8d4dbe6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -17,6 +17,7 @@ using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; using Tango.PPC.Common.MachineSetup; using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.OS; using Tango.PPC.UI.ViewsContracts; using Tango.Settings; using Tango.SharedUI.Helpers; @@ -47,6 +48,7 @@ namespace Tango.PPC.UI.ViewModels WelcomeView, WiFiSelectionView, WiFiTestView, + TimeZoneView, SetupWelcomeView, SetupProgressView, SetupCompletedView, @@ -54,6 +56,7 @@ namespace Tango.PPC.UI.ViewModels } private MachineSetupResult _setup_result; + private IOperationSystemManager _operationSystemManager; #region Properties @@ -112,6 +115,21 @@ namespace Tango.PPC.UI.ViewModels set { _failedError = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the available time zones. + /// + public List TimeZones { get; set; } + + private TimeZoneInfo _selectedTimeZone; + /// + /// Gets or sets the selected time zone. + /// + public TimeZoneInfo SelectedTimeZone + { + get { return _selectedTimeZone; } + set { _selectedTimeZone = value; RaisePropertyChangedAuto(); } + } + #endregion @@ -137,6 +155,10 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand RestartCommand { get; set; } + /// + /// Gets or sets the time zone selected command. + /// + public RelayCommand TimeZoneSelectedCommand { get; set; } #endregion #region Constructors @@ -146,7 +168,7 @@ namespace Tango.PPC.UI.ViewModels /// /// The application manager. /// The machine setup manager. - public MachineSetupViewVM(IPPCApplicationManager applicationManager, IMachineSetupManager machineSetupManager) + public MachineSetupViewVM(IPPCApplicationManager applicationManager, IMachineSetupManager machineSetupManager, IOperationSystemManager operationSystemManager) { MachineSetupManager = machineSetupManager; @@ -161,6 +183,12 @@ namespace Tango.PPC.UI.ViewModels InstallCommand = new RelayCommand(Install); RestartCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.WelcomeView); }); + TimeZoneSelectedCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.SetupWelcomeView); }); + + _operationSystemManager = operationSystemManager; + + TimeZones = _operationSystemManager.GetAvailableTimeZones().ToList(); + SelectedTimeZone = TimeZones.SingleOrDefault(x => x.ToString() == "(UTC+02:00) Jerusalem"); } #endregion @@ -250,7 +278,7 @@ namespace Tango.PPC.UI.ViewModels if (connected) { - await NavigateTo(MachineSetupView.SetupWelcomeView); + await NavigateTo(MachineSetupView.TimeZoneView); } else { @@ -284,6 +312,7 @@ namespace Tango.PPC.UI.ViewModels try { + await _operationSystemManager.ChangeTimeZone(SelectedTimeZone); _setup_result = await MachineSetupManager.Setup(SerialNumber, HostAddress); State = MachineSetupStates.Completed; LogManager.Log("Machine setup completed."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index dc30cfa93..4832eea01 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -67,6 +67,19 @@ + + + + + Please select the machine time zone + + + + + CONTINUE + + + -- cgit v1.3.1 From 00de504d4d276063ec6b732cc95e476c89182df2 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 27 Dec 2018 17:34:54 +0200 Subject: Worked on PPC publisher. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/Graphics/environment.png | Bin 0 -> 4809 bytes .../PPC/Tango.PPC.Common/DeploymentSlots.cs | 21 +++++++++++++ .../PPC/Tango.PPC.Common/PPCSettings.cs | 21 +++++++++---- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 5 ++- .../Tango.PPC.Common/Update/IPPCUpdateService.cs | 7 +++++ .../Update/MachineVersionsRequest.cs | 14 +++++++++ .../Update/MachineVersionsResponse.cs | 20 ++++++++++++ .../Tango.PPC.Common/Update/PPCUpdateService.cs | 18 ++++++++--- .../PPC/Tango.PPC.Publisher/MainWindow.xaml | 8 ++++- .../PPC/Tango.PPC.Publisher/MainWindowVM.cs | 35 ++++++++++++++------- .../PPC/Tango.PPC.Publisher/PublisherSettings.cs | 6 ++++ .../PPC/Tango.PPC.UI/Images/environment.png | Bin 0 -> 4809 bytes .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 3 +- .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 26 +++++++++++++-- .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 6 ++-- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 16 +++++++++- .../Visual_Studio/Tango.BL/ObservableEntity.cs | 3 -- .../Converters/EnumToItemsSourceConverter.cs | 10 +++++- .../Controllers/PPCController.cs | 25 ++++++++------- 21 files changed, 197 insertions(+), 47 deletions(-) create mode 100644 Software/Graphics/environment.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/environment.png (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 430acbabf..68f4424b9 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index b2e06171f..2f9c6e1b1 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Graphics/environment.png b/Software/Graphics/environment.png new file mode 100644 index 000000000..6a9486556 Binary files /dev/null and b/Software/Graphics/environment.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs new file mode 100644 index 000000000..0118592fd --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common +{ + public enum DeploymentSlots + { + [Description("https://machineservice-dev.twine-srv.com")] + Development, + [Description("https://machineservice-test.twine-srv.com")] + Testing, + [Description("https://machineservice-stage.twine-srv.com")] + Staging, + [Description("https://machineservice.twine-srv.com")] + Production + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 8413e5a4f..81168d235 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -25,11 +25,6 @@ namespace Tango.PPC.Common /// public ApplicationStates ApplicationState { get; set; } - /// - /// Gets or sets the machine service address. - /// - public String MachineServiceAddress { get; set; } - /// /// Gets or sets the machine scanning timeout seconds. /// @@ -70,6 +65,20 @@ namespace Tango.PPC.Common /// public bool EnableRemoteAssistance { get; set; } + /// + /// Gets or sets the deployment slot. + /// + public DeploymentSlots DeploymentSlot { get; set; } + + /// + /// Gets the machine service address. + /// + /// + public String GetMachineServiceAddress() + { + return DeploymentSlot.ToDescription(); + } + /// /// Initializes a new instance of the class. /// @@ -77,10 +86,10 @@ namespace Tango.PPC.Common { MachineScanningTimeoutSeconds = 20; LoggingCategories = new List(); - MachineServiceAddress = "https://machineservice.twine-srv.com/"; EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; + DeploymentSlot = DeploymentSlots.Production; } } } 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 c8c6575a5..2f04e21ef 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 @@ -125,6 +125,7 @@ TwineCatalogControl.xaml + @@ -178,6 +179,8 @@ + + @@ -344,7 +347,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs index 49bfba1cd..a16099e7c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/IPPCUpdateService.cs @@ -33,5 +33,12 @@ namespace Tango.PPC.Common.Update /// The machine version unique identifier. /// Task GetLatestVersion(LatestVersionRequest request); + + /// + /// Gets the hardware versions. + /// + /// The request. + /// + Task GetMachineVersions(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs new file mode 100644 index 000000000..bf2d86e70 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Update +{ + public class MachineVersionsRequest : WebRequestMessage + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs new file mode 100644 index 000000000..ed4ac95c2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/MachineVersionsResponse.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Transport.Web; + +namespace Tango.PPC.Common.Update +{ + public class MachineVersionsResponse : WebResponseMessage + { + public List MachineVersions { get; set; } + + public MachineVersionsResponse() + { + MachineVersions = new List(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs index b6654ef59..5692ccce9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/PPCUpdateService.cs @@ -10,28 +10,36 @@ namespace Tango.PPC.Common.Update { public class PPCUpdateService : IPPCUpdateService { - private string address; private WebTransportClient _client; public PPCUpdateService() { - address = SettingsManager.Default.GetOrCreate().MachineServiceAddress + "/api/PPC/"; _client = new WebTransportClient(); } + private String GetAddress() + { + return SettingsManager.Default.GetOrCreate().GetMachineServiceAddress() + "/api/PPC/"; + } + public Task UploadVersion(UploadVersionRequest request) { - return _client.PostJson(address + "UploadVersion", request); + return _client.PostJson(GetAddress() + "UploadVersion", request); } public Task NotifyUploadCompleted(UploadCompletedRequest request) { - return _client.PostJson(address + "NotifyUploadCompleted", request); + return _client.PostJson(GetAddress() + "NotifyUploadCompleted", request); } public Task GetLatestVersion(LatestVersionRequest request) { - return _client.PostJson(address + "GetLatestVersion", request); + return _client.PostJson(GetAddress() + "GetLatestVersion", request); + } + + public Task GetMachineVersions() + { + return _client.PostJson(GetAddress() + "GetMachineVersions", new MachineVersionsRequest()); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml index b347ce2c1..e34b82396 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml @@ -5,10 +5,11 @@ xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:common="clr-namespace:Tango.PPC.Common;assembly=Tango.PPC.Common" xmlns:examiner="clr-namespace:Tango.SQLExaminer;assembly=Tango.SQLExaminer" xmlns:local="clr-namespace:Tango.PPC.Publisher" mc:Ignorable="d" - Title="Tango PPC Publisher" Height="1000" Width="500" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}"> + Title="Tango PPC Publisher" Height="1100" Width="500" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}"> @@ -28,6 +29,11 @@ Tango Publish Utility + Deployment Slot: + + + + Build Configuration: Release diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs index 4e7dd304e..e11d01318 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs @@ -22,6 +22,7 @@ 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; @@ -121,6 +122,13 @@ namespace Tango.PPC.Publisher set { _password = value; RaisePropertyChangedAuto(); } } + private DeploymentSlots _deplotmentSlot; + public DeploymentSlots DeploymentSlot + { + get { return _deplotmentSlot; } + set { _deplotmentSlot = value; RaisePropertyChangedAuto(); OnDeploymentSlotChanged(); } + } + private String _comments; public String Comments { @@ -157,12 +165,15 @@ namespace Tango.PPC.Publisher public MainWindowVM() { - SelectedBuildConfiguration = "Release"; + _client = new PPCUpdateService(); _hashGenerator = new BasicHashGenerator(); var settings = SettingsManager.Default.GetOrCreate(); + SelectedBuildConfiguration = settings.BuildConfiguration; + DeploymentSlot = settings.DeploymentSlot; + ProvisionSequenceItems = new ObservableCollection(settings.ProvisionSequenceItems); ProvisionSequenceItemsView = CollectionViewSource.GetDefaultView(ProvisionSequenceItems); ProvisionSequenceItemsView.SortDescriptions.Add(new SortDescription(nameof(SequenceItem.Index), ListSortDirection.Ascending)); @@ -174,12 +185,6 @@ namespace Tango.PPC.Publisher SettingsManager.Default.GetOrCreate(); SettingsManager.Default.Save(); - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - MachineVersions = db.MachineVersions.ToList(); - SelectedMachineVersion = MachineVersions.OrderBy(x => x.Version).LastOrDefault(); - } - LocalVersion = FileVersionInfo.GetVersionInfo(Core.Helpers.AssemblyHelper.GetCurrentAssemblyFolder() + "\\Tango.PPC.UI.exe").ProductVersion; PublishCommand = new RelayCommand(Publish); @@ -191,11 +196,6 @@ namespace Tango.PPC.Publisher { if (SelectedMachineVersion != null) { - if (_client == null) - { - _client = new PPCUpdateService(); - } - var response = await _client.GetLatestVersion(new LatestVersionRequest() { MachineVersionGuid = SelectedMachineVersion.Guid, @@ -205,6 +205,14 @@ namespace Tango.PPC.Publisher } } + private async void OnDeploymentSlotChanged() + { + SettingsManager.Default.GetOrCreate().DeploymentSlot = DeploymentSlot; + SelectedMachineVersion = null; + MachineVersions = (await _client.GetMachineVersions()).MachineVersions; + SelectedMachineVersion = MachineVersions.OrderBy(x => x.Version).LastOrDefault(); + } + private void Publish() { Task.Factory.StartNew(async () => @@ -215,6 +223,9 @@ namespace Tango.PPC.Publisher var settings = SettingsManager.Default.GetOrCreate(); settings.ProvisionSequenceItems = ProvisionSequenceItems.ToList(); settings.UpdateSequenceItems = UpdateSequenceItems.ToList(); + settings.DeploymentSlot = DeploymentSlot; + settings.BuildConfiguration = SelectedBuildConfiguration; + settings.Save(); try diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs index d9f10cd01..6caf8a2f6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Common; using Tango.Settings; namespace Tango.PPC.Publisher @@ -13,10 +14,15 @@ namespace Tango.PPC.Publisher public List UpdateSequenceItems { get; set; } + public String BuildConfiguration { get; set; } + + public DeploymentSlots DeploymentSlot { get; set; } + public PublisherSettings() { ProvisionSequenceItems = new List(); UpdateSequenceItems = new List(); + BuildConfiguration = "Debug"; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/environment.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/environment.png new file mode 100644 index 000000000..6a9486556 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/environment.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 5fe3ae2bb..2c2ab061e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -409,6 +409,7 @@ Tango.ColorLib.dll PreserveNewest + @@ -486,7 +487,7 @@ del "$(TargetDir)firmware_package.tfp" - + \ No newline at end of file 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 7b8d4dbe6..6cf08a43a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -49,6 +49,7 @@ namespace Tango.PPC.UI.ViewModels WiFiSelectionView, WiFiTestView, TimeZoneView, + EnvironmentView, SetupWelcomeView, SetupProgressView, SetupCompletedView, @@ -130,6 +131,15 @@ namespace Tango.PPC.UI.ViewModels set { _selectedTimeZone = value; RaisePropertyChangedAuto(); } } + private DeploymentSlots _deploymentSlot; + /// + /// Gets or sets the deployment slot. + /// + public DeploymentSlots DeploymentSlot + { + get { return _deploymentSlot; } + set { _deploymentSlot = value; RaisePropertyChangedAuto(); } + } #endregion @@ -159,6 +169,11 @@ namespace Tango.PPC.UI.ViewModels /// Gets or sets the time zone selected command. /// public RelayCommand TimeZoneSelectedCommand { get; set; } + + /// + /// Gets or sets the environment selected command. + /// + public RelayCommand EnvironmentSelectedCommand { get; set; } #endregion #region Constructors @@ -172,7 +187,8 @@ namespace Tango.PPC.UI.ViewModels { MachineSetupManager = machineSetupManager; - HostAddress = Settings.MachineServiceAddress; + DeploymentSlot = Settings.DeploymentSlot; + SerialNumber = ""; CompleteCommand = new RelayCommand(CompleteSetup, () => State == MachineSetupStates.Completed); @@ -183,7 +199,13 @@ namespace Tango.PPC.UI.ViewModels InstallCommand = new RelayCommand(Install); RestartCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.WelcomeView); }); - TimeZoneSelectedCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.SetupWelcomeView); }); + TimeZoneSelectedCommand = new RelayCommand(() => { NavigateTo(MachineSetupView.EnvironmentView); }); + EnvironmentSelectedCommand = new RelayCommand(() => + { + NavigateTo(MachineSetupView.SetupWelcomeView); + Settings.DeploymentSlot = DeploymentSlot; + HostAddress = Settings.GetMachineServiceAddress(); + }); _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 79974bff4..a553f3a18 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.MachineServiceAddress); + var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber, Settings.GetMachineServiceAddress()); if (response.IsUpdateAvailable) { @@ -145,7 +145,7 @@ namespace Tango.PPC.UI.ViewModels } else { - _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber, Settings.MachineServiceAddress); + _db_compare_result = await MachineUpdateManager.UpdateDBCheck(MachineProvider.Machine.SerialNumber, Settings.GetMachineServiceAddress()); if (_db_compare_result.RequiresUpdate) { @@ -176,7 +176,7 @@ namespace Tango.PPC.UI.ViewModels try { - _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, Settings.MachineServiceAddress); + _update_result = await MachineUpdateManager.Update(MachineProvider.Machine.SerialNumber, Settings.GetMachineServiceAddress()); LogManager.Log("Machine update completed."); await NavigateTo(MachineUpdateView.UpdateCompletedView); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index 4832eea01..df50133fd 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -10,6 +10,7 @@ xmlns:connectivity="clr-namespace:Tango.PPC.Common.Connectivity;assembly=Tango.PPC.Common" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.UI.Views" + xmlns:common="clr-namespace:Tango.PPC.Common;assembly=Tango.PPC.Common" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MachineSetupViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineSetupViewVM}"> @@ -18,7 +19,7 @@ - MACHINE SETUP WIZARD + Machine Setup Wizard @@ -80,6 +81,19 @@ + + + + + Please select the machine working environment + + + + + CONTINUE + + + diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs index 5c8718f47..52ecbbbc5 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs @@ -80,7 +80,6 @@ namespace Tango.BL [Key] [Column("GUID")] [ParameterIgnore] - [JsonIgnore] public String Guid { get { return _guid; } @@ -93,7 +92,6 @@ namespace Tango.BL /// [Column("LAST_UPDATED")] [ParameterIgnore] - [JsonIgnore] public DateTime LastUpdated { get { return _lastUpdated; } @@ -378,7 +376,6 @@ Maybe you have deleted an entity that was no yet inserted into database?", LogCa { return GetDbContextFromEntity(this); } - #endregion #region Private Methods diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs index 38f3467cf..68e7a6c93 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs @@ -13,7 +13,15 @@ namespace Tango.SharedUI.Converters public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Type result = value as Type; - return Enum.GetValues(result).Cast().Select(e => new { Value = e, DisplayName = (e as Enum).ToDescription() }); + + if (parameter != null && parameter.ToString() == "false") + { + return Enum.GetValues(result); + } + else + { + return Enum.GetValues(result).Cast().Select(e => new { Value = e, DisplayName = (e as Enum).ToDescription() }); + } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 6b4190313..18e2edb0c 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -272,7 +272,7 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - var versions = db.TangoVersions.ToList(); + var versions = db.TangoVersions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList(); if (versions.Count == 0) { @@ -282,16 +282,7 @@ namespace Tango.MachineService.Controllers }; } - var machine_versions = versions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList(); - - if (machine_versions.Count > 0) - { - response.Version = db.TangoVersions.Where(x => x.MachineVersionGuid == request.MachineVersionGuid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault().Version; - } - else - { - throw new ArgumentException("The specified machine version was not found!"); - } + response.Version = versions.OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault().Version; } return response; @@ -392,6 +383,18 @@ namespace Tango.MachineService.Controllers } } + [HttpPost] + public MachineVersionsResponse GetMachineVersions(MachineVersionsRequest request) + { + using (var db = ObservablesContextHelper.CreateContext()) + { + return new MachineVersionsResponse() + { + MachineVersions = db.MachineVersions.ToList(), + }; + } + } + #endregion [HttpPost] -- cgit v1.3.1 From b50b7ddb4c231810d17e0141bb77437718b10110 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 1 Jan 2019 14:30:20 +0200 Subject: Some more work on environments... --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../MachineStudio.Dispensers/Images/dispensers.png | Bin 205567 -> 171937 bytes .../Tango.MachineStudio.Common/DeploymentSlots.cs | 23 ------------------ .../MachineStudioSettings.cs | 7 +++--- .../Tango.MachineStudio.Common.csproj | 7 ++++-- .../Update/CheckForUpdatesRequest.cs | 4 +-- .../Update/UploadCompletedRequest.cs | 4 +-- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 2 +- .../Tango.MachineStudio.UI.csproj | 6 ++++- .../ViewModels/AboutViewVM.cs | 4 +++ .../ViewModels/LoginViewVM.cs | 5 ++-- .../ViewModels/MainViewVM.cs | 2 +- .../ViewModels/UpdateViewVM.cs | 2 +- .../Tango.MachineStudio.UI/Views/AboutView.xaml | 15 +++++++++--- .../Tango.MachineStudio.UI/Views/LoginView.xaml | 3 ++- .../PPC/Tango.PPC.Common/DeploymentSlots.cs | 23 ------------------ .../PPC/Tango.PPC.Common/PPCSettings.cs | 7 +++--- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 7 ++++-- .../Update/UploadCompletedRequest.cs | 4 +-- .../PPC/Tango.PPC.Publisher/MainWindow.xaml | 3 ++- .../PPC/Tango.PPC.Publisher/MainWindowVM.cs | 7 +++--- .../PPC/Tango.PPC.Publisher/PublisherSettings.cs | 3 ++- .../Tango.PPC.Publisher/Tango.PPC.Publisher.csproj | 4 +++ .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 6 ++++- .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 5 ++-- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 24 ++++++++++++++++-- .../Tango.BL/ObservablesContextExtension.cs | 9 +++++++ .../Tango.Core/ExtensionMethods/EnumExtensions.cs | 6 +++++ .../Converters/EnumToDescriptionConverter.cs | 9 ++++++- .../Tango.SharedUI/Converters/IsEqualConverter.cs | 2 +- .../Tango.Touch/Controls/TouchListBox.cs | 2 +- .../Tango.Touch/Controls/TouchPanel.xaml | 2 +- .../Tango.Transport/Tango.Transport.csproj | 3 ++- .../Tango.Transport/Web/WebRequestSecureMessage.cs | 13 ++++++++++ Software/Visual_Studio/Tango.Web/DeploymentSlot.cs | 5 ++++ .../Tango.Web/DeploymentSlotAddressAttribute.cs | 19 +++++++++++++++ .../ExtensionMethods/DeploymentSlotExtensions.cs | 20 +++++++++++++++ Software/Visual_Studio/Tango.Web/Tango.Web.csproj | 7 ++++++ Software/Visual_Studio/Tango.Web/WebSettings.cs | 27 +++++++++++++++++++++ .../Controllers/MachineStudioController.cs | 4 +-- .../Controllers/PPCController.cs | 2 +- 44 files changed, 216 insertions(+), 91 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/DeploymentSlots.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/WebRequestSecureMessage.cs create mode 100644 Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs create mode 100644 Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs create mode 100644 Software/Visual_Studio/Tango.Web/WebSettings.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index dc70d8068..22ea0615c 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 677b08812..6c5c1ed1c 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index e1eb01992..2d4a13a9d 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 1324fab93..c16100a75 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Images/dispensers.png b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Images/dispensers.png index 2f9e1ca8b..20f812e00 100644 Binary files a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Images/dispensers.png and b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Images/dispensers.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/DeploymentSlots.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/DeploymentSlots.cs deleted file mode 100644 index b2bfabd54..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/DeploymentSlots.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Common -{ - public enum DeploymentSlots - { - [Description("https://machineservice-dev.twine-srv.com")] - Development, - [Description("https://machineservice-test.twine-srv.com")] - Testing, - [Description("https://machineservice-process.twine-srv.com")] - Process, - [Description("https://machineservice-stage.twine-srv.com")] - Staging, - [Description("https://machineservice.twine-srv.com")] - Production - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index cbaeb9d2e..90fe33958 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using System.Windows; using Tango.Logging; using Tango.Settings; +using Tango.Web; namespace Tango.MachineStudio.Common { @@ -98,7 +99,7 @@ namespace Tango.MachineStudio.Common /// /// Gets or sets the deployment slot. /// - public DeploymentSlots DeploymentSlot { get; set; } + public DeploymentSlot DeploymentSlot { get; set; } /// /// Gets the machine service address. @@ -106,7 +107,7 @@ namespace Tango.MachineStudio.Common /// public String GetMachineServiceAddress() { - return DeploymentSlot.ToDescription(); + return DeploymentSlot.ToAddress(); } /// @@ -119,7 +120,7 @@ namespace Tango.MachineStudio.Common DefaultIssueReportTags = new List(); StudioModulesBounds = new List(); Environment = WorkingEnvironment.Remote; - DeploymentSlot = DeploymentSlots.Development; + DeploymentSlot = DeploymentSlot.DEV; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 58a0d5f7e..704223d17 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -94,7 +94,6 @@ - @@ -269,6 +268,10 @@ {9652f972-2bd1-4283-99cb-fc6240434c17} Tango.Video + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + @@ -309,7 +312,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs index cf06e678d..ce700adbf 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs @@ -8,10 +8,8 @@ using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - public class CheckForUpdatesRequest : WebRequestMessage + public class CheckForUpdatesRequest : WebRequestSecureMessage { - public String Token { get; set; } - public String Version { get; set; } public bool AcceptBetaRelease { get; set; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs index fc478db50..d23d57351 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs @@ -8,8 +8,8 @@ using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - public class UploadCompletedRequest : WebRequestMessage + public class UploadCompletedRequest : WebRequestSecureMessage { - public String Token { get; set; } + } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs index 73f3f5bed..9a109679b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -204,7 +204,7 @@ namespace Tango.MachineStudio.Publisher _client.NotifyUploadCompleted(new UploadCompletedRequest() { - Token = response.Token, + AccessToken = response.Token, }).Wait(); Progress = 0; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index d162f3dd6..fb84d64bd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -423,6 +423,10 @@ {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + {f69da3a8-f823-461e-87cf-a9275abc0b15} Tango.MachineStudio.Dispensers @@ -614,7 +618,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs index e8d33b0ca..c05ce9982 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/AboutViewVM.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.Core; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.StudioApplication; @@ -19,11 +20,14 @@ namespace Tango.MachineStudio.UI.ViewModels public MachineStudioSettings MachineStudioSettings { get; set; } + public DataSource DataSource { get; set; } + public AboutViewVM(IStudioApplicationManager applicationManager) { ApplicationManager = applicationManager; Settings = SettingsManager.Default.GetOrCreate(); MachineStudioSettings = SettingsManager.Default.GetOrCreate(); + DataSource = ObservablesContext.GetActualDataSource(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index edae820e7..492e23963 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -17,6 +17,7 @@ using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; using Tango.Settings; using Tango.SharedUI; +using Tango.Web; namespace Tango.MachineStudio.UI.ViewModels { @@ -56,11 +57,11 @@ namespace Tango.MachineStudio.UI.ViewModels set { _password = value; RaisePropertyChangedAuto(); } } - private DeploymentSlots _deploymentSlot; + private DeploymentSlot _deploymentSlot; /// /// Gets or sets the deployment slot. /// - public DeploymentSlots DeploymentSlot + public DeploymentSlot DeploymentSlot { get { return _deploymentSlot; } set { _deploymentSlot = value; RaisePropertyChangedAuto(); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 818d507ae..e3a8b4e7c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -363,7 +363,7 @@ namespace Tango.MachineStudio.UI.ViewModels CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { - Token = _authenticationProvider.AccessToken, + AccessToken = _authenticationProvider.AccessToken, Version = _applicationManager.Version.ToString(), AcceptBetaRelease = _settings.AcceptBetaRelease, }).Result; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index e19dcdbe5..60a023071 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -196,7 +196,7 @@ namespace Tango.MachineStudio.UI.ViewModels CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { - Token = _authentication.AccessToken, + AccessToken = _authentication.AccessToken, Version = _application.Version.ToString(), AcceptBetaRelease = settings.AcceptBetaRelease, }).Result; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml index 682cc9ed9..696cc051f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/AboutView.xaml @@ -12,6 +12,7 @@ + @@ -42,20 +43,28 @@ - + Machine Studio: v Core Libraries: v Build Date: + Environment Mode: + + Environment Slot: + + Machine Service: + Data Source: - + + () + Allow BETA Updates: - + Change Log: diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml index c344e867a..b479dd03f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml @@ -6,6 +6,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:web="clr-namespace:Tango.Web;assembly=Tango.Web" xmlns:automation="clr-namespace:Tango.MachineStudio.Common.Automation;assembly=Tango.MachineStudio.Common" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" @@ -48,7 +49,7 @@ - + Remember me diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs deleted file mode 100644 index b2c14ec3c..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/DeploymentSlots.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Common -{ - public enum DeploymentSlots - { - [Description("https://machineservice-dev.twine-srv.com")] - Development, - [Description("https://machineservice-test.twine-srv.com")] - Testing, - [Description("https://machineservice-process.twine-srv.com")] - Process, - [Description("https://machineservice-stage.twine-srv.com")] - Staging, - [Description("https://machineservice.twine-srv.com")] - Production - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 81168d235..7ef9f9fdc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Logging; using Tango.Settings; +using Tango.Web; namespace Tango.PPC.Common { @@ -68,7 +69,7 @@ namespace Tango.PPC.Common /// /// Gets or sets the deployment slot. /// - public DeploymentSlots DeploymentSlot { get; set; } + public DeploymentSlot DeploymentSlot { get; set; } /// /// Gets the machine service address. @@ -76,7 +77,7 @@ namespace Tango.PPC.Common /// public String GetMachineServiceAddress() { - return DeploymentSlot.ToDescription(); + return DeploymentSlot.ToAddress(); } /// @@ -89,7 +90,7 @@ namespace Tango.PPC.Common EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; - DeploymentSlot = DeploymentSlots.Production; + DeploymentSlot = DeploymentSlot.PROD; } } } 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 2f04e21ef..d73829bb8 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 @@ -125,7 +125,6 @@ TwineCatalogControl.xaml - @@ -319,6 +318,10 @@ {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + {6aa425c9-ea6a-4b01-aaed-5ff122e8b663} Tango.WiFi @@ -347,7 +350,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs index 55e733e04..dab9bcefd 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Update/UploadCompletedRequest.cs @@ -8,8 +8,8 @@ using Tango.Transport.Web; namespace Tango.PPC.Common.Update { - public class UploadCompletedRequest : WebRequestMessage + public class UploadCompletedRequest : WebRequestSecureMessage { - public String Token { get; set; } + } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml index e34b82396..830c4c585 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindow.xaml @@ -7,6 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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" mc:Ignorable="d" Title="Tango PPC Publisher" Height="1100" Width="500" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}"> @@ -30,7 +31,7 @@ Deployment Slot: - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs index e11d01318..b2abd9466 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs @@ -28,6 +28,7 @@ using Tango.Settings; using Tango.SharedUI; using Tango.SQLExaminer; using Tango.Transport.Web; +using Tango.Web; namespace Tango.PPC.Publisher { @@ -122,8 +123,8 @@ namespace Tango.PPC.Publisher set { _password = value; RaisePropertyChangedAuto(); } } - private DeploymentSlots _deplotmentSlot; - public DeploymentSlots DeploymentSlot + private DeploymentSlot _deplotmentSlot; + public DeploymentSlot DeploymentSlot { get { return _deplotmentSlot; } set { _deplotmentSlot = value; RaisePropertyChangedAuto(); OnDeploymentSlotChanged(); } @@ -262,7 +263,7 @@ namespace Tango.PPC.Publisher await _client.NotifyUploadCompleted(new UploadCompletedRequest() { - Token = response.Token, + AccessToken = response.Token, }); Progress = 0; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs index 6caf8a2f6..de6fe920b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/PublisherSettings.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.PPC.Common; using Tango.Settings; +using Tango.Web; namespace Tango.PPC.Publisher { @@ -16,7 +17,7 @@ namespace Tango.PPC.Publisher public String BuildConfiguration { get; set; } - public DeploymentSlots DeploymentSlot { get; set; } + public DeploymentSlot DeploymentSlot { get; set; } public PublisherSettings() { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj index 9a4b8b595..0c465546c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/Tango.PPC.Publisher.csproj @@ -148,6 +148,10 @@ {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 2c2ab061e..93a2e6c6a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -335,6 +335,10 @@ {74e700b0-1156-4126-be40-ee450d3c3026} Tango.Transport + + {5001990f-977b-48ff-b217-0236a5022ad8} + Tango.Web + {6aa425c9-ea6a-4b01-aaed-5ff122e8b663} Tango.WiFi @@ -487,7 +491,7 @@ del "$(TargetDir)firmware_package.tfp" - + \ No newline at end of file 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 6cf08a43a..f5c6f43b9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -23,6 +23,7 @@ using Tango.Settings; using Tango.SharedUI.Helpers; using Tango.SQLExaminer; using Tango.Transport.Adapters; +using Tango.Web; namespace Tango.PPC.UI.ViewModels { @@ -131,11 +132,11 @@ namespace Tango.PPC.UI.ViewModels set { _selectedTimeZone = value; RaisePropertyChangedAuto(); } } - private DeploymentSlots _deploymentSlot; + private DeploymentSlot _deploymentSlot; /// /// Gets or sets the deployment slot. /// - public DeploymentSlots DeploymentSlot + public DeploymentSlot DeploymentSlot { get { return _deploymentSlot; } set { _deploymentSlot = value; RaisePropertyChangedAuto(); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index df50133fd..13f163ef5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -9,6 +9,7 @@ xmlns:setup="clr-namespace:Tango.PPC.Common.MachineSetup;assembly=Tango.PPC.Common" xmlns:connectivity="clr-namespace:Tango.PPC.Common.Connectivity;assembly=Tango.PPC.Common" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:web="clr-namespace:Tango.Web;assembly=Tango.Web" xmlns:local="clr-namespace:Tango.PPC.UI.Views" xmlns:common="clr-namespace:Tango.PPC.Common;assembly=Tango.PPC.Common" mc:Ignorable="d" @@ -86,8 +87,27 @@ Please select the machine working environment - - + + + + + + + + + + + + + + + CONTINUE diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs index 3fb827ce8..0bd002f60 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs @@ -187,5 +187,14 @@ namespace Tango.BL { _override_datasource = dataSource; } + + /// + /// Gets the actual data source (settings or overridden). + /// + /// + public static DataSource GetActualDataSource() + { + return _override_datasource != null ? _override_datasource : SettingsManager.Default.GetOrCreate().DataSource; + } } } diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs index e5beea90a..db3f7dc3d 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs @@ -29,6 +29,12 @@ public static class EnumExtensions return value.ToString(); } + public static T GetAttribute(this Enum value) where T : Attribute + { + FieldInfo fi = value.GetType().GetField(value.ToString()); + return fi.GetCustomAttribute(); + } + /// /// Gets the enum integer value. /// diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToDescriptionConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToDescriptionConverter.cs index 797d5c2e4..d907595de 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToDescriptionConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToDescriptionConverter.cs @@ -28,7 +28,14 @@ namespace Tango.SharedUI.Converters /// public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - return GetDescription(value, value.ToString()); + if (value != null) + { + return GetDescription(value, value.ToString()); + } + else + { + return null; + } } public static string GetDescription(object enumValue, string defDesc) diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualConverter.cs index 4d3563681..c5de0a83f 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/IsEqualConverter.cs @@ -14,7 +14,7 @@ namespace Tango.SharedUI.Converters { if (values != null && values.Length > 0) { - return values.All(x => x == values.First()); + return values.All(x => x.Equals(values.First())); } return false; diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs index 29df0129c..a64a70e4e 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.cs @@ -315,7 +315,7 @@ namespace Tango.Touch.Controls { var items = GetItems(); items.ForEach(x => x.IsSelected = false); - var item = items.FirstOrDefault(x => x.DataContext == SelectedItem); + var item = items.FirstOrDefault(x => x.DataContext.Equals(SelectedItem)); if (item != null) { diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml index 77eb794a0..c9d6bd466 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -74,7 +74,7 @@ - + diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 4e677a041..9591c8bdb 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -116,6 +116,7 @@ + @@ -145,7 +146,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/Web/WebRequestSecureMessage.cs b/Software/Visual_Studio/Tango.Transport/Web/WebRequestSecureMessage.cs new file mode 100644 index 000000000..33644208e --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/WebRequestSecureMessage.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public class WebRequestSecureMessage : WebRequestMessage + { + public String AccessToken { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs b/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs index 7ec7ab82e..6531adb64 100644 --- a/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs +++ b/Software/Visual_Studio/Tango.Web/DeploymentSlot.cs @@ -10,14 +10,19 @@ namespace Tango.Web public enum DeploymentSlot { [Description("Development")] + [DeploymentSlotAddress("https://machineservice-dev.twine-srv.com")] DEV, [Description("Testing")] + [DeploymentSlotAddress("https://machineservice-test.twine-srv.com")] TEST, [Description("Process")] + [DeploymentSlotAddress("https://machineservice-process.twine-srv.com")] PROCESS, [Description("Staging")] + [DeploymentSlotAddress("https://machineservice-stage.twine-srv.com")] STAGE, [Description("Production")] + [DeploymentSlotAddress("https://machineservice.twine-srv.com")] PROD } } diff --git a/Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs b/Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs new file mode 100644 index 000000000..c58c7a8b0 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/DeploymentSlotAddressAttribute.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Web +{ + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + public class DeploymentSlotAddressAttribute : Attribute + { + public DeploymentSlotAddressAttribute(String address) + { + Address = address; + } + + public String Address { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs b/Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs new file mode 100644 index 000000000..04e5ac300 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/ExtensionMethods/DeploymentSlotExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Web; + +public static class DeploymentSlotExtensions +{ + /// + /// Gets the deployment slot web address. + /// + /// The slot. + /// + public static String ToAddress(this DeploymentSlot slot) + { + return slot.GetAttribute().Address; + } +} + diff --git a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj index d9a1d1dd1..d0d30482d 100644 --- a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj +++ b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj @@ -246,6 +246,8 @@ + + @@ -260,6 +262,7 @@ + @@ -282,6 +285,10 @@ {e4927038-348d-4295-aaf4-861c58cb3943} Tango.PMR + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + diff --git a/Software/Visual_Studio/Tango.Web/WebSettings.cs b/Software/Visual_Studio/Tango.Web/WebSettings.cs new file mode 100644 index 000000000..fdc92810c --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/WebSettings.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; +using System.Reflection; + +namespace Tango.Web +{ + public class WebSettings : SettingsBase + { + /// + /// Gets or sets the deployment slot. + /// + public DeploymentSlot DeploymentSlot { get; set; } + + /// + /// Gets the machine service address. + /// + /// + public String GetMachineServiceAddress() + { + return DeploymentSlot.GetAttribute().Address; + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs index 4aff8fd39..c9d7ea8b6 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -51,7 +51,7 @@ namespace Tango.MachineService.Controllers using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { - if (_tokens_manager.Exists(request.Token)) + if (_tokens_manager.Exists(request.AccessToken)) { var versions = db.MachineStudioVersions.ToList(); @@ -152,7 +152,7 @@ namespace Tango.MachineService.Controllers [HttpPost] public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) { - MachineStudioPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + MachineStudioPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.AccessToken); if (upload != null) { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 18e2edb0c..6d591edd8 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -355,7 +355,7 @@ namespace Tango.MachineService.Controllers [HttpPost] public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) { - PPCPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + PPCPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.AccessToken); if (upload != null) { -- cgit v1.3.1