Ejemplo n.º 1
0
        private static string GetDrillthroughMDXInternal64(Tuple tuple, bool skipDefaultMembers)
        {
            string s       = CurrentCellAttributes(tuple, skipDefaultMembers);
            string pattern = @"^(\(){1}(.*?)(\)){1}$";

            return(Regex.Replace(s, pattern, "$2").Replace(",", ",\r\n"));
        }
 public static long TimeToCalculate(Tuple tupleToEvaluate)
 {
     Stopwatch stp = new Stopwatch();
     stp.Start();
     MDXValue m = new Expression("[Measures].Currentmember").Calculate(tupleToEvaluate);
     stp.Stop();
     return stp.ElapsedTicks;
 }
Ejemplo n.º 3
0
 public static Set AsymmetricSet(Tuple t)
 {
     Member[] mbrs = new Member[t.Members.Count];
     for (int i = 0; i <= t.Members.Count - 1; i++)
     {
         mbrs[i] = t.Members[i];
     }
     return(buildAsymmetricSet(mbrs));
 }
 public static Set AsymmetricSet(Tuple t)
 {
     Member[] mbrs = new Member[t.Members.Count];
     for (int i =0; i <= t.Members.Count-1 ; i++)
     {
         mbrs[i] = t.Members[i];
     }
     return buildAsymmetricSet(mbrs);
 }
        public static long TimeToCalculate(Tuple tupleToEvaluate)
        {
            Stopwatch stp = new Stopwatch();

            stp.Start();
            MDXValue m = new Expression("[Measures].Currentmember").Calculate(tupleToEvaluate);

            stp.Stop();
            return(stp.ElapsedTicks);
        }
 public MDXValue WriteComment(Expression expressionToEvaluate
 ,Tuple tupleToEvaluate
 , int eventSubClass
 , int numberData
 , string textData)
 {
     Context.TraceEvent(eventSubClass, numberData, textData);
     MDXValue m = expressionToEvaluate.Calculate(tupleToEvaluate);
     return m ;
 }
Ejemplo n.º 7
0
        public MDXValue WriteComment(Expression expressionToEvaluate
                                     , Tuple tupleToEvaluate
                                     , int eventSubClass
                                     , int numberData
                                     , string textData)
        {
            Context.TraceEvent(eventSubClass, numberData, textData);
            MDXValue m = expressionToEvaluate.Calculate(tupleToEvaluate);

            return(m);
        }
Ejemplo n.º 8
0
 private static string GetDrillthroughMDXInternal(Tuple tuple, string sReturnColumns, int?iMaxRows, bool skipDefaultMembers)
 {
     if (sReturnColumns != null)
     {
         //passed in a set of return columns
         return("drillthrough " + (iMaxRows == null ? "" : "maxrows " + iMaxRows) + " select (" + CurrentCellAttributes(tuple, skipDefaultMembers) + ") on 0 from [" + AMOHelpers.GetCurrentCubeName() + "] return " + sReturnColumns);
     }
     else
     {
         //passed in a reference to a measure, so just do the default drillthrough for it
         return("drillthrough " + (iMaxRows == null ? "" : "maxrows " + iMaxRows) + " select (" + CurrentCellAttributes(tuple, skipDefaultMembers) + ") on 0 from [" + AMOHelpers.GetCurrentCubeName() + "]");
     }
 }
        public static string CurrentCellAttributes(Tuple tuple)
        {
            if (tuple == null) return CurrentCellAttributes();

            // start with empty string
            StringBuilder coordinate = new StringBuilder();
            bool first = true;
            foreach (Dimension d in Context.Cubes[AMOHelpers.GetCurrentCubeName()].Dimensions)
            {
                foreach (Hierarchy h in d.AttributeHierarchies)
                {
                    // skip user hierarchies - consider attribute and parent-child hierarchies
                    // (parent-child is both user and attribute hierarchy)
                    if (h.HierarchyOrigin == HierarchyOrigin.UserHierarchy)
                        continue;

                    // skip calculated measures
                    string sOverrideMeasure = null;
                    if (d.DimensionType == DimensionTypeEnum.Measure)
                    {
                        foreach (Member m in tuple.Members)
                        {
                            if (m.ParentLevel.ParentHierarchy.ParentDimension.DimensionType == DimensionTypeEnum.Measure)
                            {
                                sOverrideMeasure = m.UniqueName;
                                break;
                            }
                        }

                        if (sOverrideMeasure == null && h.CurrentMember.Type == MemberTypeEnum.Formula)
                            continue;
                    }

                    if (!first)
                        coordinate.Append("\r\n,");
                    else
                        first = false;

                    if (sOverrideMeasure != null)
                        coordinate.Append(sOverrideMeasure);
                    else //calculate it in the context of the tuple
                        coordinate.Append(new Expression(h.UniqueName + ".CurrentMember.UniqueName").Calculate(tuple).ToString());
                }
            }

            return coordinate.ToString();
        }
