Compare commits

..

7 Commits

Author SHA1 Message Date
OlgunR
de4e9421af Revert "Add DevExpress Reporting and Custom Report Storage"
This reverts commit f19251ac1a.
2026-06-09 11:49:03 +02:00
OlgunR
b622df4187 Revert "Refactor PDF viewing and integrate DevExpress support"
This reverts commit b515b4f523.
2026-06-09 11:48:49 +02:00
OlgunR
746465d8fe Revert "Enhance PDF viewing experience with new document viewer"
This reverts commit 1cc617de42.
2026-06-09 11:48:41 +02:00
OlgunR
559829882a Revert "Add DevExpress Document Viewer page and dependencies"
This reverts commit bec9ea2356.
2026-06-09 11:48:31 +02:00
OlgunR
bec9ea2356 Add DevExpress Document Viewer page and dependencies
Updated `_ViewImports.cshtml` to include DevExpress and DevExtreme tag helpers. Created `DocumentViewerDevExpress.cshtml` for displaying a DevExpress Document Viewer with necessary CDN links. Implemented the corresponding code-behind in `DocumentViewerDevExpress.cshtml.cs` to handle model binding and report key generation.
2026-06-08 17:21:36 +02:00
OlgunR
1cc617de42 Enhance PDF viewing experience with new document viewer
- Replaced button in `Details.cshtml` with a link to a new document viewer page.
- Created `DocumentViewer.cshtml` to display PDFs using an iframe, with a back button and a link to an experimental DevExpress viewer.
- Introduced `DocumentViewerModel` in `DocumentViewer.cshtml.cs` for handling invoice ID and PDF URL.
- Updated `OnGetAsync` in `ViewPdf.cshtml.cs` to set `Content-Disposition` to inline for better PDF rendering in the browser.
2026-06-08 16:59:57 +02:00
OlgunR
b515b4f523 Refactor PDF viewing and integrate DevExpress support
- Removed folder reference for "Controllers" in the project file.
- Updated `ViewPdf.cshtml` to include layout and clarify PDF output.
- Enhanced `ViewPdf.cshtml.cs` with improved logging and error handling.
- Added MVC controller services in `Program.cs` for DevExpress functionality.
- Introduced `DocumentViewerController` to manage document viewing requests.
2026-06-08 15:14:15 +02:00
3 changed files with 2 additions and 137 deletions

View File

@@ -16,10 +16,8 @@
</Target> </Target>
<ItemGroup> <ItemGroup>
<PackageReference Include="DevExpress.AspNetCore.Reporting" Version="25.2.7" />
<PackageReference Include="DevExpress.Document.Processor" Version="25.2.7" /> <PackageReference Include="DevExpress.Document.Processor" Version="25.2.7" />
<PackageReference Include="DevExpress.Pdf.Drawing" Version="25.2.7" /> <PackageReference Include="DevExtreme.AspNet.Core" Version="25.2.*" />
<PackageReference Include="DevExtreme.AspNet.Core" Version="25.2.7" />
<PackageReference Include="MailKit" Version="4.16.0" /> <PackageReference Include="MailKit" Version="4.16.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">

View File

