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:
Alby96andClaude Opus 5.5 committed 2026-11-11 18:06:48 +01:00
1 parent cf6f849cc1
commit b341ade9e9
26 files changed
+5319 -2

No files matched your search

+30
View File
@@ -701,6 +701,36 @@ Migrazioni applicate in ordine:
- `core` 20261111004 `create_audit_log` (M20261111_004_CreateAuditLog)
- `core` 20261111005 `create_notifications` (M20261111_005_CreateNotifications)
- `core` 20261111006 `create_user_settings` (M20261111_006_CreateUserSettings)
- `core` 20261111007 `create_attachments` (M20261111_007_CreateAttachments)
#### `attachments`
| Colonna | Tipo | Null | Default | Note |
|---|---|---|---|---|
| `id` | Int64 | no | | chiave primaria, identity |
| `entity` | String(100) | no | | |
| `entity_id` | Int64 | no | | |
| `kind` | String(40) | no | | |
| `name` | String(255) | no | | |
| `mime` | String(150) | no | | |
| `size` | Int64 | no | | |
| `sha256` | String(64) | no | | |
| `version` | Int32 | no | | |
| `version_key` | String(300) | no | | |
| `generated_by` | String(100) | sì | | |
| `storage_key` | String(60) | no | | |
| `user_name` | String(100) | sì | | |
| `locked` | Bool | no | `false` | |
| `deleted_at` | DateTimeUtc | sì | | |
| `created_at` | DateTimeUtc | no | | |
| `created_by` | String(100) | sì | | |
| `updated_at` | DateTimeUtc | sì | | |
| `updated_by` | String(100) | sì | | |
| `row_version` | Int64 | no | `1` | |
- indice `ix_attachments_deleted_at` su `deleted_at`
- indice `ix_attachments_entity_entity_id` su `entity`, `entity_id`
- indice unico `ux_attachments_entity_entity_id_version_key_version` su `entity`, `entity_id`, `version_key`, `version`
#### `audit_log`