private void SingleRecoverActionCompleted(ActionBase sender) { DrRecoverAction senderAction = (DrRecoverAction)sender; senderAction.Completed -= SingleRecoverActionCompleted; senderAction.Changed -= SingleRecoverActionChanged; objectsToBeRecovered--; Program.BeginInvoke(this, () => { progressBar1.Value = progressBar1.Value < 100 ? progressBar1.Value + (100 / dataGridView1.Rows.Count) : 100; var row = FindRow(senderAction.XenObject); if (row != null) { if (senderAction.Succeeded) { row.UpdateStatus(RecoverState.Recovered, Messages.DR_WIZARD_RECOVERPAGE_STATUS_COMPLETED); } else { row.UpdateStatus(RecoverState.Error, Messages.DR_WIZARD_RECOVERPAGE_STATUS_FAILED, senderAction.Exception.Message); } labelOverallProgress.Text = string.Format(Messages.DR_WIZARD_RECOVERPAGE_OVERALL_PROGRESS, row.Index + 1, dataGridView1.Rows.Count); } }); if (senderAction.Succeeded) { if (senderAction.XenObject is VM) { RecoveredVmsUuids.Add((senderAction.XenObject as VM).uuid); } else if (senderAction.XenObject is VM_appliance) { RecoveredVmAppliancesUuids.Add((senderAction.XenObject as VM_appliance).uuid); } } if (ReportActionResultGot != null) { ReportActionResultGot(senderAction); } }
private void SingleRecoverActionChanged(ActionBase sender) { DrRecoverAction senderAction = (DrRecoverAction)sender; if (senderAction.IsCompleted) { return; } Program.BeginInvoke(this, () => { var row = FindRow(senderAction.XenObject); if (row != null && !senderAction.IsCompleted) { row.UpdateStatus(RecoverState.Recovering, Messages.DR_WIZARD_RECOVERPAGE_STATUS_WORKING, senderAction.Title); } }); }
List <AsyncAction> CreateSubActionsFor(PoolMetadata poolMetadata) { log.DebugFormat("Generating recovery actions from pool {0} (VDI {1})", poolMetadata.Pool.Name(), poolMetadata.Vdi.Name()); List <AsyncAction> subActions = new List <AsyncAction>(); VdiOpenDatabaseAction openDatabaseAction = new VdiOpenDatabaseAction(Connection, poolMetadata.Vdi); openDatabaseAction.Completed += OpenDatabaseActionCompleted; subActions.Add(openDatabaseAction); foreach (var vmAppliance in poolMetadata.VmAppliances.Values) { DrRecoverAction drRecoverAction = new DrRecoverAction(Connection, vmAppliance); drRecoverAction.Completed += SingleRecoverActionCompleted; drRecoverAction.Changed += SingleRecoverActionChanged; subActions.Add(drRecoverAction); dataGridView1.Rows.Add(new DataGridViewRowRecover(vmAppliance)); objectsToBeRecovered++; } foreach (var vm in poolMetadata.Vms.Values) { if (vm.IsAssignedToVapp()) { //VM included in an appliance continue; } DrRecoverAction drRecoverAction = new DrRecoverAction(Connection, vm); drRecoverAction.Completed += SingleRecoverActionCompleted; drRecoverAction.Changed += SingleRecoverActionChanged; subActions.Add(drRecoverAction); dataGridView1.Rows.Add(new DataGridViewRowRecover(vm)); objectsToBeRecovered++; } log.DebugFormat("Done - {0} actions generated", subActions.Count); return(subActions); }