From 9447a8a09f87d6ea2cb62860021c595386668eec Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 20 Feb 2019 22:55:15 +0200 Subject: A lot of work !!! --- .../PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs') 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 8b9aede87..6fd53bce2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -130,6 +130,7 @@ namespace Tango.PPC.Common.MachineUpdate await Login(serialNumber); DownloadUpdateRequest request = new DownloadUpdateRequest(); + request.SerialNumber = serialNumber; DownloadUpdateResponse update_response = null; @@ -298,6 +299,7 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Checking if updates available..."); CheckForUpdateRequest request = new CheckForUpdateRequest(); + request.SerialNumber = serialNumber; request.Version = _app_manager.Version.ToString(); CheckForUpdateResponse update_response = null; @@ -408,6 +410,7 @@ namespace Tango.PPC.Common.MachineUpdate Login(serialNumber).Wait(); UpdateDBRequest request = new UpdateDBRequest(); + request.SerialNumber = serialNumber; UpdateDBResponse update_response = null; -- cgit v1.3.1 From 40746c60fed9e70f3cb7f6f12f55595a77a1adfa Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 24 Feb 2019 19:04:47 +0200 Subject: Fixed PPC and Machine Studio issues before next release. Started working on Advanced Installer libraries. --- .../SQLExaminer Projects/Override Tables.sdeproj | 5 - .../SQLExaminer Projects/Provision Machine.sdeproj | 14 -- .../DB/SQLExaminer Projects/UpdateMachine.sdeproj | 5 - Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Machine Studio Installer.aip | 37 +++-- .../PPC Installer-cache/cacheIndex.txt | Bin 52 -> 52 bytes .../part2/PPC Installer v1.0.81.cab | Bin 36577575 -> 0 bytes .../PPC Installer-cache/part2/output-info.ini | Bin 92516 -> 0 bytes .../part4/PPC Installer v1.0.31.cab | Bin 0 -> 30142081 bytes .../PPC Installer-cache/part4/output-info.ini | Bin 0 -> 76376 bytes .../Advanced Installer Projects/PPC Installer.aip | 107 ++----------- .../Build/Shortcuts/Machine Studio.lnk | Bin 1516 -> 1532 bytes .../Application/IPPCApplicationManager.cs | 5 + .../HotSpot/DefaultHotSpotProvider.cs | 2 +- .../MachineUpdate/IMachineUpdateManager.cs | 2 +- .../MachineUpdate/MachineUpdateManager.cs | 167 ++++++++++++--------- .../OS/DefaultOperationSystemManager.cs | 13 +- .../DefaultRemoteAssistanceProvider.cs | 2 +- .../PPC/Tango.PPC.Common/Scripting/CmdCommand.cs | 90 ----------- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 7 +- .../UWF/DefaultUnifiedWriteFilterManager.cs | 11 +- Software/Visual_Studio/PPC/Tango.PPC.UI/App.config | 80 ---------- .../Connectivity/DefaultConnectivityProvider.cs | 1 - .../PPCApplication/DefaultPPCApplicationManager.cs | 29 +++- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs | 8 +- .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 10 +- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.AdvancedInstaller/InstallerBuilder.cs | 44 ++++++ .../Tango.AdvancedInstaller/PackageType.cs | 14 ++ .../Properties/AssemblyInfo.cs | 7 + .../Tango.AdvancedInstaller/ReturnCodes.cs | 45 ++++++ .../Tango.AdvancedInstaller.csproj | 59 ++++++++ .../Tango.Core/Components/CmdCommand.cs | 94 ++++++++++++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 3 +- .../Configurations/ProvisionMachine.xml | Bin 73156 -> 72322 bytes .../AdvancedInstaller/AdvancedInstaller_TST.cs | 45 ++++++ .../AdvancedInstaller/DemoProject/DemoProject.aip | 142 ++++++++++++++++++ .../AdvancedInstaller/DemoProject/Files/File1.txt | 1 + .../AdvancedInstaller/DemoProject/Files/File2.txt | 1 + .../AdvancedInstaller/DemoProject/Files/File3.txt | 1 + .../Tango.UnitTesting/Tango.UnitTesting.csproj | 22 ++- Software/Visual_Studio/Tango.sln | 54 ++++++- 44 files changed, 717 insertions(+), 414 deletions(-) delete mode 100644 Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/PPC Installer v1.0.81.cab delete mode 100644 Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/output-info.ini create mode 100644 Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/PPC Installer v1.0.31.cab create mode 100644 Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/output-info.ini delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs create mode 100644 Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs create mode 100644 Software/Visual_Studio/Tango.AdvancedInstaller/PackageType.cs create mode 100644 Software/Visual_Studio/Tango.AdvancedInstaller/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Tango.AdvancedInstaller/ReturnCodes.cs create mode 100644 Software/Visual_Studio/Tango.AdvancedInstaller/Tango.AdvancedInstaller.csproj create mode 100644 Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs create mode 100644 Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/AdvancedInstaller_TST.cs create mode 100644 Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/DemoProject.aip create mode 100644 Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File1.txt create mode 100644 Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File2.txt create mode 100644 Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File3.txt (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs') diff --git a/Software/DB/SQLExaminer Projects/Override Tables.sdeproj b/Software/DB/SQLExaminer Projects/Override Tables.sdeproj index 26173fa4f..742eeeab4 100644 --- a/Software/DB/SQLExaminer Projects/Override Tables.sdeproj +++ b/Software/DB/SQLExaminer Projects/Override Tables.sdeproj @@ -23,7 +23,6 @@ - @@ -187,7 +186,6 @@ - @@ -603,8 +601,6 @@ - - @@ -962,7 +958,6 @@ - diff --git a/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj b/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj index 735f79ec2..2d978092e 100644 --- a/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj +++ b/Software/DB/SQLExaminer Projects/Provision Machine.sdeproj @@ -23,7 +23,6 @@ - @@ -187,7 +186,6 @@ - @@ -603,8 +601,6 @@ - - @@ -962,7 +958,6 @@ - @@ -982,7 +977,6 @@ - @@ -1012,7 +1006,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1044,7 +1037,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1193,7 +1185,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1222,7 +1213,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1253,7 +1243,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1722,7 +1711,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1747,7 +1735,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - @@ -1774,7 +1761,6 @@ WHERE MACHINES.SERIAL_NUMBER = '@' - diff --git a/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj b/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj index ba3752fff..316867f86 100644 --- a/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj +++ b/Software/DB/SQLExaminer Projects/UpdateMachine.sdeproj @@ -23,7 +23,6 @@ - @@ -187,7 +186,6 @@ - @@ -603,8 +601,6 @@ - - @@ -962,7 +958,6 @@ - diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index a50e98776..19a7f9e56 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 63616d500..71bdb175e 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip index 46b47ce70..c55783488 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip @@ -10,17 +10,15 @@ - - - + - + - + @@ -61,6 +59,7 @@ + @@ -105,6 +104,7 @@ + @@ -279,16 +279,13 @@ - - - - + @@ -315,6 +312,8 @@ + + @@ -576,7 +575,7 @@ - + @@ -667,7 +666,7 @@ - + @@ -679,9 +678,6 @@ - - - @@ -700,7 +696,7 @@ - + @@ -712,6 +708,7 @@ + @@ -747,7 +744,6 @@ - @@ -770,10 +766,14 @@ + + + + @@ -832,10 +832,10 @@ - - + + @@ -853,7 +853,6 @@ - diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt index a603ff06b..6d87e9201 100644 Binary files a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt and b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/cacheIndex.txt differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/PPC Installer v1.0.81.cab b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/PPC Installer v1.0.81.cab deleted file mode 100644 index d5ef54e45..000000000 Binary files a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/PPC Installer v1.0.81.cab and /dev/null differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/output-info.ini b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/output-info.ini deleted file mode 100644 index 004bb1282..000000000 Binary files a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part2/output-info.ini and /dev/null differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/PPC Installer v1.0.31.cab b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/PPC Installer v1.0.31.cab new file mode 100644 index 000000000..34a8833fd Binary files /dev/null and b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/PPC Installer v1.0.31.cab differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/output-info.ini b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/output-info.ini new file mode 100644 index 000000000..fc3b9bfe0 Binary files /dev/null and b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache/part4/output-info.ini differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 77edcf7d0..b1484077e 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -18,10 +18,10 @@ - + - + @@ -50,7 +50,7 @@ - + @@ -66,22 +66,15 @@ + - - - - - - - - @@ -108,7 +101,6 @@ - @@ -128,46 +120,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -203,19 +169,15 @@ - - - - + - - + @@ -242,26 +204,19 @@ + + - - - - - - - - - @@ -305,17 +260,15 @@ - - - + @@ -329,26 +282,15 @@ - + - - - - - - - - - - - @@ -362,28 +304,13 @@ - - - - - - - - - - - - - - - @@ -478,20 +405,9 @@ - - - - - - - - - - - @@ -503,7 +419,7 @@ - + @@ -571,6 +487,7 @@ + diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index 34b13a9c4..d8c2c376b 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/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index f07ba39a9..7769c74f6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -65,6 +65,11 @@ namespace Tango.PPC.Common.Application /// void Restart(); + /// + /// Runs the updater utility and exits the application. + /// + void UpdateApplication(String updaterPath, String arguments); + /// /// Enteres the application technician mode. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs index 5a6b2405c..4f035d814 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; +using Tango.Core.Components; using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; -using Tango.PPC.Common.Scripting; using Tango.Settings; namespace Tango.PPC.Common.HotSpot 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 ffe3f6b5c..e6c91ec10 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs @@ -54,7 +54,7 @@ namespace Tango.PPC.Common.MachineUpdate /// Updates all the "overwrite-able" database tables. /// /// - Task UpdateDB(DbCompareResult dbCompareResult); + Task UpdateDB(DbCompareResult dbCompareResult, String serialNumber); /// /// Gets the update package file information. 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 6fd53bce2..2a53d765e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -203,7 +203,7 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Initializing {nameof(ExaminerSequenceConfigurationRunner)}..."); - UpdateProgress("Updating Database", "Initializing provisioning sequence..."); + UpdateProgress("Updating Database", "Initializing update sequence..."); ExaminerSequenceConfigurationRunner runner = new ExaminerSequenceConfigurationRunner( Path.Combine(_newPackageTempFolder, "Update Scripts", "config.xml"), @@ -318,62 +318,70 @@ namespace Tango.PPC.Common.MachineUpdate /// The serial number. /// The machine service address. /// - public Task UpdateDB(DbCompareResult dbCompareResult) + public Task UpdateDB(DbCompareResult dbCompareResult, String serialNumber) { return Task.Factory.StartNew(() => { LogManager.Log("Starting database update..."); - LogManager.Log("Looking for OverrideData script on application path..."); + LogManager.Log("Looking for update scripts configuration on application path..."); - String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "OverrideData.xml"); + String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "config.xml"); if (!File.Exists(config_file)) { - config_file = Path.Combine(PathHelper.GetStartupPath(), "Provision Scripts", "OverrideData.xml"); - } - - if (!File.Exists(config_file)) - { - throw LogManager.Log(new FileNotFoundException("Could not locate OverrideData.xml file on application folder.")); + throw LogManager.Log(new FileNotFoundException($"Could not locate '{config_file}' file on application folder.")); } UpdateDBResponse update_response = dbCompareResult.UpdateDBResponse; var localDataSource = SettingsManager.Default.GetOrCreate().DataSource; - LogManager.Log($"Overriding database static tables '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); + LogManager.Log($"Updating database '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); - ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(config_file); - builder.SetSource(update_response.DataSource); - builder.SetTarget(localDataSource); - builder.Synchronize(); + ExaminerSequenceConfiguration config_sequence = ExaminerSequenceConfiguration.FromFile(config_file); - var config = builder.Build(); - - ExaminerProcess process = new ExaminerProcess(config, ExaminerProcessType.Data); - process.Progress += (x, msg) => + foreach (var item in config_sequence.Items.Where(x => x.Type == ExaminerSequenceItemType.Data).OrderBy(x => x.Index)) { - LogManager.Log(msg); - }; + LogManager.Log($"Executing update script '{item.FileName}...'"); - LogManager.Log("Starting synchronization process..."); - - try - { - var result = process.Execute().Result; + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(Path.Combine(Path.GetDirectoryName(config_file), item.FileName)); + builder.SetSource(update_response.DataSource); + builder.SetTarget(localDataSource); - if (result.ExitCode != ExaminerProcessExitCode.Success) + if (item.RequiresSerialNumber) { - throw LogManager.Log(new InvalidDataException(String.Format("OverrideData script has terminated with exit code '{0}'.", result.ExitCode))); + builder.SetMachineSerialNumber(serialNumber); } - LogManager.Log("Synchronization completed successfully!"); - } - catch (Exception ex) - { - throw LogManager.Log(ex, "Setup manager error while trying to update the database."); + builder.Synchronize(); + + var config = builder.Build(); + + ExaminerProcess process = new ExaminerProcess(config, ExaminerProcessType.Data); + process.Progress += (x, msg) => + { + LogManager.Log(msg); + }; + + try + { + var result = process.Execute().Result; + + if (result.ExitCode != ExaminerProcessExitCode.Success) + { + throw LogManager.Log(new InvalidDataException(String.Format("OverrideData script has terminated with exit code '{0}'.", result.ExitCode))); + } + + LogManager.Log("Script executed successfully."); + } + catch (Exception ex) + { + throw LogManager.Log(ex, "Setup manager error while trying to update the database."); + } } + + LogManager.Log("Update completed successfully."); }); } @@ -391,18 +399,13 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Checking if database update is required for serial number {serialNumber}..."); - LogManager.Log("Looking for OverrideData script on application path..."); + LogManager.Log("Looking for update scripts configuration on application path..."); - String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "OverrideData.xml"); + String config_file = Path.Combine(PathHelper.GetStartupPath(), "Update Scripts", "config.xml"); if (!File.Exists(config_file)) { - config_file = Path.Combine(PathHelper.GetStartupPath(), "Provision Scripts", "OverrideData.xml"); - } - - if (!File.Exists(config_file)) - { - throw LogManager.Log(new FileNotFoundException("Could not locate OverrideData.xml file on application folder.")); + throw LogManager.Log(new FileNotFoundException($"Could not locate '{config_file}' file on application folder.")); } LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); @@ -420,53 +423,75 @@ namespace Tango.PPC.Common.MachineUpdate var localDataSource = SettingsManager.Default.GetOrCreate().DataSource; - LogManager.Log($"Comparing database static tables '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); + LogManager.Log($"Comparing database '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); var report_file = TemporaryManager.CreateFile(".xml"); - ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(config_file); - builder.SetSource(update_response.DataSource); - builder.SetTarget(localDataSource); - builder.SetReportFile(report_file); + ExaminerSequenceConfiguration config_sequence = ExaminerSequenceConfiguration.FromFile(config_file); - var config = builder.Build(); + bool has_differences = false; - ExaminerProcess process = new ExaminerProcess(config, ExaminerProcessType.Data); - process.Progress += (x, msg) => + foreach (var item in config_sequence.Items.Where(x => x.Type == ExaminerSequenceItemType.Data).OrderBy(x => x.Index)) { - LogManager.Log(msg); - }; + LogManager.Log($"Executing update script '{item.FileName}...'"); - LogManager.Log("Starting comparison process..."); - LogManager.Log("Generating report on " + report_file); + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(Path.Combine(Path.GetDirectoryName(config_file), item.FileName)); + builder.SetSource(update_response.DataSource); + builder.SetTarget(localDataSource); + builder.SetReportFile(report_file); - try - { - var result = process.Execute().Result; - - if (result.ExitCode != ExaminerProcessExitCode.Success) + if (item.RequiresSerialNumber) { - throw LogManager.Log(new InvalidDataException(String.Format("OverrideData script has terminated with exit code '{0}'.", result.ExitCode))); + builder.SetMachineSerialNumber(serialNumber); } - LogManager.Log("Comparison completed successfully!"); - LogManager.Log("Loading report file..."); + var config = builder.Build(); - ExaminerDataReport report = ExaminerDataReport.FromFile(report_file); - report_file.Delete(); + ExaminerProcess process = new ExaminerProcess(config, ExaminerProcessType.Data); + process.Progress += (x, msg) => + { + LogManager.Log(msg); + }; - LogManager.Log("Comparison summary: \n" + report.Totals.ToJsonString()); + LogManager.Log("Starting comparison process..."); + LogManager.Log("Generating report on " + report_file); - return new DbCompareResult() + try { - RequiresUpdate = report.HasDifferences, - UpdateDBResponse = update_response, - }; + var result = process.Execute().Result; + + if (result.ExitCode != ExaminerProcessExitCode.Success) + { + throw LogManager.Log(new InvalidDataException(String.Format("Update script has terminated with exit code '{0}'.", result.ExitCode))); + } + + LogManager.Log("Comparison completed successfully!"); + LogManager.Log("Loading report file..."); + + ExaminerDataReport report = ExaminerDataReport.FromFile(report_file); + report_file.Delete(); + + LogManager.Log("Comparison summary: \n" + report.Totals.ToJsonString()); + + if (report.HasDifferences) + { + has_differences = true; + break; + } + } + catch (Exception ex) + { + throw LogManager.Log(ex, "Update manager error while trying to compare the database."); + } } - catch (Exception ex) + + LogManager.Log("Comparison completed successfully."); + + return new DbCompareResult() { - throw LogManager.Log(ex, "Update manager error while trying to compare the database."); - } + RequiresUpdate = has_differences, + UpdateDBResponse = update_response, + }; }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index 650cda9ff..9e44a5028 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -5,13 +5,13 @@ using System.Management; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -using Tango.PPC.Common.Scripting; namespace Tango.PPC.Common.OS { using System.Collections.ObjectModel; using System.Diagnostics; using Tango.Core; + using Tango.Core.Components; using SLID = Guid; //SLID id declaration as typedef GUID SLID; in slpublic.h /// @@ -83,9 +83,16 @@ namespace Tango.PPC.Common.OS CmdCommand command = new CmdCommand("cscript", $"C:\\Windows\\System32\\slmgr.vbs -ipk {activationKey}"); await command.Run(); - await Task.Delay(10000); + bool activated = false; - if (!(await IsActivated())) + for (int i = 0; i < 10; i++) + { + await Task.Delay(2000); + activated = await IsActivated(); + if (activated) break; + } + + if (!activated) { throw new ApplicationException("The activation was completed but activation status returned a false response."); } 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 1d727d81b..eae13a882 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs @@ -5,8 +5,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; +using Tango.Core.Components; using Tango.PPC.Common.Connection; -using Tango.PPC.Common.Scripting; namespace Tango.PPC.Common.RemoteAssistance { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs deleted file mode 100644 index 5abbd49d1..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; - -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); - - _process = new Process(); - _process.StartInfo.CreateNoWindow = true; - _process.StartInfo.FileName = processName; - _process.StartInfo.UseShellExecute = false; - _process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - _process.StartInfo.RedirectStandardError = true; - _process.StartInfo.RedirectStandardOutput = true; - _process.StartInfo.Arguments = arguments; - _process.StartInfo.Verb = "runas"; - - if (WorkingDir != null) - { - _process.StartInfo.WorkingDirectory = WorkingDir; - } - - Arguments = arguments; - } - - public Task Run() - { - return Task.Factory.StartNew(() => - { - LogManager.Log($"Starting process {_process.StartInfo.FileName} with arguments {Arguments}..."); - _process.Start(); - _process.WaitForExit((int)Timeout.TotalMilliseconds); - - 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{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}."); - } - } - else - { - throw new TimeoutException($"The process {_process.StartInfo.FileName} has not exited within the given timeout of {Timeout.TotalSeconds} seconds."); - } - }); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index e47437f4d..fe2f87fb2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -190,7 +190,6 @@ - @@ -355,7 +354,9 @@ false - + + + @@ -366,7 +367,7 @@ - + \ No newline at end of file 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 1e7357b2f..65cb3f466 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Tango.PPC.Common.Scripting; +using Tango.Core.Components; namespace Tango.PPC.Common.UWF { @@ -34,6 +34,15 @@ namespace Tango.PPC.Common.UWF public async Task Setup() { CmdCommand command = null; + try + { + + command = new CmdCommand(UWF_PATH, $"filter disable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; + await command.Run(); + + } + catch { } command = new CmdCommand(UWF_PATH, "overlay set-type disk"); command.OutputEncoding = CmdCommand.OutEncoding.Unicode; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index 15a7107bd..ea49af905 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -11,86 +11,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index 5fc7f00df..e7aff7357 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -17,7 +17,6 @@ using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.Notifications; -using Tango.PPC.Common.Scripting; using Tango.Settings; using Tango.WiFi; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 4b5874907..f7711318f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -161,7 +161,7 @@ namespace Tango.PPC.UI.PPCApplication //Start watchdog _watchdogServer = new WatchDogServer(Application.Current.Dispatcher); -#if RELEASE +#if !DEBUG if (settings.EnableWatchDog) { @@ -380,6 +380,33 @@ namespace Tango.PPC.UI.PPCApplication Environment.Exit(0); } + /// + /// Runs the updater utility and exits the application. + /// + public void UpdateApplication(String updaterPath, String arguments) + { + if (IsShuttingDown) return; + + IsShuttingDown = true; + + try + { + _watchdogServer.Dispose(); + + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) + { + vm.OnApplicationShuttingDown(); + } + } + catch { } + + LogManager.Log($"Executing '{updaterPath}' with arguments '{arguments}'..."); + Process.Start(updaterPath, arguments); + + LogManager.Log("Terminating application..."); + Environment.Exit(0); + } + /// /// Enteres the application technician mode. /// 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 fa54f491e..b7c1f4eff 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("1.0.6.0")] +[assembly: AssemblyVersion("1.0.3.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs index 1bd1e1eea..aca9dbcf7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineSetupViewVM.cs @@ -282,13 +282,9 @@ namespace Tango.PPC.UI.ViewModels /// private void CompleteSetup() { - String updater_exe = Path.Combine(_setup_result.UpdatePackagePath, "Tango.PPC.Updater.exe"); - LogManager.Log("Completing machine setup..."); - LogManager.Log($"Executing '{updater_exe}' with arguments '{PathHelper.GetStartupPath()}'..."); - Process.Start(updater_exe, PathHelper.GetStartupPath()); - LogManager.Log("Terminating application process!"); - _appManager.ShutDown(); + String updater_exe = Path.Combine(_setup_result.UpdatePackagePath, "Tango.PPC.Updater.exe"); + _appManager.UpdateApplication(updater_exe, PathHelper.GetStartupPath()); } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 6046f0300..b5b5f56bc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -194,7 +194,7 @@ namespace Tango.PPC.UI.ViewModels try { - await MachineUpdateManager.UpdateDB(_db_compare_result); + await MachineUpdateManager.UpdateDB(_db_compare_result, MachineProvider.Machine.SerialNumber); LogManager.Log("Database update completed."); await NavigateTo(MachineUpdateView.UpdateCompletedView); } @@ -213,14 +213,12 @@ namespace Tango.PPC.UI.ViewModels private void CompleteUpdate() { + LogManager.Log("Completing machine update..."); + if (!IsDbUpdate) { String updater_exe = Path.Combine(_update_result.UpdatePackagePath, "Tango.PPC.Updater.exe"); - LogManager.Log("Completing machine setup..."); - LogManager.Log($"Executing '{updater_exe}' with arguments '{PathHelper.GetStartupPath()}'..."); - Process.Start(updater_exe, PathHelper.GetStartupPath()); - LogManager.Log("Terminating application process!"); - ApplicationManager.ShutDown(); + ApplicationManager.UpdateApplication(updater_exe, PathHelper.GetStartupPath()); } else { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index efc5f8179..d72e75011 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs b/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs new file mode 100644 index 000000000..c9c5f73c3 --- /dev/null +++ b/Software/Visual_Studio/Tango.AdvancedInstaller/InstallerBuilder.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Components; + +namespace Tango.AdvancedInstaller +{ + public class InstallerBuilder + { + public String AdvancedInstallerPath { get; set; } + + public String ProjectFile { get; set; } + + public String OutputFolder { get; set; } + + public String ProductVersion { get; set; } + + public String ProductName { get; set; } + + public PackageType PackageType { get; set; } + + public InstallerBuilder() + { + AdvancedInstallerPath = @"C:\Program Files (x86)\Caphyon\Advanced Installer 15.6\bin\x86\advinst.exe"; + } + + public Task Build() + { + return Task.Factory.StartNew(() => + { + CmdCommand command = new CmdCommand(AdvancedInstallerPath, $"/edit \"{ProjectFile}\" /SetVersion {ProductVersion}"); + command.Run().Wait(); + + command = new CmdCommand(AdvancedInstallerPath, $"/edit \"{ProjectFile}\" /SetPackageName \"{OutputFolder}\\{ProductName}_v{ProductVersion}.{PackageType.ToString().ToLower()}\" -buildname DefaultBuild"); + command.Run().Wait(); + + command = new CmdCommand(AdvancedInstallerPath, $"/rebuild \"{ProjectFile}\""); + command.Run().Wait(); + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.AdvancedInstaller/PackageType.cs b/Software/Visual_Studio/Tango.AdvancedInstaller/PackageType.cs new file mode 100644 index 000000000..75120665c --- /dev/null +++ b/Software/Visual_Studio/Tango.AdvancedInstaller/PackageType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.AdvancedInstaller +{ + public enum PackageType + { + MSI, + EXE, + } +} diff --git a/Software/Visual_Studio/Tango.AdvancedInstaller/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.AdvancedInstaller/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..a8dc804ce --- /dev/null +++ b/Software/Visual_Studio/Tango.AdvancedInstaller/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tango - Business logic components")] +[assembly: ComVisible(false)] +[assembly: AssemblyVersion("2.0.36.1608")] \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.AdvancedInstaller/ReturnCodes.cs b/Software/Visual_Studio/Tango.AdvancedInstaller/ReturnCodes.cs new file mode 100644 index 000000000..20673d00f --- /dev/null +++ b/Software/Visual_Studio/Tango.AdvancedInstaller/ReturnCodes.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.AdvancedInstaller +{ + public enum ReturnCodes : uint + { + [Description("Command executed successfully.")] + NO_ERROR = 0, + + [Description("Exception occurs and no other error code is specified.")] + UNSPECIFIED_ERROR = 0xE0010064, + + [Description("Invalid MSI identifier.")] + ERROR_BAD_IDENTIFIER = 0xE0010065, + + [Description("Duplicated search signature.")] + ERROR_DUPLICATED_SEARCH_SIGNATURE = 0xE0010066, + + [Description("Search signature was not found.")] + ERROR_SEARCH_NOT_FOUND = 0xE0010067, + + [Description("File is missing.")] + ERROR_FILE_NOT_FOUND = 0xE0010068, + + [Description("Command line is invalid.")] + ERROR_MALFORMED_COMMAND_LINE = 0xE0010069, + + [Description("Command file format is invalid (possible unsupported encoding).")] + ERROR_UNSUPPORTED_CMD_FILE_FORMAT = 0xE001006A, + + [Description("The date is invalid MS DOS date.")] + ERROR_INVALID_MS_DOS_DATE = 0xE001006B, + + [Description("User does not have license to build the project and trial has expired.")] + ERROR_NO_LICENSE = 0xE001006C, + + [Description("Unable to acquire a floating license (no slots or unable to contact the license server).")] + ERROR_NO_FLOATING_LICENSE = 0xE001006D, + } +} diff --git a/Software/Visual_Studio/Tango.AdvancedInstaller/Tango.AdvancedInstaller.csproj b/Software/Visual_Studio/Tango.AdvancedInstaller/Tango.AdvancedInstaller.csproj new file mode 100644 index 000000000..2062df763 --- /dev/null +++ b/Software/Visual_Studio/Tango.AdvancedInstaller/Tango.AdvancedInstaller.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {C5DF1816-34E5-4700-824C-29623A1BAA22} + Library + Properties + Tango.AdvancedInstaller + Tango.AdvancedInstaller + v4.6.1 + 512 + true + + + true + full + false + ..\Build\Core\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\Build\Core\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + GlobalVersionInfo.cs + + + + + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs b/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs new file mode 100644 index 000000000..ef8c913eb --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.Core.Components +{ + 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 int ExitCode { get; set; } + + public OutEncoding OutputEncoding { get; set; } + + public CmdCommand(String processName, String arguments) + { + Timeout = TimeSpan.FromSeconds(5); + + _process = new Process(); + _process.StartInfo.CreateNoWindow = true; + _process.StartInfo.FileName = processName; + _process.StartInfo.UseShellExecute = false; + _process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + _process.StartInfo.RedirectStandardError = true; + _process.StartInfo.RedirectStandardOutput = true; + _process.StartInfo.Arguments = arguments; + _process.StartInfo.Verb = "runas"; + + if (WorkingDir != null) + { + _process.StartInfo.WorkingDirectory = WorkingDir; + } + + Arguments = arguments; + } + + public Task Run() + { + return Task.Factory.StartNew(() => + { + LogManager.Log($"Starting process {_process.StartInfo.FileName} with arguments {Arguments}..."); + _process.Start(); + _process.WaitForExit((int)Timeout.TotalMilliseconds); + + 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{output}"); + LogManager.Log($"Process Standard Error:\n{error}"); + + ExitCode = _process.ExitCode; + + if (_process.ExitCode != 0) + { + throw new IOException($"The process {_process.StartInfo.FileName} has exited with the code {_process.ExitCode}."); + } + } + else + { + throw new TimeoutException($"The process {_process.StartInfo.FileName} has not exited within the given timeout of {Timeout.TotalSeconds} seconds."); + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index eb80279ef..5d83c5137 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -85,6 +85,7 @@ GlobalVersionInfo.cs + @@ -194,7 +195,7 @@ - + diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml index 6860053c5..83ca86da3 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.UnitTesting/AdvancedInstaller/AdvancedInstaller_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/AdvancedInstaller_TST.cs new file mode 100644 index 000000000..60a047c0c --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/AdvancedInstaller_TST.cs @@ -0,0 +1,45 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.AdvancedInstaller; +using Tango.Core.IO; + +namespace Tango.UnitTesting.AdvancedInstaller +{ + [TestClass] + [TestCategory("Advanced Installer")] + public class AdvancedInstaller_TST + { + [TestMethod] + public void Set_Version_and_Package_name_And_Build() + { + InstallerBuilder builder = new InstallerBuilder(); + + var demo_project_path = Directory.GetCurrentDirectory() + "\\AdvancedInstaller\\DemoProject"; + var project_Path = Path.Combine(demo_project_path, "DemoProject.aip"); + var files_path = Path.Combine(demo_project_path, "Files"); + var added_file = files_path + "\\addedFile.txt"; + + File.WriteAllText(added_file, "Added File!"); + + var output_folder = TemporaryManager.Default.CreateFolder(); + + builder.ProjectFile = project_Path; + builder.OutputFolder = output_folder; + builder.ProductName = "TEST TEST TEST"; + builder.ProductVersion = "2.0.0.0"; + builder.PackageType = PackageType.MSI; + + builder.Build().Wait(); + + File.Delete(added_file); + + output_folder.Display(); + } + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/DemoProject.aip b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/DemoProject.aip new file mode 100644 index 000000000..a4889c4c0 --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/DemoProject.aip @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File1.txt b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File1.txt new file mode 100644 index 000000000..98336a696 --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File1.txt @@ -0,0 +1 @@ +File1 \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File2.txt b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File2.txt new file mode 100644 index 000000000..c717c6dee --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File2.txt @@ -0,0 +1 @@ +File2 \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File3.txt b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File3.txt new file mode 100644 index 000000000..7dd5c2097 --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/AdvancedInstaller/DemoProject/Files/File3.txt @@ -0,0 +1 @@ +File3 \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index 833e21330..357a2344b 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -99,6 +99,7 @@ GlobalVersionInfo.cs + @@ -116,6 +117,9 @@ + + PreserveNewest + @@ -136,6 +140,10 @@ {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} Tango.PPC.Common + + {c5df1816-34e5-4700-824c-29623a1baa22} + Tango.AdvancedInstaller + {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL @@ -209,7 +217,17 @@ Tango.DBObservablesGenerator.CLI - + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + @@ -224,7 +242,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 6e3e89f19..af35afd9f 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -262,6 +262,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Publisher.UI", "P EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.WebClientGenerator", "Utilities\Tango.WebClientGenerator\Tango.WebClientGenerator.csproj", "{E470673E-AEC8-4555-9136-D2F66B02DBFB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.AdvancedInstaller", "Tango.AdvancedInstaller\Tango.AdvancedInstaller.csproj", "{C5DF1816-34E5-4700-824C-29623A1BAA22}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AppVeyor|Any CPU = AppVeyor|Any CPU @@ -4679,6 +4681,46 @@ Global {E470673E-AEC8-4555-9136-D2F66B02DBFB}.Release|x64.Build.0 = Release|Any CPU {E470673E-AEC8-4555-9136-D2F66B02DBFB}.Release|x86.ActiveCfg = Release|Any CPU {E470673E-AEC8-4555-9136-D2F66B02DBFB}.Release|x86.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|ARM.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|ARM.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|ARM64.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|ARM64.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|x64.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|x64.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|x86.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.AppVeyor|x86.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|ARM.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|ARM64.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|x64.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|x64.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|x86.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Debug|x86.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|Any CPU.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|Any CPU.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|ARM.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|ARM.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|ARM64.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|ARM64.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|x64.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|x64.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|x86.ActiveCfg = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.DefaultBuild|x86.Build.0 = Debug|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|Any CPU.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|ARM.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|ARM.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|ARM64.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|ARM64.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|x64.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|x64.Build.0 = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|x86.ActiveCfg = Release|Any CPU + {C5DF1816-34E5-4700-824C-29623A1BAA22}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4764,12 +4806,12 @@ Global {E470673E-AEC8-4555-9136-D2F66B02DBFB} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_UpdateFileVersion = False - BuildVersion_StartDate = 2000/1/1 - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs BuildVersion_UseGlobalSettings = False + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_StartDate = 2000/1/1 + BuildVersion_UpdateFileVersion = False + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} EndGlobalSection EndGlobal -- cgit v1.3.1 From 0c696317f92460cdbed77493f57523fbb617d65c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 24 Feb 2019 19:32:33 +0200 Subject: Fixed some issues with PPC update. --- .../MachineUpdate/MachineUpdateManager.cs | 80 +++++++++++++--------- .../PPC/Tango.PPC.Common/Publish/PPCPublisher.cs | 2 +- .../PPC/Tango.PPC.Publisher.UI/MainWindow.xaml | 8 +-- 3 files changed, 53 insertions(+), 37 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs') 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 2a53d765e..64827f15f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -113,13 +113,19 @@ namespace Tango.PPC.Common.MachineUpdate await Task.Delay(1000); IMachineOperator op = _machineProvider.MachineOperator; - if (op.State != Transport.TransportComponentState.Connected) - { - throw new InvalidOperationException("Could not perform an update while the machine is not connected."); - } - if (op.Status != MachineStatuses.ReadyToDye) + + if (_machineProvider.Machine.SetupFirmware) { - throw new InvalidOperationException($"Could not perform an update while the machine is in a {op.Status} status."); + LogManager.Log("Machine is configured to update firmware..."); + + if (op.State != Transport.TransportComponentState.Connected) + { + throw LogManager.Log(new InvalidOperationException("Could not perform an update while the machine is not connected.")); + } + if (op.Status != MachineStatuses.ReadyToDye) + { + throw LogManager.Log(new InvalidOperationException($"Could not perform an update while the machine is in a {op.Status} status.")); + } } //Connect to machine service and get matching packages for this machine. @@ -238,38 +244,48 @@ namespace Tango.PPC.Common.MachineUpdate } //Updating firmware - UpdateProgress("Updating Firmware", "Connecting to firmware device..."); - LogManager.Log(""); - LogManager.Log("-------------------------------------------------------------------------"); - LogManager.Log("Updating Firmware..."); - - UpdateProgress("Updating Firmware", "Loading firmware package..."); - var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp"); - var stream = new FileStream(tfpPath, FileMode.Open); - var handler = await op.UpgradeFirmware(stream); - handler.Failed += (_, ex) => + if (_machineProvider.Machine.SetupFirmware) { - stream.Dispose(); - result.SetException(ex); - }; - handler.Completed += (_, __) => + UpdateProgress("Updating Firmware", "Connecting to firmware device..."); + LogManager.Log(""); + LogManager.Log("-------------------------------------------------------------------------"); + LogManager.Log("Updating Firmware..."); + + UpdateProgress("Updating Firmware", "Loading firmware package..."); + var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp"); + var stream = new FileStream(tfpPath, FileMode.Open); + var handler = await op.UpgradeFirmware(stream); + handler.Failed += (_, ex) => + { + stream.Dispose(); + result.SetException(ex); + }; + handler.Completed += (_, __) => + { + UpdateProgress("Updating Firmware", "Firmware update completed successfully."); + stream.Dispose(); + result.SetResult(new MachineUpdateResult() + { + UpdatePackagePath = _newPackageTempFolder, + }); + }; + handler.Canceled += (_, __) => + { + stream.Dispose(); + result.SetException(new Exception("The operation has been canceled.")); + }; + handler.Progress += (_, e) => + { + UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); + }; + } + else { - UpdateProgress("Updating Firmware", "Firmware update completed successfully."); - stream.Dispose(); result.SetResult(new MachineUpdateResult() { UpdatePackagePath = _newPackageTempFolder, }); - }; - handler.Canceled += (_, __) => - { - stream.Dispose(); - result.SetException(new Exception("The operation has been canceled.")); - }; - handler.Progress += (_, e) => - { - UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); - }; + } } catch (Exception ex) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs index 1a6c57607..e7f44f183 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Publish/PPCPublisher.cs @@ -246,7 +246,7 @@ namespace Tango.PPC.Common.Publish using (ZipFile zip = new ZipFile()) { - zip.AddFile(Options.TfpPath, "/"); + zip.AddFile(Options.TfpPath, "/").FileName = "firmware_package.tfp"; String provision_dir = "Provision Scripts"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml index 1bdc062de..f29b6bd44 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher.UI/MainWindow.xaml @@ -60,15 +60,15 @@ - Local Version: - + Remote Version: + - Remote Version: - + Local Version: + -- cgit v1.3.1