Ejemplo n.º 1
0
 public AreaChartComponent(IOptions <DashReportAppSettings> appSettings)
 {
     this.appSettings = appSettings.Value;
 }
Ejemplo n.º 2
0
 public ReportComponent(IReportService reportService, IOptions <DashReportAppSettings> appSettings)
 {
     this.reportService = reportService;
     this.appSettings   = appSettings.Value;
 }
Ejemplo n.º 3
0
 public HistogramsComponent(IOptions <DashReportAppSettings> appSettings)
 {
     this.appSettings = appSettings.Value;
 }
Ejemplo n.º 4
0
        public async static Task <ReportEntity> Execute(Guid id, string cSharpCode, IReportService reportService, DashReportAppSettings appSettings, ReportType ContentType = ReportType.View)
        {
            var output = new List <string>();

            // define source code, then parse it (to the type used for compilation)
            SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(cSharpCode);


            var coreDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location);

            var files = Directory.GetFiles(coreDir, "*.dll");

            List <MetadataReference> references = new List <MetadataReference>();

            foreach (var item in files)
            {
                var fi = new FileInfo(item);
                if (fi.Name.Contains("System."))
                {
                    references.Add(MetadataReference.CreateFromFile(item));
                }
            }

            references.Add(MetadataReference.CreateFromFile(typeof(TimeZoneExtention).Assembly.Location));

            // define other necessary objects for compilation
            string assemblyName = Path.GetRandomFileName();

            // analyse and generate IL code from syntax tree
            CSharpCompilation compilation = CSharpCompilation.Create(
                assemblyName,
                syntaxTrees: new[] { syntaxTree },
                references: references,
                options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));

            using (var ms = new MemoryStream())
            {
                // write IL code into memory
                EmitResult result = compilation.Emit(ms);

                if (!result.Success)
                {
                    // handle exceptions
                    IEnumerable <Diagnostic> failures = result.Diagnostics.Where(diagnostic =>
                                                                                 diagnostic.IsWarningAsError ||
                                                                                 diagnostic.Severity == DiagnosticSeverity.Error);

                    foreach (Diagnostic diagnostic in failures)
                    {
                        output.Add(diagnostic.Id + ": " + diagnostic.GetMessage());
                        //Console.Error.WriteLine("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
                    }
                }
                else
                {
                    // load this 'virtual' DLL so that we can use
                    ms.Seek(0, SeekOrigin.Begin);
                    Assembly assembly = Assembly.Load(ms.ToArray());

                    // just need to define these two....
                    Dictionary <string, object> parameterValues = new Dictionary <string, object>(); // empty right now


                    // create instance of the desired class and call the desired function
                    Type         type = assembly.GetType("DashReportViewer.Reports.Report");
                    ReportEntity obj  = (ReportEntity)Activator.CreateInstance(type, parameterValues, reportService);

                    await obj.Run();



                    var components = new List <BaseReportReportComponent>();
                    foreach (Widget widget in obj.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(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 (obj != null)
                    {
                        return(obj);
                    }
                    throw new Exception("Report is null");
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
 public ReportService(IServiceProvider serviceProvider, IOptions <DashReportAppSettings> appSettings, DashReportViewerContext dashReportViewerContext)
 {
     this.serviceProvider         = serviceProvider;
     this.appSettings             = appSettings.Value;
     this.dashReportViewerContext = dashReportViewerContext;
 }
Ejemplo n.º 6
0
 public UsersController(IOptions <DashReportAppSettings> appSettings, IUserService userService)
 {
     this.appSettings = appSettings.Value;
     this.userService = userService;
 }
Ejemplo n.º 7
0
 public TableComponent(IOptions <DashReportAppSettings> appSettings)
 {
     this.appSettings = appSettings.Value;
 }
Ejemplo n.º 8
0
 public GaugeChartReportViewComponent(IOptions <DashReportAppSettings> appSettings)
 {
     this.appSettings = appSettings.Value;
 }
Ejemplo n.º 9
0
 public CandlestickChartComponent(IOptions <DashReportAppSettings> appSettings)
 {
     this.appSettings = appSettings.Value;
 }
Ejemplo n.º 10
0
 public ReportController(IReportService reportService, INotesService notesService, IOptions <DashReportAppSettings> appSettings)
 {
     this.reportService = reportService;
     this.appSettings   = appSettings.Value;
     this.notesService  = notesService;
 }
 public CompanyHeaderViewComponent(IOptions <DashReportAppSettings> appSettings)
 {
     this.appSettings = appSettings.Value;
 }
Ejemplo n.º 12
0
 public EditorController(IReportService reportService, IOptions <DashReportAppSettings> appSettings)
 {
     this.reportService = reportService;
     this.appSettings   = appSettings.Value;
 }