示例#1
0
        //установка значения атриибутов
        public void SetValueAttributes(IgObject gobj, AttributesDictionary source)
        {
            if (gobj == null)
            {
                throw new IgObjectsNullReferenceExceptions();
            }
            if (source == null)
            {
                throw new ArgumentNullException($"Класс-слоаварь равен null");
            }
            gobj.CheckOutWithCheckStatus();

            foreach (var item in source)
            {
                IAttribute attr = gobj.GetAttributesAny()[item.Key];
                if (attr.CommandResult.Successful && attr != null)
                {
                    attr.SetValue(item.Value);
                }
            }
            gobj.SaveAndCheckIn();
            if (!gobj.CommandResult.Successful)
            {
                throw new GalaxyExceptions($"Не удается охранить объект {gobj.Tagname}.");
            }
        }
示例#2
0
        //Получить тип
        // если вернулось MxNoData - значит атрибута не существует
        // TODO: проверить нужен ли check out
        public static MxDataType GetAttributeMxDataType(this IgObject gobj, string attrname)
        {
            if (gobj == null)
            {
                throw new ArgumentNullException($" Объект {gobj.Tagname} не существует или NULL");
            }
            if (string.IsNullOrWhiteSpace(attrname))
            {
                throw new Exception($"Имя атрибута {nameof(attrname)} не может быть пустым");
            }
            MxDataType type = MxDataType.MxNoData;

            gobj.CheckOutWithCheckStatus();
            if (gobj.IsExistAttribute(attrname))
            {
                type = gobj.ConfigurableAttributes[attrname].DataType;
                gobj.SaveAndCheckIn($"Получение типа атрибута {attrname} для объекта {gobj}.");
            }
            else
            {
                throw new AttributeNullReferenceException();
            }
            return(type);
        }