// 知识库
        // GET: /Platform/CustomerLevel/

        public ActionResult Index(string keyword, string ordering, int pageIndex = 1)
        {
            var model =
                _iCustomerLevelService.GetAll()
                .Select(
                    a =>
                    new
            {
                a.CustomerLevelName,
                a.SystemId,
                a.CreatedDate,
                a.Remark,
                a.Id
            }).Search(keyword);


            if (!string.IsNullOrEmpty(ordering))
            {
                model = model.OrderBy(ordering, null);
            }


            if (!string.IsNullOrEmpty(Request["report"]))
            {
                //导出
                var reportModel = new Report(model.ToReportSource());
                return(new ReportResult(reportModel));
            }

            return(View(model.ToPagedList(pageIndex)));
        }
示例#2
0
        public ActionResult Details(string reportType, int width = 550, int height = 350)
        {
            var chart = new Chart {
                Height = height, Width = width
            };

            chart.Legends.Add("图例");
            var chartArea = new ChartArea("Area1")
            {
                AxisX = { Interval = 1 }, Area3DStyle = { Enable3D = true }
            };

            chart.ChartAreas.Add(chartArea);

            var seriescountAll = new Series();

            switch (reportType)
            {
            case "BusinessState":
                chart.Titles.Add(new Title("业务状态", Docking.Top, new Font("微软雅黑", 20), Color.Black));

                seriescountAll.ChartArea = "Area1";

                seriescountAll.IsVisibleInLegend   = true;
                seriescountAll.IsValueShownAsLabel = true;
                seriescountAll.Label = "#VALX  #VALY";
                seriescountAll.Points.DataBind(
                    _iBusinessStateService.GetAll(a => a.Statistics && a.Customers.Any(b => !b.Deleted))
                    .Select(a => new { Key = a.BusinessStateName, Count = a.Customers.Count() }), "Key", "Count",
                    "");
                seriescountAll.ChartType = SeriesChartType.Funnel;

                chart.Series.Add(seriescountAll);

                break;

            case "BusinessChance":

                chart.Titles.Add(new Title("业务机会", Docking.Top, new Font("微软雅黑", 20), Color.Black));

                seriescountAll.ChartArea = "Area1";

                seriescountAll.IsVisibleInLegend   = true;
                seriescountAll.IsValueShownAsLabel = true;
                seriescountAll.Label = "#VALX  #VALY";
                seriescountAll.Points.DataBind(
                    _iBusinessChanceService.GetAll(a => a.CustomerBusinessChances.Any(b => !b.Deleted))
                    .Select(a => new { Key = a.BusinessChanceName, Count = a.CustomerBusinessChances.Count() }),
                    "Key", "Count", "");

                seriescountAll.ChartType = SeriesChartType.Pie;

                chart.Series.Add(seriescountAll);

                break;

            case "CustomerType":

                chart.Titles.Add(new Title("客户类型", Docking.Top, new Font("微软雅黑", 20), Color.Black));

                seriescountAll.ChartArea           = "Area1";
                seriescountAll.Color               = Color.CornflowerBlue;
                seriescountAll.IsVisibleInLegend   = true;
                seriescountAll.IsValueShownAsLabel = true;
                seriescountAll.Label               = "#VALX  #VALY";
                seriescountAll.Points.DataBind(_iCustomerTypeService.GetAll(a => a.Customers.Any(b => !b.Deleted))
                                               .Select(a => new { Key = a.CustomerTypeName, Count = a.Customers.Count() }), "Key", "Count", "");

                seriescountAll.ChartType = SeriesChartType.Doughnut;

                chart.Series.Add(seriescountAll);

                break;

            case "CustomerLevel":

                chart.Titles.Add(new Title("客户等级", Docking.Top, new Font("微软雅黑", 20), Color.Black));

                seriescountAll.ChartArea = "Area1";

                seriescountAll.IsVisibleInLegend   = true;
                seriescountAll.IsValueShownAsLabel = true;
                seriescountAll.Label = "#VALX  #VALY";

                seriescountAll.Points.DataBind(_iCustomerLevelService.GetAll(a => a.Customers.Any(b => !b.Deleted))
                                               .Select(a => new { Key = a.CustomerLevelName, Count = a.Customers.Count() }), "Key", "Count", "");

                seriescountAll.ChartType = SeriesChartType.Doughnut;

                chart.Series.Add(seriescountAll);

                break;
            }

            var imageStream = new MemoryStream();

            chart.SaveImage(imageStream, ChartImageFormat.Png);
            imageStream.Position = 0;
            return(new FileStreamResult(imageStream, "image/png"));
        }