예제 #1
0
        public String GetLevelList(int cubeId, int dimensionId, int hierarchyId)
        {
            using (AdomdConnection mdConn = new AdomdConnection())
            {
                mdConn.ConnectionString = "provider=msolap;Data Source=V1LGORPC\\ASMAIN;initial catalog=AdventureWorksDW2014Multidimensional-EE;";
                mdConn.Open();

                List <CubeDef> realCubeList = Utilities.Utilities.GetRealCubeList(mdConn.Cubes);

                CubeDef cubeDef = realCubeList[cubeId];

                Microsoft.AnalysisServices.AdomdClient.Hierarchy hierarchy = cubeDef.Dimensions[dimensionId].Hierarchies[hierarchyId];

                List <Models.Level> levelList = new List <Models.Level>();

                foreach (Microsoft.AnalysisServices.AdomdClient.Level level in hierarchy.Levels)
                {
                    Models.Level newLevel = new Models.Level(level);

                    levelList.Add(newLevel);
                }

                return(JsonConvert.SerializeObject(levelList, Formatting.Indented));
            }
        }
예제 #2
0
 public Hierarchy(Microsoft.AnalysisServices.AdomdClient.Hierarchy obj)
 {
     _obj = obj;
 }
예제 #3
0
 public Hierarchy(AsAdomdClient.Hierarchy obj)
 {
     _obj = obj;
 }
예제 #4
0
 public Hierarchy(Microsoft.AnalysisServices.AdomdClient.Hierarchy hierarchy)
 {
     _obj = hierarchy;
 }
        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 LevelCollection(AdomdConnection connection, Hierarchy parentHierarchy)
 {
     this.levelCollectionInternal = new LevelCollectionInternal(connection, parentHierarchy);
 }
 internal LevelCollectionInternal(AdomdConnection connection, Hierarchy parentHierarchy) : base(connection, InternalObjectType.InternalTypeLevel, parentHierarchy.ParentDimension.ParentCube.metadataCache)
 {
     this.parentHierarchy = parentHierarchy;
     base.Initialize((DataRow)((IAdomdBaseObject)parentHierarchy).MetadataData, null);
 }
예제 #8
0
 public Hierarchy(Microsoft.AnalysisServices.AdomdClient.Hierarchy obj)
 {
     _obj = obj;
 }