/// <summary> /// 根据存储过程替换参数,并执行查询 /// </summary> /// <param name="data">条件</param> private void DoProc(dynamic data) { var db = DBCRMTree.GetInstance(); object queryParams = data.queryParams; var MF_FL_FB_Code = (int)data.MF_FL_FB_Code; var rp_code = BL_Reports.GetReportCode(MF_FL_FB_Code); var sql = BL_Reports.GetReportSql(rp_code, queryParams); var items = db.Query <dynamic>(sql); var pageInfo = JsonConvert.SerializeObject(new { total = 0, rows = items }); Response.Write(pageInfo); }
/// <summary> /// 分页 /// </summary> /// <param name="data">分页条件</param> private void DoPage(dynamic data) { Page <dynamic> pager = new Page <dynamic>(); pager.Items = new List <dynamic>(); var db = DBCRMTree.GetInstance(); object queryParams = data.queryParams; var MF_FL_FB_Code = (int)data.MF_FL_FB_Code; var rp_code = BL_Reports.GetReportCode(MF_FL_FB_Code); var sql = BL_Reports.GetReportSql(rp_code, queryParams); var dataInfo = string.Empty; if (sql.SQL.IndexOf(";Exec", StringComparison.OrdinalIgnoreCase) >= 0) { var qData = db.Query <dynamic>(sql); dataInfo = JsonConvert.SerializeObject(new { total = qData.Count(), rows = qData }); } else { var pSql = PetaPoco.Sql.Builder; var sort = (string)data.sort; var order = (string)data.order; pSql.Append("select * from(" + sql.SQL, sql.Arguments); pSql.Append(") as dt"); if (!string.IsNullOrWhiteSpace(sort)) { pSql.Append(string.Format(" order by {0} {1}", sort, order)); } pager = db.Page <dynamic>((long)data.pageNumber, (long)data.pageSize, pSql); //pager.Items[0].Results = "<div style=\"width:100%;height:100%\">100<span class=\"SType50\" />75<span class=\"SType50\" />45</div>"; dataInfo = JsonConvert.SerializeObject(new { total = pager.TotalItems, rows = pager.Items }); } Response.Write(dataInfo); }