//---------------------------------------------------------------------
        private void CacheWindowsComputerObjects()
        {
            MonitoringClass windowsComputerClass;

            windowsComputerClass = m_managementGroup.GetMonitoringClass(SystemMonitoringClass.WindowsComputer);

            m_windowsComputers = m_managementGroup.GetPartialMonitoringObjects(windowsComputerClass);
        }
        //---------------------------------------------------------------------
        private string GetImageKey(
            MonitoringClass monitoringClass
            )
        {
            ReadOnlyCollection <MonitoringImageReference> imageRefs;

            if (m_classIdToMonitoringImageReferences.ContainsKey(monitoringClass.Id))
            {
                imageRefs = m_classIdToMonitoringImageReferences[monitoringClass.Id];
            }
            else
            {
                imageRefs = monitoringClass.GetMonitoringImageReferences();
                m_classIdToMonitoringImageReferences.Add(monitoringClass.Id, imageRefs);
            }

            string imageKey = string.Empty;

            foreach (ManagementPackImageReference imageRef in imageRefs)
            {
                MonitoringImageObject imageObj;

                if (m_imageIdToImageMap.ContainsKey(imageRef.ImageID.Id))
                {
                    imageObj = m_imageIdToImageMap[imageRef.ImageID.Id];
                }
                else
                {
                    imageObj = m_managementGroup.GetMonitoringImageObject(imageRef.ImageID.Id);
                    m_imageIdToImageMap.Add(imageRef.ImageID.Id, imageObj);
                }

                Bitmap classImage = new Bitmap(imageObj.ImageData);

                if (classImage.Height == 16 && classImage.Width == 16)
                {
                    imageKey = imageRef.ImageID.Id.ToString();
                    break;
                }
            }

            if (imageKey == string.Empty)
            {
                if (monitoringClass.Base == null)
                {
                    return(imageKey);
                }

                MonitoringClass parentMonitoringClass = m_managementGroup.GetMonitoringClass(monitoringClass.Base.Id);

                imageKey = GetImageKey(parentMonitoringClass);
            }

            return(imageKey);
        }
示例#3
0
        //---------------------------------------------------------------------
        private void instancesComboBox_DropDown(object sender, EventArgs e)
        {
            if (m_monitoringObjects == null)
            {
                MonitoringClass monitoringClass = m_managementGroup.GetMonitoringClass(m_managementPackClass.Id);

                m_monitoringObjects = m_managementGroup.GetPartialMonitoringObjects(monitoringClass);

                instancesComboBox.Items.Clear();

                foreach (PartialMonitoringObject monitoringObject in m_monitoringObjects)
                {
                    instancesComboBox.Items.Add(monitoringObject);
                }

                if (m_currentMonitoringObject != null && m_isContextCurrentlyGroup == false)
                {
                    instancesComboBox.SelectedItem = m_currentMonitoringObject;
                }
            }
        }
示例#4
0
        //---------------------------------------------------------------------
        internal static string RetrieveContext(
            ManagementPackOverride mpOverrride,
            ManagementGroup managementGroup
            )
        {
            string context = "Unknown";

            if (mpOverrride.ContextInstance == null)
            {
                string className;

                className = GetBestElementName(managementGroup.GetMonitoringClass(mpOverrride.Context.Id));

                context = string.Format("All Instances of type {0}", className);
            }
            else
            {
                PartialMonitoringObject monitoringObject;

                try
                {
                    try
                    {
                        monitoringObject = managementGroup.GetPartialMonitoringObject((Guid)mpOverrride.ContextInstance);
                        context          = monitoringObject.DisplayName;
                    }
                    catch (Microsoft.EnterpriseManagement.Common.MonitoringException exception)
                    {
                        managementGroup.Reconnect();
                        monitoringObject = managementGroup.GetMonitoringObject((Guid)mpOverrride.ContextInstance);
                    }
                }
                catch (Microsoft.EnterpriseManagement.Common.MonitoringException exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }

            return(context);
        }
示例#5
0
        //---------------------------------------------------------------------
        internal static string RetrieveContext(
            ManagementPackOverride mpOverrride,
            ManagementGroup        managementGroup
            )
        {
            string context = "Unknown";

            if (mpOverrride.ContextInstance == null)
            {
                string className;

                className = GetBestElementName(managementGroup.GetMonitoringClass(mpOverrride.Context.Id));

                context = string.Format("All Instances of type {0}", className);
            }
            else
            {
                PartialMonitoringObject monitoringObject;

                try
                {
                    try
                    {
                        monitoringObject = managementGroup.GetPartialMonitoringObject((Guid)mpOverrride.ContextInstance);
                        context = monitoringObject.DisplayName;
                    }
                    catch (Microsoft.EnterpriseManagement.Common.MonitoringException exception)
                    {
                        managementGroup.Reconnect();
                        monitoringObject = managementGroup.GetMonitoringObject((Guid)mpOverrride.ContextInstance);
                    }
                }
                catch (Microsoft.EnterpriseManagement.Common.MonitoringException exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }

            return (context);
        }