From 8270aa37dee33cda98603a995de823df393f7294 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 17 Dec 2018 10:20:36 +0200 Subject: Added support for azure authentication in data source. --- .../MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 4032c946c..cafd0328a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -69,6 +69,9 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider = notificationProvider; } + /// + /// Called when the application has been started + /// public override void OnApplicationStarted() { base.OnApplicationStarted(); -- cgit v1.3.1 From f131b2573bfb617998927ea1072eb946b800d5e7 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 18 Dec 2018 17:59:41 +0200 Subject: PPC working on tablet ! --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../SQLExaminer Projects/Override Tables.sdeproj | 16 +-- .../SQLExaminer Projects/Provision Machine.sdeproj | 133 ++++++++++++------ .../DB/SQLExaminer Projects/UpdateMachine.sdeproj | 36 ++--- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Synchronization/MachineSetupResponse.proto | 6 + .../ViewModels/MainViewVM.cs | 9 +- .../Connection/DefaultMachineProvider.cs | 70 ++++------ .../MachineSetup/MachineSetupManager.cs | 41 +++--- .../OS/DefaultWindowsActivationManager.cs | 2 +- .../PPC/Tango.PPC.Common/PPCSettings.cs | 13 +- .../DefaultRemoteAssistanceProvider.cs | 2 +- .../PPC/Tango.PPC.Common/Scripting/CmdCommand.cs | 33 ++++- .../UWF/DefaultUnifiedWriteFilterManager.cs | 28 ++-- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 2 +- .../Visual_Studio/Tango.BL/Entities/Machine.cs | 150 +++++++++++++++++++++ .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 5 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 15 +++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 150 ++++++++++----------- .../Synchronization/MachineSetupResponse.cs | 150 ++++++++++++++++++++- .../SQLExaminer/Configurations/OverrideData.xml | Bin 79756 -> 79236 bytes .../Configurations/ProvisionMachine.xml | Bin 57496 -> 61232 bytes .../SQLExaminer/Configurations/UpdateMachine.xml | Bin 25530 -> 27128 bytes .../Controllers/SynchronizationController.cs | 10 +- 27 files changed, 629 insertions(+), 244 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index d4024c9c0..0652c7b97 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 339755212..4897c62e5 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/SQLExaminer Projects/Override Tables.sdeproj b/Software/DB/SQLExaminer Projects/Override Tables.sdeproj index ae9528a15..932ea95fb 100644 --- a/Software/DB/SQLExaminer Projects/Override Tables.sdeproj +++ b/Software/DB/SQLExaminer Projects/Override Tables.sdeproj @@ -165,14 +165,6 @@ - - - - - - - - @@ -671,8 +663,6 @@ - - @@ -681,6 +671,12 @@ + + + + + + diff --git a/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj b/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj index 2fb056697..267cf1abb 100644 --- a/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj +++ b/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj @@ -90,24 +90,24 @@ + + + + + + + + - - - - - - - - @@ -165,14 +165,6 @@ - - - - - - - - @@ -324,8 +316,8 @@ - + @@ -671,16 +663,20 @@ - - + + + + + + @@ -781,6 +777,7 @@ + @@ -799,7 +796,6 @@ - @@ -944,6 +940,8 @@ + + @@ -953,8 +951,6 @@ - - @@ -1044,7 +1040,8 @@ LEFT JOIN USERS ON USERS.ORGANIZATION_GUID = ORGANIZATION_GUID LEFT JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID LEFT JOIN ADDRESSES ON ADDRESSES.GUID = USERS.ADDRESS_GUID OR ADDRESSES.GUID = ORGANIZATIONS.ADDRESS_GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]> @@ -1075,7 +1072,8 @@ LEFT JOIN USERS ON USERS.ORGANIZATION_GUID = ORGANIZATION_GUID LEFT JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID LEFT JOIN ADDRESSES ON ADDRESSES.GUID = USERS.ADDRESS_GUID OR ADDRESSES.GUID = ORGANIZATIONS.ADDRESS_GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1118,7 +1116,8 @@ FROM CATS INNER JOIN MACHINES ON MACHINES.GUID = CATS.MACHINE_GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1144,7 +1143,8 @@ FROM CATS INNER JOIN MACHINES ON MACHINES.GUID = CATS.MACHINE_GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1183,7 +1183,8 @@ WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1208,7 +1209,8 @@ WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1254,7 +1256,8 @@ LEFT JOIN USERS ON USERS.ORGANIZATION_GUID = ORGANIZATION_GUID LEFT JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID LEFT JOIN CONTACTS ON CONTACTS.GUID = USERS.CONTACT_GUID OR CONTACTS.GUID = ORGANIZATIONS.CONTACT_GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1284,7 +1287,8 @@ LEFT JOIN USERS ON USERS.ORGANIZATION_GUID = ORGANIZATION_GUID LEFT JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID LEFT JOIN CONTACTS ON CONTACTS.GUID = USERS.CONTACT_GUID OR CONTACTS.GUID = ORGANIZATIONS.CONTACT_GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1331,7 +1335,29 @@ FROM MACHINES INNER JOIN IDS_PACKS ON CONFIGURATIONS.GUID = IDS_PACKS.CONFIGURATION_GUID WHERE MACHINES.SERIAL_NUMBER = '@' + ]]> + +
+ + + + + + + + + + + + + + + + + +
+
@@ -1377,16 +1404,20 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - - + + + + + + @@ -1406,14 +1437,20 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - - + + + + + + + +
@@ -1435,14 +1472,20 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - - + + + + + + + + @@ -1466,7 +1509,8 @@ FROM ORGANIZATIONS INNER JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]> @@ -1490,7 +1534,8 @@ FROM ORGANIZATIONS INNER JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1531,7 +1576,8 @@ FROM USERS INNER JOIN ORGANIZATIONS ON ORGANIZATIONS.GUID = USERS.ORGANIZATION_GUID INNER JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1560,7 +1606,8 @@ FROM USERS INNER JOIN ORGANIZATIONS ON ORGANIZATIONS.GUID = USERS.ORGANIZATION_GUID INNER JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1602,7 +1649,8 @@ LEFT JOIN USERS ON USERS.ORGANIZATION_GUID = ORGANIZATION_GUID LEFT JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID LEFT JOIN USERS_ROLES ON USERS_ROLES.USER_GUID = USERS.GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
@@ -1628,7 +1676,8 @@ LEFT JOIN USERS ON USERS.ORGANIZATION_GUID = ORGANIZATION_GUID LEFT JOIN MACHINES ON MACHINES.ORGANIZATION_GUID = ORGANIZATIONS.GUID LEFT JOIN USERS_ROLES ON USERS_ROLES.USER_GUID = USERS.GUID -WHERE MACHINES.SERIAL_NUMBER = '@']]> +WHERE MACHINES.SERIAL_NUMBER = '@' +]]>
diff --git a/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj b/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj index ae2bb1bed..fb395f586 100644 --- a/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj +++ b/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj @@ -165,14 +165,6 @@ - - - - - - - - @@ -671,8 +663,6 @@ - - @@ -681,6 +671,12 @@ + + + + + + @@ -1175,16 +1171,20 @@ WHERE MACHINES.SERIAL_NUMBER = '@']]> - - + + + + + + @@ -1204,8 +1204,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@']]> - - @@ -1233,14 +1231,20 @@ WHERE MACHINES.SERIAL_NUMBER = '@']]> - - + + + + + + + +
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index f47422306..81ed33c36 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 e2f31b24d..76a2f4509 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto b/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto index 781379a88..cc0d675b9 100644 --- a/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto +++ b/Software/PMR/Messages/Synchronization/MachineSetupResponse.proto @@ -14,4 +14,10 @@ message MachineSetupResponse string DbPassword = 5; string OSKey = 6; + + bool SetupActivation = 7; + bool SetupRemoteAssistance = 8; + bool SetupUWF = 9; + bool SetupFirmware = 10; + bool IsDemo = 11; } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 5ae5c531c..5a5df0d0f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -196,7 +196,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels MachinesProvider = new SuggestionProvider((filter) => { - return _db.Machines.Where(x => x.SerialNumber.StartsWith(filter)).ToList(); + try + { + return _db.Machines.Where(x => x.SerialNumber.StartsWith(filter)).ToList(); + } + catch + { + return new List(); + } }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 52d738220..340b64765 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -107,9 +107,7 @@ namespace Tango.PPC.Common.Connection var settings = SettingsManager.Default.GetOrCreate(); - var demo = settings.DemoMode; - - if (!demo) + if (!Machine.IsDemo) { if (String.IsNullOrWhiteSpace(settings.EmbeddedComPort)) { @@ -146,13 +144,15 @@ namespace Tango.PPC.Common.Connection { LogManager.Log("Application in demo mode!"); + var emulator_channel_name = "emulator-" + Guid.NewGuid().ToString(); + LogManager.Log("Starting embedded emulator..."); - MachineEmulator emulator = new MachineEmulator(new BasicTransporter(new MemoryTransportAdapter("emulator"))); + MachineEmulator emulator = new MachineEmulator(new BasicTransporter(new MemoryTransportAdapter(emulator_channel_name))); await emulator.Start(); LogManager.Log("Emulator started. Connecting to emulator..."); - MemoryTransportAdapter adapter = new MemoryTransportAdapter("emulator"); + MemoryTransportAdapter adapter = new MemoryTransportAdapter(emulator_channel_name); MachineOperator.Adapter = adapter; MachineOperator.JobHandlingMode = JobHandlerModes.SettingUp; LogManager.Log("Connecting machine operator..."); @@ -239,59 +239,35 @@ namespace Tango.PPC.Common.Connection var settings = SettingsManager.Default.GetOrCreate(); - var demo = settings.DemoMode; - - if (!demo) + if (String.IsNullOrWhiteSpace(settings.EmbeddedComPort)) { - if (String.IsNullOrWhiteSpace(settings.EmbeddedComPort)) - { - TimeSpan timeout = TimeSpan.FromSeconds(SettingsManager.Default.GetOrCreate().MachineScanningTimeoutSeconds); - - onProgress?.Invoke("Scanning for the machine..."); - LogManager.Default.Log("Scanning for machine on available serial ports..."); - Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_115200); - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, timeout); + TimeSpan timeout = TimeSpan.FromSeconds(SettingsManager.Default.GetOrCreate().MachineScanningTimeoutSeconds); - onProgress?.Invoke("Machine discovered on port: " + response.Adapter.Address); - LogManager.Default.Log("Machine discovered on port: " + response.Adapter.Address); - LogManager.Default.Log("Device Information:"); - LogManager.Default.Log(response.Response.DeviceInformation.ToJsonString()); + onProgress?.Invoke("Scanning for the machine..."); + LogManager.Default.Log("Scanning for machine on available serial ports..."); + Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_115200); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, timeout); - machineOperator.Adapter = response.Adapter; - machineOperator.JobHandlingMode = JobHandlerModes.SettingUp; - LogManager.Default.Log("Connecting machine operator..."); + onProgress?.Invoke("Machine discovered on port: " + response.Adapter.Address); + LogManager.Default.Log("Machine discovered on port: " + response.Adapter.Address); + LogManager.Default.Log("Device Information:"); + LogManager.Default.Log(response.Response.DeviceInformation.ToJsonString()); - onProgress?.Invoke("Connecting machine operator..."); - await machineOperator.Connect(); - } - else - { - LogManager.Default.Log($"Connecting to machine on {settings.EmbeddedComPort}..."); + machineOperator.Adapter = response.Adapter; + machineOperator.JobHandlingMode = JobHandlerModes.SettingUp; + LogManager.Default.Log("Connecting machine operator..."); - onProgress?.Invoke($"Connecting to machine on {settings.EmbeddedComPort}..."); - UsbTransportAdapter adapter = new UsbTransportAdapter(settings.EmbeddedComPort, UsbSerialBaudRates.BR_115200); - machineOperator.Adapter = adapter; - machineOperator.JobHandlingMode = JobHandlerModes.SettingUp; - await machineOperator.Connect(); - } + onProgress?.Invoke("Connecting machine operator..."); + await machineOperator.Connect(); } else { - LogManager.Default.Log("Application in demo mode!"); - - onProgress?.Invoke("Application in demo mode, Starting embedded emulator..."); + LogManager.Default.Log($"Connecting to machine on {settings.EmbeddedComPort}..."); - LogManager.Default.Log("Starting embedded emulator..."); - MachineEmulator emulator = new MachineEmulator(new BasicTransporter(new MemoryTransportAdapter("emulator"))); - await emulator.Start(); - - LogManager.Default.Log("Emulator started. Connecting to emulator..."); - - MemoryTransportAdapter adapter = new MemoryTransportAdapter("emulator"); + onProgress?.Invoke($"Connecting to machine on {settings.EmbeddedComPort}..."); + UsbTransportAdapter adapter = new UsbTransportAdapter(settings.EmbeddedComPort, UsbSerialBaudRates.BR_115200); machineOperator.Adapter = adapter; machineOperator.JobHandlingMode = JobHandlerModes.SettingUp; - LogManager.Default.Log("Connecting machine operator..."); - onProgress?.Invoke("Connecting machine operator..."); await machineOperator.Connect(); } 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 145512562..e1795d06a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -98,23 +98,7 @@ namespace Tango.PPC.Common.MachineSetup IMachineOperator op = null; - var demoMode = SettingsManager.Default.GetOrCreate().DemoMode; - - if (!demoMode) - { - //Connecting to machine... - LogManager.Log("Initiating machine connection..."); - - UpdateProgress("Connecting to machine", "Connecting..."); - op = await DefaultMachineProvider.CreateMinimalMachineOperator((msg) => - { - UpdateProgress("Connecting to machine", msg); - }); - } - else - { - LogManager.Log("Application in demo mode. Skipping machine connection..."); - } + var settings = SettingsManager.Default.GetOrCreate(); //Connect to machine service and get matching packages for this machine. UpdateProgress("Validating serial number", "Connecting to machine service..."); @@ -140,16 +124,34 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log($"Machine setup response received: {Environment.NewLine}{setup_response.ToJsonString()}"); - if (!demoMode) + if (setup_response.SetupFirmware) + { + //Connecting to machine... + LogManager.Log("Initiating machine connection..."); + + UpdateProgress("Connecting to machine", "Connecting..."); + op = await DefaultMachineProvider.CreateMinimalMachineOperator((msg) => + { + UpdateProgress("Connecting to machine", msg); + }); + } + + if (setup_response.SetupActivation) { LogManager.Log("Activating windows license..."); UpdateProgress("Activating operation system license", "Activating..."); await _windows_activation_manager.Activate(setup_response.OSKey); + } + if (setup_response.SetupRemoteAssistance) + { LogManager.Log("Installing remote assistance..."); UpdateProgress("Installing remote assistance", "Installing..."); await _remoteAssistance.InstallRemoteAssistance(serialNumber); + } + if (setup_response.SetupUWF) + { LogManager.Log("Activating unified write filter..."); UpdateProgress("Activating disk protection", "Activating..."); await _uwf.Setup(); @@ -286,7 +288,7 @@ namespace Tango.PPC.Common.MachineSetup throw LogManager.Log(ex, "Setup manager error while trying to synchronize database."); } - if (!demoMode) + if (setup_response.SetupFirmware) { //Updating firmware UpdateProgress("Updating Firmware", "Connecting to firmware device..."); @@ -324,7 +326,6 @@ namespace Tango.PPC.Common.MachineSetup } else { - LogManager.Log("Application in demo mode. Skipping firmware upgrade..."); result.SetResult(new MachineSetupResult() { UpdatePackagePath = _newPackageTempFolder, diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs index 2305e24ff..610328bc2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultWindowsActivationManager.cs @@ -68,7 +68,7 @@ namespace Tango.PPC.Common.OS /// public async Task Activate(string activationKey) { - CmdCommand command = new CmdCommand("slmgr", $"-ipk {activationKey}"); + CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); await command.Run(); if (!await IsActivated()) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 142c3afe9..c33db4854 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -15,11 +15,6 @@ namespace Tango.PPC.Common /// public class PPCSettings : SettingsBase { - /// - /// Gets or sets the machine serial number. - /// - public String MachineSerialNumber { get; set; } - /// /// Gets or sets the logging categories. /// @@ -50,11 +45,6 @@ namespace Tango.PPC.Common /// public String AutoConnectWiFiName { get; set; } - /// - /// Gets or sets a value indicating whether the application is in demo mode. - /// - public bool DemoMode { get; set; } - /// /// Gets or sets the embedded COM port if not specified will use auto scanning. /// @@ -92,9 +82,8 @@ namespace Tango.PPC.Common { MachineScanningTimeoutSeconds = 20; LoggingCategories = new List(); - MachineSerialNumber = "1111"; UpdateServiceAddress = "http://twine01/PPCUpdateService/PPCUpdateService.svc"; - MachineServiceAddress = "http://twine01/MachineService"; + MachineServiceAddress = "http://machineservice.twine-srv.com/"; EmbeddedComPort = null; ExternalBridgePassword = "Aa123456"; HotSpotPassword = "Aa123456"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs index 25ae2dcf7..040546b59 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs @@ -18,7 +18,7 @@ namespace Tango.PPC.Common.RemoteAssistance public class DefaultRemoteAssistanceProvider : ExtendedObject, IRemoteAssistanceProvider { private IMachineProvider _machineProvider; - private String _installer_path = "C:\\Program Files(x86)\\TeamViewer\\TeamViewer_Host.msi"; + private String _installer_path = "C:\\Program Files (x86)\\TeamViewer\\TeamViewer_Host.msi"; private bool _isEnabled; /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs index abae98f06..5abbd49d1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs @@ -11,12 +11,22 @@ namespace Tango.PPC.Common.Scripting { public class CmdCommand : ExtendedObject { + public enum OutEncoding + { + Default, + Unicode, + } + private Process _process; public String Arguments { get; set; } public TimeSpan Timeout { get; set; } + public String WorkingDir { get; set; } + + public OutEncoding OutputEncoding { get; set; } + public CmdCommand(String processName, String arguments) { Timeout = TimeSpan.FromSeconds(5); @@ -30,6 +40,12 @@ namespace Tango.PPC.Common.Scripting _process.StartInfo.RedirectStandardOutput = true; _process.StartInfo.Arguments = arguments; _process.StartInfo.Verb = "runas"; + + if (WorkingDir != null) + { + _process.StartInfo.WorkingDirectory = WorkingDir; + } + Arguments = arguments; } @@ -43,9 +59,22 @@ namespace Tango.PPC.Common.Scripting if (_process.HasExited) { + String output = _process.StandardOutput.ReadToEnd(); + String error = _process.StandardError.ReadToEnd(); + + if (OutputEncoding == OutEncoding.Unicode) + { + byte[] data = Encoding.Default.GetBytes(output); + output = Encoding.Unicode.GetString(data); + + data = Encoding.Default.GetBytes(error); + error = Encoding.Unicode.GetString(data); + } + LogManager.Log($"Process exited with exit code {_process.ExitCode}."); - LogManager.Log($"Process Standard Output:\n{_process.StandardOutput.ReadToEnd()}"); - LogManager.Log($"Process Standard Error:\n{_process.StandardError.ReadToEnd()}"); + LogManager.Log($"Process Standard Output:\n{output}"); + LogManager.Log($"Process Standard Error:\n{error}"); + if (_process.ExitCode != 0) { throw new IOException($"The process {_process.StartInfo.FileName} has exited with the code {_process.ExitCode}."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs index f673171a5..1e7357b2f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs @@ -14,6 +14,7 @@ namespace Tango.PPC.Common.UWF public class DefaultUnifiedWriteFilterManager : IUnifiedWriteFilterManager { private const int UWF_CAPACITY_MB = 5000; + private const string UWF_PATH = "C:\\Windows\\Sysnative\\uwfmgr.exe"; private String[] _exclusions = { @@ -34,28 +35,35 @@ namespace Tango.PPC.Common.UWF { CmdCommand command = null; - command = new CmdCommand("uwfmgr.exe", "overlay twine-type disk"); + command = new CmdCommand(UWF_PATH, "overlay set-type disk"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); - command = new CmdCommand("uwfmgr.exe", $"overlay twine-size {UWF_CAPACITY_MB}"); + command = new CmdCommand(UWF_PATH, $"overlay set-size {UWF_CAPACITY_MB}"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); - command = new CmdCommand("uwfmgr.exe", $"overlay twine-warningthreshold {UWF_CAPACITY_MB}"); + command = new CmdCommand(UWF_PATH, $"overlay set-warningthreshold {UWF_CAPACITY_MB}"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); - command = new CmdCommand("uwfmgr.exe", $"overlay twine-criticalthreshold {UWF_CAPACITY_MB}"); + command = new CmdCommand(UWF_PATH, $"overlay set-criticalthreshold {UWF_CAPACITY_MB}"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); - command = new CmdCommand("uwfmgr.exe", $"volume protect c:"); + command = new CmdCommand(UWF_PATH, $"volume protect c:"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); foreach (var exclusion in _exclusions) { - command = new CmdCommand("uwfmgr.exe", $"file add-exclusion \"{exclusion}\""); + command = new CmdCommand(UWF_PATH, $"file add-exclusion \"{exclusion}\""); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); } - command = new CmdCommand("uwfmgr.exe", $"filter enable"); + command = new CmdCommand(UWF_PATH, $"filter enable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); } @@ -64,7 +72,8 @@ namespace Tango.PPC.Common.UWF /// public async Task Enable() { - CmdCommand command = new CmdCommand("uwfmgr.exe", $"filter enable"); + CmdCommand command = new CmdCommand(UWF_PATH, $"filter enable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); } @@ -73,7 +82,8 @@ namespace Tango.PPC.Common.UWF /// public async Task Disable() { - CmdCommand command = new CmdCommand("uwfmgr.exe", $"filter disable"); + CmdCommand command = new CmdCommand(UWF_PATH, $"filter disable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index 740b0d203..efd2a15b8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("2.0.15.1608")] +[assembly: AssemblyVersion("2.0.17.1608")] 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 04e764c20..dc30cfa93 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -114,7 +114,7 @@ Setup Failed - + Tap 'RESTART' to restart the process RESTART diff --git a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs index ba54d5a1e..383492905 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs @@ -43,6 +43,16 @@ namespace Tango.BL.Entities public event EventHandler AutoCheckForUpdatesChanged; + public event EventHandler SetupActivationChanged; + + public event EventHandler SetupRemoteAssistanceChanged; + + public event EventHandler SetupUwfChanged; + + public event EventHandler SetupFirmwareChanged; + + public event EventHandler IsDemoChanged; + public event EventHandler> CatsChanged; public event EventHandler DefaultColorSpaceChanged; @@ -471,6 +481,146 @@ namespace Tango.BL.Entities } } + protected Boolean _setupactivation; + + /// + /// Gets or sets the machine setup activation. + /// + + [Column("SETUP_ACTIVATION")] + + public Boolean SetupActivation + { + get + { + return _setupactivation; + } + + set + { + if (_setupactivation != value) + { + _setupactivation = value; + + SetupActivationChanged?.Invoke(this, value); + + RaisePropertyChanged(nameof(SetupActivation)); + } + } + } + + protected Boolean _setupremoteassistance; + + /// + /// Gets or sets the machine setup remote assistance. + /// + + [Column("SETUP_REMOTE_ASSISTANCE")] + + public Boolean SetupRemoteAssistance + { + get + { + return _setupremoteassistance; + } + + set + { + if (_setupremoteassistance != value) + { + _setupremoteassistance = value; + + SetupRemoteAssistanceChanged?.Invoke(this, value); + + RaisePropertyChanged(nameof(SetupRemoteAssistance)); + } + } + } + + protected Boolean _setupuwf; + + /// + /// Gets or sets the machine setup uwf. + /// + + [Column("SETUP_UWF")] + + public Boolean SetupUwf + { + get + { + return _setupuwf; + } + + set + { + if (_setupuwf != value) + { + _setupuwf = value; + + SetupUwfChanged?.Invoke(this, value); + + RaisePropertyChanged(nameof(SetupUwf)); + } + } + } + + protected Boolean _setupfirmware; + + /// + /// Gets or sets the machine setup firmware. + /// + + [Column("SETUP_FIRMWARE")] + + public Boolean SetupFirmware + { + get + { + return _setupfirmware; + } + + set + { + if (_setupfirmware != value) + { + _setupfirmware = value; + + SetupFirmwareChanged?.Invoke(this, value); + + RaisePropertyChanged(nameof(SetupFirmware)); + } + } + } + + protected Boolean _isdemo; + + /// + /// Gets or sets the machine is demo. + /// + + [Column("IS_DEMO")] + + public Boolean IsDemo + { + get + { + return _isdemo; + } + + set + { + if (_isdemo != value) + { + _isdemo = value; + + IsDemoChanged?.Invoke(this, value); + + RaisePropertyChanged(nameof(IsDemo)); + } + } + } + protected SynchronizedObservableCollection _cats; /// diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index b4c998ef1..341f2aa2a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -41,6 +41,11 @@ namespace Tango.DAL.Remote.DB public string OS_KEY { get; set; } public bool AUTO_LOGIN { get; set; } public bool AUTO_CHECK_FOR_UPDATES { get; set; } + public bool SETUP_ACTIVATION { get; set; } + public bool SETUP_REMOTE_ASSISTANCE { get; set; } + public bool SETUP_UWF { get; set; } + public bool SETUP_FIRMWARE { get; set; } + public bool IS_DEMO { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection CATS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 45af1f873..7a01d5db8 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -708,6 +708,11 @@ + + + + + @@ -3795,6 +3800,11 @@ + + + + + @@ -6045,6 +6055,11 @@ + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index b0706a849..c16e38955 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,81 +5,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs b/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs index 53b31b77f..e2650cf2b 100644 --- a/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs +++ b/Software/Visual_Studio/Tango.PMR/Synchronization/MachineSetupResponse.cs @@ -23,15 +23,17 @@ namespace Tango.PMR.Synchronization { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChpNYWNoaW5lU2V0dXBSZXNwb25zZS5wcm90bxIZVGFuZ28uUE1SLlN5bmNo", - "cm9uaXphdGlvbiKGAQoUTWFjaGluZVNldHVwUmVzcG9uc2USDwoHVmVyc2lv", + "cm9uaXphdGlvbiL3AQoUTWFjaGluZVNldHVwUmVzcG9uc2USDwoHVmVyc2lv", "bhgBIAEoCRITCgtCbG9iQWRkcmVzcxgCIAEoCRIRCglEYkFkZHJlc3MYAyAB", "KAkSEgoKRGJVc2VyTmFtZRgEIAEoCRISCgpEYlBhc3N3b3JkGAUgASgJEg0K", - "BU9TS2V5GAYgASgJQiUKI2NvbS50d2luZS50YW5nby5wbXIuc3luY2hyb25p", - "emF0aW9uYgZwcm90bzM=")); + "BU9TS2V5GAYgASgJEhcKD1NldHVwQWN0aXZhdGlvbhgHIAEoCBIdChVTZXR1", + "cFJlbW90ZUFzc2lzdGFuY2UYCCABKAgSEAoIU2V0dXBVV0YYCSABKAgSFQoN", + "U2V0dXBGaXJtd2FyZRgKIAEoCBIOCgZJc0RlbW8YCyABKAhCJQojY29tLnR3", + "aW5lLnRhbmdvLnBtci5zeW5jaHJvbml6YXRpb25iBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.MachineSetupResponse), global::Tango.PMR.Synchronization.MachineSetupResponse.Parser, new[]{ "Version", "BlobAddress", "DbAddress", "DbUserName", "DbPassword", "OSKey" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Synchronization.MachineSetupResponse), global::Tango.PMR.Synchronization.MachineSetupResponse.Parser, new[]{ "Version", "BlobAddress", "DbAddress", "DbUserName", "DbPassword", "OSKey", "SetupActivation", "SetupRemoteAssistance", "SetupUWF", "SetupFirmware", "IsDemo" }, null, null, null) })); } #endregion @@ -68,6 +70,11 @@ namespace Tango.PMR.Synchronization { dbUserName_ = other.dbUserName_; dbPassword_ = other.dbPassword_; oSKey_ = other.oSKey_; + setupActivation_ = other.setupActivation_; + setupRemoteAssistance_ = other.setupRemoteAssistance_; + setupUWF_ = other.setupUWF_; + setupFirmware_ = other.setupFirmware_; + isDemo_ = other.isDemo_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -141,6 +148,61 @@ namespace Tango.PMR.Synchronization { } } + /// Field number for the "SetupActivation" field. + public const int SetupActivationFieldNumber = 7; + private bool setupActivation_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool SetupActivation { + get { return setupActivation_; } + set { + setupActivation_ = value; + } + } + + /// Field number for the "SetupRemoteAssistance" field. + public const int SetupRemoteAssistanceFieldNumber = 8; + private bool setupRemoteAssistance_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool SetupRemoteAssistance { + get { return setupRemoteAssistance_; } + set { + setupRemoteAssistance_ = value; + } + } + + /// Field number for the "SetupUWF" field. + public const int SetupUWFFieldNumber = 9; + private bool setupUWF_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool SetupUWF { + get { return setupUWF_; } + set { + setupUWF_ = value; + } + } + + /// Field number for the "SetupFirmware" field. + public const int SetupFirmwareFieldNumber = 10; + private bool setupFirmware_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool SetupFirmware { + get { return setupFirmware_; } + set { + setupFirmware_ = value; + } + } + + /// Field number for the "IsDemo" field. + public const int IsDemoFieldNumber = 11; + private bool isDemo_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool IsDemo { + get { return isDemo_; } + set { + isDemo_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MachineSetupResponse); @@ -160,6 +222,11 @@ namespace Tango.PMR.Synchronization { if (DbUserName != other.DbUserName) return false; if (DbPassword != other.DbPassword) return false; if (OSKey != other.OSKey) return false; + if (SetupActivation != other.SetupActivation) return false; + if (SetupRemoteAssistance != other.SetupRemoteAssistance) return false; + if (SetupUWF != other.SetupUWF) return false; + if (SetupFirmware != other.SetupFirmware) return false; + if (IsDemo != other.IsDemo) return false; return true; } @@ -172,6 +239,11 @@ namespace Tango.PMR.Synchronization { if (DbUserName.Length != 0) hash ^= DbUserName.GetHashCode(); if (DbPassword.Length != 0) hash ^= DbPassword.GetHashCode(); if (OSKey.Length != 0) hash ^= OSKey.GetHashCode(); + if (SetupActivation != false) hash ^= SetupActivation.GetHashCode(); + if (SetupRemoteAssistance != false) hash ^= SetupRemoteAssistance.GetHashCode(); + if (SetupUWF != false) hash ^= SetupUWF.GetHashCode(); + if (SetupFirmware != false) hash ^= SetupFirmware.GetHashCode(); + if (IsDemo != false) hash ^= IsDemo.GetHashCode(); return hash; } @@ -206,6 +278,26 @@ namespace Tango.PMR.Synchronization { output.WriteRawTag(50); output.WriteString(OSKey); } + if (SetupActivation != false) { + output.WriteRawTag(56); + output.WriteBool(SetupActivation); + } + if (SetupRemoteAssistance != false) { + output.WriteRawTag(64); + output.WriteBool(SetupRemoteAssistance); + } + if (SetupUWF != false) { + output.WriteRawTag(72); + output.WriteBool(SetupUWF); + } + if (SetupFirmware != false) { + output.WriteRawTag(80); + output.WriteBool(SetupFirmware); + } + if (IsDemo != false) { + output.WriteRawTag(88); + output.WriteBool(IsDemo); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -229,6 +321,21 @@ namespace Tango.PMR.Synchronization { if (OSKey.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(OSKey); } + if (SetupActivation != false) { + size += 1 + 1; + } + if (SetupRemoteAssistance != false) { + size += 1 + 1; + } + if (SetupUWF != false) { + size += 1 + 1; + } + if (SetupFirmware != false) { + size += 1 + 1; + } + if (IsDemo != false) { + size += 1 + 1; + } return size; } @@ -255,6 +362,21 @@ namespace Tango.PMR.Synchronization { if (other.OSKey.Length != 0) { OSKey = other.OSKey; } + if (other.SetupActivation != false) { + SetupActivation = other.SetupActivation; + } + if (other.SetupRemoteAssistance != false) { + SetupRemoteAssistance = other.SetupRemoteAssistance; + } + if (other.SetupUWF != false) { + SetupUWF = other.SetupUWF; + } + if (other.SetupFirmware != false) { + SetupFirmware = other.SetupFirmware; + } + if (other.IsDemo != false) { + IsDemo = other.IsDemo; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -289,6 +411,26 @@ namespace Tango.PMR.Synchronization { OSKey = input.ReadString(); break; } + case 56: { + SetupActivation = input.ReadBool(); + break; + } + case 64: { + SetupRemoteAssistance = input.ReadBool(); + break; + } + case 72: { + SetupUWF = input.ReadBool(); + break; + } + case 80: { + SetupFirmware = input.ReadBool(); + break; + } + case 88: { + IsDemo = input.ReadBool(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml index 6c9e5b267..61ca6aedb 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml index c6f4e5825..003d76bde 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml index f2671bee8..ca0b7f8f1 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml differ diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs index 6126594c5..d675a348f 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs @@ -98,9 +98,9 @@ namespace Tango.MachineService.Controllers throw new AuthenticationException("The specified serial number could not be found."); } - if (machine.OsKey == null) + if (machine.SetupActivation && machine.OsKey == null) { - throw new InvalidDataException("The specified machine is not associated with an OS activation key."); + throw new InvalidDataException("The specified machine is configured to perform an OS activation but is not associated with an OS activation key."); } var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); @@ -134,6 +134,12 @@ namespace Tango.MachineService.Controllers response.DbUserName = credentials.UserName; response.DbPassword = credentials.Password; response.OSKey = machine.OsKey; + response.SetupActivation = machine.SetupActivation; + response.SetupRemoteAssistance = machine.SetupRemoteAssistance; + response.SetupUWF = machine.SetupUwf; + response.SetupFirmware = machine.SetupFirmware; + response.IsDemo = machine.IsDemo; + } return response; -- cgit v1.3.1 From 0f5a0b13fc4408952d90d2450c642a7948b88879 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 10:02:27 +0200 Subject: Starting working on improving web api's access... --- .../Properties/AssemblyInfo.cs | 2 +- .../MachineSetup/MachineSetupManager.cs | 2 +- .../MachineUpdate/MachineUpdateManager.cs | 6 +- .../Tango.PPC.UpdateService/PPCUpdateService.svc | 1 - .../PPCUpdateService.svc.cs | 193 -------------- .../Properties/AssemblyInfo.cs | 36 --- .../Publish PPC Update Service via FTP.pubxml | 21 -- .../Tango.PPC.UpdateService.csproj | 144 ----------- .../PPC/Tango.PPC.UpdateService/Web.Debug.config | 30 --- .../PPC/Tango.PPC.UpdateService/Web.Release.config | 31 --- .../PPC/Tango.PPC.UpdateService/Web.config | 114 --------- .../PPC/Tango.PPC.UpdateService/packages.config | 4 - .../Tango.UnitTesting/MachineService_TST.cs | 2 +- .../Controllers/PPCController.cs | 239 +++++++++++++++++ .../Controllers/SynchronizationController.cs | 285 --------------------- .../Tango.MachineService.csproj | 4 +- 16 files changed, 247 insertions(+), 867 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/AssemblyInfo.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/PublishProfiles/Publish PPC Update Service via FTP.pubxml delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Tango.PPC.UpdateService.csproj delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Debug.config delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Release.config delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.config delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UpdateService/packages.config create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index c311df44b..2b58baa21 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("3.5.79.18305")] +[assembly: AssemblyVersion("3.5.80.18305")] [assembly: ComVisible(false)] \ No newline at end of file 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 e1795d06a..eb47ae231 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -114,7 +114,7 @@ namespace Tango.PPC.Common.MachineSetup { using (var http = new ProtoWebClient()) { - setup_response = await http.Post(machineServiceAddress + "/api/Synchronization/MachineSetup", request); + setup_response = await http.Post(machineServiceAddress + "/api/PPC/MachineSetup", request); } } catch (Exception ex) 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 9ae77df6f..ce45258f5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -113,7 +113,7 @@ namespace Tango.PPC.Common.MachineUpdate using (var http = new ProtoWebClient()) { - update_response = await http.Post(machineServiceAddress + "/api/Synchronization/MachineUpdate", request); + update_response = await http.Post(machineServiceAddress + "/api/PPC/MachineUpdate", request); } LogManager.Log($"Machine update response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -294,7 +294,7 @@ namespace Tango.PPC.Common.MachineUpdate using (var http = new ProtoWebClient()) { - update_response = http.Post(machineServiceAddress + "/api/Synchronization/CheckForUpdate", request).Result; + update_response = http.Post(machineServiceAddress + "/api/PPC/CheckForUpdate", request).Result; } LogManager.Log($"Check for update response received: {Environment.NewLine}{update_response.ToJsonString()}"); @@ -405,7 +405,7 @@ namespace Tango.PPC.Common.MachineUpdate using (var http = new ProtoWebClient()) { - update_response = http.Post(machineServiceAddress + "/api/Synchronization/UpdateDB", request).Result; + update_response = http.Post(machineServiceAddress + "/api/PPC/UpdateDB", request).Result; } LogManager.Log($"Update DB response received: {Environment.NewLine}{update_response.ToJsonString()}"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc deleted file mode 100644 index ea2b9c582..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc +++ /dev/null @@ -1 +0,0 @@ -<%@ ServiceHost Language="C#" Debug="true" Service="Tango.PPC.UpdateService.PPCUpdateService" CodeBehind="PPCUpdateService.svc.cs" %> \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc.cs b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc.cs deleted file mode 100644 index 2474e310c..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/PPCUpdateService.svc.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Runtime.Serialization; -using System.ServiceModel; -using System.ServiceModel.Web; -using System.Text; -using Tango.BL; -using Tango.BL.Entities; -using Tango.BL.Enumerations; -using Tango.Logging; -using Tango.PPC.Common.Update; - -namespace Tango.PPC.UpdateService -{ - public class PPCUpdateService : IPPCUpdateService - { - private LogManager LogManager = LogManager.Default; - - private class PendingUpload - { - public String Token { get; set; } - - public String Version { get; set; } - - public String UserGuid { get; set; } - - public String Comments { get; set; } - - public String MachineVersionGuid { get; set; } - - public String FilePath { get; set; } - } - - private static List _pendingUploads; - - static PPCUpdateService() - { - _pendingUploads = new List(); - } - - public UploadVersionResponse UploadVersion(UploadVersionRequest request) - { - try - { - UploadVersionResponse response = new UploadVersionResponse(); - - using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) - { - db.Configuration.LazyLoadingEnabled = false; - - //Load relation first... - db.Roles.ToList(); - db.Permissions.ToList(); - db.UsersRoles.ToList(); - db.RolesPermissions.ToList(); - - var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); - - if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) - { - var versions = db.TangoVersions.ToList().Where(x => x.MachineVersionGuid == request.MachineVersionGuid).OrderByDescending(x => Version.Parse(x.Version)).ToList(); - - TangoVersion latestVersion = new TangoVersion(); - latestVersion.Version = "0.0.0.0"; - - if (versions.Count > 0) - { - latestVersion = versions.FirstOrDefault(); - } - - Version currentVersion = Version.Parse(request.Version); - - String newVersionFileName = Path.GetRandomFileName() + "_" + currentVersion.ToString() + ".zip"; - - String newVersionFilePath = "/Tango Versions/" + newVersionFileName; - - if (currentVersion > Version.Parse(latestVersion.Version)) - { - response.FtpHost = ConfigurationManager.AppSettings["FtpHost"].ToString(); - response.UserName = ConfigurationManager.AppSettings["UserName"].ToString(); - response.Password = ConfigurationManager.AppSettings["Password"].ToString(); - response.FileName = newVersionFileName; - response.FilePath = newVersionFilePath; - response.Token = Guid.NewGuid().ToString(); - - _pendingUploads.Add(new PendingUpload() - { - UserGuid = user.Guid, - Comments = request.Comments, - Token = response.Token, - Version = request.Version, - FilePath = response.FilePath, - MachineVersionGuid = request.MachineVersionGuid, - }); - } - else - { - throw new FaultException("New version must be greater than latest version."); - } - } - else - { - throw new FaultException("Invalid user credentials."); - } - } - - return response; - } - catch (Exception ex) - { - LogManager.Log(ex); - throw new FaultException(ex.ToString()); - } - } - - public void NotifyUploadCompleted(UploadCompletedRequest request) - { - try - { - PendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); - - if (upload != null) - { - _pendingUploads.RemoveAll(x => x.Token == upload.Token); - - using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) - { - db.Configuration.LazyLoadingEnabled = false; - - db.TangoVersions.Add(new TangoVersion() - { - Comments = upload.Comments, - FtpFilePath = upload.FilePath, - UserGuid = upload.UserGuid, - Version = upload.Version, - MachineVersionGuid = upload.MachineVersionGuid - }); - - db.SaveChanges(); - } - } - else - { - throw new FaultException("Invalid Token."); - } - } - catch (Exception ex) - { - LogManager.Log(ex); - throw new FaultException(ex.ToString()); - } - } - - public LatestVersionResponse GetLatestVersion(String machineVersionGuid) - { - try - { - LatestVersionResponse response = new LatestVersionResponse(); - - using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) - { - var versions = db.TangoVersions.Where(x => x.MachineVersionGuid == machineVersionGuid).ToList(); - - if (versions.Count > 0) - { - response.Version = db.TangoVersions.Where(x => x.MachineVersionGuid == machineVersionGuid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault().Version; - } - else - { - return new LatestVersionResponse() - { - Version = "0.0.0.0" - }; - } - } - - return response; - } - catch (Exception ex) - { - throw new FaultException(ex.ToString()); - } - } - - private String GetServerAddress() - { - return ConfigurationManager.AppSettings["ServerAddress"].ToString(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/AssemblyInfo.cs deleted file mode 100644 index 7cf1e50d3..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Tango.PPC.UpdateService")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tango.PPC.UpdateService")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("01c3ef89-6a17-4d70-a71f-0395a212f2f8")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/PublishProfiles/Publish PPC Update Service via FTP.pubxml b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/PublishProfiles/Publish PPC Update Service via FTP.pubxml deleted file mode 100644 index c2c570917..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Properties/PublishProfiles/Publish PPC Update Service via FTP.pubxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - FTP - Release - Any CPU - - True - False - twine01 - False - True - - PPCUpdateService|Roy - <_SavePWD>True - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Tango.PPC.UpdateService.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Tango.PPC.UpdateService.csproj deleted file mode 100644 index 900e41529..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Tango.PPC.UpdateService.csproj +++ /dev/null @@ -1,144 +0,0 @@ - - - - Debug - AnyCPU - - - 2.0 - {01C3EF89-6A17-4D70-A71F-0395A212F2F8} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Tango.PPC.UpdateService - Tango.PPC.UpdateService - v4.6.1 - True - true - true - - - - - - - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - - ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll - - - ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - PPCUpdateService.svc - - - - - - - - - - - Web.config - - - Web.config - - - - - {F441FEEE-322A-4943-B566-110E12FD3B72} - Tango.BL - - - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} - Tango.Core - - - {BC932DBD-7CDB-488C-99E4-F02CF441F55E} - Tango.Logging - - - {0be74eee-22cb-4dba-b896-793b9e1a3ac0} - Tango.PPC.Common - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - - - - - True - True - 52137 - / - http://localhost:52137/ - False - False - - - False - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Debug.config b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Debug.config deleted file mode 100644 index fae9cfefa..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Release.config b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Release.config deleted file mode 100644 index da6e960b8..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.config b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.config deleted file mode 100644 index d73fd1425..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/Web.config +++ /dev/null @@ -1,114 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/packages.config deleted file mode 100644 index 9256e1591..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UpdateService/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs index 4afa31edf..954d53da8 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs @@ -17,7 +17,7 @@ namespace Tango.UnitTesting public void Check_For_Updates() { ITransportWebClient client = new ProtoWebClient(); - var result = client.Post("http://localhost:51581/api/Synchronization/CheckForUpdate", new CheckForUpdateRequest() + var result = client.Post("http://localhost:51581/api/PPC/CheckForUpdate", new CheckForUpdateRequest() { SerialNumber = "0000", Version = "0.0.0.0", diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs new file mode 100644 index 000000000..c5e85f819 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -0,0 +1,239 @@ +using Google.Protobuf; +using Microsoft.Azure; +using Microsoft.Azure.Management.Sql; +using Microsoft.SqlServer.Management.Smo; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Threading.Tasks; +using System.Web.Hosting; +using System.Web.Http; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.Core.DB; +using Tango.Core.Helpers; +using Tango.Core.IO; +using Tango.Logging; +using Tango.MachineService.Helpers; +using Tango.MachineService.Models; +using Tango.MachineService.SMO; +using Tango.PMR.Stubs; +using Tango.PMR.Synchronization; +using Tango.Synchronization.Local; +using Tango.Synchronization.Remote; + +namespace Tango.MachineService.Controllers +{ + public class PPCController : ProtoController + { + [HttpPost] + public MachineSetupResponse MachineSetup(MachineSetupRequest request) + { + MachineSetupResponse response = new MachineSetupResponse(); + + LogManager.Log("Setup request received: " + request.ToString()); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.Configuration.LazyLoadingEnabled = false; + String serial_number = request.SerialNumber; + + var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); + + if (machine == null) + { + throw new AuthenticationException("The specified serial number could not be found."); + } + + if (machine.SetupActivation && machine.OsKey == null) + { + throw new InvalidDataException("The specified machine is configured to perform an OS activation but is not associated with an OS activation key."); + } + + var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); + + var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + + response.Version = latest_machine_version.Version; + + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetTangoVersionsContainer(client); + var blob = container.GetBlockBlobReference(latest_machine_version.BlobName); + + response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + + DbCredentials credentials = new DbCredentials(); + + using (SmoManager manager = new SmoManager()) + { + credentials = manager.CreateRandomLoginAndUser(); + + Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => + { + using (SmoManager m = new SmoManager()) + { + m.DeleteLoginAndUser(credentials.UserName); + } + }); + } + + response.DbAddress = Config.DB_ADDRESS; + response.DbUserName = credentials.UserName; + response.DbPassword = credentials.Password; + response.OSKey = machine.OsKey; + response.SetupActivation = machine.SetupActivation; + response.SetupRemoteAssistance = machine.SetupRemoteAssistance; + response.SetupUWF = machine.SetupUwf; + response.SetupFirmware = machine.SetupFirmware; + response.IsDemo = machine.IsDemo; + + } + + return response; + } + + [HttpPost] + public DownloadUpdateResponse MachineUpdate(DownloadUpdateRequest request) + { + DownloadUpdateResponse response = new DownloadUpdateResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.Configuration.LazyLoadingEnabled = false; + String serial_number = request.SerialNumber; + + var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); + + if (machine == null) + { + throw new AuthenticationException("The specified serial number could not be found."); + } + + var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); + + var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + + response.Version = latest_machine_version.Version; + + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetTangoVersionsContainer(client); + var blob = container.GetBlockBlobReference(latest_machine_version.BlobName); + + response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + + DbCredentials credentials = new DbCredentials(); + + using (SmoManager manager = new SmoManager()) + { + credentials = manager.CreateRandomLoginAndUser(); + + Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => + { + using (SmoManager m = new SmoManager()) + { + m.DeleteLoginAndUser(credentials.UserName); + } + }); + } + + response.DbAddress = Config.DB_ADDRESS; + response.DbUserName = credentials.UserName; + response.DbPassword = credentials.Password; + } + + return response; + } + + [HttpPost] + public CheckForUpdateResponse CheckForUpdate(CheckForUpdateRequest request) + { + CheckForUpdateResponse response = new CheckForUpdateResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.Configuration.LazyLoadingEnabled = false; + + var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == request.SerialNumber); + + if (machine == null) + { + throw new AuthenticationException("The specified serial number could not be found."); + } + + var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); + + var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + + if (Version.Parse(latest_machine_version.Version) > Version.Parse(request.Version)) + { + response.IsUpdateAvailable = true; + } + + response.Version = latest_machine_version.Version; + } + + return response; + } + + [HttpPost] + public UpdateDBResponse UpdateDB(UpdateDBRequest request) + { + UpdateDBResponse response = new UpdateDBResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.Configuration.LazyLoadingEnabled = false; + String serial_number = request.SerialNumber; + + var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); + + if (machine == null) + { + throw new AuthenticationException("The specified serial number could not be found."); + } + + DbCredentials credentials = new DbCredentials(); + + using (SmoManager manager = new SmoManager()) + { + credentials = manager.CreateRandomLoginAndUser(); + + Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => + { + using (SmoManager m = new SmoManager()) + { + m.DeleteLoginAndUser(credentials.UserName); + } + }); + } + + response.DbAddress = Config.DB_ADDRESS; + response.DbUserName = credentials.UserName; + response.DbPassword = credentials.Password; + } + + return response; + } + + [HttpPost] + public Machine PersonTest(Person p) + { + using (var db = ObservablesContextHelper.CreateContext()) + { + var machine = new MachineBuilder(db) + .Set(x => x.SerialNumber == "1111") + .WithOrganization() + .WithConfiguration().Build(); + + return machine; + } + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs deleted file mode 100644 index d675a348f..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs +++ /dev/null @@ -1,285 +0,0 @@ -using Google.Protobuf; -using Microsoft.Azure; -using Microsoft.Azure.Management.Sql; -using Microsoft.SqlServer.Management.Smo; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Authentication; -using System.Threading.Tasks; -using System.Web.Hosting; -using System.Web.Http; -using Tango.BL; -using Tango.BL.Builders; -using Tango.BL.Entities; -using Tango.Core.DB; -using Tango.Core.Helpers; -using Tango.Core.IO; -using Tango.Logging; -using Tango.MachineService.Helpers; -using Tango.MachineService.Models; -using Tango.MachineService.SMO; -using Tango.PMR.Stubs; -using Tango.PMR.Synchronization; -using Tango.Synchronization.Local; -using Tango.Synchronization.Remote; - -namespace Tango.MachineService.Controllers -{ - public class SynchronizationController : ProtoController - { - ///// - ///// Expects a DB synchronization request from a remote machine and returns the synchronized version of the machine database. - ///// - ///// The request. - ///// - //[HttpPost] - //public SynchronizeDBResponse Synchronize(SynchronizeDBRequest request) - //{ - // var tempFolder = TemporaryManager.Default.CreateFolder(); - - // try - // { - // //File path for the reflected remote data base SQLite. - // String masterSQLiteFile = Path.Combine(tempFolder, "Remote.db"); - // //File path for the received machine SQLite db. - // String slaveSQLiteFile = Path.Combine(tempFolder, "Local.db"); - - // //Save the machine db to file. - // File.WriteAllBytes(slaveSQLiteFile, request.LocalDB.ToByteArray()); - - // //Copy an SQLite db template. - // File.Copy(HostingEnvironment.MapPath(@"~/App_Data/Tango.db"), masterSQLiteFile); - - // //Synchronize the SQL Server db with the new SQLite template. (Overwrite basically) - // RemoteDBSynchronizer.Synchronize(masterSQLiteFile, request.SerialNumber, true); - - // //Synchronize the received machine db with the filled template. - // LocalDBSynchronizer.Synchronize(masterSQLiteFile, slaveSQLiteFile); - - // //Send the synchronized machine db to the machine to the machine. - // SynchronizeDBResponse response = new SynchronizeDBResponse(); - // response.RemoteDB = ByteString.CopyFrom(File.ReadAllBytes(slaveSQLiteFile)); - - // return response; - // } - // catch (Exception) - // { - // throw; - // } - // finally - // { - // //Remove all temporary files and folder. - // tempFolder.Delete(); - // } - //} - - [HttpPost] - public MachineSetupResponse MachineSetup(MachineSetupRequest request) - { - MachineSetupResponse response = new MachineSetupResponse(); - - LogManager.Log("Setup request received: " + request.ToString()); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - db.Configuration.LazyLoadingEnabled = false; - String serial_number = request.SerialNumber; - - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); - - if (machine == null) - { - throw new AuthenticationException("The specified serial number could not be found."); - } - - if (machine.SetupActivation && machine.OsKey == null) - { - throw new InvalidDataException("The specified machine is configured to perform an OS activation but is not associated with an OS activation key."); - } - - var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); - - var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); - - response.Version = latest_machine_version.Version; - - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetTangoVersionsContainer(client); - var blob = container.GetBlockBlobReference(latest_machine_version.BlobName); - - response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); - - DbCredentials credentials = new DbCredentials(); - - using (SmoManager manager = new SmoManager()) - { - credentials = manager.CreateRandomLoginAndUser(); - - Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => - { - using (SmoManager m = new SmoManager()) - { - m.DeleteLoginAndUser(credentials.UserName); - } - }); - } - - response.DbAddress = Config.DB_ADDRESS; - response.DbUserName = credentials.UserName; - response.DbPassword = credentials.Password; - response.OSKey = machine.OsKey; - response.SetupActivation = machine.SetupActivation; - response.SetupRemoteAssistance = machine.SetupRemoteAssistance; - response.SetupUWF = machine.SetupUwf; - response.SetupFirmware = machine.SetupFirmware; - response.IsDemo = machine.IsDemo; - - } - - return response; - } - - [HttpPost] - public DownloadUpdateResponse MachineUpdate(DownloadUpdateRequest request) - { - DownloadUpdateResponse response = new DownloadUpdateResponse(); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - db.Configuration.LazyLoadingEnabled = false; - String serial_number = request.SerialNumber; - - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); - - if (machine == null) - { - throw new AuthenticationException("The specified serial number could not be found."); - } - - var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); - - var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); - - response.Version = latest_machine_version.Version; - - var client = StorageHelper.GetStorageBlobClient(); - var container = StorageHelper.GetTangoVersionsContainer(client); - var blob = container.GetBlockBlobReference(latest_machine_version.BlobName); - - response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); - - DbCredentials credentials = new DbCredentials(); - - using (SmoManager manager = new SmoManager()) - { - credentials = manager.CreateRandomLoginAndUser(); - - Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => - { - using (SmoManager m = new SmoManager()) - { - m.DeleteLoginAndUser(credentials.UserName); - } - }); - } - - response.DbAddress = Config.DB_ADDRESS; - response.DbUserName = credentials.UserName; - response.DbPassword = credentials.Password; - } - - return response; - } - - [HttpPost] - public CheckForUpdateResponse CheckForUpdate(CheckForUpdateRequest request) - { - CheckForUpdateResponse response = new CheckForUpdateResponse(); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - db.Configuration.LazyLoadingEnabled = false; - - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == request.SerialNumber); - - if (machine == null) - { - throw new AuthenticationException("The specified serial number could not be found."); - } - - var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid); - - var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); - - if (Version.Parse(latest_machine_version.Version) > Version.Parse(request.Version)) - { - response.IsUpdateAvailable = true; - } - - response.Version = latest_machine_version.Version; - } - - return response; - } - - [HttpPost] - public UpdateDBResponse UpdateDB(UpdateDBRequest request) - { - UpdateDBResponse response = new UpdateDBResponse(); - - using (ObservablesContext db = ObservablesContextHelper.CreateContext()) - { - db.Configuration.LazyLoadingEnabled = false; - String serial_number = request.SerialNumber; - - var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number); - - if (machine == null) - { - throw new AuthenticationException("The specified serial number could not be found."); - } - - DbCredentials credentials = new DbCredentials(); - - using (SmoManager manager = new SmoManager()) - { - credentials = manager.CreateRandomLoginAndUser(); - - Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) => - { - using (SmoManager m = new SmoManager()) - { - m.DeleteLoginAndUser(credentials.UserName); - } - }); - } - - response.DbAddress = Config.DB_ADDRESS; - response.DbUserName = credentials.UserName; - response.DbPassword = credentials.Password; - } - - return response; - } - - [HttpPost] - public Machine PersonTest(Person p) - { - using (var db = ObservablesContextHelper.CreateContext()) - { - var machine = new MachineBuilder(db) - .Set(x => x.SerialNumber == "1111") - .WithOrganization() - .WithConfiguration().Build(); - - return machine; - } - } - } -} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index 9f0b2cba2..c7fdab45c 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -279,7 +279,7 @@ - + Global.asax @@ -365,7 +365,7 @@ False - + -- cgit v1.3.1 From c3ed01b6c75c44cfeca650b43deb058b1551a9bb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 14:52:54 +0200 Subject: Moved machine studio update azure !!! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1532 -> 1516 bytes .../MachineStudioSettings.cs | 3 + .../Tango.MachineStudio.Common.csproj | 6 +- .../Update/CheckForUpdatesRequest.cs | 8 +- .../Update/CheckForUpdatesResponse.cs | 23 +-- .../Update/IMachineStudioUpdateService.cs | 14 +- .../Update/LatestVersionRequest.cs | 15 ++ .../Update/LatestVersionResponse.cs | 15 ++ .../Update/MachineStudioUpdateService.cs | 42 +++++ .../Update/UploadCompletedRequest.cs | 5 +- .../Update/UploadCompletedResponse.cs | 14 ++ .../Update/UploadVersionRequest.cs | 10 +- .../Update/UploadVersionResponse.cs | 22 +-- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 40 ++--- .../Tango.MachineStudio.Publisher.csproj | 7 +- .../Tango.MachineStudio.UI.csproj | 3 +- .../ViewModels/LoadingViewVM.cs | 6 +- .../ViewModels/MainViewVM.cs | 5 +- .../ViewModels/UpdateViewVM.cs | 35 ++-- .../PPC/Tango.PPC.Publisher/MainWindowVM.cs | 25 ++- .../Tango.PPC.Publisher/Tango.PPC.Publisher.csproj | 4 + .../Tango.BL/Entities/MachineStudioVersion.cs | 20 +-- .../Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 6 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 142 ++++++++-------- .../Tango.Transport/Tango.Transport.csproj | 4 + .../Tango.Transport/Web/StorageBlobDownloader.cs | 65 +++++++ .../Web/StorageBlobProgressEventArgs.cs | 14 ++ .../Tango.Transport/Web/StorageBlobUploader.cs | 61 +++++++ .../Controllers/MachineStudioController.cs | 186 +++++++++++++++++++++ .../Controllers/PPCController.cs | 8 +- .../Tango.MachineService/Helpers/StorageHelper.cs | 6 + .../Models/MachineStudioPendingUpload.cs | 26 +++ .../Models/PPCPendingUpload.cs | 22 +++ .../Tango.MachineService/Models/PendingUpload.cs | 22 --- .../Tango.MachineService.csproj | 8 +- 38 files changed, 651 insertions(+), 243 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs create mode 100644 Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs create mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs delete mode 100644 Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 5b346239d..260afa6c7 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 1801b28f7..0c46ed4ec 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 09ae17244..adc17d481 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index 67e052ecc..cab3d2bfc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -43,6 +43,8 @@ namespace Tango.MachineStudio.Common ///
public String UpdateServiceAddress { get; set; } + public String MachineServiceAddress { get; set; } + /// /// Gets or sets the allow beta release. /// @@ -96,6 +98,7 @@ namespace Tango.MachineStudio.Common LastBounds = new Rect(); LoggingCategories = new List(); UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; + MachineServiceAddress = "http://machineservice.twine-srv.com/"; DefaultIssueReportTags = new List(); StudioModulesBounds = new List(); } 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 8cf65a13d..31d28def8 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 @@ -122,8 +122,12 @@ + + + + @@ -304,7 +308,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 0047e311b..11911dd7e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs @@ -4,22 +4,18 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class CheckForUpdatesRequest + public class CheckForUpdatesRequest : WebRequestMessage { - [DataMember] public String Email { get; set; } - [DataMember] public String Password { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public bool AcceptBetaRelease { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs index f34f12d8f..b0577f40b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs @@ -4,37 +4,22 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class CheckForUpdatesResponse + public class CheckForUpdatesResponse : WebResponseMessage { - [DataMember] public bool IsUpdateAvailable { get; set; } - [DataMember] public bool IsStable { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public String Comments { get; set; } - [DataMember] - public String FtpHost { get; set; } - - [DataMember] - public String FilePath { get; set; } - - [DataMember] - public String UserName { get; set; } - - [DataMember] - public String Password { get; set; } - - [DataMember] public bool ForcedUpdate { get; set; } + + public String BlobAddress { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs index 53e49e52c..4a7df7caa 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs @@ -4,23 +4,19 @@ using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; +using System.Threading.Tasks; using Tango.MachineStudio.Common.Update; namespace Tango.MachineStudio.Common.Update { - [ServiceContract] public interface IMachineStudioUpdateService { - [OperationContract] - CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request); + Task CheckForUpdates(CheckForUpdatesRequest request); - [OperationContract] - UploadVersionResponse UploadVersion(UploadVersionRequest request); + Task UploadVersion(UploadVersionRequest request); - [OperationContract] - void NotifyUploadCompleted(UploadCompletedRequest request); + Task NotifyUploadCompleted(UploadCompletedRequest request); - [OperationContract] - String GetLatestVersion(); + Task GetLatestVersion(LatestVersionRequest request); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs new file mode 100644 index 000000000..b4e7bd975 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Update +{ + public class LatestVersionRequest : WebRequestMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs new file mode 100644 index 000000000..b90cbf370 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/LatestVersionResponse.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.MachineStudio.Common.Update +{ + public class LatestVersionResponse : WebResponseMessage + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs new file mode 100644 index 000000000..aae1fe70d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/MachineStudioUpdateService.cs @@ -0,0 +1,42 @@ +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.MachineStudio.Common.Update +{ + public class MachineStudioUpdateService : IMachineStudioUpdateService + { + private string address; + private WebTransportClient _client; + + public MachineStudioUpdateService() + { + address = SettingsManager.Default.GetOrCreate().MachineServiceAddress + "/api/MachineStudio/"; + _client = new WebTransportClient(); + } + + public Task CheckForUpdates(CheckForUpdatesRequest request) + { + return _client.PostJson(address + "CheckForUpdates", request); + } + + public Task UploadVersion(UploadVersionRequest request) + { + return _client.PostJson(address + "UploadVersion", request); + } + + public Task NotifyUploadCompleted(UploadCompletedRequest request) + { + return _client.PostJson(address + "NotifyUploadCompleted", request); + } + + public Task GetLatestVersion(LatestVersionRequest request) + { + return _client.PostJson(address + "GetLatestVersion", request); + } + } +} 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 ce6096792..fc478db50 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs @@ -4,13 +4,12 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class UploadCompletedRequest + public class UploadCompletedRequest : WebRequestMessage { - [DataMember] public String Token { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.cs new file mode 100644 index 000000000..89850e3e5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedResponse.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.MachineStudio.Common.Update +{ + public class UploadCompletedResponse : WebResponseMessage + { + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs index 83739f615..c55cb9a22 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs @@ -4,28 +4,22 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class UploadVersionRequest + public class UploadVersionRequest : WebRequestMessage { - [DataMember] public String Email { get; set; } - [DataMember] public String Password { get; set; } - [DataMember] public String Version { get; set; } - [DataMember] public String Comments { get; set; } - [DataMember] public bool ForcedUpdate { get; set; } - [DataMember] public bool IsStable { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs index 36dc3df30..4d13fc6ad 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs @@ -4,28 +4,14 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using Tango.Transport.Web; namespace Tango.MachineStudio.Common.Update { - [DataContract] - public class UploadVersionResponse + public class UploadVersionResponse : WebResponseMessage { - [DataMember] - public String FtpHost { get; set; } - - [DataMember] - public String FilePath { get; set; } - - [DataMember] - public String FileName { get; set; } - - [DataMember] - public String UserName { get; set; } - - [DataMember] - public String Password { get; set; } - - [DataMember] public String Token { get; set; } + + public String BlobAddress { 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 ffeefb820..73f3f5bed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -19,6 +19,7 @@ using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Update; using Tango.Settings; using Tango.SharedUI; +using Tango.Transport.Web; namespace Tango.MachineStudio.Publisher { @@ -26,7 +27,6 @@ namespace Tango.MachineStudio.Publisher { private BasicHashGenerator _hashGenerator; private String _appPath = AppDomain.CurrentDomain.BaseDirectory + "..\\Release"; - private ChannelFactory _service; private IMachineStudioUpdateService _client; private String _email; @@ -114,14 +114,15 @@ namespace Tango.MachineStudio.Publisher public MainWindowVM() { + _client = new MachineStudioUpdateService(); + MaxProgress = 100; _hashGenerator = new BasicHashGenerator(); PublishCommand = new RelayCommand(Publish, () => Email != null && Password != null && Comments != null && CurrentVersion != null && LatestVersion != null && !IsUpdating && Version.Parse(CurrentVersion) > Version.Parse(LatestVersion)); - _service = UpdateServiceHelper.GetUpdateServiceChannel(); - _client = _service.CreateChannel(); + var client = new MachineStudioUpdateService(); UpdateVersions(); @@ -136,7 +137,7 @@ namespace Tango.MachineStudio.Publisher private void UpdateVersions() { CurrentVersion = FileVersionInfo.GetVersionInfo(_appPath + "\\Tango.MachineStudio.UI.exe").ProductVersion; - LatestVersion = _client.GetLatestVersion(); + LatestVersion = _client.GetLatestVersion(new LatestVersionRequest()).Result.Version; } private void Publish() @@ -152,7 +153,7 @@ namespace Tango.MachineStudio.Publisher Task.Factory.StartNew(() => { IsUpdating = true; - String tempFile = String.Empty; + String tempFile = TemporaryManager.CreateFile(); try { @@ -164,9 +165,7 @@ namespace Tango.MachineStudio.Publisher Comments = Comments, ForcedUpdate = ForcedUpdate, IsStable = IsStable, - }); - - tempFile = Path.Combine(Path.GetTempPath(), response.FileName); + }).Result; using (ZipFile zip = new ZipFile()) { @@ -190,28 +189,23 @@ namespace Tango.MachineStudio.Publisher Progress = 0; MaxProgress = 100; - FileStreamWrapper fs = null; - - using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) => - { - InvokeUINow(() => - { - Thread.Sleep(10); - Progress = ((double)current / (double)fs.Length) * 100d; - }); - })) + using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress,tempFile)) { - using (FtpClient ftp = new FtpClient(response.FtpHost, response.UserName, response.Password)) + uploader.Progress += (x, e) => { - ftp.ConnectAsync().Wait(); - ftp.UploadAsync(fs, response.FilePath, FtpExists.Overwrite, true).Wait(); - } + InvokeUINow(() => + { + Progress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + + uploader.Upload().Wait(); } _client.NotifyUploadCompleted(new UploadCompletedRequest() { Token = response.Token, - }); + }).Wait(); Progress = 0; UpdateVersions(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj index c462c21f4..a7e3e045b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/Tango.MachineStudio.Publisher.csproj @@ -55,6 +55,7 @@ ..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll + @@ -145,6 +146,10 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common @@ -165,7 +170,7 @@ - + \ No newline at end of file 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 b3926190f..d3c22341d 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 @@ -69,6 +69,7 @@ ..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + ..\..\packages\SimpleValidator.0.6.1.0\lib\net40\SimpleValidator.dll @@ -609,7 +610,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/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index cafd0328a..545d51ef2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -94,15 +94,15 @@ namespace Tango.MachineStudio.UI.ViewModels Status = "Checking for critical updates..."; LogManager.Log("Checking for forced update..."); - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { Email = "ForceUpdate", Password = "ForceUpdate", Version = ApplicationManager.Version.ToString(), - }); + }).Result; if (response.IsUpdateAvailable && response.ForcedUpdate) { 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 c9cd3276f..befad162c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -359,8 +359,7 @@ namespace Tango.MachineStudio.UI.ViewModels { if (_authenticationProvider.CurrentUser != null) { - var service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { @@ -368,7 +367,7 @@ namespace Tango.MachineStudio.UI.ViewModels Password = _authenticationProvider.CurrentUser.Password, Version = _applicationManager.Version.ToString(), AcceptBetaRelease = _settings.AcceptBetaRelease, - }); + }).Result; IsUpdateAvailable = response.IsUpdateAvailable; LatestVersion = response.Version; 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 a9624da2d..af197ca3b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -24,6 +24,7 @@ using Tango.SharedUI; using Tango.MachineStudio.UI.Messages; using Tango.Settings; using Tango.MachineStudio.Common; +using Tango.Transport.Web; namespace Tango.MachineStudio.UI.ViewModels { @@ -193,8 +194,7 @@ namespace Tango.MachineStudio.UI.ViewModels { Thread.Sleep(2000); - service = UpdateServiceHelper.GetUpdateServiceChannel(); - var client = service.CreateChannel(); + var client = new MachineStudioUpdateService(); CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() { @@ -202,7 +202,7 @@ namespace Tango.MachineStudio.UI.ViewModels Password = _authentication.CurrentUser.Password, Version = _application.Version.ToString(), AcceptBetaRelease = settings.AcceptBetaRelease, - }); + }).Result; if (response.IsUpdateAvailable) { @@ -260,29 +260,18 @@ namespace Tango.MachineStudio.UI.ViewModels { logManager.Log("Creating temporary file " + tempFile); - int fileSize = 0; - - using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) => - { - InvokeUINow(() => - { - Thread.Sleep(10); - DownloadProgress = ((double)current / (double)fileSize) * 100d; - }); - })) + using (StorageBlobDownloader downloader = new StorageBlobDownloader(_updateInfo.BlobAddress, tempFile.Path)) { - using (FtpClient ftp = new FtpClient(_updateInfo.FtpHost, _updateInfo.UserName, _updateInfo.Password)) + downloader.Progress += (x, e) => { - logManager.Log("Connecting to FTP site: " + _updateInfo.FtpHost); - ftp.ConnectAsync().Wait(); - logManager.Log("Retrieving download size..."); - fileSize = (int)ftp.GetFileSize(_updateInfo.FilePath); - logManager.Log("Download size: " + fileSize + " bytes."); - logManager.Log("Starting download..."); - ftp.DownloadAsync(fs, _updateInfo.FilePath).Wait(); - } - } + InvokeUINow(() => + { + DownloadProgress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + downloader.Download().Wait(); + } Status = UpdateStatus.Updating; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs index 881403ea8..4e7dd304e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs @@ -26,6 +26,7 @@ using Tango.PPC.Common.Update; using Tango.Settings; using Tango.SharedUI; using Tango.SQLExaminer; +using Tango.Transport.Web; namespace Tango.PPC.Publisher { @@ -234,20 +235,18 @@ namespace Tango.PPC.Publisher Progress = 0; MaxProgress = 100; - CloudBlockBlob blob = new CloudBlockBlob(new Uri(response.BlobAddress)); - - FileStreamWrapper fs = null; - - using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) => + using (StorageBlobUploader uploader = new StorageBlobUploader(response.BlobAddress, tempFile)) { - InvokeUINow(() => + uploader.Progress += (x, e) => { - Thread.Sleep(10); - Progress = ((double)current / (double)fs.Length) * 100d; - }); - })) - { - await blob.UploadFromStreamAsync(fs); + InvokeUINow(() => + { + Thread.Sleep(10); + Progress = ((double)e.Current / (double)e.Total) * 100d; + }); + }; + + await uploader.Upload(); } await _client.NotifyUploadCompleted(new UploadCompletedRequest() @@ -277,7 +276,7 @@ namespace Tango.PPC.Publisher dlg.DefaultExt = ".tup"; if (dlg.ShowDialog().Value) { - Task.Factory.StartNew(() => + Task.Factory.StartNew(() => { try { 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 ef692809f..9a4b8b595 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 @@ -144,6 +144,10 @@ {e1e66ed9-597d-45fa-8048-de90a6930484} Tango.SQLExaminer + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common diff --git a/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs b/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs index 3167b3ccf..cc1425529 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/MachineStudioVersion.cs @@ -27,7 +27,7 @@ namespace Tango.BL.Entities public event EventHandler VersionChanged; - public event EventHandler FtpFilePathChanged; + public event EventHandler BlobNameChanged; public event EventHandler CommentsChanged; @@ -65,30 +65,30 @@ namespace Tango.BL.Entities } } - protected String _ftpfilepath; + protected String _blobname; /// - /// Gets or sets the machinestudioversion ftp file path. + /// Gets or sets the machinestudioversion blob name. /// - [Column("FTP_FILE_PATH")] + [Column("BLOB_NAME")] - public String FtpFilePath + public String BlobName { get { - return _ftpfilepath; + return _blobname; } set { - if (_ftpfilepath != value) + if (_blobname != value) { - _ftpfilepath = value; + _blobname = value; - FtpFilePathChanged?.Invoke(this, value); + BlobNameChanged?.Invoke(this, value); - RaisePropertyChanged(nameof(FtpFilePath)); + RaisePropertyChanged(nameof(BlobName)); } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs index eed787485..a4f10de26 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE_STUDIO_VERSIONS.cs @@ -18,7 +18,7 @@ namespace Tango.DAL.Remote.DB public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } public string VERSION { get; set; } - public string FTP_FILE_PATH { get; set; } + public string BLOB_NAME { get; set; } public string COMMENTS { get; set; } public string USER_GUID { get; set; } public bool FORCE_UPDATE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 7a01d5db8..86cf4ed6a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -669,7 +669,7 @@ - + @@ -3757,7 +3757,7 @@ - + @@ -6032,7 +6032,7 @@ - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index c16e38955..cf9ff4f22 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,81 +5,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + + + + + + diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 02e5381ee..4e677a041 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -34,6 +34,7 @@ ..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll @@ -111,6 +112,9 @@ + + + diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs new file mode 100644 index 000000000..603463823 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs @@ -0,0 +1,65 @@ +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.IO; + +namespace Tango.Transport.Web +{ + public class StorageBlobDownloader : IDisposable + { + private bool _disposed; + private FileStreamWrapper _stream; + private long _fileSize; + + public CloudBlockBlob Blob { get; private set; } + + public event EventHandler Progress; + + public StorageBlobDownloader(CloudBlockBlob blob, String fileName) + { + Blob = blob; + _stream = new FileStreamWrapper(fileName, FileMode.Create, OnProgress); + } + + public StorageBlobDownloader(String blobAddress, String fileName) : this(new CloudBlockBlob(new Uri(blobAddress)), fileName) + { + + } + + private void OnProgress(long current) + { + Progress?.Invoke(this, new StorageBlobProgressEventArgs() + { + Current = current, + Total = _fileSize, + }); + } + + public async Task Download() + { + if (_disposed) + { + throw new ObjectDisposedException("The storage blob downloader can only be used once."); + } + + await Blob.FetchAttributesAsync(); + _fileSize = Blob.Properties.Length; + + await Blob.DownloadToStreamAsync(_stream); + Dispose(); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + _stream.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs new file mode 100644 index 000000000..ae48e34cf --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobProgressEventArgs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Transport.Web +{ + public class StorageBlobProgressEventArgs : EventArgs + { + public long Total { get; set; } + public long Current { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs new file mode 100644 index 000000000..8d645f33f --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobUploader.cs @@ -0,0 +1,61 @@ +using Microsoft.WindowsAzure.Storage.Blob; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.IO; + +namespace Tango.Transport.Web +{ + public class StorageBlobUploader : IDisposable + { + private bool _disposed; + private FileStreamWrapper _stream; + + public CloudBlockBlob Blob { get; private set; } + + public event EventHandler Progress; + + public StorageBlobUploader(CloudBlockBlob blob, String fileName) + { + Blob = blob; + _stream = new FileStreamWrapper(fileName, FileMode.Open, OnProgress); + } + + public StorageBlobUploader(String blobAddress, String fileName) : this(new CloudBlockBlob(new Uri(blobAddress)), fileName) + { + + } + + private void OnProgress(long current) + { + Progress?.Invoke(this, new StorageBlobProgressEventArgs() + { + Current = current, + Total = _stream.Length, + }); + } + + public async Task Upload() + { + if (_disposed) + { + throw new ObjectDisposedException("The storage blob uploader can only be used once."); + } + + await Blob.UploadFromStreamAsync(_stream); + Dispose(); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + _stream.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs new file mode 100644 index 000000000..245c18b9b --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/MachineStudioController.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Web.Http; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.MachineService.Helpers; +using Tango.MachineService.Models; +using Tango.MachineStudio.Common.Update; + +namespace Tango.MachineService.Controllers +{ + public class MachineStudioController : JsonController + { + private static List _pendingUploads; + + static MachineStudioController() + { + _pendingUploads = new List(); + } + + [HttpPost] + public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request) + { + LogManager.Log("Request received..."); + + CheckForUpdatesResponse response = new CheckForUpdatesResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + //Load relation first... + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null && user.HasPermission(Permissions.RunMachineStudio) || (request.Email == "ForceUpdate")) + { + var versions = db.MachineStudioVersions.ToList(); + + MachineStudioVersion latestVersion = null; + + if (request.AcceptBetaRelease) + { + latestVersion = versions.OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + } + else + { + latestVersion = versions.Where(x => x.Stable).OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + } + + Version currentVersion = Version.Parse(request.Version); + + bool isForcedUpdate = versions.Exists(x => x.ForceUpdate && Version.Parse(x.Version) > currentVersion); + + String comments = String.Join(Environment.NewLine, versions.OrderBy(x => Version.Parse(x.Version)).Where(x => Version.Parse(x.Version) > currentVersion).Select(x => x.Comments)); + + if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersion) + { + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetMachineStudioVersionsContainer(client); + var blob = container.GetBlockBlobReference(latestVersion.BlobName); + + response.BlobAddress = StorageHelper.GenerateBlobReadSignature(blob, TimeSpan.FromMinutes(60)); + + response.IsUpdateAvailable = true; + response.Version = latestVersion.Version; + response.Comments = latestVersion.Comments; + response.ForcedUpdate = isForcedUpdate; + response.IsStable = latestVersion.Stable; + } + } + else + { + throw new AuthenticationException("Invalid user credentials."); + } + } + + return response; + } + + [HttpPost] + public UploadVersionResponse UploadVersion(UploadVersionRequest request) + { + UploadVersionResponse response = new UploadVersionResponse(); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + //Load relation first... + db.Roles.ToList(); + db.Permissions.ToList(); + db.UsersRoles.ToList(); + db.RolesPermissions.ToList(); + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null && user.HasPermission(Permissions.PublishMachineStudioVersion)) + { + var latestVersion = db.MachineStudioVersions.ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + Version currentVersion = Version.Parse(request.Version); + + if (latestVersion == null || currentVersion > Version.Parse(latestVersion.Version)) + { + String newVersionFileName = "Machine Studio Version" + " " + currentVersion.ToString() + ".zip"; + + var client = StorageHelper.GetStorageBlobClient(); + var container = StorageHelper.GetMachineStudioVersionsContainer(client); + var blob = StorageHelper.CreateEmptyBlob(container, newVersionFileName); + + response.Token = Guid.NewGuid().ToString(); + response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); + + _pendingUploads.Add(new MachineStudioPendingUpload() + { + UserGuid = user.Guid, + Comments = request.Comments, + ForcedUpdate = request.ForcedUpdate, + Token = response.Token, + Version = request.Version, + IsStable = request.IsStable, + BlobName = blob.Name, + }); + } + else + { + throw new ArgumentException("New version must be greater than latest version."); + } + } + else + { + throw new AuthenticationException("Invalid user credentials."); + } + } + + return response; + } + + [HttpPost] + public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) + { + MachineStudioPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + + if (upload != null) + { + _pendingUploads.RemoveAll(x => x.Token == upload.Token); + + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + db.MachineStudioVersions.Add(new MachineStudioVersion() + { + Comments = upload.Comments, + BlobName = upload.BlobName, + UserGuid = upload.UserGuid, + Version = upload.Version, + ForceUpdate = upload.ForcedUpdate, + Stable = upload.IsStable, + }); + + db.SaveChanges(); + } + + return new UploadCompletedResponse(); + } + else + { + throw new ArgumentException("Invalid Token."); + } + } + + [HttpPost] + public LatestVersionResponse GetLatestVersion(LatestVersionRequest request) + { + using (ObservablesContext db = ObservablesContextHelper.CreateContext()) + { + var version = db.MachineStudioVersions.ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); + return new LatestVersionResponse() { Version = version != null ? version.Version : "0.0.0.0" }; + } + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 45396e47a..9ce22bbb0 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -37,13 +37,13 @@ namespace Tango.MachineService.Controllers { public class PPCController : JsonController { - private static List _pendingUploads; + private static List _pendingUploads; #region Constructors static PPCController() { - _pendingUploads = new List(); + _pendingUploads = new List(); } #endregion @@ -315,7 +315,7 @@ namespace Tango.MachineService.Controllers response.Token = Guid.NewGuid().ToString(); response.BlobAddress = StorageHelper.GenerateBlobWriteSignature(blob, TimeSpan.FromMinutes(30)); - _pendingUploads.Add(new PendingUpload() + _pendingUploads.Add(new PPCPendingUpload() { UserGuid = user.Guid, Comments = request.Comments, @@ -342,7 +342,7 @@ namespace Tango.MachineService.Controllers [HttpPost] public UploadCompletedResponse NotifyUploadCompleted(UploadCompletedRequest request) { - PendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); + PPCPendingUpload upload = _pendingUploads.FirstOrDefault(x => x.Token == request.Token); if (upload != null) { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs index 04d5bbffe..a2cc2a0dc 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Helpers/StorageHelper.cs @@ -24,6 +24,12 @@ namespace Tango.MachineService.Helpers return container; } + public static CloudBlobContainer GetMachineStudioVersionsContainer(CloudBlobClient client) + { + var container = client.GetContainerReference("machine-studio-versions"); + return container; + } + public static CloudBlockBlob CreateEmptyBlob(CloudBlobContainer container, String name) { CloudBlockBlob emptyBlob = container.GetBlockBlobReference(name); diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs new file mode 100644 index 000000000..0347d35ea --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Models/MachineStudioPendingUpload.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.MachineService.Models +{ + public class MachineStudioPendingUpload + { + public String Token { get; set; } + + public String Version { get; set; } + + public String UserGuid { get; set; } + + public String Comments { get; set; } + + public bool ForcedUpdate { get; set; } + + public String FilePath { get; set; } + + public bool IsStable { get; set; } + + public String BlobName { get; set; } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs new file mode 100644 index 000000000..10797e758 --- /dev/null +++ b/Software/Visual_Studio/Web/Tango.MachineService/Models/PPCPendingUpload.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.MachineService.Models +{ + public class PPCPendingUpload + { + public String Token { get; set; } + + public String Version { get; set; } + + public String UserGuid { get; set; } + + public String Comments { get; set; } + + public String MachineVersionGuid { get; set; } + + public String BlobName { get; set; } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs b/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs deleted file mode 100644 index f18b3756a..000000000 --- a/Software/Visual_Studio/Web/Tango.MachineService/Models/PendingUpload.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Tango.MachineService.Models -{ - public class PendingUpload - { - public String Token { get; set; } - - public String Version { get; set; } - - public String UserGuid { get; set; } - - public String Comments { get; set; } - - public String MachineVersionGuid { get; set; } - - public String BlobName { 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 acb4ad84e..c6245e18e 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -270,11 +270,13 @@ + - + + @@ -305,6 +307,10 @@ + + {CB0B0AA2-BB24-4BCA-A720-45E397684E12} + Tango.MachineStudio.Common + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common -- cgit v1.3.1 From fbf514c96a53c464019290da0412410989dfb3d1 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 17:54:36 +0200 Subject: Improved RML Builder loading time.. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 20578304 -> 20578304 bytes .../ViewModels/MainViewVM.cs | 2 +- .../ViewModels/MainViewVM.cs | 1 - .../Visual_Studio/Tango.BL/Builders/RmlBuilder.cs | 34 +++++++++------------ 5 files changed, 15 insertions(+), 22 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index c5ed078e6..29c02c4ab 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 9f4498621..1c5b90031 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/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 55ef56ce4..12f69ba7f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1482,7 +1482,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().WithMediaProperties().Build(); + _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); if (_selectedRML.Ccts.Count == 0) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index ef6fc816b..f8966b729 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -206,7 +206,6 @@ namespace Tango.MachineStudio.RML.ViewModels .Set(guid) .WithActiveParametersGroup() .WithLiquidFactors() - .WithMediaProperties() .BuildAsync(); if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) diff --git a/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs index a67a2cf7a..7b5d9b7ff 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RmlBuilder.cs @@ -16,16 +16,24 @@ namespace Tango.BL.Builders } + protected override IQueryable OnSetQuery(IQueryable query) + { + return query. + Include(x => x.MediaMaterial). + Include(x => x.MediaColor). + Include(x => x.MediaPurpose). + Include(x => x.MediaCondition). + Include(x => x.LinearMassDensityUnit). + Include(x => x.FiberShape). + Include(x => x.FiberSynth); + } + public virtual RmlBuilder WithAllParametersGroup() { return AddStep(1, () => { - var groups = Context.ProcessParametersTablesGroups.Where(x => x.RmlGuid == Entity.Guid).ToList(); - - foreach (var group in groups) - { - Context.ProcessParametersTables.Where(x => x.ProcessParametersTablesGroupGuid == group.Guid).OrderBy(x => x.TableIndex).ToList(); - } + Context.ProcessParametersTablesGroups.Where(x => x.RmlGuid == Entity.Guid).ToList(); + Context.ProcessParametersTables.Where(x => x.ProcessParametersTablesGroup.RmlGuid == Entity.Guid).OrderBy(x => x.TableIndex).ToList(); }); } @@ -65,19 +73,5 @@ namespace Tango.BL.Builders Context.LiquidTypesRmls.Where(x => x.RmlGuid == Entity.Guid).Include(x => x.LiquidType).OrderBy(x => x.LiquidType.Code).ToList(); }); } - - public virtual RmlBuilder WithMediaProperties() - { - return AddStep(6, () => - { - Context.MediaMaterials.SingleOrDefault(x => x.Guid == Entity.MediaMaterialGuid); - Context.MediaColors.SingleOrDefault(x => x.Guid == Entity.MediaColorGuid); - Context.MediaPurposes.SingleOrDefault(x => x.Guid == Entity.MediaPurposeGuid); - Context.MediaConditions.SingleOrDefault(x => x.Guid == Entity.MediaConditionGuid); - Context.LinearMassDensityUnits.SingleOrDefault(x => x.Guid == Entity.LinearMassDensityUnitGuid); - Context.FiberShapes.SingleOrDefault(x => x.Guid == Entity.FiberShapeGuid); - Context.FiberSynths.SingleOrDefault(x => x.Guid == Entity.FiberSynthGuid); - }); - } } } -- cgit v1.3.1 From 59839a4cf53ce9ef07348926d9cf5f8e8d020c91 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 18:08:24 +0200 Subject: Improved Job Builder speed. --- .../Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs | 9 ++++++++- Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs | 5 +---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 12f69ba7f..333a31802 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1482,7 +1482,14 @@ namespace Tango.MachineStudio.Developer.ViewModels { LogManager.Log("Invalidating liquid factors, process parameters and process group history..."); - _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); + if (_selectedRML != ActiveJob.Rml) + { + _selectedRML = new RmlBuilder(_activeJobDbContext).Set(SelectedRML).WithAllParametersGroup().WithCAT(SelectedMachine.Guid).WithCCT().WithLiquidFactors().Build(); + } + else + { + _selectedRML = ActiveJob.Rml; + } if (_selectedRML.Ccts.Count == 0) { diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs index da418a990..3b0d1b0e1 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs @@ -39,10 +39,7 @@ namespace Tango.BL.Builders { return AddStep(2, () => { - foreach (var segment in Entity.Segments.ToList()) - { - Context.BrushStops.Where(x => x.SegmentGuid == segment.Guid).Include(x => x.ColorSpace).Include(x => x.ColorCatalog).OrderBy(x => x.StopIndex).ToList(); - } + Context.BrushStops.Where(x => x.Segment.JobGuid == Entity.Guid).Include(x => x.ColorSpace).Include(x => x.ColorCatalog).OrderBy(x => x.StopIndex).ToList(); }); } -- cgit v1.3.1 From cf8bc0e91d375eecb206cfe70fa43b153a1b5860 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 19 Dec 2018 18:13:00 +0200 Subject: Redundant. --- .../Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs | 9 --------- 1 file changed, 9 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio') 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 af197ca3b..3fec96629 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -186,8 +186,6 @@ namespace Tango.MachineStudio.UI.ViewModels var settings = SettingsManager.Default.GetOrCreate(); - ChannelFactory service = null; - Task.Factory.StartNew(() => { try @@ -221,13 +219,6 @@ namespace Tango.MachineStudio.UI.ViewModels logManager.Log(ex, "Error while checking for version update!"); Status = UpdateStatus.Error; } - finally - { - if (service != null) - { - service.Close(); - } - } }); } -- cgit v1.3.1