protected void MeasureFieldAdd_Click(object sende, EventArgs e) { Olap.MeasureFieldInfoCollection selectedItems = new Olap.MeasureFieldInfoCollection(lbSelectedMetricFields.Items); ListEditItem item = lbMetricFields.SelectedItem; if (item != null && selectedItems.Find(item.Value.ToString()) == null) { selectedItems.Add(new Olap.MeasureFieldInfo(item)); Helpers.SetDataSource(lbSelectedMetricFields, selectedItems, "UniqueName", "Caption"); } }
private void LoadFields() { String connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["OLAPConnection"].ConnectionString; using (AdomdConnection conn = new AdomdConnection(connectionString)) { conn.Open(); CubeDef cubeDef = null; foreach (CubeDef cube in conn.Cubes) { if (cube.Type == CubeType.Cube) { cubeDef = cube; break; } } if (cubeDef == null) { m_DimFieldCollection.Clear(); m_MeasureFieldCollection.Clear(); return; } DimensionCollection dimCollection = cubeDef.Dimensions; foreach (Dimension dim in dimCollection) { if (dim.DimensionType == DimensionTypeEnum.Measure) { continue; } HierarchyCollection hierarchyColl = dim.Hierarchies; foreach (Hierarchy hier in hierarchyColl) { m_DimFieldCollection.Add(new Olap.DimensionFieldInfo(hier)); } } MeasureCollection measureCollection = cubeDef.Measures; foreach (Measure m in measureCollection) { m_MeasureFieldCollection.Add(new Olap.MeasureFieldInfo(m)); } } }
public override void Load_InitData() { if (Mode != ControlMode.New) { return; } ASPxComboBox cbbKeyField; try { cbbKeyField = (ASPxComboBox)this.FindControl("cbbKeyField"); if (cbbKeyField == null) { return; } } #if DEBUG catch (Exception ex) { throw ex; } #else catch () { return; } #endif // Load fields String connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["OLAPConnection"].ConnectionString; using (AdomdConnection conn = new AdomdConnection(connectionString)) { conn.Open(); // Find a cube CubeDef cubeDef = null; CubeCollection cubeCollection = conn.Cubes; int numOfCube = cubeCollection.Count - 1; for (; numOfCube > 0; numOfCube--) { cubeDef = cubeCollection[numOfCube]; if (cubeDef.Type == CubeType.Cube) { break; } } if (this is wcNormalFilter || this is wcTimeFilter) { Olap.DimensionFieldInfoCollection fields = new Olap.DimensionFieldInfoCollection(); // Load dimension field DimensionCollection dimCollection = cubeDef.Dimensions; int numOfDim = dimCollection.Count; for (int dimIndex = 0; dimIndex < numOfDim; dimIndex++) { Dimension dim = dimCollection[dimIndex]; if (this is wcNormalFilter) { if (dim.UniqueName == "[ARDimTime]" || dim.DimensionType == DimensionTypeEnum.Measure) { continue; } } else if (this is wcNumFilter) { if (dim.DimensionType != DimensionTypeEnum.Measure) { continue; } } else // Date { if (dim.UniqueName != "[ARDimTime]") { continue; } } foreach (Hierarchy hier in dim.Hierarchies) { fields.Add(new Olap.DimensionFieldInfo(hier)); } } Helpers.SetDataSource(cbbKeyField, fields, "UniqueName", "Caption"); } else // wcNumFilter { Olap.MeasureFieldInfoCollection fields = new Olap.MeasureFieldInfoCollection(); MeasureCollection measureCollection = cubeDef.Measures; int numOfMeasure = measureCollection.Count; for (int mIndex = 0; mIndex < numOfMeasure; mIndex++) { Measure m = measureCollection[mIndex]; fields.Add(new Olap.MeasureFieldInfo(m)); } Helpers.SetDataSource(cbbKeyField, fields, "UniqueName", "Caption"); } } }