public Dictionary <String, MeasureInfo> GetMeasures(String cubeName) { try { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Measures List Started \r\n cubeName: '{1}'", DateTime.Now.ToString(), cubeName); Dictionary <String, MeasureInfo> list = new Dictionary <String, MeasureInfo>(); CubeDef cube = FindCube(cubeName); if (cube != null) { foreach (Measure measure in cube.Measures) { MeasureInfo info = InfoHelper.CreateMeasureInfo(measure); if (info != null) { if (!list.ContainsKey(info.UniqueName)) { list.Add(info.UniqueName, info); } } } } return(list); } finally { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Measures List Completed ", DateTime.Now.ToString(), cubeName); } }
public MeasureInfo GetMeasure(String cubeName, String measureUniqueName) { try { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Measure '{1}' Started \r\n cubeName: '{2}'", DateTime.Now.ToString(), measureUniqueName, cubeName); if (String.IsNullOrEmpty(measureUniqueName)) { return(null); } CubeDef cube = FindCube(cubeName); if (cube != null) { foreach (Measure measure in cube.Measures) { MeasureInfo info = InfoHelper.CreateMeasureInfo(measure); if (info != null) { if (info.UniqueName.ToLower() == measureUniqueName.ToLower()) { return(info); } } } } return(null); } finally { System.Diagnostics.Trace.TraceInformation("{0} Ranet.Olap.Core.Providers.OlapMetadataProvider Get Measure '{1}' Completed ", DateTime.Now.ToString(), measureUniqueName, cubeName); } }
/// <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); } }