Exemplo n.º 1
0
        public Soway.Query.BoolExp.BoolExpression GetQueryExp(Soway.Service.Report.BoolExp exp, QueryModel model, Model.SqlCon con, Soway.Query.QueryInstance ins)
        {
            Soway.Query.BoolExp.BoolExpresstionFacotry fac = new Query.BoolExp.BoolExpresstionFacotry(ins);
            var result = new BoolExpression();

            if (exp.Col != null)
            {
                //简单类型
                var col = model.Columns.First(p => p.ID == exp.Col.ID);

                result.Exp = fac.CreateBoolExpression(new Query.CompareCol()
                {
                    Col = col,
                    SelectedTableName = model.Table.ShowName
                }, QueryCache.GetCompareType(con, col.DataType).First(p => p.ID.ToString() == exp.CompareOp.ID), exp.ValueExp,
                                                      exp.ValueFmt, exp.ParamName);
            }
            else if (exp.FirstExp != null)
            {
                //复杂类型

                result =
                    GetQueryExp(exp.FirstExp, model, con, ins);
                foreach (var sequence in exp.Sequences)
                {
                    fac.AddBoolExpression(
                        result,
                        sequence.BoolOp,
                        GetQueryExp(sequence.AddedExp, model, con, ins));
                }
            }


            return(result);
        }
Exemplo n.º 2
0
        protected override void ImplementBusinessLogic()
        {
            var view       = new Soway.Model.View.AutoViewFactory(this.Info.AppSqlCon, this).GetView(this.Opt.ViewId);
            var queryModel = new Soway.Model.Query.QueryFactory(this.Info.AppSqlCon, this).GetQueryModel(view);

            this.ReturnData.Cols = new List <QueryCol>();
            foreach (var col in queryModel.Columns)
            {
                var item = new QueryCol()
                {
                    Name    = col.ShowName,
                    ID      = col.ID,
                    PrpType = col.DataType,
                    ModelId = col.ModelId,
                    States  = col.States
                };
                item.CompareTypes = new List <CompareOpItem>();
                foreach (var compare in QueryCache.GetCompareType(this.Info.AppSqlCon, col.DataType))
                {
                    item.CompareTypes.Add(new CompareOpItem()
                    {
                        ID   = compare.ID.ToString(),
                        Name = compare.ShowName
                    });
                }

                item.QueryTypes = new List <QueryType>();

                foreach (var select in QueryCache.GetSelectedType(this.Info.AppSqlCon, col.DataType))
                {
                    item.QueryTypes.Add(new QueryType()
                    {
                        ID   = select.ID.ToString(),
                        Name = select.Show,
                    });
                }
                this.ReturnData.Cols.Add(item);
            }
        }
Exemplo n.º 3
0
        protected override void ImplementBusinessLogic()
        {
            var view = new Soway.Model.View.AutoViewFactory(this.Info.AppSqlCon, this).GetView(this.Opt.ViewId);

            var sqlCon     = GetViewSql(view);
            var fac        = new Soway.Model.Query.QueryFactory(this.Info.AppSqlCon, this);
            var queryModel = fac.GetQueryModel(view);
            var cxt        = new Soway.Query.QueryContext(fac, sqlCon.ToString());

            cxt.Add(queryModel.Table);
            cxt.Ins.BoolExp = new BoolExpAdapter(queryModel).GetQueryExp(this.Opt.FilterExp,
                                                                         queryModel, this.Info.AppSqlCon, cxt.Ins);
            new Soway.Query.QueryInsFac().RefreshQueryInsReportParam(cxt.Ins);
            foreach (var col in this.Opt.ReportCols)
            {
                var queryCol     = queryModel.Columns.First(p => p.ID == col.ColId);
                var selectedType = QueryCache.GetSelectedType(this.Info.AppSqlCon, queryCol.DataType);
                cxt.Ins.SelectedCols.Add(new Query.SelectedCol()
                {
                    DataCol       = queryModel.Columns.First(p => p.ID == col.ColId),
                    SelectType    = selectedType.First(p => p.ID.ToString() == col.SelectedTypeId),
                    SelectedIndex = col.Index,
                    SelectedName  = col.ColName,
                    OrderType     = col.OrderType,
                    SelectedTable = cxt.Ins.SelectedTables.Tables.First()
                });
            }



            var qresult = cxt.GetResult(sqlCon.ToString(), Opt.PageSize);

            qresult.CurrentPage = this.Opt.CurrentPage;
            var table = qresult.GetData();

            Soway.Report.ReportFactory rfac = new Soway.Report.ReportFactory();

            Soway.Report.TableFormat rfmt  = new Soway.Report.TableFormat();
            List <ReportCell>        cells = new List <ReportCell>();
            int row = 0;

            foreach (DataColumn column in table.Columns)
            {
                rfmt.ValueCell.Add(new Soway.Report.ValueCell
                {
                    SourceColumn = column.ColumnName,
                    Name         = column.ColumnName
                });
                cells.Add(new ReportCell()
                {
                    Col = 0, Row = row, ColSpan = 1, RowSpan = 1, FmtValue = column.ColumnName
                });
            }
            var matrix = new Soway.Report.Views.MatrixTableFactory().CreateMatrixTable(rfmt, table);

            foreach (var cell in matrix.Cells)
            {
                row++;
                foreach (var vcell in cell.Cells)
                {
                    cells.Add(new ReportCell()
                    {
                        Col      = 0,
                        Row      = row,
                        ColSpan  = 1,
                        RowSpan  = 1,
                        FmtValue = vcell.Value.ToString()
                    });
                }
            }


            result.CurrentPage  = Opt.CurrentPage;
            result.PageSize     = Opt.PageSize;
            result.TotalPages   = qresult.TotalPages;
            result.TotalRecords = qresult.TotalRecords;
            result.ViewId       = Opt.ViewId;
            result.Cells        = cells;
        }