public static IDictionary <String, ManagementPackProperty> GetManagementPackProperties(string entityClassName)
        {
            ManagementPackClass            clazz = GetManagementPackClass(entityClassName);
            IList <ManagementPackProperty> props = clazz.GetProperties();
            IDictionary <String, ManagementPackProperty> keyedProperties = new Dictionary <String, ManagementPackProperty>();

            foreach (var prop in props)
            {
                keyedProperties.Add(prop.Name, prop);
            }
            return(keyedProperties);
        }
        public static ManagementPackProperty GetManagementPackClassPropertyByName(string strClassName, string strPropertyName, EnterpriseManagementGroup emg)
        {
            ManagementPackClass            cls            = GetClassByName(strClassName, emg);
            IList <ManagementPackProperty> listProperties = cls.GetProperties();

            foreach (ManagementPackProperty property in listProperties)
            {
                if (property.Name == strPropertyName)
                {
                    return(property);
                }
            }

            return(null);
        }
Beispiel #3
0
        public void TestGetAllESightApplicanceAsync()
        {
            string clazzName          = EntityTypeConst.BladeServer.Fan;
            ManagementPackClass clazz = OM12Connection.GetManagementPackClass(clazzName);
            var clazzProps            = clazz.GetProperties();
            var list  = OM12Connection.All <PartialMonitoringObject>(clazzName);
            var first = list.FirstOrDefault();

            var props     = OM12Connection.GetManagementPackProperties(first);
            var baseProps = OM12Connection.GetManagementPackProperties(EntityTypeConst.ESight.HuaweiServer);

            var Status = first[props["Status"]].Value;
            var DN     = first[baseProps["DN"]].Value;

            Console.WriteLine(clazz);
        }
 public IEnumerable<ManagementPackProperty> GetActivityPropertyDefinitions(ManagementPackClass c)
 {
     if (c.Id != ActivityClass.Id && c.GetBaseTypes().FirstOrDefault(x => x.Id == ActivityClass.Id) == default(ManagementPackType))
         throw new InvalidOperationException("Activity type is not deriven from 'PurgarNET.AAConnector.RunbookActivity'");
     return c.GetProperties();
 }
        public static EnterpriseManagementObject ConvertIdataitemToEmo(IDataItem iDataItem)
        {
            if (iDataItem == null)
            {
                throw new NullReferenceException("Cannot convert a null iDataItem to an EnterpriseManagementObject");
            }

            EnterpriseManagementObject emo;

            var emg = Common.GetManagementGroup();


            IDataItem iDataItemClass = iDataItem["$Class$"] as IDataItem;
            var       classGuid      = (Guid)iDataItemClass["Id"]; //probably notification activity class

            ManagementPackClass mpcClass = emg.EntityTypes.GetClass(classGuid);


            if ((bool)iDataItem["$IsNew$"] == true)
            {
                emo    = new CreatableEnterpriseManagementObject(emg, mpcClass);
                emo.Id = (Guid)iDataItem["$Id$"];
            }
            else
            {
                emo = emg.EntityObjects.GetObject <EnterpriseManagementObject>(new Guid(iDataItem["$Id$"].ToString()), ObjectQueryOptions.Default);
                //We cannot jsut return this, since if the user was within an SR, and then opened the activity, and hit apply on the activity (but not the SR), then the iDataItem updates with a cached version, while the emo does not update.
                // So if we only return the emo, then all of the original values will be returned.
            }

            //cemo[null, "DisplayName"].Value = iDataItem["DisplayName"]; //the displayname on the idataitem is null
            foreach (var thisProp in mpcClass.GetProperties())
            {
                if (thisProp.Type == ManagementPackEntityPropertyTypes.@enum)
                {
                    if (iDataItem[thisProp.Name] != null && (iDataItem[thisProp.Name] as IDataItem)["DisplayName"] != null && (iDataItem[thisProp.Name] as IDataItem)["Id"] != null)
                    {
                        emo[null, thisProp.Name].Value = (iDataItem[thisProp.Name] as IDataItem)["Id"]; //yes, the enumeration is another IDataItem.
                    }
                }
                else
                {
                    emo[null, thisProp.Name].Value = iDataItem[thisProp.Name];
                }
            }

            //Also get all properties from base classes too. "Id" might be nice eh?
            var baseClasses = mpcClass.GetBaseTypes();

            foreach (var thisBaseType in baseClasses)
            {
                foreach (var thisProp in thisBaseType.GetProperties())
                {
                    if ((bool)iDataItem["$IsNew$"] == true && thisProp.Name == "Id")
                    {
                        continue;
                    }

                    try
                    {
                        if (thisProp.Type == ManagementPackEntityPropertyTypes.@enum)
                        {
                            if (iDataItem[thisProp.Name] != null && (iDataItem[thisProp.Name] as IDataItem)["DisplayName"] != null && (iDataItem[thisProp.Name] as IDataItem)["Id"] != null)
                            {
                                emo[thisBaseType, thisProp.Name].Value = (iDataItem[thisProp.Name] as IDataItem)["Id"];
                            }
                        }
                        else
                        {
                            emo[thisBaseType, thisProp.Name].Value = iDataItem[thisProp.Name];
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Failed to set emo prop from iDataItem prop - " + ex.Message);
                    }
                }
            }

            return(emo);
        }