Ejemplo n.º 1
0
        //---------------------------------------------------------------------
        private void changeTargetMenuItem_Click(
            object sender,
            EventArgs e
            )
        {
            try
            {
                if (SelectedItems.Count == 0)
                {
                    return;
                }

                MPOverride mpOverride = ((OverrideInfo)SelectedItems[0].Tag).m_override;

                if (mpOverride.ManagementPackOverride.GetManagementPack().Sealed)
                {
                    MessageBox.Show("Its not possible to modify an override that is defined in a sealed MP");
                    return;
                }

                MPClass mpClass = mpOverride.Target;

                OverrideTargetEditor targetEditor;

                targetEditor = new OverrideTargetEditor(m_managementGroup,
                                                        mpClass.ManagementPackClass,
                                                        mpOverride.ManagementPackOverride.ContextInstance);

                if (targetEditor.ShowDialog(this) == DialogResult.OK)
                {
                    if (targetEditor.IsInstanceContext)
                    {
                        PartialMonitoringObject context = targetEditor.InstanceContext;

                        IList <ManagementPackClass> contextClasses = context.GetMostDerivedClasses();

                        //TODO - dmuscett 2012/11/19 - this works for custom groups, but what for non-groups?
                        // Are we practically changing the override to a most specific one? Need more testing...
                        mpOverride.ManagementPackOverride.Context = contextClasses[contextClasses.Count - 1];

                        mpOverride.ManagementPackOverride.ContextInstance = context.Id;
                    }
                    else
                    {
                        mpOverride.ManagementPackOverride.ContextInstance = null;
                    }

                    mpOverride.ManagementPackOverride.Status = ManagementPackElementStatus.PendingUpdate;

                    mpOverride.ManagementPackOverride.GetManagementPack().AcceptChanges();
                }
            }
            catch (Microsoft.EnterpriseManagement.Common.ManagementPackException exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------
        private void changeTargetMenuItem_Click(
            object      sender,
            EventArgs   e
            )
        {
            try
            {
                if (SelectedItems.Count == 0)
                {
                    return;
                }

                MPOverride mpOverride = ((OverrideInfo)SelectedItems[0].Tag).m_override;

                if (mpOverride.ManagementPackOverride.GetManagementPack().Sealed)
                {
                    MessageBox.Show("Its not possible to modify an override that is defined in a sealed MP");
                    return;
                }

                MPClass mpClass = mpOverride.Target;

                OverrideTargetEditor targetEditor;

                targetEditor = new OverrideTargetEditor(m_managementGroup,
                                                        mpClass.ManagementPackClass,
                                                        mpOverride.ManagementPackOverride.ContextInstance);

                if (targetEditor.ShowDialog(this) == DialogResult.OK)
                {
                    if (targetEditor.IsInstanceContext)
                    {
                        PartialMonitoringObject context = targetEditor.InstanceContext;

                        IList<ManagementPackClass> contextClasses = context.GetMostDerivedClasses();

                        //TODO - dmuscett 2012/11/19 - this works for custom groups, but what for non-groups?
                        // Are we practically changing the override to a most specific one? Need more testing...
                        mpOverride.ManagementPackOverride.Context = contextClasses[contextClasses.Count - 1];

                        mpOverride.ManagementPackOverride.ContextInstance = context.Id;

                    }
                    else
                    {
                        mpOverride.ManagementPackOverride.ContextInstance = null;
                    }

                    mpOverride.ManagementPackOverride.Status = ManagementPackElementStatus.PendingUpdate;

                    mpOverride.ManagementPackOverride.GetManagementPack().AcceptChanges();
                }
            }
            catch (Microsoft.EnterpriseManagement.Common.ManagementPackException exception)
            {
                MessageBox.Show(exception.Message);
            }
        }