示例#1
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);
        }
示例#2
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);
        }