Esempio n. 1
0
        internal MdxAxis GenerateCurrentAxis(AxisInfo AxesInfo)
        {
            var newExpression = this.Expression;

            foreach (var Hierarchy in AxesInfo.Hierarchies)
            {
                if (Hierarchy.ExpandedCells.Count > 0)
                {
                    var SetExpanded = new MdxSetExpression();
                    foreach (var Tuple in Hierarchy.ExpandedCells.Keys)
                    {
                        SetExpanded.Expressions.Add(new MdxTupleExpression(Tuple));
                    }
                    newExpression = new MdxFunctionExpression
                                        ("ORDER"
                                        , new MdxFunctionExpression("DRILLDOWNMEMBER", newExpression, SetExpanded, RECURSIVE)
                                        , ONE
                                        );
                }
                if (Hierarchy.CollapsedCells.Count > 0)
                {
                    var SetCollapsed = new MdxSetExpression();
                    foreach (var Tuple in Hierarchy.CollapsedCells.Keys)
                    {
                        SetCollapsed.Expressions.Add(new MdxTupleExpression(Tuple));
                    }
                    newExpression = new MdxFunctionExpression("DRILLUPMEMBER", newExpression, SetCollapsed);
                }
            }
            if (newExpression == this.Expression)
            {
                return(this);
            }

            return(new MdxAxis(this.Name, newExpression, this.Having, this.DimensionProperties));
        }
		internal MdxAxis GenerateCurrentAxis(AxisInfo AxesInfo)
		{
			var newExpression=this.Expression;
			foreach (var Hierarchy in AxesInfo.Hierarchies)
			{
				if (Hierarchy.ExpandedCells.Count > 0)
				{
					var SetExpanded = new MdxSetExpression();
					foreach (var Tuple in Hierarchy.ExpandedCells.Keys)
					{
						SetExpanded.Expressions.Add(new MdxTupleExpression(Tuple));
					}
					newExpression =new MdxFunctionExpression
					( "ORDER"
					,new MdxFunctionExpression("DRILLDOWNMEMBER", newExpression,	SetExpanded, RECURSIVE)
					, ONE
					);
				}
				if (Hierarchy.CollapsedCells.Count > 0)
				{
					var SetCollapsed=new MdxSetExpression();
					foreach(var Tuple in Hierarchy.CollapsedCells.Keys)
					{
						SetCollapsed.Expressions.Add(new MdxTupleExpression(Tuple));
					}
					newExpression = new MdxFunctionExpression("DRILLUPMEMBER", newExpression,	SetCollapsed);
				}
			}
			if (newExpression==this.Expression)
				return this;
				
			return new MdxAxis(this.Name,newExpression,this.Having,this.DimensionProperties);
		}
        private MdxAxis GetWrappedAxis(MdxAxis ax, IList<DrillActionContainer> actions)
        {
            MdxExpression axisExpression = ax.Expression;

            // 1. Если первым на оси стоит ключевое слово NON EMPTY то выражение формируем из его аргументов, а уже потом все это выражение обрамляем ключевым словом NON EMPTY 
            // 2. Если запрос на оси обрамлен функцией HIERARCHIZE, то выражение формируем из ее аргумента, а уже потом все это выражение обрамляем функцией HIERARCHIZE
            /* 
             * Флаг NonEmpty перенесен в MdxAxis. Проверок не требуется.
             * 
            MdxNonEmptyExpression nonEmpty = ax.Expression as MdxNonEmptyExpression;
            if (actions != null && actions.Count > 0)
            {
                if (nonEmpty != null)
                {
                    MdxExpression expression = nonEmpty.Expression;
                    MdxFunctionExpression hierarchize = expression as MdxFunctionExpression;
                    if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1)
                    {
                        expression = hierarchize.Arguments[0];
                    }

                    axisExpression = new MdxNonEmptyExpression(
                        new MdxFunctionExpression("HIERARCHIZE",
                            new MdxExpression[]
                        {
                            GetWrappedExpression(expression, actions)
                        }));
                }
                else
                {
                    MdxExpression expression = ax.Expression;
                    MdxFunctionExpression hierarchize = expression as MdxFunctionExpression;
                    if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1)
                    {
                        expression = hierarchize.Arguments[0];
                    }

                    axisExpression = new MdxFunctionExpression(
                                 "HIERARCHIZE",
                                 new MdxExpression[]
                        {
                            GetWrappedExpression(expression, actions)
                        });
                }
            }
            */

            if (actions.Count > 0)
            {
                var expression = ax.Expression;
                var hierarchize = expression as MdxFunctionExpression;
                if (hierarchize != null && hierarchize.Name.ToLower() == "hierarchize" && hierarchize.Arguments.Count == 1)
                {
                    expression = hierarchize.Arguments[0];
                }

                axisExpression = new MdxFunctionExpression(
                             "HIERARCHIZE",
                             new MdxExpression[]
                        {
                            GetWrappedExpression(expression, actions)
                        });
            }


            // Возможность убрать пустые колонки
            /*
            if (nonEmpty == null && actions == History.CurrentHistoryItem.ColumnsActionChain && HideEmptyColumns)
            {
                axisExpression = new MdxNonEmptyExpression(axisExpression);
            }
            */
            // Возможность убрать пустые строки
            /*
            if (nonEmpty == null && actions == History.CurrentHistoryItem.RowsActionChain && HideEmptyRows)
            {
                axisExpression = new MdxNonEmptyExpression(axisExpression);
            }
            */
            if (History.CurrentHistoryItem.ColumnsActionChain.Equals(actions) && HideEmptyColumns)
            {
                ax.NonEmpty = true;
            }
            if (History.CurrentHistoryItem.RowsActionChain.Equals(actions) && HideEmptyRows)
            {
                ax.NonEmpty = true;
            }

            return new MdxAxis(
                    ax.Name,
                    axisExpression,
                    ax.Having,
                    ax.DimensionProperties
                    )
            {
                NonEmpty = ax.NonEmpty
            };
        }
		public override MdxExpression Process(MdxExpression expr)
		{
			if (expr == null)
				return null;

			string uniqueName = args.Member.UniqueName;
			string hierarchyUniqueName = args.Member.HierarchyUniqueName;

			var drillDownExpr =
				new MdxFunctionExpression
				("Distinct"
				, new MdxFunctionExpression
					("DrillDownMember"
					, expr
					, new MdxObjectReferenceExpression(uniqueName)
					)
				);
			MdxExpression filter = new MdxFunctionExpression
						("IsAncestor"
						, new MdxObjectReferenceExpression(uniqueName)
						, new MdxObjectReferenceExpression(hierarchyUniqueName + ".CURRENTMEMBER")
						);

			MdxExpression isSelf = new MdxBinaryExpression
							(new MdxObjectReferenceExpression(uniqueName)
							, new MdxObjectReferenceExpression(hierarchyUniqueName + ".CURRENTMEMBER")
							, "IS"
							);

			if (HideSelf)
			{
				isSelf =
						new MdxBinaryExpression
						(isSelf
						, new MdxFunctionExpression
							("IsLeaf"
							, new MdxObjectReferenceExpression(uniqueName)
							)
						, "AND"
						);
			};

			filter =
					new MdxBinaryExpression
					(filter
					, isSelf
					, "OR"
					);
			if (!SingleDimension)
			{
				var tupleBase = GenTupleBase();
				if (tupleBase.Members.Count > 0)
				{
					filter = new MdxBinaryExpression
							(filter
							, new MdxBinaryExpression
									(GenTupleBaseCurrent()
									, GenTupleBase()
									, "IS"
									)
							, "AND"
							);
				}
			}
			return new MdxFunctionExpression("FILTER", drillDownExpr, filter);

		}
		MdxExpression SortExpression(MdxExpression expr, SortDescriptor descr)
		{
			if (descr == null)
				return expr;

			if (!String.IsNullOrEmpty(descr.SortBy))
			{
				String orderType = String.Empty;
				if (descr.Type == SortTypes.Ascending)
					orderType = "BASC";
				if (descr.Type == SortTypes.Descending)
					orderType = "BDESC";

				if (!String.IsNullOrEmpty(orderType))
				{
					expr = new MdxFunctionExpression("ORDER",
					new MdxExpression[] {
                                expr,
                                new MdxObjectReferenceExpression(String.Format("({0})", descr.SortBy)),
                                new MdxConstantExpression(orderType) 
                            });
				}
			}
			return expr;
		}
Esempio n. 6
0
 public MdxPropertyExpression(MdxExpression expr, MdxFunctionExpression func)
     : this(expr, func.Name)
 {
     this.Args.AddRange(func.Arguments);
     this.IsFunction = true;
 }
		public MdxPropertyExpression(MdxExpression expr, MdxFunctionExpression func)
			: this(expr, func.Name)
		{
			this.Args.AddRange(func.Arguments);
			this.IsFunction = true;
		}