protected override void OnLoad(EventArgs e) { base.OnLoad(e); dgvDemoObjects.AutoGenerateColumns = false; try { // Extension method GetOrCreateConnector defined in Maximus.Base.Library.Console assembly, see https://github.com/MaxxVolk/Maximus.Base.Library/tree/master/Maximus.Base.Library.Console myConnector = ManagementGroup.ConnectorFramework.GetOrCreateConnector( connectorID: myConnectorId, name: myConnectorName, displayName: myConnectorDisplayName, description: myConnectorDescription, discoveryDataIsManaged: true ); if (myConnector == null) { throw new Exception("Cannot find/create the connector."); } ConsoleJobs.RunJob(this, delegate { // inserted object will be hosted at All Management Servers Resource Pool scieDemoObjects = new SCOMClassInstanceEditor <SCOMAthonDemoClassClassAdapter>(managementGroup: ManagementGroup, seedClass: ManagementGroup.EntityTypes.GetClass(DemoClassIds.SCOMAthonDemoClassClassId), insertConnector: myConnector); }); if (scieDemoObjects == null) { throw new Exception("Cannot load management point editor."); } bsDemoObjects = new BindingSource { DataSource = scieDemoObjects }; dgvDemoObjects.DataSource = bsDemoObjects; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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(); } }); }
/// <summary> /// Deletes the requested management pack if possible. /// The user is prompted to confirm the action. /// </summary> /// <param name="sender">GridView Data being acted upon</param> /// <param name="e">Event Arguments</param> private void OnDelete(object sender, CommandEventArgs e) { ManagementPack gridSelectedItem = (GridSelectedItem as GitHubPackDetail).InstalledManagementPack; ICollection <ManagementPack> dependentManagementPacks = SDKHelper.GetDependentManagementPacks(this, gridSelectedItem); if (dependentManagementPacks == null) { return; } if (dependentManagementPacks.Count > 0) { (new MPDeleteStatusDialog(dependentManagementPacks)).ShowDialog(this); return; } if (!UninstallConfirmed(gridSelectedItem)) { return; } StartProgressForm(); if (!SDKHelper.UnInstallManagementPack(this, ManagementGroup, gridSelectedItem).JobSucceeded) { MessageBoxOptions messageBoxOption = (MessageBoxOptions)0; if (RightToLeft == RightToLeft.Yes) { messageBoxOption = MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading; } IApplicationInfo service = (IApplicationInfo)GetService(typeof(IApplicationInfo)); MessageBox.Show(this, "The MP Delete Failed", service.ProductTitle, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1, messageBoxOption); } ConsoleJobs.RunJob(this, (object sender2, ConsoleJobEventArgs e2) => UpdateCache(), new object[0]); EndProgressForm(); }
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); } }); }