public override void PageLeave(PageLoadedDirection direction, ref bool cancel) { try { if (direction == PageLoadedDirection.Forward) { if (!AllSelectedHostsConnected()) { foreach (PatchingHostsDataGridViewRow row in dataGridViewHosts.Rows) row.UpdateIcon(); dataGridViewHosts.Invalidate(); cancel = true; return; } //Upload the patches to the masters if it is necessary List<Host> masters = SelectedMasters; //Do RBAC check foreach (Host master in masters) { if(Helpers.MidnightRideOrGreater(master.Connection)&&!(Role.CanPerform(new RbacMethodList("pool_patch.apply"),master.Connection))) { string nameLabel = master.Name; Pool pool = Helpers.GetPoolOfOne(master.Connection); if (pool != null) nameLabel = pool.Name; new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, string.Format(Messages.RBAC_UPDATES_WIZARD, master.Connection.Username, nameLabel), Messages.UPDATES_WIZARD)).ShowDialog(this); cancel = true; base.PageLeave(direction, ref cancel); return; } } switch (SelectedUpdateType) { case UpdateType.NewRetail: foreach (Host selectedServer in masters) { Host master = Helpers.GetMaster(selectedServer.Connection); UploadPatchAction action = new UploadPatchAction(master.Connection, SelectedNewPatch); new ActionProgressDialog(action, ProgressBarStyle.Blocks).ShowDialog(); if (action.Succeeded) { _patch = action.PatchRefs[master]; NewUploadedPatches.Add(_patch); } else { cancel = true; break; } } break; case UpdateType.Existing: foreach (Host selectedServer in masters) { List<Pool_patch> poolPatches = new List<Pool_patch>(selectedServer.Connection.Cache.Pool_patches); if (poolPatches.Find(patch => patch.uuid == SelectedExistingPatch.uuid) == null) { //Download patch from server Upload in the selected server var actionCopyPatch = new CopyPatchFromHostToOther(SelectedExistingPatch.Connection, selectedServer, SelectedExistingPatch); new ActionProgressDialog(actionCopyPatch, ProgressBarStyle.Blocks).ShowDialog(); if (!actionCopyPatch.Succeeded) { cancel = true; break; } } } break; } } base.PageLeave(direction, ref cancel); } catch (Exception e) { log.Debug(e); throw;//better throw an exception rather than closing the wizard suddenly and silently } }
private void InstallOEMUpdates() { List<AsyncAction> actions = new List<AsyncAction>(); progressBar.Maximum = SelectedMasters.Count * 100; //Upload the patches using patch-upload to the master foreach (Host selectedServer in SelectedMasters) { AsyncAction action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatch); actions.Add(action); } oemWorker = new BackgroundWorker(); oemWorker.WorkerReportsProgress = true; oemWorker.DoWork += new DoWorkEventHandler(oemWorker_DoWork); oemWorker.ProgressChanged += new ProgressChangedEventHandler(oemWorker_ProgressChanged); oemWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(oemWorker_RunWorkerCompleted); oemWorker.RunWorkerAsync(actions); }
private void PrepareUploadActions() { OnPageUpdated(); SuppPackVdis.Clear(); uploadActions.Clear(); //Upload the patches to the masters if it is necessary List<Host> masters = SelectedMasters; foreach (Host selectedServer in masters) { AsyncAction action = null; switch (SelectedUpdateType) { case UpdateType.NewRetail: if (CanUploadUpdateOnHost(SelectedNewPatchPath, selectedServer)) { bool deleteFileOnCancel = AllDownloadedPatches.ContainsValue(SelectedNewPatchPath); action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatchPath, true, deleteFileOnCancel); } break; case UpdateType.Existing: if (!PatchExistsOnPool(_patch, selectedServer)) { //Download patch from server Upload in the selected server action = new CopyPatchFromHostToOther(SelectedExistingPatch.Connection, selectedServer, SelectedExistingPatch); } break; case UpdateType.ISO: if (CanUploadUpdateOnHost(SelectedNewPatchPath, selectedServer)) { _poolUpdate = null; _patch = null; action = new UploadSupplementalPackAction( selectedServer.Connection, SelectedServers.Where(s => s.Connection == selectedServer.Connection).ToList(), SelectedNewPatchPath, true); } break; } if (action != null) { action.Changed += singleAction_Changed; action.Completed += singleAction_Completed; } else { _patch = GetPatchFromPatchPath(); } uploadActions.Add(selectedServer, action); } foreach (KeyValuePair<Host, AsyncAction> uploadAction in uploadActions) { flickerFreeListBox1.Items.Add(uploadAction); } flickerFreeListBox1.Refresh(); OnPageUpdated(); }