private MdxSelectStatement CreateWrappedStatement() { if (!string.IsNullOrEmpty(Query) && m_OriginalStatement == null) { using (MdxDomProvider provider = MdxDomProvider.CreateProvider()) { m_OriginalStatement = provider.ParseMdx(this.Query) as MdxSelectStatement; } } MdxSelectStatement select = null; try { if (m_OriginalStatement != null) { select = m_OriginalStatement.Clone() as MdxSelectStatement; // (MdxSelectStatement)Serializer.Deserialize(Serializer.Serialize(m_OriginalStatement)); if (select != null) { if (History.CurrentHistoryItem != null) { if (select.Axes.Count > 0) { select.Axes[0] = GetWrappedAxis(select.Axes[0], History.CurrentHistoryItem.ColumnsActionChain); if (select.Axes.Count > 1) { select.Axes[1] = GetWrappedAxis(select.Axes[1], History.CurrentHistoryItem.RowsActionChain); } // Переворот осей if (RotateAxes) { if (select.Axes.Count > 1) { MdxExpression axis0_expression = select.Axes[0].Expression; select.Axes[0].Expression = select.Axes[1].Expression; select.Axes[1].Expression = axis0_expression; } } } } } } } catch (Exception ex) { throw ex; } return(select); }
private String MoveAxes(String originalQuery) { string result = String.Empty; if (!String.IsNullOrEmpty(originalQuery)) { using (MdxDomProvider provider = MdxDomProvider.CreateProvider()) { MdxSelectStatement statement = provider.ParseMdx(originalQuery) as MdxSelectStatement; if (statement != null) { if (statement.Where == null) { statement.Where = new MdxWhereClause(); } if (statement.Axes != null && statement.Axes.Count > 2) { IList <MdxExpression> expr = new List <MdxExpression>(); if (statement.Where.Expression != null) { expr.Add(statement.Where.Expression); } for (int i = 2; i < statement.Axes.Count; i++) { expr.Add(statement.Axes[i].Expression); } statement.Where.Expression = new MdxTupleExpression(expr); while (statement.Axes.Count > 2) { statement.Axes.RemoveAt(2); } } StringBuilder sb = new StringBuilder(); provider.GenerateMdxFromDom(statement, sb, new MdxGeneratorOptions()); result = sb.ToString(); } } } return(result); }
private MdxSelectStatement GetMoveAxesStatement(String originalQuery) { MdxSelectStatement statement = null; if (!String.IsNullOrEmpty(originalQuery)) { using (MdxDomProvider provider = MdxDomProvider.CreateProvider()) { statement = provider.ParseMdx(originalQuery) as MdxSelectStatement; if (statement != null) { if (statement.Where == null) { statement.Where = new MdxWhereClause(); } if (statement.Axes != null && statement.Axes.Count > 2) { IList <MdxExpression> expr = new List <MdxExpression>(); if (statement.Where.Expression != null) { expr.Add(statement.Where.Expression); } for (int i = 2; i < statement.Axes.Count; i++) { expr.Add(statement.Axes[i].Expression); } statement.Where.Expression = new MdxTupleExpression(expr); while (statement.Axes.Count > 2) { statement.Axes.RemoveAt(2); } } } } } return(statement); }