/// <summary> /// Gets the specified attribute field value for the element. /// </summary> /// <param name="tableIndex">The attribute table index that holds the specified field.</param> /// <param name="fieldName">The field name for which to get the value.</param> /// <returns>An object that holds the value. Returns null, if the value was not found.</returns> // [System::Runtime::CompilerServices::IndexerNameAttribute("Attribute")] public object this[int tableIndex, string fieldName] { get { OlapAttributeTable table = _dimension.AttributeTables[tableIndex]; OlapAttributeTableField field = null; if (table == null) { throw new OlapException(string.Format("The attribute table {0} does not exist", tableIndex.ToString())); } for (int i = 0; i < table.FieldCount; i++) { field = table.Fields[i]; if (fieldName.ToLower().Equals(field.Name.ToLower())) { return(this[table, field]); } } throw new OlapException(string.Format("The field {0} does not exist", fieldName)); } set { OlapAttributeTable table = _dimension.AttributeTables[tableIndex]; OlapAttributeTableField field = null; if (table == null) { throw new OlapException(string.Format("The attribute table {0} does not exist", tableIndex.ToString())); } for (int i = 0; i < table.FieldCount; i++) { field = table.Fields[i]; if (fieldName.ToLower().Equals(field.Name.ToLower())) { this[table, field] = value; return; } } throw new OlapException(string.Format("The field {0} does not exist", fieldName)); } }
/// <summary> /// Initializes a new instance of the OlapAttributeTables class. /// </summary> /// <param name="attributeTable">The Olap attribute table that owns this collection.</param> public OlapAttributeTableFields(OlapAttributeTable attributeTable) { _attributeTable = attributeTable; }
/// <summary> /// Gets the specified attribute field value for the element. /// </summary> /// <param name="table">The attribute table that has the field.</param> /// <param name="field">The field for which to get the value.</param> /// <returns>An object that holds the value. Returns null, if the value was not found.</returns> // [System::Runtime::CompilerServices::IndexerNameAttribute("Attribute")] public object this[OlapAttributeTable table, OlapAttributeTableField field] { get { string key = string.Empty; bool cacheAttribute = false; int tableId = table.Id; if (_dimension.CacheAttributes) { key = string.Concat(_name, KeySeparator, field.Name); cacheAttribute = true; bool found = false; switch (tableId) { case 1: found = _dimension.Attribute1Cache.ContainsKey(key); if (found) { return(_dimension.Attribute1Cache[key]); } break; case 2: found = _dimension.Attribute2Cache.ContainsKey(key); if (found) { return(_dimension.Attribute2Cache[key]); } break; case 3: found = _dimension.Attribute3Cache.ContainsKey(key); if (found) { return(_dimension.Attribute3Cache[key]); } break; default: throw new OlapException("Invalid attribute table requested"); } } OlapAttributeTableFieldDefinition def = new OlapAttributeTableFieldDefinition(); def.Type = (char)field.Type; def.Decimals = field.Decimals; def.FieldWidth = field.Width; object result = NativeOlapApi.AttributeGetValue(_dimension.Server.Store.ClientSlot, _dimension.Server.ServerHandle, _dimension.Name, tableId, field.Name, _name, def, _dimension.Server.LastErrorInternal); if (cacheAttribute) { switch (tableId) { case 1: _dimension.Attribute1Cache.Add(key, result); break; case 2: _dimension.Attribute2Cache.Add(key, result); break; case 3: _dimension.Attribute3Cache.Add(key, result); break; } } return(result); } set { OlapAttributeTableFieldDefinition def = new OlapAttributeTableFieldDefinition(); def.Type = (char)field.Type; def.Decimals = field.Decimals; def.FieldWidth = field.Width; NativeOlapApi.AttributeSetValue(_dimension.Server.Store.ClientSlot, _dimension.Server.ServerHandle, _dimension.Name, table.Id, field.Name, _name, def, value, _dimension.Server.LastErrorInternal); } }