예제 #1
0
        public DetailPagingRet DetailPaging(ExecuteDelegate executeAction,
                                            int pageIndex, int pageSize,
                                            string fixedSql, string selectSql, SqlParameter[] paramValues,
                                            CommandType commandType = CommandType.Text
                                            )
        {
            //##0 init
            string SELECTSQL, orderBodyString, SELECTWithoutOrder, fromBodyString, FINALSQL;
            int    totalCount = 0;

            //##1 Check
            DealHelper.DetailPagingHelper_Prepare(selectSql, out SELECTSQL);

            try
            {
                DealHelper.DetailPagingHelper_SplitStrings(SELECTSQL, out orderBodyString, out SELECTWithoutOrder, out fromBodyString);

                //##2 get finall sql
                DetailPagingHelper_SqlPageAndCount(paramValues, orderBodyString, SELECTWithoutOrder, fixedSql, pageIndex, pageSize,
                                                   out FINALSQL);

                //##3 exec sql expreession and return result
                DataTable querydt = executeAction(FINALSQL, paramValues, commandType);
                return(DetailPagingHelper_returnResult(querydt, totalCount));
            }
            catch (SqlException ex)
            {
                throw DealHelper.DetailPagingHelper_CatchException_SqlException(ex, fixedSql, SELECTSQL);
            }
            catch (Exception ex)
            {
                throw DealHelper.DetailPagingHelper_CatchException_CommonException(ex, fixedSql, SELECTSQL, totalCount);
            }
        }
        /// <summary>
        /// Detail to PagingAsync
        /// </summary>
        public async Task <DetailPagingRet> DetailPagingAsync(ExecuteAsyncDelegate executeAction,
                                                              int pageIndex, int pageSize,
                                                              string fixedSql, string selectSql, SqlParameter[] paramValues,
                                                              CommandType commandType = CommandType.Text
                                                              )
        {
            //##0 init
            string SELECTSQL, orderBodyString, SELECTWithoutOrder, fromBodyString, FINALSQL;
            int    totalCount = 0;
            var    paras      = new List <SqlParameter>();

            //##1 Check
            DealHelper.DetailPagingHelper_Prepare(selectSql, out SELECTSQL);

            try
            {
                DealHelper.DetailPagingHelper_SplitStrings(SELECTSQL, out orderBodyString, out SELECTWithoutOrder, out fromBodyString);

                string sqlCount;
                DetailPagingHelper_SqlCount(fixedSql, SELECTSQL, SELECTWithoutOrder, fromBodyString, orderBodyString, out sqlCount);

                //##2 get record total and begin to page
                DataTable countDt = await executeAction(sqlCount, paramValues, commandType);

                DetailPagingHelper_SqlPage(countDt, paramValues, orderBodyString, SELECTWithoutOrder, fixedSql,
                                           pageIndex, pageSize,
                                           ref SELECTSQL, ref paras,
                                           out totalCount, out FINALSQL);


                //##3 exec sql expreession and return result
                DataTable querydt = await executeAction(FINALSQL, paras.ToArray(), commandType);

                return(DetailPagingHelper_returnResult(querydt, totalCount));
            }
            catch (SqlException ex)
            {
                throw DealHelper.DetailPagingHelper_CatchException_SqlException(ex, fixedSql, SELECTSQL);
            }
            catch (Exception ex)
            {
                throw DealHelper.DetailPagingHelper_CatchException_CommonException(ex, fixedSql, SELECTSQL, totalCount);
            }
        }