private void OnMaintenanceModeStartStatus(object sender, CommandStatusEventArgs e) { e.CommandStatus.Enabled = false; ConsoleUserSettings service = (ConsoleUserSettings)GetService(typeof(ConsoleUserSettings)); if (!ManagementGroupSession.IsUserOperator || service != null && Grid.SelectedRows.Count > service.MaxItemsForMaintenanceMode) { e.CommandStatus.Visible = false; } else { e.CommandStatus.Visible = true; e.CommandStatus.Enabled = GridSelectedItems?.All(si => !si.InMaintenanceMode) ?? false; } }
private void OnMaintenanceModeEnd(object sender, CommandEventArgs e) { ConsoleJobs.RunJob(this, (param0, param1) => { IEnumerable <InstanceState> monitoringObjects = GridSelectedItems.Where(si => si.InMaintenanceMode); if (!monitoringObjects.Any()) { return; } using (MaintenanceModeExitDialog maintenanceModeExitDialog = new MaintenanceModeExitDialog()) { if (maintenanceModeExitDialog.ShowDialog() != DialogResult.Yes) { return; } foreach (InstanceState monitoringObject in monitoringObjects) { monitoringObject.GetPartialMonitoringObject(ManagementGroup).StopMaintenanceMode(DateTime.UtcNow, maintenanceModeExitDialog.ApplyToContained ? TraversalDepth.Recursive : TraversalDepth.OneLevel); } UpdateCache(); } }); }
private void OnMaintenanceModeStart(object sender, CommandEventArgs e) { ConsoleJobs.RunJob(this, (param0, param1) => { IEnumerable <InstanceState> monitoringObjects = GridSelectedItems.Where(i => !i.InMaintenanceMode); if (!monitoringObjects.Any()) { return; } using (MaintenanceModeDialog maintenanceModeDialog = new MaintenanceModeDialog()) { Site.Container.Add(maintenanceModeDialog); foreach (InstanceState monitoringObject in monitoringObjects) { maintenanceModeDialog.EntityItems.Add(monitoringObject.GetPartialMonitoringObject(ManagementGroup)); } if (maintenanceModeDialog.ShowDialog() != DialogResult.OK) { return; } UpdateCache(UpdateReason.Refresh); } }); }