- 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.
62 lines
2.0 KiB
C#
62 lines
2.0 KiB
C#
using DXApp.TemplateKitProject.Data;
|
|
using DXApp.TemplateKitProject.DevExpressExtensions;
|
|
using DXApp.TemplateKitProject.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using DevExpress.AspNetCore;
|
|
using DevExpress.AspNetCore.Reporting;
|
|
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
|
|
builder.Services.AddDevExpressControls();
|
|
builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();
|
|
|
|
// Datenbank
|
|
var connectionString = builder.Configuration.GetConnectionString("EcmContext")
|
|
?? throw new InvalidOperationException("Connection string 'EcmContext' not found.");
|
|
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
options.UseSqlServer(connectionString));
|
|
|
|
// Services
|
|
builder.Services.AddScoped<PdfAttachmentExtractorService>();
|
|
builder.Services.AddScoped<PdfResultPackageService>();
|
|
builder.Services.AddScoped<ZugferdExtractorService>();
|
|
builder.Services.AddScoped<ZugferdParserService>();
|
|
builder.Services.AddScoped<ZugferdImportService>();
|
|
builder.Services.AddScoped<AttachmentViewerService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
// MIME-Types für PDF.js UND DevExpress registrieren
|
|
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
|
|
provider.Mappings[".mjs"] = "text/javascript";
|
|
provider.Mappings[".ftl"] = "text/plain";
|
|
provider.Mappings[".woff2"] = "font/woff2";
|
|
provider.Mappings[".woff"] = "font/woff";
|
|
|
|
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
|
|
|
|
// DevExpress Middleware
|
|
app.UseDevExpressControls();
|
|
|
|
app.UseRouting();
|
|
app.UseAuthorization();
|
|
|
|
// Controller-Routen verfügbar machen (wichtig für DevExpress WebDocumentViewer)
|
|
app.MapControllers();
|
|
app.MapRazorPages();
|
|
app.Run(); |