Ejemplo n.º 10
0
 private static string GetDrillthroughMDXInternal(Tuple tuple, string sReturnColumns, int?iMaxRows)
 {
     return(GetDrillthroughMDXInternal(tuple, sReturnColumns, iMaxRows, true));
 }
Ejemplo n.º 11
0
 public static string CurrentCellAttributes(Tuple tuple)
 {
     return(CurrentCellAttributes(tuple, false));
 }
Ejemplo n.º 12
0
 public static string GetCustomDrillthroughMDX(string sReturnColumns, Tuple tuple, int iMaxRows)
 {
     return(GetDrillthroughMDXInternal(tuple, sReturnColumns, iMaxRows));
 }
Ejemplo n.º 13
0
 public static string GetCustomDrillthroughMDX(string sReturnColumns, Tuple tuple, int iMaxRows, bool skipDefaultMembers)
 {
     return(GetDrillthroughMDXInternal(tuple, sReturnColumns, iMaxRows, skipDefaultMembers));
 }
Ejemplo n.º 14
0
 public static string GetCustomDrillthroughMDX(string sReturnColumns, Tuple tuple)
 {
     return(GetDrillthroughMDXInternal(tuple, sReturnColumns, null));
 }
        public static string CurrentCellAttributes(Tuple tuple)
        {
            if (tuple == null)
            {
                return(CurrentCellAttributes());
            }

            // start with empty string
            StringBuilder coordinate = new StringBuilder();
            bool          first      = true;

            foreach (Dimension d in Context.Cubes[AMOHelpers.GetCurrentCubeName()].Dimensions)
            {
                foreach (Hierarchy h in d.AttributeHierarchies)
                {
                    // skip user hierarchies - consider attribute and parent-child hierarchies
                    // (parent-child is both user and attribute hierarchy)
                    if (h.HierarchyOrigin == HierarchyOrigin.UserHierarchy)
                    {
                        continue;
                    }

                    // skip calculated measures
                    string sOverrideMeasure = null;
                    if (d.DimensionType == DimensionTypeEnum.Measure)
                    {
                        foreach (Member m in tuple.Members)
                        {
                            if (m.ParentLevel.ParentHierarchy.ParentDimension.DimensionType == DimensionTypeEnum.Measure)
                            {
                                sOverrideMeasure = m.UniqueName;
                                break;
                            }
                        }

                        if (sOverrideMeasure == null && h.CurrentMember.Type == MemberTypeEnum.Formula)
                        {
                            continue;
                        }
                    }

                    if (!first)
                    {
                        coordinate.Append("\r\n,");
                    }
                    else
                    {
                        first = false;
                    }

                    if (sOverrideMeasure != null)
                    {
                        coordinate.Append(sOverrideMeasure);
                    }
                    else //calculate it in the context of the tuple
                    {
                        coordinate.Append(new Expression(h.UniqueName + ".CurrentMember.UniqueName").Calculate(tuple).ToString());
                    }
                }
            }

            return(coordinate.ToString());
        }
 private static string GetDrillthroughMDXInternal(Tuple tuple, string sReturnColumns, int? iMaxRows)
 {
     if (sReturnColumns != null)
     {
         //passed in a set of return columns
         return "drillthrough " + (iMaxRows == null ? "" : "maxrows " + iMaxRows) + " select (" + CurrentCellAttributes(tuple) + ") on 0 from [" + AMOHelpers.GetCurrentCubeName() + "] return " + sReturnColumns;
     }
     else
     {
         //passed in a reference to a measure, so just do the default drillthrough for it
         return "drillthrough " + (iMaxRows == null ? "" : "maxrows " + iMaxRows) + " select (" + CurrentCellAttributes(tuple) + ") on 0 from [" + AMOHelpers.GetCurrentCubeName() + "]";
     }
 }
 public static string GetDefaultDrillthroughMDX(Tuple tuple)
 {
     return GetDrillthroughMDXInternal(tuple, null, null);
 }
 public static string GetCustomDrillthroughMDX(string sReturnColumns, Tuple tuple)
 {
     return GetDrillthroughMDXInternal(tuple, sReturnColumns, null);
 }
 public static string GetCustomDrillthroughMDX(string sReturnColumns, Tuple tuple, int iMaxRows)
 {
     return GetDrillthroughMDXInternal(tuple, sReturnColumns, iMaxRows);
 }
