protected override void RefreshTree() { base.RefreshTree(); if (CubeInfo != null) { // Если задано уникальное имя измерения, то создаем для данного измерения узел if (!String.IsNullOrEmpty(DimensionUniqueName)) { DimensionInfo info = CubeInfo.GetDimension(DimensionUniqueName); if (info != null) { if (!String.IsNullOrEmpty(HierarchyUniqueName)) { HierarchyInfo hierarchyInfo = info.GetHierarchy(HierarchyUniqueName); if (hierarchyInfo != null) { HierarchyTreeNode hierarchyNode = AddHierarchyNode(null, hierarchyInfo); CreateLevels(hierarchyNode, hierarchyInfo, false); hierarchyNode.IsExpanded = true; return; } else { LogManager.LogError(this, String.Format(Localization.MetadataResponseException_HierarchyByUniqueName_InDimension_NotFound, HierarchyUniqueName, DimensionUniqueName)); } } else { DimensionTreeNode dimNode = AddDimensionNode(null, info); CreateHierarchies(dimNode, info, true); dimNode.IsExpanded = true; return; } } else { LogManager.LogError(this, String.Format(Localization.MetadataResponseException_DimensionByUniqueName_InCube_NotFound, DimensionUniqueName, CubeName)); } } // Отображаем все измерения CreateDimensions(null, CubeInfo, true); } }
/// <summary> /// Возвращает список кубов /// </summary> /// <returns></returns> public CubeDefInfo GetCubeMetadata(String cubeName, MetadataQueryType type) { try { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Getting Cube '{1}' Metadata Started", DateTime.Now.ToString(), cubeName); CubeDef cube = FindCube(cubeName); if (cube != null) { CubeDefInfo cube_info = InfoHelper.CreateCubeInfo(cube); foreach (Dimension dim in cube.Dimensions) { DimensionInfo dim_info = InfoHelper.CreateDimensionInfo(dim); cube_info.Dimensions.Add(dim_info); foreach (Hierarchy hierarchy in dim.Hierarchies) { HierarchyInfo hier_info = InfoHelper.CreateHierarchyInfo(hierarchy); dim_info.Hierarchies.Add(hier_info); foreach (Level level in hierarchy.Levels) { LevelInfo level_info = InfoHelper.CreateLevelInfo(level); hier_info.Levels.Add(level_info); } //AdomdConnection conn = GetConnection(ConnectionString); //// Для каждой иерархии пытаемся определить элемент, который имеет тип MemberTypeEnum.All //try //{ // AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection(); // restrictions.Add("CATALOG_NAME", conn.Database); // restrictions.Add("CUBE_NAME", OlapHelper.ConvertToNormalStyle(cubeName)); // restrictions.Add("DIMENSION_UNIQUE_NAME", dim.UniqueName); // restrictions.Add("HIERARCHY_UNIQUE_NAME", hierarchy.UniqueName); // restrictions.Add("MEMBER_TYPE", 2/*MemberTypeEnum.All*/); // DataSet ds = conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions); // if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) // { // DataTable table = ds.Tables[0]; // if (table.Columns.Contains("MEMBER_UNIQUE_NAME")) // { // object obj = ds.Tables[0].Rows[0]["MEMBER_UNIQUE_NAME"]; // if (obj != null) // hier_info.Custom_AllMemberUniqueName = obj.ToString(); // } // } //}catch //{ //} //// Для каждой иерархии пытаемся определить элемент, который имеет тип MemberTypeEnum.Unknown //try //{ // AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection(); // restrictions.Add("CATALOG_NAME", conn.Database); // restrictions.Add("CUBE_NAME", OlapHelper.ConvertToNormalStyle(cubeName)); // restrictions.Add("DIMENSION_UNIQUE_NAME", dim.UniqueName); // restrictions.Add("HIERARCHY_UNIQUE_NAME", hierarchy.UniqueName); // restrictions.Add("MEMBER_TYPE", 0 /*MemberTypeEnum.Unknown.All*/); // DataSet ds = conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions); // if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) // { // DataTable table = ds.Tables[0]; // if (table.Columns.Contains("MEMBER_UNIQUE_NAME")) // { // object obj = ds.Tables[0].Rows[0]["MEMBER_UNIQUE_NAME"]; // if (obj != null) // hier_info.Custom_UnknownMemberUniqueName = obj.ToString(); // } // } //} //catch //{ //} } } foreach (Kpi kpi in cube.Kpis) { KpiInfo kpi_info = InfoHelper.CreateKpiInfo(kpi); cube_info.Kpis.Add(kpi_info); } foreach (Measure measure in cube.Measures) { MeasureInfo measure_info = InfoHelper.CreateMeasureInfo(measure); cube_info.Measures.Add(measure_info); } foreach (NamedSet set in cube.NamedSets) { NamedSetInfo set_info = InfoHelper.CreateNamedSetInfo(set); cube_info.NamedSets.Add(set_info); } if (type == MetadataQueryType.GetCubeMetadata_AllMembers) { AdomdConnection conn = GetConnection(); // Для каждой иерархии пытаемся определить элемент, который имеет тип MemberTypeEnum.All try { AdomdRestrictionCollection restrictions = new AdomdRestrictionCollection(); restrictions.Add("CATALOG_NAME", conn.Database); restrictions.Add("CUBE_NAME", OlapHelper.ConvertToNormalStyle(cubeName)); restrictions.Add("MEMBER_TYPE", 2 /*MemberTypeEnum.All*/); DataSet ds = conn.GetSchemaDataSet("MDSCHEMA_MEMBERS", restrictions); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataTable table = ds.Tables[0]; if (table.Columns.Contains("MEMBER_UNIQUE_NAME") && table.Columns.Contains("HIERARCHY_UNIQUE_NAME") && table.Columns.Contains("DIMENSION_UNIQUE_NAME")) { foreach (DataRow row in ds.Tables[0].Rows) { String dimension_UniqueName = row["DIMENSION_UNIQUE_NAME"] != null ? row["DIMENSION_UNIQUE_NAME"].ToString() : String.Empty; String hierarchy_UniqueName = row["HIERARCHY_UNIQUE_NAME"] != null ? row["HIERARCHY_UNIQUE_NAME"].ToString() : String.Empty; String member_UniqueName = row["MEMBER_UNIQUE_NAME"] != null ? row["MEMBER_UNIQUE_NAME"].ToString() : String.Empty; if (!String.IsNullOrEmpty(dimension_UniqueName) && !String.IsNullOrEmpty(hierarchy_UniqueName) && !String.IsNullOrEmpty(member_UniqueName)) { DimensionInfo dimension = cube_info.GetDimension(dimension_UniqueName); if (dimension != null) { HierarchyInfo hierarchy = dimension.GetHierarchy(hierarchy_UniqueName); if (hierarchy != null) { hierarchy.Custom_AllMemberUniqueName = member_UniqueName; } } } } } } } catch (Exception ex) { //throw ex; } } cube_info.MeasureGroups = GetMeasureGroups(cubeName); return(cube_info); } return(null); } finally { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Getting Cube '{1}' Metadata Completed", DateTime.Now.ToString(), cubeName); } }