Ejemplo n.º 1
0
        public async Task <IActionResult> Execute(string code)
        {
            Guid id = Guid.Parse("a21fda13-f36f-4af5-ac05-2a3dabae04ef");
            await reportService.UpdateCode(id, code);

            var result = await Compile.Execute(id, code, reportService, appSettings);

            return(Json(result));
        }
Ejemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync(Guid reportType, string param = null, ReportType ContentType = ReportType.View)
        {
            var paramsList = new Dictionary <string, object>();

            if (!String.IsNullOrWhiteSpace(param))
            {
                var fields = param.Split(',');
                foreach (var fieldItem in fields)
                {
                    var fielder = fieldItem.Replace("[", "");
                    fielder = fielder.Replace("]", "");
                    var fieldDef = fielder.Split('~');

                    var name  = fieldDef[0];
                    var value = fieldDef[1];

                    paramsList.Add(name, value);
                }
            }

            var result = await reportService.GetCode(reportType);

            if (result != null && !String.IsNullOrWhiteSpace(result.Code))
            {
                var report = await Compile.Execute(reportType, result.Code, reportService, appSettings);

                //var report = await reportService.RunReport(AppDomain.CurrentDomain, reportType, paramsList);

                var components = new List <BaseReportReportComponent>();
                foreach (Widget widget in report.RawData)
                {
                    if (widget.Content.GetType() == typeof(TableContent))
                    {
                        components.Add(new TableReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(AreaChartContent))
                    {
                        components.Add(new AreaChartReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(GaugeChartContent))
                    {
                        components.Add(new GaugeChartReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(BubbleChartContent))
                    {
                        components.Add(new BubbleChartReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(CalendarChartContent))
                    {
                        components.Add(new CalendarChartReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(PieChartContent))
                    {
                        components.Add(new PieChartReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(HistogramsContent))
                    {
                        components.Add(new HistogramsReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(ScatterChartContent))
                    {
                        components.Add(new ScatterChartReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(TextContent))
                    {
                        components.Add(new TextReportComponent(widget));
                    }
                    else if (widget.Content.GetType() == typeof(AnnotationChartContent))
                    {
                        components.Add(new AnnotationChartReportComponent(widget));
                    }
                }

                if (report != null)
                {
                    var viewModel = new ReportViewModel()
                    {
                        ReportName             = report.Name,
                        ReportDescription      = report.Description,
                        UniqueID               = report.Id,
                        Components             = components,
                        ContentType            = ContentType,
                        Parameters             = report.Parameters,
                        SideBarBackgroundColor = appSettings.SideBarColor
                    };

                    return(View(viewModel));
                }
                throw new Exception("Report is null");
            }
            else
            {
                return(View(null));
            }
        }