示例#1
0
 public Hierarchy this[int index]
 {
     get
     {
         if (index < 0 || index >= this.Count)
         {
             throw new ArgumentOutOfRangeException("index");
         }
         if (this.IsMetadata)
         {
             DataRow row = this.internalCollection[index];
             return(HierarchyCollectionInternal.GetHiearchyByRow(this.connection, row, this.parentDimension, base.Catalog, base.SessionId));
         }
         DataTable hierarchyTable = this.axis.AxisDataset[index];
         return(new Hierarchy(this.connection, hierarchyTable, this.cubeName, this.axis.ParentAxis, index));
     }
 }
示例#2
0
 public Hierarchy Find(string index)
 {
     if (index == null)
     {
         throw new ArgumentNullException("index");
     }
     if (this.IsMetadata)
     {
         DataRow dataRow = base.FindObjectByName(index, (DataRow)((IAdomdBaseObject)this.parentDimension).MetadataData, Hierarchy.hierarchyNameColumn);
         if (dataRow == null && index == this.parentDimension.Name)
         {
             dataRow = base.FindObjectByName(null, (DataRow)((IAdomdBaseObject)this.parentDimension).MetadataData, Hierarchy.hierarchyNameColumn);
         }
         if (dataRow == null)
         {
             return(null);
         }
         return(HierarchyCollectionInternal.GetHiearchyByRow(this.connection, dataRow, this.parentDimension, base.Catalog, base.SessionId));
     }
     else
     {
         if (this.Count == 0)
         {
             return(null);
         }
         if (this.parentDimension == null)
         {
             this.parentDimension = this[0].ParentDimension;
         }
         Hierarchy hierarchy = this.parentDimension.hierarchies.Find(index);
         if (hierarchy != null && this.axis.AxisDataset.Contains(hierarchy.UniqueName))
         {
             return(hierarchy);
         }
         return(null);
     }
 }
        internal object InternalGetSchemaObject(SchemaObjectType schemaObjectType, string uniqueName, bool retryUniqueName)
        {
            DataRow dataRow;

            if (SchemaObjectType.ObjectTypeMember == schemaObjectType)
            {
                ListDictionary listDictionary = new ListDictionary();
                listDictionary.Add(CubeCollectionInternal.cubeNameRest, this.Name);
                AdomdUtils.AddCubeSourceRestrictionIfApplicable(this.Connection, listDictionary);
                string requestType = "MDSCHEMA_MEMBERS";
                string key         = "MEMBER_UNIQUE_NAME";
                listDictionary.Add(key, uniqueName);
                AdomdUtils.AddMemberBinaryRestrictionIfApplicable(this.Connection, listDictionary);
                DataRowCollection rows = AdomdUtils.GetRows(this.Connection, requestType, listDictionary);
                if (rows.Count != 1)
                {
                    throw new ArgumentException(SR.Indexer_ObjectNotFound(uniqueName), "uniqueName");
                }
                dataRow = rows[0];
            }
            else
            {
                dataRow = this.metadataCache.FindObjectByUniqueName(schemaObjectType, uniqueName);
                if (dataRow == null && retryUniqueName)
                {
                    ListDictionary listDictionary2 = new ListDictionary();
                    listDictionary2.Add(CubeCollectionInternal.cubeNameRest, this.Name);
                    AdomdUtils.AddCubeSourceRestrictionIfApplicable(this.Connection, listDictionary2);
                    string schemaName;
                    string text;
                    switch (schemaObjectType)
                    {
                    case SchemaObjectType.ObjectTypeDimension:
                        schemaName = DimensionCollectionInternal.schemaName;
                        text       = DimensionCollectionInternal.dimUNameRest;
                        goto IL_16D;

                    case SchemaObjectType.ObjectTypeHierarchy:
                        schemaName = HierarchyCollectionInternal.schemaName;
                        text       = HierarchyCollectionInternal.hierUNameRest;
                        goto IL_16D;

                    case SchemaObjectType.ObjectTypeLevel:
                        schemaName = LevelCollectionInternal.schemaName;
                        text       = LevelCollectionInternal.levelUNameRest;
                        goto IL_16D;

                    case SchemaObjectType.ObjectTypeMember:
                    case (SchemaObjectType)5:
                        break;

                    case SchemaObjectType.ObjectTypeMeasure:
                        schemaName = MeasureCollectionInternal.schemaName;
                        text       = Measure.uniqueNameColumn;
                        goto IL_16D;

                    case SchemaObjectType.ObjectTypeKpi:
                        schemaName = KpiCollectionInternal.schemaName;
                        text       = Kpi.kpiNameColumn;
                        goto IL_16D;

                    default:
                        if (schemaObjectType == SchemaObjectType.ObjectTypeNamedSet)
                        {
                            schemaName = NamedSetCollectionInternal.schemaName;
                            text       = "SET_NAME";
                            goto IL_16D;
                        }
                        break;
                    }
                    throw new ArgumentOutOfRangeException("schemaObjectType");
IL_16D:
                    listDictionary2.Add(text, uniqueName);
                    AdomdUtils.AddObjectVisibilityRestrictionIfApplicable(this.Connection, schemaName, listDictionary2);
                    DataRowCollection rows2 = AdomdUtils.GetRows(this.Connection, schemaName, listDictionary2);
                    if (rows2.Count > 0)
                    {
                        uniqueName = (rows2[0][text] as string);
                        if (uniqueName != null)
                        {
                            dataRow = this.metadataCache.FindObjectByUniqueName(schemaObjectType, uniqueName);
                        }
                    }
                }
            }
            if (dataRow == null)
            {
                throw new ArgumentException(SR.Indexer_ObjectNotFound(uniqueName), "uniqueName");
            }
            switch (schemaObjectType)
            {
            case SchemaObjectType.ObjectTypeDimension:
            {
                object result = DimensionCollectionInternal.GetDimensionByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID);
                return(result);
            }

            case SchemaObjectType.ObjectTypeHierarchy:
            {
                Dimension parentDimension = (Dimension)this.InternalGetSchemaObject(SchemaObjectType.ObjectTypeDimension, dataRow[Dimension.uniqueNameColumn].ToString());
                object    result          = HierarchyCollectionInternal.GetHiearchyByRow(this.Connection, dataRow, parentDimension, this.baseData.Catalog, this.baseData.SessionID);
                return(result);
            }

            case SchemaObjectType.ObjectTypeLevel:
            {
                string    uniqueName2     = dataRow[Hierarchy.uniqueNameColumn].ToString();
                Hierarchy parentHierarchy = (Hierarchy)this.InternalGetSchemaObject(SchemaObjectType.ObjectTypeHierarchy, uniqueName2);
                object    result          = LevelCollectionInternal.GetLevelByRow(this.Connection, dataRow, parentHierarchy, this.baseData.Catalog, this.baseData.SessionID);
                return(result);
            }

            case SchemaObjectType.ObjectTypeMember:
            {
                object result = new Member(this.Connection, dataRow, null, null, MemberOrigin.Metadata, this.Name, null, -1, this.baseData.Catalog, this.baseData.SessionID);
                return(result);
            }

            case (SchemaObjectType)5:
                break;

            case SchemaObjectType.ObjectTypeMeasure:
            {
                object result = MeasureCollectionInternal.GetMeasureByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID);
                return(result);
            }

            case SchemaObjectType.ObjectTypeKpi:
            {
                object result = KpiCollectionInternal.GetKpiByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID);
                return(result);
            }

            default:
                if (schemaObjectType == SchemaObjectType.ObjectTypeNamedSet)
                {
                    object result = NamedSetCollectionInternal.GetNamedSetByRow(this.Connection, dataRow, this, this.baseData.Catalog, this.baseData.SessionID);
                    return(result);
                }
                break;
            }
            throw new ArgumentOutOfRangeException("schemaObjectType");
        }
 internal HierarchiesEnumerator(HierarchyCollectionInternal hierarchies)
 {
     this.hierarchies  = hierarchies;
     this.currentIndex = -1;
 }
示例#5
0
 internal HierarchyCollection(AdomdConnection connection, Dimension parentDimension, bool isAttribute)
 {
     this.hierarchyCollectionInternal = new HierarchyCollectionInternal(connection, parentDimension, isAttribute);
 }
示例#6
0
 internal HierarchyCollection(AdomdConnection connection, Set axis, string cubeName)
 {
     this.hierarchyCollectionInternal = new HierarchyCollectionInternal(connection, axis, cubeName);
 }