diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-12 19:24:47 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-12 19:24:47 +0200 |
| commit | 618750acb5b4592f81b79b50ece01a8d6ec598d9 (patch) | |
| tree | 36970d638faf0afb9ae8ec223ac54f59c5b69faf /Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages | |
| parent | 10edb8b5413129c1f0553318031f83490abb52b5 (diff) | |
| download | Tango-618750acb5b4592f81b79b50ece01a8d6ec598d9.tar.gz Tango-618750acb5b4592f81b79b50ece01a8d6ec598d9.zip | |
Added progress support for package runner.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages')
4 files changed, 50 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs index 74ba59bad..c94aedeb0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs @@ -25,6 +25,7 @@ namespace Tango.PPC.Common.UpdatePackages private PackagesFile _packagesFile; public event EventHandler<PackageStateChangedEventArgs> PackageStateChanged; + public event EventHandler<PackageProgressEventArgs> PackageProgress; public DefaultPackageRunner() { @@ -189,6 +190,27 @@ namespace Tango.PPC.Common.UpdatePackages { OnPackageRuns(att.Name, installedPackage.State, installedPackage.Type); installedPackage.InstallationDate = DateTime.Now; + context.ProgressAction = (message, isIntermediate, progress, total) => + { + PackageProgress?.Invoke(this, new PackageProgressEventArgs() + { + PackageName = att.Name, + Message = message, + IsIntermediate = isIntermediate, + Progress = progress, + Total = total + }); + }; + + PackageProgress?.Invoke(this, new PackageProgressEventArgs() + { + PackageName = type == PackageType.Pre ? "Preparing" : "Finalizing", + Message = att.Name, + IsIntermediate = true, + Progress = 0, + Total = 100 + }); + packageInstance.Run(context).GetAwaiter().GetResult(); installedPackage.State = PackageInstallationState.Installed; installedPackage.FailedReason = null; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs index dcdfa8b60..b864100aa 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs @@ -9,6 +9,7 @@ namespace Tango.PPC.Common.UpdatePackages public interface IPackageRunner { event EventHandler<PackageStateChangedEventArgs> PackageStateChanged; + event EventHandler<PackageProgressEventArgs> PackageProgress; Task<PackagesFile> GetPackagesFile(); Task<PackageRunnerResult> Run(PackageType type, Version deltaVersion, String packagesFolder); Task<bool> IsPackageInstallationRequired(PackageType type, String packagesFolder); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageContext.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageContext.cs index 24044e567..2276fa637 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageContext.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageContext.cs @@ -11,10 +11,20 @@ namespace Tango.PPC.Common.UpdatePackages { public class PackageContext { + public delegate void PackageProgressDelegate(String message, bool isIntermediate = true, double progress = 0, double maximum = 100); + + private PackageProgressDelegate packageProgressAction; + public IPPCApplicationManager ApplicationManager { get; set; } public IMachineProvider MachineProvider { get; set; } public INotificationProvider NotificationProvider { get; set; } public Version InstalledVersion { get; set; } public Version DeltaVersion { get; set; } + internal PackageProgressDelegate ProgressAction { get; set; } + + public void ReportProgress(String message, bool isIntermediate = true, double progress = 0, double maximum = 100) + { + packageProgressAction?.Invoke(message, isIntermediate, progress, maximum); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageProgressEventArgs.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageProgressEventArgs.cs new file mode 100644 index 000000000..ebf0b23a6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageProgressEventArgs.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.UpdatePackages +{ + public class PackageProgressEventArgs : EventArgs + { + public String PackageName { get; set; } + public String Message { get; set; } + public bool IsIntermediate { get; set; } + public double Progress { get; set; } + public double Total { get; set; } + } +} |