@@ -1,119 +0,0 @@
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Web.Extensions;
using DXApp.TemplateKitProject.Data;
using Microsoft.EntityFrameworkCore;
namespace DXApp.TemplateKitProject.DevExpressExtensions;
public class CustomReportStorageWebExtension : ReportStorageWebExtension
{
private readonly AppDbContext _db;
private readonly ILogger<CustomReportStorageWebExtension> _logger;
public CustomReportStorageWebExtension(
AppDbContext db,
ILogger<CustomReportStorageWebExtension> logger)
{
_db = db;
_logger = logger;
}
public override bool CanSetData(string url)
{
// Wir erlauben KEIN Speichern von Änderungen über den Viewer
// PDFs sind bei uns Read-Only im Viewer
return false;
}
public override bool IsValidUrl(string url)
{
// Prüfen ob URL dem Format entspricht: "invoice-{id}"
return url.StartsWith("invoice-", StringComparison.OrdinalIgnoreCase);
}
public override byte[] GetData(string url)
{
try
{
_logger.LogDebug("GetData aufgerufen für URL: {Url}", url);
// URL-Format: "invoice-123" → ID extrahieren
if (!url.StartsWith("invoice-", StringComparison.OrdinalIgnoreCase))
{
_logger.LogWarning("Ungültige URL: {Url}", url);
return Array.Empty<byte>();
}
var idString = url.Substring("invoice-".Length);
if (!int.TryParse(idString, out var invoiceId))
{
_logger.LogWarning("Ungültige Invoice-ID in URL: {Url}", url);
return Array.Empty<byte>();
}
// Rechnung aus Datenbank laden
var invoice = _db.ZugferdInvoices
.AsNoTracking()
.FirstOrDefault(i => i.Id == invoiceId);
if (invoice == null)
{
_logger.LogWarning("Rechnung mit ID {Id} nicht gefunden.", invoiceId);
return Array.Empty<byte>();
}
// Prüfen ob ResultFilePath existiert
if (string.IsNullOrEmpty(invoice.ResultFilePath))
{
_logger.LogWarning(
"Rechnung {Id} hat keine Result-PDF (ResultFilePath ist leer).",
invoiceId);
return Array.Empty<byte>();
}
// Datei vom Dateisystem laden
if (!File.Exists(invoice.ResultFilePath))
{
_logger.LogError(
"Result-PDF-Datei nicht gefunden: {Path}",
invoice.ResultFilePath);
return Array.Empty<byte>();
}
var pdfBytes = File.ReadAllBytes(invoice.ResultFilePath);
_logger.LogInformation(
"Result-PDF geladen: Invoice {Id}, Größe: {Size} Bytes",
invoiceId,
pdfBytes.Length);
return pdfBytes;
}
catch (Exception ex)
{
_logger.LogError(ex, "Fehler beim Laden der PDF für URL: {Url}", url);
return Array.Empty<byte>();
}
}
public override Dictionary<string, string> GetUrls()
{
// Diese Methode wird verwendet um eine Liste aller verfügbaren Reports zu liefern
// Für unseren Use-Case nicht benötigt (wir laden immer spezifisch eine Invoice)
return new Dictionary<string, string>();
}
public override void SetData(XtraReport report, string url)
{
// Nicht implementiert - wir erlauben kein Speichern über den Viewer
throw new NotSupportedException(
"Das Speichern von Reports über den Document Viewer ist nicht unterstützt.");
}
public override string SetNewData(XtraReport report, string defaultUrl)
{
// Nicht implementiert - wir erstellen keine neuen Reports über den Viewer
throw new NotSupportedException(
"Das Erstellen neuer Reports über den Document Viewer ist nicht unterstützt.");
}
}

View File

@@ -1,19 +1,11 @@
using DXApp.TemplateKitProject.Data; using DXApp.TemplateKitProject.Data;
using DXApp.TemplateKitProject.DevExpressExtensions;
using DXApp.TemplateKitProject.Services; using DXApp.TemplateKitProject.Services;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;
using DevExpress.XtraReports.Web.Extensions;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages(); builder.Services.AddRazorPages();
// DevExpress Controls und Reporting Services
builder.Services.AddDevExpressControls();
builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();
// Datenbank // Datenbank
var connectionString = builder.Configuration.GetConnectionString("EcmContext") var connectionString = builder.Configuration.GetConnectionString("EcmContext")
?? throw new InvalidOperationException("Connection string 'EcmContext' not found."); ?? throw new InvalidOperationException("Connection string 'EcmContext' not found.");
@@ -38,18 +30,12 @@ if (!app.Environment.IsDevelopment())
app.UseHttpsRedirection(); app.UseHttpsRedirection();
// MIME-Types für PDF.js UND DevExpress registrieren // MIME-Types für PDF.js registrieren (einmaliger UseStaticFiles-Aufruf)
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider(); var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
provider.Mappings[".mjs"] = "text/javascript"; provider.Mappings[".mjs"] = "text/javascript";
provider.Mappings[".ftl"] = "text/plain"; provider.Mappings[".ftl"] = "text/plain";
provider.Mappings[".woff2"] = "font/woff2";
provider.Mappings[".woff"] = "font/woff";
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
// DevExpress Middleware
app.UseDevExpressControls();
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
app.MapRazorPages(); app.MapRazorPages();