Exemple #1
0
        public CellSetData RefreshQuery(Func <MdxObject, MdxObject> objectConsumerPattern)
        {
            CellSetData res = null;

            if (!string.IsNullOrEmpty(Query))
            {
                using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                {
                    StringBuilder sb = new StringBuilder();
                    provider.GenerateMdxFromDom(this.CreateWrappedStatement(), sb, new MdxGeneratorOptions());

                    String new_Query = sb.ToString();

                    res = ExecuteQuery(new_Query);
                    //if (!String.IsNullOrEmpty(res))
                    //{
                    //    Application[QUERY] = new_Query;
                    //}
                }
            }
            else
            {
                // Пустой запрос
                res = new CellSetData();
            }
            return(res);
        }
Exemple #2
0
        public virtual DataSourceInfoArgs GetDataSourceInfo(ServiceCommandArgs args)
        {
            DataSourceInfoArgs res = new DataSourceInfoArgs();

            bool queryIsOK = true;

            try
            {
                using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                {
                    StringBuilder sb = new StringBuilder();
                    provider.GenerateMdxFromDom(this.CreateWrappedStatement(), sb, new MdxGeneratorOptions());

                    String new_Query = sb.ToString();

                    res.MDXQuery           = new_Query;
                    res.MovedAxes_MDXQuery = MoveAxes(new_Query);
                }
            }
            catch (Exception ex)
            {
                res.MDXQuery = ex.ToString();
                queryIsOK    = false;
            }

            res.ConnectionString = Executor.Connection.ConnectionID;
            res.UpdateScript     = UpdateScript;

            return(res);
        }
        public virtual DataSourceInfoArgs GetDataSourceInfo(UpdateEntry entry)
        {
            DataSourceInfoArgs res = new DataSourceInfoArgs();

            try
            {
                using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                {
                    StringBuilder sb = new StringBuilder();
                    provider.GenerateMdxFromDom(this.CreateWrappedStatement(), sb, new MdxGeneratorOptions());

                    String new_Query = sb.ToString();

                    res.MDXQuery           = new_Query;
                    res.MovedAxes_MDXQuery = MoveAxes(new_Query);
                }
            }
            catch (Exception ex)
            {
                res.MDXQuery = ex.ToString();
            }

            //res.ConnectionString = Connection.ConnectionID;
            res.UpdateScript = UpdateScript;

            return(res);
        }
Exemple #4
0
        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;
            MdxSelectStatement statement = GetMoveAxesStatement(originalQuery);

            if (statement != null)
            {
                using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                {
                    StringBuilder sb = new StringBuilder();
                    provider.GenerateMdxFromDom(statement, sb, new MdxGeneratorOptions());
                    result = sb.ToString();
                }
            }
            return(result);
        }
        public String BuildDrillThrough(CellInfo cell)
        {
            String result = String.Empty;

            if (cell != null)
            {
                //var tuple = new Dictionary<String, MemberInfo>();
                //if (cell.ColumnMember != null && cell.ColumnMember != MemberInfo.Empty)
                //{
                //    cell.ColumnMember.CollectAncestors(tuple);
                //}
                //if (cell.RowMember != null && cell.RowMember != MemberInfo.Empty)
                //{
                //    cell.RowMember.CollectAncestors(tuple);
                //}

                //var statement = GetMoveAxesStatement(RefreshQuery());
                var statement = this.CreateWrappedStatement();
                var tuple     = cell.GetTuple();
                if (statement != null && tuple != null && tuple.Count > 0)
                {
                    statement.Axes.Clear();
                    List <MdxExpression> members = new List <MdxExpression>();
                    foreach (var member in tuple.Values)
                    {
                        var expr = new MdxObjectReferenceExpression(member.UniqueName, member.Caption);
                        members.Add(expr);
                    }

                    statement.Axes.Add(new MdxAxis("0", new MdxTupleExpression(members)));

                    using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                    {
                        StringBuilder sb = new StringBuilder();
                        provider.GenerateMdxFromDom(statement, sb, new MdxGeneratorOptions());
                        result = sb.ToString();
                    }

                    if (!String.IsNullOrEmpty(result))
                    {
                        result = String.Format("DRILLTHROUGH {0}", result);
                    }
                }
            }
            return(result);
        }
Exemple #7
0
        public String RefreshQuery(Func <MdxObject, MdxObject> objectConsumerPattern)
        {
            String res = String.Empty;

            if (!string.IsNullOrEmpty(Query))
            {
                using (MdxDomProvider provider = MdxDomProvider.CreateProvider())
                {
                    StringBuilder sb = new StringBuilder();
                    provider.GenerateMdxFromDom(this.CreateWrappedStatement(), sb, new MdxGeneratorOptions());

                    res = sb.ToString();
                }
            }

            return(res);
        }
Exemple #8
0
        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);
        }