Esempio n. 1
0
        /// <summary>
        /// 执行分页数据
        /// </summary>
        /// <param name="inEnt"></param>
        /// <param name="sqlStr"></param>
        /// <returns></returns>
        public async Task <ResultObj <Dictionary <string, object> > > QueryPageExecute(QuerySearchDto inEnt)
        {
            ResultObj <Dictionary <string, object> > reObj = new ResultObj <Dictionary <string, object> >();
            Dictionary <string, object> reEnt = new Dictionary <string, object>();
            SysQueryEntity query = await dal.Single(i => i.code == inEnt.code);

            if (query == null)
            {
                return(reObj);
            }

            string whereStr = "";
            string AllSql   = MakeSql(inEnt, query.queryConf, ref whereStr);

            if (string.IsNullOrWhiteSpace(inEnt.orderStr))
            {
                inEnt.orderStr = "(SELECT 0)";
            }
            reObj.msg = MakePageSql(AllSql, inEnt.page, inEnt.rows, inEnt.orderStr, whereStr);
            try
            {
                var sqlList = reObj.msg.Split(';');
                if (sqlList.Count() > 0)
                {
                    reObj.dataList = dal.Query(sqlList[0]);
                }

                if (sqlList.Count() > 1)
                {
                    int allNum = 0;
                    int.TryParse(await dal.ExecuteScalarAsync(sqlList[1]), out allNum);
                    reObj.total = allNum;
                }
            }
            catch (Exception e)
            {
                LogHelper.WriteErrorLog(this.GetType(), "执行分页数据失败", e);
                return(reObj);
            }
            return(reObj);
        }