Пример #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
        // Установить значение любого объекта GR
        public static void SetAttributeValueRegular(this IgObject obj
                                                    , bool isUDA
                                                    , string name
                                                    , MxDataType type
                                                    , object value
                                                    , string description = ""
                                                    , string engUnits    = ""
                                                    )
        {
            if (obj == null)
            {
                throw new ArgumentNullException("IgObject is null");
            }
            //Все типы MxString* сводятся только в тип MxInternationalizedString
            if (type == MxDataType.MxString || type == MxDataType.MxInternationalizedString || type == MxDataType.MxBigString)
            {
                type = MxDataType.MxInternationalizedString;
            }

            if (SystemAttributes.TryGetValue(name, out var act))
            {
                obj.CheckOutWithCheckStatus();
                try
                {
                    act(obj, value?.ToString());
                    obj.SaveAndCheckIn($"System attribute {name} = {(value == null ? "null" : $"\"{value}\"")}");
                }
Пример #3
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);
        }