private void StartVMsActionChanged(ActionBase sender) { StartVMsAndAppliancesAction senderAction = (StartVMsAndAppliancesAction)sender; if (senderAction.IsCompleted) { return; } Program.BeginInvoke(this, () => { var row = dataGridView1.Rows[dataGridView1.RowCount - 1] as DataGridViewRowRecover; //last row is "Start VMs and Appliances" row if (row != null && !senderAction.IsCompleted) { row.UpdateStatus(RecoverState.Recovering, Messages.DR_WIZARD_RECOVERPAGE_STATUS_WORKING, senderAction.Description); } }); }
private void StartVMsActionCompleted(ActionBase sender) { StartVMsAndAppliancesAction senderAction = (StartVMsAndAppliancesAction)sender; senderAction.Completed -= StartVMsActionCompleted; senderAction.Changed -= StartVMsActionChanged; if (ReportActionResultGot != null) { ReportActionResultGot(senderAction); } log.Debug("Finished starting VMs and appliances"); Program.BeginInvoke(this, () => { progressBar1.Value = 100; var row = dataGridView1.Rows[dataGridView1.RowCount - 1] as DataGridViewRowRecover; //last row is "Start VMs and Appliances" row 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); } OnPageUpdated(); if (ReportLineGot != null) { ReportLineGot(labelTitle.Text, 0, true); } }); }
private void StartRecoveredVMs(bool paused) { List <VM> vmsToStart = new List <VM>(); foreach (var uuid in RecoveredVmsUuids) { foreach (VM vm in Connection.Cache.VMs) { if (vm.uuid == uuid) { vmsToStart.Add(vm); } } } List <VM_appliance> vmAppliancesToStart = new List <VM_appliance>(); foreach (var uuid in RecoveredVmAppliancesUuids) { foreach (VM_appliance vmAppliance in Connection.Cache.VM_appliances) { if (vmAppliance.uuid == uuid) { vmAppliancesToStart.Add(vmAppliance); } } } var action = new StartVMsAndAppliancesAction(Connection, vmsToStart, vmAppliancesToStart, VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm, paused); if (action != null) { action.Completed += StartVMsActionCompleted; action.Changed += StartVMsActionChanged; action.RunAsync(); } }