Ejemplo n.º 20
0
        public static string CurrentCellAttributes(Tuple tuple, bool skipDefaultMembers)
        {
            if (tuple == null)
            {
                return(FindCurrentMembers.FindCurrentTuple());              // CurrentCellAttributes();
            }
            // start with empty string
            StringBuilder coordinate = new StringBuilder();
            bool          first      = true;

            foreach (Dimension d in Context.Cubes[AMOHelpers.GetCurrentCubeName()].Dimensions)
            {
                foreach (Hierarchy h in d.AttributeHierarchies)
                {
                    // skip user hierarchies - consider attribute and parent-child hierarchies
                    // (parent-child is both user and attribute hierarchy)
                    if (h.HierarchyOrigin == HierarchyOrigin.UserHierarchy)
                    {
                        continue;
                    }

                    // skip calculated measures
                    string sOverrideMeasure = null;
                    if (d.DimensionType == DimensionTypeEnum.Measure)
                    {
                        foreach (Member m in tuple.Members)
                        {
                            try
                            {
                                if (m.ParentLevel.ParentHierarchy.ParentDimension.DimensionType == DimensionTypeEnum.Measure)
                                {
                                    sOverrideMeasure = m.UniqueName;
                                    break;
                                }
                            }
                            catch (Exception ex)
                            {
                                // DPG 16 Jan 2015
                                // if we get an error trying to figure out if we are looking at the Measures Dimension
                                // we can just log it and continue. As far as I'm aware this only happens when one of the dimensions/attributes
                                // in the tuple is not visible and this should only occur for non-measures dimensions.
                                // so simply logging the exception and moving on to the next member should not do any harm.
                                int eventSubClass = 999;
                                Context.TraceEvent(eventSubClass, 0, string.Format("ERROR GetCustomDrillthroughMDX() Exception: {0}", ex.Message));
                            }
                        }

                        if (sOverrideMeasure == null && h.CurrentMember.Type == MemberTypeEnum.Formula)
                        {
                            continue;
                        }
                    }

                    var sCurrMbr = new Expression(h.UniqueName + ".CurrentMember.UniqueName").Calculate(tuple).ToString();

                    // If skipDefaultMembers is true and the current member is the default member
                    // the move on to the next hierarchy
                    if (sCurrMbr == null || (sCurrMbr == h.DefaultMember && skipDefaultMembers))
                    {
                        continue;
                    }

                    if (!first)
                    {
                        coordinate.Append("\r\n,");
                    }
                    else
                    {
                        first = false;
                    }

                    if (sOverrideMeasure != null)
                    {
                        coordinate.Append(sOverrideMeasure);
                    }
                    else //calculate it in the context of the tuple
                    {
                        coordinate.Append(sCurrMbr);
                    }
                }
            }

            return(coordinate.ToString());
        }
 public static string GetDefaultDrillthroughMDX(Tuple tuple, int iMaxRows)
 {
     return GetDrillthroughMDXInternal(tuple, null, iMaxRows);
 }
