Exemplo n.º 1
0
        protected override DataTable FetchRows(TkDbContext context, DataSet dataSet,
                                               IParamBuilder builder, int topCount)
        {
            SqlSelector selector = new SqlSelector(context, dataSet);

            using (selector)
            {
                IParamBuilder addBuilder = CreateAdditionCondition(context, fScheme);
                builder = ParamBuilder.CreateParamBuilder(builder, addBuilder);
                string whereSql;
                if (builder == null)
                {
                    whereSql = string.Empty;
                }
                else
                {
                    whereSql = "WHERE " + builder.Sql;
                }

                TableSchemeData schemeData = TableSchemeData.Create(context, fScheme);
                var             result     = context.ContextConfig.GetListSql(schemeData.SelectFields,
                                                                              GetTableName(context), schemeData.KeyFieldArray,
                                                                              whereSql, OrderBy, 0, topCount);
                ISimpleAdapter adapter = selector;
                adapter.SetSql(result.ListSql, builder);
                context.ContextConfig.SetListData(result, adapter, dataSet, 0, TopCount, EASYSEARCH_TABLE_NAME);

                return(dataSet.Tables[EASYSEARCH_TABLE_NAME]);
            }
        }
Exemplo n.º 2
0
        void ISqlProvider.SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet,
                                      int startRecord, int maxRecords, string srcTable)
        {
            TkDebug.AssertArgumentNull(adapter, "adapter", this);
            TkDebug.AssertArgumentNull(dataSet, "dataSet", this);
            TkDebug.AssertArgumentNullOrEmpty(srcTable, "srcTable", this);

            SetListData(context, adapter, dataSet, startRecord, maxRecords, srcTable);
        }
Exemplo n.º 3
0
        public void SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet,
                                int startRecord, int maxRecords, string srcTable)
        {
            TkDebug.AssertArgumentNull(adapter, "adapter", this);
            TkDebug.AssertArgumentNull(dataSet, "dataSet", this);
            TkDebug.AssertArgumentNullOrEmpty(srcTable, "srcTable", this);

            DbUtil.FillDataSet(adapter, dataSet, srcTable);
        }
Exemplo n.º 4
0
        protected virtual void SetListData(IListSqlContext context, ISimpleAdapter adapter,
                                           DataSet dataSet, int startRecord, int maxRecords, string srcTable)
        {
            TkDebug.AssertArgument(startRecord >= 0, "startRecord", string.Format(
                                       ObjectUtil.SysCulture, "参数startRecord不能为负数,现在的值为{0}", startRecord), this);
            TkDebug.AssertArgument(maxRecords >= 0, "number", string.Format(ObjectUtil.SysCulture,
                                                                            "参数maxRecords不能为负数,现在的值为{0}", maxRecords), this);

            DbUtil.FillDataSet(adapter, dataSet, srcTable, startRecord, maxRecords);
        }
Exemplo n.º 5
0
        void ISqlProvider.SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet,
                                      int startRecord, int maxRecords, string srcTable)
        {
            TkDebug.AssertArgumentNull(adapter, "adapter", this);
            TkDebug.AssertArgumentNull(dataSet, "dataSet", this);
            TkDebug.AssertArgumentNullOrEmpty(srcTable, "srcTable", this);
            TkDebug.AssertArgument(startRecord >= 0, "startRecord", string.Format(ObjectUtil.SysCulture,
                                                                                  "参数startRecord不能为负数,现在的值为{0}", startRecord), this);
            TkDebug.AssertArgument(maxRecords >= 0, "number", string.Format(ObjectUtil.SysCulture,
                                                                            "参数maxRecords不能为负数,现在的值为{0}", maxRecords), this);

            DbUtil.FillDataSet(adapter, dataSet, srcTable, startRecord, maxRecords);
        }
Exemplo n.º 6
0
        protected override void SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet,
                                            int startRecord, int maxRecords, string srcTable)
        {
            TkDebug.AssertArgumentNull(context, "context", this);

            YukonListSqlContext sqlContext = context.Convert <YukonListSqlContext>();

            if (sqlContext.UseTopSql)
            {
                base.SetListData(context, adapter, dataSet, startRecord, maxRecords, srcTable);
            }
            else
            {
                DbUtil.FillDataSet(adapter, dataSet, srcTable);
            }
        }
