Beispiel #1
0
        //---------------------------------------------------------------------
        private void AddWorkflowsToXmlDocument(MPClass mpClass, XmlElement classElement, XmlDocument document)
        {
            foreach (KeyValuePair <Guid, MPWorkflow> workflowPair in mpClass.MPWorkflows)
            {
                XmlElement workflowElement;

                if (workflowPair.Value.Workflow is ManagementPackMonitor)
                {
                    workflowElement = document.CreateElement("Monitor");
                }
                else if (workflowPair.Value.Workflow is ManagementPackRule)
                {
                    workflowElement = document.CreateElement("Rule");
                }
                else if (workflowPair.Value.Workflow is ManagementPackDiscovery)
                {
                    workflowElement = document.CreateElement("Discovery");
                }
                else
                {
                    throw new ApplicationException("Unknown element type");
                }

                workflowElement.SetAttribute("Name", Common.GetBestElementName(workflowPair.Value.Workflow));

                classElement.AppendChild(workflowElement);

                AddOverridesToXmlDocument(workflowPair.Value, workflowElement, document);
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
0
 internal MPOverride(
     ManagementPackOverride  mpOverride,
     MPWorkflow              workflow,
     MPClass                 workflowTarget
     )
 {
     m_override          = mpOverride;
     m_workflow          = workflow;
     m_workflowTarget    = workflowTarget;
 }
Beispiel #4
0
 internal MPOverride(
     ManagementPackOverride mpOverride,
     MPWorkflow workflow,
     MPClass workflowTarget
     )
 {
     m_override       = mpOverride;
     m_workflow       = workflow;
     m_workflowTarget = workflowTarget;
 }
Beispiel #5
0
        //---------------------------------------------------------------------
        private void AddWorkflowNodesToObjectTree(
            MPClass mpClass,
            TreeNode classNode
            )
        {
            TreeNode monitorsNode    = new TreeNode("Monitors");;
            TreeNode rulesNode       = new TreeNode("Rules");
            TreeNode discoveriesNode = new TreeNode("Discoveries");

            foreach (KeyValuePair <Guid, MPWorkflow> workflowPair in mpClass.MPWorkflows)
            {
                string   workflowName = Common.GetBestElementName(workflowPair.Value.Workflow);
                TreeNode treeNode     = new TreeNode(workflowName);

                treeNode.Tag = workflowPair.Value;

                if (workflowPair.Value.Workflow is ManagementPackMonitor)
                {
                    monitorsNode.Nodes.Add(treeNode);
                }
                else if (workflowPair.Value.Workflow is ManagementPackRule)
                {
                    rulesNode.Nodes.Add(treeNode);
                }
                else if (workflowPair.Value.Workflow is ManagementPackDiscovery)
                {
                    discoveriesNode.Nodes.Add(treeNode);
                }
            }

            if (monitorsNode.Nodes.Count > 0)
            {
                classNode.Nodes.Add(monitorsNode);
            }

            if (rulesNode.Nodes.Count > 0)
            {
                classNode.Nodes.Add(rulesNode);
            }

            if (discoveriesNode.Nodes.Count > 0)
            {
                classNode.Nodes.Add(discoveriesNode);
            }
        }
        //---------------------------------------------------------------------
        private void AddWorkflowNodesToObjectTree(
            MPClass                 mpClass,
            TreeNode                classNode
            )
        {
            TreeNode monitorsNode       = new TreeNode("Monitors");;
            TreeNode rulesNode          = new TreeNode("Rules");
            TreeNode discoveriesNode    = new TreeNode("Discoveries");

            foreach (KeyValuePair<Guid, MPWorkflow> workflowPair in mpClass.MPWorkflows)
            {
                string      workflowName    = Common.GetBestElementName(workflowPair.Value.Workflow);
                TreeNode    treeNode        = new TreeNode(workflowName);

                treeNode.Tag = workflowPair.Value;

                if (workflowPair.Value.Workflow is ManagementPackMonitor)
                {
                    monitorsNode.Nodes.Add(treeNode);
                }
                else if (workflowPair.Value.Workflow is ManagementPackRule)
                {
                    rulesNode.Nodes.Add(treeNode);
                }
                else if (workflowPair.Value.Workflow is ManagementPackDiscovery)
                {
                    discoveriesNode.Nodes.Add(treeNode);
                }
            }

            if (monitorsNode.Nodes.Count > 0)
            {
                classNode.Nodes.Add(monitorsNode);
            }

            if (rulesNode.Nodes.Count > 0)
            {
                classNode.Nodes.Add(rulesNode);
            }

            if (discoveriesNode.Nodes.Count > 0)
            {
                classNode.Nodes.Add(discoveriesNode);
            }
        }
Beispiel #7
0
        //---------------------------------------------------------------------
        private void DisplayOverridesForMPWorkflow(TreeNode treeNode)
        {
            overrideListView.ClearOverrides();

            if (!(treeNode.Tag is MPWorkflow))
            {
                return;
            }

            MPWorkflow workflow       = (MPWorkflow)treeNode.Tag;
            MPClass    workflowTarget = (MPClass)treeNode.Parent.Parent.Tag;

            List <MPOverride> overrides = new List <MPOverride>();

            foreach (ManagementPackOverride mpOverride in workflow.Overrides)
            {
                overrides.Add(new MPOverride(mpOverride, workflow, workflowTarget));
            }

            overrideListView.AddOverrides(overrides);
        }
        //---------------------------------------------------------------------
        private void AddWorkflowsToXmlDocument(MPClass mpClass, XmlElement classElement, XmlDocument document)
        {
            foreach (KeyValuePair<Guid, MPWorkflow> workflowPair in mpClass.MPWorkflows)
            {
                XmlElement workflowElement;

                if (workflowPair.Value.Workflow is ManagementPackMonitor)
                {
                    workflowElement = document.CreateElement("Monitor");
                }
                else if (workflowPair.Value.Workflow is ManagementPackRule)
                {
                    workflowElement = document.CreateElement("Rule");
                }
                else if (workflowPair.Value.Workflow is ManagementPackDiscovery)
                {
                    workflowElement = document.CreateElement("Discovery");
                }
                else
                {
                    throw new ApplicationException("Unknown element type");
                }

                workflowElement.SetAttribute("Name", Common.GetBestElementName(workflowPair.Value.Workflow));

                classElement.AppendChild(workflowElement);

                AddOverridesToXmlDocument(workflowPair.Value, workflowElement, document);
            }
        }