Revert "Refactor PDF viewing and integrate DevExpress support"

This reverts commit b515b4f523.
This commit is contained in:
OlgunR
2026-06-09 11:48:49 +02:00
parent 746465d8fe
commit b622df4187
5 changed files with 11 additions and 49 deletions

View File

@@ -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)
{
}
}
}

View File

@@ -29,4 +29,8 @@
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.71" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
</Project>

View File

@@ -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.
}

View File

@@ -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<ViewPdfModel> _logger;
public ViewPdfModel(AppDbContext db, ILogger<ViewPdfModel> logger)
{
_db = db;
_logger = logger;
}
public async Task<IActionResult> 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");
}
}

View File

@@ -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();