feat: attachments, file store and in-house PDF/CSV/XLSX/ZIP writers (#34)
Documents need attachments and generated files (SPEC 9.4) before the UI of M3 can show them, and the spec forbids external libraries for PDF and spreadsheets. - VolumeFileStore keeps files under <data>/files/<COMPANY>/<yyyy>/<guid>, writing a .part file in the same folder with size limit and SHA-256, then quota and scanner checks (IFileScanner hook, no-op by default). - attachments table (migration 007) with kind, version series, lock, trash and the uploading user; AttachmentService uploads, adds generated files as the next version, lists, opens, zips, locks, trashes, restores and purges after 30 days (new system job system.attachments-trash). - FileGenerationService runs IFileGenerator implementations into the store; three generators for the fictitious test document (PDF, CSV, XLSX). - CsvWriter (Italian Excel defaults, formula-injection guard), XlsxWriter, ZipStreamWriter and PdfWriter (standard Type1 fonts, WinAnsi, AFM widths, JPEG, Flate, xref) only write asynchronously, so they can stream to an HTTP response. - ADR 0021 records versioning, storage layout, PDF scope and CSV defaults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cf6f849cc1
commit
b341ade9e9
26 files changed
+5319
-2
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.Globalization;
|
||||
using Khaemhat.Application.Audit;
|
||||
using Khaemhat.Application.Configuration;
|
||||
using Khaemhat.Application.Files;
|
||||
using Khaemhat.Application.Instance;
|
||||
using Khaemhat.Application.Jobs;
|
||||
using Khaemhat.Application.Licensing;
|
||||
@@ -10,6 +11,7 @@ using Khaemhat.Application.Notifications;
|
||||
using Khaemhat.Application.Preferences;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Caching;
|
||||
using Khaemhat.Core.Files;
|
||||
using Khaemhat.Core.Logging;
|
||||
using Khaemhat.Core.Security;
|
||||
using Khaemhat.Data;
|
||||
@@ -20,6 +22,7 @@ using Khaemhat.Data.Migrations;
|
||||
using Khaemhat.Data.PostgreSql;
|
||||
using Khaemhat.Data.Sqlite;
|
||||
using Khaemhat.Infrastructure.Caching;
|
||||
using Khaemhat.Infrastructure.Files;
|
||||
using Khaemhat.Infrastructure.Licensing;
|
||||
using Khaemhat.Infrastructure.Logging;
|
||||
using Khaemhat.Infrastructure.Security;
|
||||
@@ -144,6 +147,18 @@ internal static class KhaemhatServices
|
||||
services.AddScoped<KeyboardShortcutService>();
|
||||
services.AddScoped<ToastService>();
|
||||
services.AddScoped<DialogService>();
|
||||
|
||||
// Files and attachments (#34): store on the data volume, antivirus hook, attachments, generators, trash job.
|
||||
services.AddSingleton(FileStoreOptions.ForDataDirectory(options.DataDir));
|
||||
services.AddSingleton<IFileScanner, NoOpFileScanner>();
|
||||
services.AddSingleton<IFileStore, VolumeFileStore>();
|
||||
services.AddSingleton<AttachmentService>();
|
||||
services.AddSingleton<IFileGenerator, DemoPdfGenerator>();
|
||||
services.AddSingleton<IFileGenerator, DemoCsvGenerator>();
|
||||
services.AddSingleton<IFileGenerator, DemoXlsxGenerator>();
|
||||
services.AddSingleton<FileGeneratorRegistry>();
|
||||
services.AddSingleton<FileGenerationService>();
|
||||
services.AddSingleton<IScheduledJob, AttachmentTrashPurgeJob>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user