Beispiel #1
0
        static void Main(string[] args)
        {
            var jsreportDirectory = Path.Combine(System.Environment.CurrentDirectory.Substring(0, System.Environment.CurrentDirectory.LastIndexOf("bin")), "jsreport");

            Console.WriteLine("Starting jsreport in " + jsreportDirectory);

            var rs = new LocalReporting()
                     .UseBinary(JsReportBinary.GetBinary())
                     .KillRunningJsReportProcesses()
                     .RunInDirectory(jsreportDirectory)
                     .Configure(cfg => cfg.CreateSamples()
                                .FileSystemStore()
                                .BaseUrlAsWorkingDirectory())
                     .AsWebServer()
                     .RedirectOutputToConsole()
                     .Create();

            rs.StartAsync().Wait();

            Process.Start(new ProcessStartInfo("cmd", $"/c start http://localhost:5488"));

            Console.ReadKey();

            rs.KillAsync().Wait();
        }
        public void GenerateEventReport(int eventId)
        {
            var rs = new LocalReporting()
                     .RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "jsreport"))
                     .KillRunningJsReportProcesses()
                     .UseBinary(JsReportBinary.GetBinary())
                     .Configure(cfg => cfg.AllowedLocalFilesAccess().FileSystemStore().BaseUrlAsWorkingDirectory())
                     .AsUtility()
                     .Create();

            var r = new PaxResult {
                pos = 1, number = 25, class_name = "GS", car = "GTI", name = "Aaron Hall", best_run = 33.456, pax_time = 30.234, diff = 0, from_first = 0, points = 10000
            };

            var p = new Pax {
                year = 2019, event_num = 5, date = "8/19/2018", drivers = new List <PaxResult>()
            };

            for (int i = 0; i < 200; ++i)
            {
                p.drivers.Add(r);
            }

            var json = JsonConvert.SerializeObject(p);

            var invoiceReport = rs.RenderByNameAsync("EventPaxReport", json).Result;

            invoiceReport.Content.CopyTo(File.OpenWrite("event.pdf"));
            invoiceReport.Content.Close();
            rs.KillAsync();
        }
Beispiel #3
0
        static async task Main(string[] args)
        {
            var rs = new LocalReporting()
                     .UseBinary(JsReportBinary.GetBinary())
                     .RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "jsreport"))
                     .KillRunningJsReportProcesses()
                     .Configure(cfg => cfg.CreateSamples().FileSystemStore())
                     .AsWebServer()
                     .RedirectOutputToConsole()
                     .Create();


            await rs.StartAsync();

            Console.ReadKey();
            await rs.KillAsync();
        }