From 9277bbd2fa070c69b83904f8fe5628fab2b947b8 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 25 Nov 2018 17:52:49 +0200 Subject: Working on job export import to storage. --- .../MachineUpdate/IMachineUpdateManager.cs | 7 +++++ .../MachineUpdate/MachineUpdateManager.cs | 34 ++++++++++++++++++++++ .../MachineUpdate/MachineUpdateSteps.cs | 3 +- 3 files changed, 43 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs index d2be997b5..13752b931 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs @@ -42,6 +42,13 @@ namespace Tango.PPC.Common.MachineUpdate /// Task Update(String serialNumber, String machineServiceAddress); + /// + /// Performs a machine update using the specified software update package path. + /// + /// Name of the file. + /// + Task Update(String fileName); + /// /// Checks if any update are available for the specified machine serial number. /// 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 a75ca9017..d3757e50d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -445,6 +445,40 @@ namespace Tango.PPC.Common.MachineUpdate }); } + /// + /// Performs a machine update using the specified software update package path. + /// + /// Name of the file. + /// + public Task Update(string fileName) + { + return Task.Factory.StartNew(() => + { + CurrentStep = MachineUpdateSteps.UpdatingFromPackage; + + LogManager.Log($"Starting machine update from update package '{fileName}'..."); + + //Create temporary folders for packages. + var _newPackageTempFolder = TemporaryManager.CreateFolder(); + _newPackageTempFolder.Persist = true; + + LogManager.Log("Extracting downloaded zip file..."); + //Extract software package. + ZipFile.ExtractToDirectory(fileName, _newPackageTempFolder); + + LogManager.Log("Copying latest updater utility to application path..."); + //Copy new updater utility to app path. + File.Copy(Path.Combine(_newPackageTempFolder, "Tango.PPC.Updater.exe"), Path.Combine(PathHelper.GetStartupPath(), "Tango.PPC.Updater.exe"), true); + + LogManager.Log("Update operation completed!"); + + return new MachineUpdateResult() + { + UpdatePackagePath = _newPackageTempFolder, + }; + }); + } + #endregion } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateSteps.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateSteps.cs index 3d8208e4b..74931d2d4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateSteps.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateSteps.cs @@ -16,6 +16,7 @@ namespace Tango.PPC.Common.MachineUpdate [Description("Synchronizing Data")] SynchronizingData, [Description("Updating Configuration")] - SynchronizingMachineConfiguration + SynchronizingMachineConfiguration, + UpdatingFromPackage } } -- cgit v1.3.1