From b622df4187d0e6cd33eac0af22e095adfb45b374 Mon Sep 17 00:00:00 2001 From: OlgunR Date: Tue, 9 Jun 2026 11:48:49 +0200 Subject: [PATCH] Revert "Refactor PDF viewing and integrate DevExpress support" This reverts commit b515b4f523d6532dcbe1de3ff5054e3bdd2e629a. --- .../Controllers/DocumentViewerController.cs | 16 ----------- .../DXApp.TemplateKitProject.csproj | 4 +++ .../Pages/Invoices/ViewPdf.cshtml | 6 +--- .../Pages/Invoices/ViewPdf.cshtml.cs | 28 ++++--------------- DXApp.TemplateKitProject/Program.cs | 6 ---- 5 files changed, 11 insertions(+), 49 deletions(-) delete mode 100644 DXApp.TemplateKitProject/Controllers/DocumentViewerController.cs diff --git a/DXApp.TemplateKitProject/Controllers/DocumentViewerController.cs b/DXApp.TemplateKitProject/Controllers/DocumentViewerController.cs deleted file mode 100644 index 638aa97..0000000 --- a/DXApp.TemplateKitProject/Controllers/DocumentViewerController.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using DevExpress.AspNetCore.Reporting.WebDocumentViewer; -using DevExpress.AspNetCore.Reporting.WebDocumentViewer.Native.Services; - -namespace DXApp.TemplateKitProject.Controllers -{ - [Route("DocumentViewer")] - public class DocumentViewerController : WebDocumentViewerController - { - // Hier den erwarteten DevExpress-Service injizieren und an die Basisklasse weitergeben - public DocumentViewerController(IWebDocumentViewerMvcControllerService controllerService) - : base(controllerService) - { - } - } -} \ No newline at end of file diff --git a/DXApp.TemplateKitProject/DXApp.TemplateKitProject.csproj b/DXApp.TemplateKitProject/DXApp.TemplateKitProject.csproj index 9ad3b1f..b0e4ad9 100644 --- a/DXApp.TemplateKitProject/DXApp.TemplateKitProject.csproj +++ b/DXApp.TemplateKitProject/DXApp.TemplateKitProject.csproj @@ -29,4 +29,8 @@ + + + + diff --git a/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml b/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml index 122106c..8fd4c95 100644 --- a/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml +++ b/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml @@ -1,6 +1,2 @@ @page -@model DXApp.TemplateKitProject.Pages.Invoices.ViewPdfModel -@{ - Layout = "_Layout"; - // Diese Seite liefert keinen HTML-Content; der Handler gibt die PDF zurück. -} \ No newline at end of file +@model DXApp.TemplateKitProject.Pages.Invoices.ViewPdfModel \ No newline at end of file diff --git a/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml.cs b/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml.cs index a13f182..13c9690 100644 --- a/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml.cs +++ b/DXApp.TemplateKitProject/Pages/Invoices/ViewPdf.cshtml.cs @@ -1,40 +1,24 @@ -using Microsoft.AspNetCore.Mvc; +using DXApp.TemplateKitProject.Data; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using DXApp.TemplateKitProject.Data; using Microsoft.EntityFrameworkCore; namespace DXApp.TemplateKitProject.Pages.Invoices; -public class ViewPdfModel : PageModel +public class ViewPdfModel(AppDbContext db) : PageModel { - private readonly AppDbContext _db; - private readonly ILogger _logger; - - public ViewPdfModel(AppDbContext db, ILogger logger) - { - _db = db; - _logger = logger; - } - public async Task OnGetAsync(int id) { - // Sicherheit: defensive checks, gleiche Logik wie CustomReportStorageWebExtension - var invoice = await _db.ZugferdInvoices - .AsNoTracking() + var invoice = await db.ZugferdInvoices .FirstOrDefaultAsync(i => i.Id == id); - if (invoice is null) - return NotFound(); - - if (string.IsNullOrEmpty(invoice.ResultFilePath)) + if (invoice is null || string.IsNullOrEmpty(invoice.ResultFilePath)) return NotFound(); if (!System.IO.File.Exists(invoice.ResultFilePath)) return NotFound(); var bytes = await System.IO.File.ReadAllBytesAsync(invoice.ResultFilePath); - _logger.LogInformation("ViewPdf: Invoice {Id} ausgeliefert ({Size} Bytes).", id, bytes.Length); - - return File(bytes, "application/pdf", $"{Path.GetFileName(invoice.ResultFilePath)}"); + return File(bytes, "application/pdf"); } } \ No newline at end of file diff --git a/DXApp.TemplateKitProject/Program.cs b/DXApp.TemplateKitProject/Program.cs index e384f61..14ce1b5 100644 --- a/DXApp.TemplateKitProject/Program.cs +++ b/DXApp.TemplateKitProject/Program.cs @@ -8,9 +8,6 @@ using DevExpress.XtraReports.Web.Extensions; var builder = WebApplication.CreateBuilder(args); -// MVC-Controller hinzufügen (benötigt für DevExpress WebDocumentViewer) -builder.Services.AddControllersWithViews(); - builder.Services.AddRazorPages(); // DevExpress Controls und Reporting Services @@ -55,8 +52,5 @@ app.UseDevExpressControls(); app.UseRouting(); app.UseAuthorization(); - -// Controller-Routen verfügbar machen (wichtig für DevExpress WebDocumentViewer) -app.MapControllers(); app.MapRazorPages(); app.Run(); \ No newline at end of file