using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using XenAdmin.Wizards.PatchingWizard.PlanActions; using XenAPI; namespace XenAdmin.Wizards.PatchingWizard { class UpdateProgressBackgroundWorker : BackgroundWorker { public List PlanActions { get; private set; } public List DelayedActions { get; private set; } private Host master; public List FinsihedActions = new List(); public PlanAction FailedWithExceptionAction = null; public List doneActions = new List(); public PlanAction InProgressAction { get; set; } public UpdateProgressBackgroundWorker(Host master, List planActions, List delayedActions) { this.master = master; this.PlanActions = planActions; this.DelayedActions = delayedActions; } public List AllActions { get { return PlanActions.Concat(DelayedActions).ToList(); } } public int TotalNumberOfActions { get { return PlanActions.Count + DelayedActions.Count; } } public int ProgressPercent { get { return (int)(1.0 / (double)TotalNumberOfActions * (double)(FinsihedActions.Count)); } } public new void CancelAsync() { if (PlanActions != null) PlanActions.ForEach(pa => { if (!pa.IsComplete) pa.Cancel(); }); base.CancelAsync(); } } }