Files
DXApp/DXApp.TemplateKitProject/Program.cs
OlgunR f19251ac1a Add DevExpress Reporting and Custom Report Storage
Updated project dependencies to include DevExpress Reporting and PDF Drawing libraries. Registered DevExpress services and middleware in `Program.cs`. Added `CustomReportStorageWebExtension` to handle read-only invoice reports, including database and file system integration. Enhanced logging for better traceability and error handling.
2026-06-08 08:38:44 +02:00

56 lines
1.8 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);
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();
app.MapRazorPages();
app.Run();