Exemplo n.º 7
0
        public void SelectTopRows(int topCount, IParamBuilder builder, string orderBy)
        {
            TkDebug.AssertArgumentNull(builder, "builder", this);
            TkDebug.AssertArgument(topCount > 0, "topCount", "参数必须大于0", this);

            string whereSql = builder.Sql;

            if (!string.IsNullOrEmpty(whereSql))
            {
                whereSql = "WHERE " + whereSql;
            }
            var listContext = Context.ContextConfig.GetListSql(ListFields, Context.EscapeName(TableName),
                                                               GetKeyFieldArray(), whereSql, orderBy, 0, topCount);

            SqlSelector selector = new SqlSelector(Context, HostDataSet);

            using (selector)
            {
                ISimpleAdapter adapter = selector;
                adapter.SetSql(listContext.ListSql, builder);
                Context.ContextConfig.SetListData(listContext, adapter, HostDataSet, 0,
                                                  topCount, TableName);
            }
        }
Exemplo n.º 8
0
 public void SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet,
                         int startRecord, int maxRecords, string srcTable)
 {
     InternalSqlProvider.SetListData(context, adapter, dataSet, startRecord, maxRecords, srcTable);
 }
Exemplo n.º 9
0
 internal static int FillDataSet(ISimpleAdapter adapter, DataSet dataSet, string tableName,
                                 int startRecord, int maxRecords)
 {
     TkTrace.LogInfo(adapter.SelectSql);
     return(adapter.Fill(dataSet, startRecord, maxRecords, tableName));
 }
Exemplo n.º 10
0
        //private readonly static Type BlobType = typeof(byte[]);

        internal static int FillDataSet(ISimpleAdapter adapter, DataSet dataSet, string tableName)
        {
            TkTrace.LogInfo(adapter.SelectSql);
            return(adapter.Fill(dataSet, tableName));
        }
Exemplo n.º 11
0
        protected void FillListDataSet(IInputData input, int pageNumber, int pageSize, int start)
        {
            ParamBuilderContainer condition = CreateListCondition(input);

            IOperateRight operateRight = null;

            if (TabSheets != null && TabSheets.Count > 0)
            {
                var selectedTab = GetSelectTabSheet(input);
                selectedTab.Selected = true;
                condition.Add(selectedTab.ParamBuilder);
                DataSet.Tables.Add(TabSheets.CreateTable("TabSheet"));
            }

            if (input.QueryString["GetData"] != "Page" && !input.IsPost)
            {
                MainResolver.FillCodeTable(input.Style);
                CreateListOperators(input, ref operateRight);
            }

            ListSortInfo listInfo = new ListSortInfo(input);
            string       orderby  = null;

            if (input.IsPost)
            {
                orderby = SetPostListInfo(input, condition, listInfo);
            }
            else
            {
                orderby = SetGetListInfo(input, condition, listInfo);
            }

            CountInfo pageInfo = CreatePageInfo(input, pageNumber, pageSize, condition);

            DataSet.Tables.Add(EnumUtil.Convert(pageInfo).CreateTable("Count"));
            DataSet.Tables.Add(EnumUtil.Convert(listInfo).CreateTable("Sort"));

            if (pageInfo.TotalCount <= 0)
            {
                OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize,
                                                           pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition));
                return;
            }

            int    recCount    = pageSize * pageNumber + start;
            string whereSql    = condition.IsEmpty ? string.Empty : "WHERE " + condition.Sql;
            var    listContext = FillListTable(MainResolver.ListFields, GetTableName(Context),
                                               MainResolver.GetKeyFieldArray(), whereSql, orderby, recCount, pageSize);

            SqlSelector selector = new SqlSelector(Context, DataSet);

            using (selector)
            {
                ISimpleAdapter adapter = selector;
                adapter.SetSql(listContext.ListSql, condition);
                Context.ContextConfig.SetListData(listContext, adapter, DataSet, recCount,
                                                  pageSize, FillTableName);

                MainResolver.AddVirtualFields();

                if (Operators != null)
                {
                    if (operateRight == null)
                    {
                        operateRight = Operators.Right.CreateObject();
                    }
                    var allOperators = Operators.Operators;
                    if (allOperators != null)
                    {
                        CreateRowOperators(input, operateRight, allOperators);
                    }
                }
                MainResolver.Decode(input.Style);

                OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize,
                                                           pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition));
            }
        }