Esempio n. 1
0
        public Task <IActionResult> GenerateAsync(
            Controller controller, TemplateConfiguration templateConfiguration, Product product)
        {
            var products = new List <Product> {
                product
            };

            using var reportFileStream = File.OpenRead(templateConfiguration.FilePath);

            var report = new Report();

            report.Load(reportFileStream);
            report.RegisterData(products, "Products");

            var localizationStrings = new ReportLocalizationStringsBuilder(_localizer)
                                      .Build(templateConfiguration.RequiredLocalizationStrings);

            report.RegisterData(
                new List <ReportLocalizationStrings> {
                localizationStrings
            }, "LocalizationStrings");

            report.Prepare();

            using var exportStream = File.Create("Labels.pdf");
            new PDFSimpleExport().Export(report, exportStream);

            return(Task.FromResult <IActionResult>(controller.RedirectToAction("ProductInfo", "Home")));
        }
Esempio n. 2
0
        public Task <IActionResult> GenerateAsync(
            Controller controller,
            TemplateConfiguration templateConfiguration,
            Product product)
        {
            var products = new List <Product> {
                product
            };

            using var reportFileStream = File.OpenRead(templateConfiguration.FilePath);

            var report = new Report();

            report.Load(reportFileStream);
            report.RegisterData(products, "Products");

            var localizationStrings = new ReportLocalizationStringsBuilder(_localizer)
                                      .Build(templateConfiguration.RequiredLocalizationStrings);

            report.RegisterData(
                new List <ReportLocalizationStrings> {
                localizationStrings
            }, "LocalizationStrings");

            report.Prepare();

            var exportStream = new MemoryStream();

            new PDFSimpleExport().Export(report, exportStream);

            exportStream.Position = 0;
            return(Task.FromResult <IActionResult>(controller.File(exportStream, "application/pdf")));
        }
Esempio n. 3
0
        public Task <IActionResult> GenerateAsync(
            Controller controller, TemplateConfiguration templateConfiguration, Product product)
        {
            var webReport = new WebReport();

            using var reportStream = File.OpenRead(templateConfiguration.FilePath);

            webReport.Report.Load(reportStream);
            webReport.Report.RegisterData(new List <Product> {
                product
            }, "Products");


            var localizationStrings = new ReportLocalizationStringsBuilder(_localizer)
                                      .Build(templateConfiguration.RequiredLocalizationStrings);

            webReport.Report.RegisterData(
                new List <ReportLocalizationStrings> {
                localizationStrings
            }, "LocalizationStrings");

            // ReSharper disable once Mvc.ViewNotResolved
            return(Task.FromResult <IActionResult>(controller.View("WebReport", webReport)));
        }