示例#1
0
        //[GZipOrDeflate]
        public ActionResult Category(string report, string title)
        {
            if (report.IsEmpty())
            {
                return(Redirect("/Report/Index"));
            }
            CommondController  commond        = new CommondController(_db);
            rpt_categorydetail categoryDetail = commond.GetCategoryDetail(report);
            string             sqlValue       = null;

            if (HttpContext.Request.QueryString["CustomQuery"] != null)
            {
                sqlValue = SessionHelper.GetSqlValue().IsEmpty() ? categoryDetail.Sqlvalue : SessionHelper.GetSqlValue();
            }
            if (HttpContext.Request.QueryString["RestSetUp"] == null && HttpContext.Request.QueryString["CustomQuery"] == null)
            {
                SessionHelper.RestSqlValue();
                SessionHelper.RestTotalName();
            }

            if (categoryDetail == null)
            {
                BugLog.Write("report=------" + report);
                throw new ArgumentException("报表类别为空  请联系管理员;");
            }
            DataTable T = commond.GetDataTableOneRow(sqlValue ?? categoryDetail.Sqlvalue);

            #region T 不为空的时候
            if (T != null && T.Rows.Count > 0)
            {
                var CName = T.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray();
                var CType = T.Columns.Cast <DataColumn>().Select(x => x.DataType.FullName).ToArray();

                ViewBag.ColumnName = CName;
                ViewBag.ColumnType = CType;
                ViewBag.Total      = categoryDetail.Total.IsEmpty() ? "" : categoryDetail.Total;
                ViewBag.zdString   = string.Join(",", CName);
                ViewBag.lxString   = string.Join(",", CType);
                ViewBag.排序字段       = categoryDetail.Sort.IsEmpty() ? CName[0] : CName.Contains(categoryDetail.Sort) ? categoryDetail.Sort : CName[0];
                ViewBag.排序方式       = categoryDetail.Order.IsEmpty() ? "desc" : categoryDetail.Order;
                ViewBag.显示的类型      = "System.TimeSpan,System.Byte[]";
                ViewBag.Title      = categoryDetail.Detailedname ?? title;
                ViewBag.report     = categoryDetail.Id;
            }
            #endregion
            return(View());
        }
示例#2
0
        private ActionResult TotalMethod(PageList pageList, TotalType totalTypes)
        {
            if (pageList.report.IsEmpty())
            {
                return(Content("参数不能为空"));
            }

            CommondController  commond        = new CommondController(_db);
            rpt_categorydetail categoryDetail = commond.GetCategoryDetail(pageList.report);

            if (categoryDetail == null)
            {
                return(Content("参数出错"));
            }
            string sqlValue = string.Empty;

            if (totalTypes == TotalType.PageTotal)
            {
                sqlValue = Session["LimitSqlValue"].ToString() ?? "";
            }
            else if (totalTypes == TotalType.TableTotal)
            {
                sqlValue = commond.GetSqlValue(pageList.report, isFillter: true); /*TODO: isFillter:true TotalMethod*/
            }
            else
            {
                return(Content("错误的请求类型"));
            }

            if (sqlValue.IsNotEmpty())
            {
                string orderCountSql = commond.GetOrderCountSqlValue(sqlValue);

                pageList.total = categoryDetail.Total;
                string[] totalList = categoryDetail.Total.Split(',');
                ViewBag.columnname = totalList;
                string sum = totalList.sumField();
                sqlValue = string.Format("select {0} from ({1}) xiaoji", sum, sqlValue);

                DataSet ds = commond.GetDataSet(orderCountSql + ";" + sqlValue);

                return(PartialView("_PartialTotal", ds));
            }

            return(Content("sql语句为空"));
        }