private void btnOK_Click(object sender, EventArgs e) { // Have any of the fields in the tab pages changed? if (!HasChanged) { Close(); return; } if (!ValidToSave) { // Keep dialog open and allow user to correct the error as // indicated by the balloon tooltip. DialogResult = DialogResult.None; return; } // Yes, save to the LocalXenObject. List<AsyncAction> actions = SaveSettings(); Program.Invoke(Program.MainWindow.GeneralPage, Program.MainWindow.GeneralPage.EnableDisableEdit); // Add a save changes on the beginning of the actions to enact the alterations that were just changes to the xenObjectCopy. // Must come first because some pages' SaveChanges() rely on modifying the object via the xenObjectCopy before their actions are run. actions.Insert(0, new SaveChangesAction(xenObjectCopy, xenObjectBefore, true)); _action = new MultipleAction( connection, string.Format(Messages.UPDATE_PROPERTIES, Helpers.GetName(xenObject).Ellipsise(50)), Messages.UPDATING_PROPERTIES, Messages.UPDATED_PROPERTIES, actions); _action.SetObject(xenObjectCopy); _action.Completed += action_Completed; Close(); if (_startAction) { _action.RunAsync(); } }
protected override void FinishWizard() { Action = new CreateVMAction(xenConnection, page_1_Template.SelectedTemplate, page_1_Template.CopyBiosStrings ? page_1b_BiosLocking.CopyBiosStringsFrom : null, page_2_Name.SelectedName, page_2_Name.SelectedDescription, page_3_InstallationMedia.SelectedInstallMethod, page_3_InstallationMedia.SelectedPvArgs, page_3_InstallationMedia.SelectedCD, page_3_InstallationMedia.SelectedUrl, m_affinity, page_5_CpuMem.SelectedVcpus, page_5_CpuMem.SelectedMemoryDynamicMin, page_5_CpuMem.SelectedMemoryDynamicMax, page_5_CpuMem.SelectedMemoryStaticMax, page_6b_LunPerVdi.MapLunsToVdisRequired ? page_6b_LunPerVdi.MappedDisks : page_6_Storage.SelectedDisks, page_6_Storage.FullCopySR, page_7_Networking.SelectedVifs, page_8_Finish.StartImmediately, VMOperationCommand.WarningDialogHAInvalidConfig, VMOperationCommand.StartDiagnosisForm, gpuCapability ? pageVgpu.GpuGroup : null, gpuCapability ? pageVgpu.VgpuType : null, page_5_CpuMem.SelectedCoresPerSocket, page_CloudConfigParameters.ConfigDriveTemplateText); Action.RunAsync(); base.FinishWizard(); }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); if (_thisPageHasBeenCompleted) { actionManualMode = null; actionsWorker = null; oemWorker = null; return; } if (SelectedUpdateType == UpdateType.NewOem) { InstallOEMUpdates(); return; } //if we reach here it's either UpdateType.NewRetail or UpdateType.Existing if (!IsAutomaticMode) { actionManualMode = new ApplyPatchAction(new List<Pool_patch> { Patch }, SelectedServers); actionManualMode.Changed += action_Changed; actionManualMode.Completed += action_Completed; textBoxLog.Text = ManualTextInstructions; actionManualMode.RunAsync(); return; } _nextEnabled = false; OnPageUpdated(); List<PlanAction> planActions = new List<PlanAction>(); foreach (Pool pool in SelectedPools) { List<Pool_patch> poolPatches = new List<Pool_patch>(pool.Connection.Cache.Pool_patches); Pool_patch poolPatch = poolPatches.Find(delegate(Pool_patch otherPatch) { if (Patch != null) return otherPatch.uuid == Patch.uuid; return false; }); List<Host> poolHosts = new List<Host>(pool.Connection.Cache.Hosts); Host master = SelectedServers.Find(host => host.IsMaster() && poolHosts.Contains(host)); if (master != null) planActions.AddRange(CompileActionList(master, poolPatch)); foreach (Host server in SelectedServers) { if (poolHosts.Contains(server)) { if (!server.IsMaster()) { // check patch isn't already applied here if (poolPatch.AppliedOn(server) == DateTime.MaxValue) planActions.AddRange(CompileActionList(server, poolPatch)); } } } planActions.Add(new UnwindProblemsAction(ProblemsResolvedPreCheck)); } actionsWorker = new BackgroundWorker(); actionsWorker.DoWork += new DoWorkEventHandler(PatchingWizardAutomaticPatchWork); actionsWorker.WorkerReportsProgress = true; actionsWorker.ProgressChanged += new ProgressChangedEventHandler(actionsWorker_ProgressChanged); actionsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(actionsWorker_RunWorkerCompleted); actionsWorker.WorkerSupportsCancellation = true; actionsWorker.RunWorkerAsync(planActions); }