public SerializedICubeAddress(ICubeAddress address) { if (address.Measure != null) { MeasureDisplayName = address.Measure.DisplayName; MeasureUniqueName = address.Measure.UniqueName; } if (address.MeasureMode != null) { MeasureMode = address.MeasureMode.Caption; } if (address.LevelsCount > 0) { Levels = new string[address.LevelsCount]; Members = new string[address.LevelsCount]; for (var i = 0; i < address.LevelsCount; i++) { Levels[i] = address.Levels(i).UniqueName; Members[i] = address.Members(i).UniqueName; } } Tag = address.Tag; }
internal virtual bool GetCell(ICubeAddress Address, out object Value) { Value = null; if (fM.FGrid.DeferLayoutUpdate) { return(false); } var r = new Dictionary <Level, Member>(Address.FLevelsAndMembers.Count); var levelcount = Address.LevelsCount; for (var i = 0; i < levelcount; i++) { var m = Address.Members(i); if (m.FMemberType == MemberType.mtCalculated && string.IsNullOrEmpty(((CalculatedMember)m).Expression)) { return(false); } r.Add(Address.Levels(i), m); } if (fM.FGrid.isCalculatedState) { CurrentMap.ClearRequestMap(); CurrentMap.AddRequest(r); DoRetrieveData(); CurrentMap.ClearRequestMap(); } return(false); }
/// <summary> /// Updates the fact table contents for the records aggregated in the Cube cell with /// a specified address /// </summary> public override void Writeback(ICubeAddress Address, object NewValue, WritebackMethod Method) { ((MOlapCube)FCube).EnsureConnected(); var sb = new StringBuilder("UPDATE CUBE ["); sb.Append(((MOlapCube)FCube).CubeName); sb.Append("] SET ("); sb.Append(Address.Measure.UniqueName); for (var i = 0; i < Address.LevelsCount; i++) { sb.Append(","); sb.Append(Address.Members(i).UniqueName); } sb.Append(") = "); var nv = Convert.ToDouble(NewValue); sb.Append(nv.ToString(CultureInfo.InvariantCulture.NumberFormat)); sb.Append(" "); switch (Method) { case WritebackMethod.wmEqualAllocation: sb.Append(" USE_EQUAL_ALLOCATION"); break; case WritebackMethod.wmEqualIncrement: sb.Append(" USE_EQUAL_INCREMENT"); break; case WritebackMethod.wmWeightedAllocation: sb.Append(" USE_WEIGHTED_ALLOCATION"); break; case WritebackMethod.wmWeightedIncrement: sb.Append(" USE_WEIGHTED_INCREMENT"); break; } ((MOlapCube)FCube).ExecuteMDXCommand(sb.ToString()); Clear(); RebuildGridMembers(); }
/// <summary> /// Retrieves the source data that was used to create a specified cell in a cube /// </summary> /// <param name="Address"></param> /// <param name="AdataSet"></param> /// <param name="RowsToFetch"></param> public override void Drillthrough(ICubeAddress Address, DataTable AdataSet, int RowsToFetch, ICollection <string> columns) { ((MOlapCube)FCube).EnsureConnected(); var sb = new StringBuilder("DRILLTHROUGH "); if (RowsToFetch > 0) { sb.Append("MAXROWS "); sb.Append(RowsToFetch); } sb.Append(" SELECT {"); sb.Append(Address.Measure.UniqueName); sb.Append("} on 0"); for (var i = 0; i < Address.LevelsCount; i++) { sb.Append(", {"); var m = Address.Members(i); if (m.Filtered) { bool single; string set; ((MOlapCube)FCube).CreateVisibleSet(m.FLevel.FHierarchy, out single, out set, m, false); if (!single) { throw new Exception(string.Format(RadarUtils.GetResStr("rsMuitifilterDrillthroughError"), m.FLevel.FHierarchy.DisplayName)); } sb.Append(set); } else { sb.Append(Address.Members(i).UniqueName); } sb.Append("} on "); sb.Append(i + 1); } var j = Address.LevelsCount; for (var i = 0; i < FGrid.FFilteredHierarchies.Count; i++) { if (Address.GetMemberByHierarchy(FGrid.FFilteredHierarchies[i]) != null) { continue; } bool single; string set; ((MOlapCube)FCube).CreateVisibleSet(FGrid.FFilteredHierarchies[i], out single, out set, new HashSet <Member>(), false); if (!single) { throw new Exception( string.Format(RadarUtils.GetResStr("rsMuitifilterDrillthroughError"), FGrid.FFilteredHierarchies[i].DisplayName)); } sb.Append(", {"); sb.Append(set); sb.Append("} on "); sb.Append(++j); } sb.Append(" FROM "); sb.Append(((MOlapCube)FCube).ApplySubcubeFilter()); if (columns != null && columns.Count > 0) { sb.Append(" RETURN "); var b = false; foreach (var s in columns) { if (b) { sb.Append(", "); } else { b = true; } sb.Append(s); } } Drillthrough(AdataSet, sb.ToString()); }
internal override IEnumerable <Member> GetMembersList(ICubeAddress a, Members MembersList) { Dictionary <long, MembersListStorage> sd = null; if (fSortedData == null) { long cnt = 1; for (var i = 0; i < a.LevelsCount; i++) { cnt *= a.Levels(i).CompleteMembersCount; } if (cnt <= 300) { return(MembersList.ToArray()); } fSortedData = new Dictionary <string, Dictionary <long, MembersListStorage> >(); } CheckLineAlive(); //return MembersList.ToArray(); var sb = new StringBuilder(); for (var i = 0; i < a.LevelsCount; i++) { var l = a.Levels(i); if (l != MembersList[0].Level) { sb.Append(l.ID + "|"); } } var lkey = sb.ToString(); if (!fSortedData.TryGetValue(lkey, out sd)) { sd = new Dictionary <long, MembersListStorage>(); fSortedData.Add(lkey, sd); } var muls = new long[a.LevelsCount]; long multiplier = 1; long sdkey = 0; for (var i = 0; i < a.LevelsCount; i++) { var l = a.Levels(i); if (l != MembersList[0].Level) { sdkey += a.Members(i).ID *multiplier; muls[i] = multiplier; multiplier *= l.CompleteMembersCount; } else { muls[i] = -1; } } if (sd.Count == 0) { for (var i = 0; i < fIndexes.Length; i++) { var mm = fM.DecodeLineIdx(fIndexes[i]); long ckey = 0; var id = -1; for (var j = 0; j < a.LevelsCount; j++) { if (muls[j] > 0) { ckey += mm[j] * muls[j]; } else { id = mm[j]; } } MembersListStorage ss; if (!sd.TryGetValue(ckey, out ss)) { ss = new MembersListStorage(); sd.Add(ckey, ss); } ss.ids.Add(id); } } MembersListStorage mms = null; if (!sd.TryGetValue(sdkey, out mms)) { return(new List <Member>()); } return(mms.GetList(MembersList[0].Level)); }