Exemplo n.º 1
0
        private void Load()
        {
            if (Invalid)
            {
                IsInitialized = false;
            }

            if (!IsInitialized)
            {
                Collection = new System.Collections.Generic.List <OlapAttributeTableField>(0);
                System.Collections.ArrayList fields = NativeOlapApi.AttributeTableFields(_attributeTable.Dimension.Server.Store.ClientSlot, _attributeTable.Dimension.Server.ServerHandle, this._attributeTable.Dimension.Name, _attributeTable.Id, _attributeTable.Dimension.Server.LastErrorInternal);
                if (fields != null)
                {
                    for (int i = 0; i < fields.Count; i++)
                    {
                        OlapAttributeTableFieldDefinition fieldDef = (OlapAttributeTableFieldDefinition)fields[i];
                        OlapAttributeTableFieldType       type;
                        switch (fieldDef.Type)
                        {
                        case 'C':
                            type = OlapAttributeTableFieldType.OlapAttributeTableFieldTypeCharacter;
                            break;

                        case 'N':
                            type = OlapAttributeTableFieldType.OlapAttributeTableFieldTypeNumeric;
                            break;

                        case 'D':
                            type = OlapAttributeTableFieldType.OlapAttributeTableFieldTypeDate;
                            break;

                        case 'L':
                            type = OlapAttributeTableFieldType.OlapAttributeTableFieldTypeLogical;
                            break;

                        default:
                            throw new OlapException("Found unknown attribute field type: " + fieldDef.Type);
                        }
                        Collection.Add(new OlapAttributeTableField(_attributeTable, fieldDef.FieldName, fieldDef.Id, fieldDef.FieldWidth, fieldDef.Decimals, type));
                    }
                }
                else
                {
                    if (_attributeTable.Dimension.Server.LastErrorInternal.Value != 0)
                    {
                        throw new OlapException("Receiving the attribute table field collection failed!", _attributeTable.Dimension.Server.LastErrorInternal.Value);
                    }
                }
                Invalid       = false;
                IsInitialized = true;
            }
        }