Ejemplo n.º 22
0
        // Implied casting seems to cause an issue here where passing in a tuple
        // reference gets cast to a scalar value which then treats 0 as false and non-zero as true
        //public static string GetDefaultDrillthroughMDX(bool skipDefaultMembers)
        //{
        //    return GetDrillthroughMDXInternal(null, null, null,skipDefaultMembers);
        //}

        public static string GetDefaultDrillthroughMDX(Tuple tuple)
        {
            return(GetDrillthroughMDXInternal(tuple, null, null));
        }
Ejemplo n.º 23
0
 public static string GetDefaultDrillthroughMDX(Tuple tuple, int iMaxRows, bool skipDefaultMembers)
 {
     return(GetDrillthroughMDXInternal(tuple, null, iMaxRows, skipDefaultMembers));
 }
Ejemplo n.º 24
0
        private static Set buildAsymmetricSet(params Member[] memberList)
        {
            Context.TraceEvent(100, 0, "AsymmetricSet: Starting");
            // build a list of all the unique Hierarchies from the members in memberList.
            List <Hierarchy> hierList = new List <Hierarchy>();

            foreach (Member m in memberList)
            {
                // Check that the member variable is correctly populated. If the user passes
                // in a non-existant member we get a member object whose properties are all
                // null or empty strings.
                if (m.UniqueName.Length > 0)
                {
                    if (!hierList.Exists(delegate(Hierarchy h) { if (h.UniqueName == m.ParentLevel.ParentHierarchy.UniqueName)
                                                                 {
                                                                     return(true);
                                                                 }
                                                                 else
                                                                 {
                                                                     return(false);
                                                                 } }))
                    {
                        hierList.Add(m.ParentLevel.ParentHierarchy);
                    }
                }
            }

            // SetBuilder & TupleBuilder are IDisposeable so we ensure they
            // are disposed by utilizing a using block.
            using (SetBuilder asymSet = new SetBuilder())
            {
                foreach (Member paramMbr in memberList)
                {
                    if (paramMbr.UniqueName.Length > 0)
                    {
                        // create a tuple for each member that was passed in,
                        // combined with the default member from the other hierarchies.
                        using (TupleBuilder tb = new TupleBuilder())
                        {
                            foreach (Hierarchy h in hierList) // for each unique hierarchy
                            {
                                Hierarchy paramHier = paramMbr.ParentLevel.ParentHierarchy;
                                if (paramHier.UniqueName == h.UniqueName)
                                {
                                    //System.Diagnostics.Trace.WriteLine("Adding member " + paramMbr.UniqueName);
                                    tb.Add(paramMbr);
                                }
                                else
                                {
                                    Member defMbr = MDX.StrToSet(h.DefaultMember).Tuples[0].Members[0];
                                    //System.Diagnostics.Trace.WriteLine("Adding default member " + defMbr.UniqueName);
                                    tb.Add(defMbr);
                                }
                            }
                            Tuple t = tb.ToTuple();

                            // if the members added to the TupleBuilder will result in a non-existant tuple
                            // (eg. [Calendar Quarter 1] and [December])  the ToTuple method returns a Tuple
                            // containing 0 members. If such a tuple is added to the SetBuilder, the
                            // SetBuilder.ToSet will throw an exception
                            if (t.Members.Count > 0)
                            {
                                asymSet.Add(tb.ToTuple());
                            }
                        } // using tb
                    }
                }         //foreach paramMbr
                Context.TraceEvent(100, asymSet.Count, "AsymmetricSet: Finished (" + asymSet.Count.ToString() + " tuples generated)");
                return(asymSet.ToSet());
            } //using SetBuilder
        }