public AsyncAction Solve() { AsyncAction a = null; switch (solution) { case Solution.EjectCD: a = new ChangeVMISOAction(vm.Connection, vm, null, vm.FindVMCDROM()); dialog.SetSession(a); dialog.DoAction(a); break; case Solution.Suspend: a = new VMSuspendAction(vm); dialog.SetSession(a); dialog.DoAction(a); break; case Solution.InstallPVDrivers: a = new InstallToolsCommand(Program.MainWindow, vm).ExecuteGetAction(); // The install pv tools action is marked as complete after they have taken the user to the console and loaded the disc // Rescanning when the action is 'complete' in this case doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text. dialog.SetSession(a); solutionAction = a; return(a); } solutionAction = a; solution = Solution.None; // we show this, then register an event handler on the action completed to re-update the text/solution this.error = Messages.EVACUATE_SOLUTION_IN_PROGRESS; return(a); }
public void ChangeCD(VDI vdi) { changing = true; Enabled = false; ChangeVMISOAction action = new ChangeVMISOAction(connection, vm, vdi, cdrom); action.Completed += delegate { Program.Invoke(this, delegate() { changing = false; SelectCD(); Enabled = true; }); }; action.RunAsync(); }
private void dataGridViewVms_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex >= 0 && e.RowIndex < dataGridViewVms.RowCount && e.ColumnIndex == columnAction.Index && dataGridViewVms.Rows[e.RowIndex] is VmPrecheckRow row && row.HasSolution()) { AsyncAction action = null; switch (row.Solution) { case Solution.EjectCD: action = new ChangeVMISOAction(row.vm.Connection, row.vm, null, row.vm.FindVMCDROM()); break; case Solution.Suspend: action = new VMSuspendAction(row.vm); break; case Solution.Shutdown: action = new VMHardShutdown(row.vm); break; case Solution.InstallPVDrivers: var cmd = new InstallToolsCommand(Program.MainWindow, row.vm, dataGridViewVms); cmd.Execute(); // The install pv tools action is marked as complete after they have taken the user to the // console and loaded the disc. Rescanning when the action is 'complete' in this case // doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text. return; } if (action != null) { action.Completed += a => Rebuild(); action.RunAsync(GetSudoElevationResult()); } //set this after starting the action so that the row is updated correctly row.SolutionAction = action; } }