Esempio n. 1
0
        internal IEnumerable <Member> GetMembersList(ICubeAddress a, Members MembersList)
        {
            if (a.Measure == null ||
                !CalculatedByServer(a.Measure) ||
                MembersList[0].MemberType == MemberType.mtMeasure ||
                MembersList[0].MemberType == MemberType.mtMeasureMode)
            {
                return(MembersList.ToArray());
            }

            if (a.GetMemberByHierarchy(MembersList[0].Level.Hierarchy) != null)
            {
                return(MembersList.ToArray());
            }

            var aa = a.Clone();

            aa.AddMember(MembersList[0]);
            var M = GetMetaline(aa.FLevelsAndMembers.Keys);
            var L = M.GetLine(aa.FHierID, aa.Measure, aa.Measure.ShowModes[0]);

            return(L.GetMembersList(aa, MembersList));
        }
        /// <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());
        }