Add email template support and improve type safety
Updated documentation to include details on the `TBSIG_EMAIL_TEMPLATE` table, its structure, and runtime behavior. Enhanced code by introducing the `IDocument` interface and adding properties/methods to support email templates and document signing workflows. Replaced `int` with the `EnvelopeStatus` enum for improved type safety. Removed unused `Signed` property from `EnvelopeReceiverDto`. Added extension methods for `IDocument` and `IDocReceiverElement` to verify signing status. Updated deployment and troubleshooting guides to highlight email template requirements.
This commit is contained in:
30
AGENTS.md
30
AGENTS.md
@@ -13,7 +13,7 @@ This section explains every markdown file in the repo: what it contains, why it
|
||||
### Core Architecture Docs (Active — Always Relevant)
|
||||
|
||||
#### `AGENTS.md` ← you are here
|
||||
**What:** Authoritative agent/copilot onboarding guide. Covers project structure, route table, render mode rules, coordinate system, API gaps, and common mistakes.
|
||||
**What:** Authoritative agent/copilot onboarding guide. Covers project structure, route table, render mode rules, coordinate system, API gaps, database/email-template reference, and common mistakes.
|
||||
**Why it exists:** Single source of truth for agents so they don't re-derive architecture from code on every session.
|
||||
**When you need it:** Always. Read first on every session.
|
||||
**Maintenance:** Update whenever project structure, routes, render modes, or naming conventions change.
|
||||
@@ -63,7 +63,7 @@ This section explains every markdown file in the repo: what it contains, why it
|
||||
### Deployment Docs
|
||||
|
||||
#### `EnvelopeGenerator.Server/EnvelopeGenerator.Server/README.md`
|
||||
**What:** IIS publish and deployment guide for `EnvelopeGenerator.Server`. Covers why self-contained publish is required (WASM assembly version strictness), the exact `dotnet publish` command, IIS Application Pool settings (`No Managed Code`), directory structure after publish, and common deployment errors.
|
||||
**What:** IIS publish and deployment guide for `EnvelopeGenerator.Server`. Covers why self-contained publish is required (WASM assembly version strictness), the exact `dotnet publish` command, IIS Application Pool settings (`No Managed Code`), directory structure after publish, common deployment errors, and the email-template table (`TBSIG_EMAIL_TEMPLATE`) that must exist in the target DB.
|
||||
**Why it exists:** Blazor Auto (Server + WASM hybrid) has non-obvious deployment requirements that differ from a standard ASP.NET Core app. Forgetting self-contained publish or using the wrong app pool will break WASM loading in production.
|
||||
**When you need it:**
|
||||
- Deploying to IIS for the first time
|
||||
@@ -309,6 +309,32 @@ Manual testing workflow:
|
||||
- `TBSIG_RECEIVER` - Receiver registry
|
||||
- `TBSIG_ENVELOPE_DOCUMENT` - PDF binary data
|
||||
- `TBSIG_ENVELOPE_HISTORY` - Audit trail
|
||||
- `TBSIG_EMAIL_TEMPLATE` - Notification mail templates (HTML, `de-DE`, placeholder tokens)
|
||||
|
||||
### Email Templates (`TBSIG_EMAIL_TEMPLATE`)
|
||||
|
||||
All notification mails are rendered from `dbo.TBSIG_EMAIL_TEMPLATE` (`GUID`, `NAME`, `SUBJECT`, `BODY`, `LANG_CODE`, `ADDED_WHEN`, `CHANGED_WHEN`). Current data: 10 rows, all `de-DE`, HTML bodies sharing one layout (600px card, gradient header, `[NAME_PORTAL]` branding). Templates are resolved by `NAME` (`EmailTemplateType`), never by `GUID`; GUIDs 7 and 8 are unused.
|
||||
|
||||
| GUID | `NAME` | Purpose | Recipient |
|
||||
|---|---|---|---|
|
||||
| 1 | `DocumentReceived` | "[NAME_SENDER] sent you a document to [SIGNATURE_TYPE]" + document link, optional `[MESSAGE]` | Every receiver on envelope creation (`CreateEnvelopeCommandHandler`) |
|
||||
| 2 | `DocumentDeleted` | Envelope deleted/withdrawn by sender, includes `[REASON]` | Receivers (`EnvelopeDeletedNotification`) |
|
||||
| 3 | `DocumentSigned` | Confirms successful signing/confirmation (`[FINAL_STATUS]`, `[RECEIVER_ACTION]`) | The acting receiver (`SendSignedMailBehavior`, `FinalizeEnvelopeCommand`) |
|
||||
| 4 | `DocumentCompleted` | Envelope completed; finished document + result report attached | Receivers (payload exists, no active dispatch in repo) |
|
||||
| 5 | `DocumentAccessCodeReceived` | Access code (`[DOCUMENT_ACCESS_CODE]`) for viewing/signing | The receiver (`SendAccessCodeCommand`) |
|
||||
| 6 | `DocumentRejected_ADM` | A receiver rejected the envelope, includes `[REASON]` | Sender/ADM |
|
||||
| 9 | `DocumentRejected_REC` | Confirms the rejection; "sender was informed" | The rejecting receiver |
|
||||
| 10 | `DocumentRejected_REC_2` | "Another party rejected; sender will contact you if needed" | All other receivers |
|
||||
| 11 | `DocumentShared` | "[NAME_RECEIVER] shared a document for viewing" + link | The newly shared (read-only) recipient (`ReadOnlyController`) |
|
||||
| 12 | `TotpSecret` | 2FA QR code (`[TFA_QR_CODE]`), valid until `[TFA_EXPIRATION]` | The receiver (TFA registration, `TfaRegistrationController`) |
|
||||
|
||||
**Key placeholders:** `[NAME_PORTAL]`, `[NAME_SENDER]`, `[NAME_RECEIVER]`, `[DOCUMENT_TITLE]`, `[LINK_TO_DOCUMENT]`, `[REASON]`, `[SIGNATURE_TYPE]`, `[FINAL_STATUS]`, `[FINAL_ACTION]`, `[DOCUMENT_ACCESS_CODE]`, `[TFA_QR_CODE]`, `[TFA_EXPIRATION]`. Defaults for `[NAME_PORTAL]`, `[SIGNATURE_TYPE]` and `[REASON]` come from `MailParams:Placeholders` in `appsettings.json`; the rest are filled at send time (`EnvelopeMailService` / notification payloads).
|
||||
|
||||
**Notes:**
|
||||
- Actively dispatched in this repo: 1, 2, 3, 5, 11. Templates 4, 6, 9, 10, 12 have notification payloads in `Application/Common/Interfaces/Services/Notification/` but no in-repo `new ...Notification` call — assume the legacy Form app or DB-side automation dispatches them.
|
||||
- Templates are runtime data, not code: they must exist in the target DB. A missing template makes `EnvelopeMailService` log a `DataIntegrityIssue` and skip the mail.
|
||||
- Edit via `UpdateEmailTemplateCommand`; reset-to-default values live in `ResetEmailTemplateCommand`. DB trigger `TBSIG_EMAIL_TEMPLATE_AFT_UPD` is registered through `DbTriggerParams.EmailTemplate`.
|
||||
- Do not change `GUID`s — lookup is by `NAME`, but downstream tooling/reporting may key on the ID.
|
||||
|
||||
### Data Structure (Domain + EGDbContext)
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing document metadata and elements without binary payload.
|
||||
/// </summary>
|
||||
public record DocumentDetailsDto
|
||||
public record DocumentDetailsDto : IDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the document.
|
||||
@@ -24,4 +26,9 @@ public record DocumentDetailsDto
|
||||
/// Gets or sets the collection of elements associated with the document for receiver interactions, if any.
|
||||
/// </summary>
|
||||
public IEnumerable<DocReceiverElementDto>? Elements { get; init; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<IDocReceiverElement>? ElementsBase => Elements;
|
||||
}
|
||||
|
||||
@@ -79,13 +79,4 @@ public record EnvelopeReceiverDto
|
||||
///
|
||||
/// </summary>
|
||||
public bool HasPhoneNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this receiver has signed the envelope.
|
||||
/// Checks if there is a DocumentSigned history entry for this receiver in the envelope's history.
|
||||
/// </summary>
|
||||
public bool Signed => Envelope?.Histories?.Any(h =>
|
||||
h.Receiver?.Id == ReceiverId &&
|
||||
h.Status == EnvelopeStatus.DocumentSigned
|
||||
) ?? false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace EnvelopeGenerator.Application.Common.Dto.History;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Dto.History;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object for creating a new envelope history record.
|
||||
@@ -18,7 +20,7 @@ public class HistoryCreateDto
|
||||
/// <summary>
|
||||
/// Gets or sets the status of the envelope at the time of the action.
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
public EnvelopeStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time when the action occurred.
|
||||
|
||||
@@ -144,7 +144,7 @@ public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, Hi
|
||||
{
|
||||
EnvelopeId = envelopeId,
|
||||
UserReference = userReference,
|
||||
Status = (int) status,
|
||||
Status = status,
|
||||
ActionDate = DateTime.Now,
|
||||
Comment = comment
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Linq;
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
{
|
||||
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
|
||||
public class Document : IHasEnvelope, IHasAddedWhen
|
||||
public class Document : IDocument, IHasEnvelope, IHasAddedWhen
|
||||
{
|
||||
public Document()
|
||||
{
|
||||
@@ -66,6 +66,12 @@ namespace EnvelopeGenerator.Domain.Entities
|
||||
#endif
|
||||
Elements { get; set; }
|
||||
|
||||
public IEnumerable<IDocReceiverElement>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ElementsBase => Elements;
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if nullable
|
||||
|
||||
@@ -7,5 +7,36 @@
|
||||
double X { get; set; }
|
||||
|
||||
double Y { get; set; }
|
||||
|
||||
string
|
||||
#if nullable
|
||||
?
|
||||
# endif
|
||||
FullName { get; set; }
|
||||
|
||||
string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Place { get; set; }
|
||||
|
||||
byte[]
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Ink { get; set; }
|
||||
}
|
||||
|
||||
public static class DocReceiverElementExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsSigned(this IDocReceiverElement element)
|
||||
=> element.FullName != null
|
||||
&& element.Place != null &&
|
||||
element.Ink != null;
|
||||
}
|
||||
}
|
||||
29
EnvelopeGenerator.Domain/Interfaces/IDocument.cs
Normal file
29
EnvelopeGenerator.Domain/Interfaces/IDocument.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Interfaces
|
||||
{
|
||||
public interface IDocument
|
||||
{
|
||||
IEnumerable<IDocReceiverElement>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ElementsBase { get; }
|
||||
}
|
||||
|
||||
public static class DocumentExtensions
|
||||
{
|
||||
public static bool IsSigned<TElement, TElements>(this IDocument document)
|
||||
{
|
||||
if(document.ElementsBase == null)
|
||||
throw new ArgumentNullException(nameof(document.ElementsBase), "Elements collection cannot be null. Please add with Includ()");
|
||||
|
||||
foreach (var element in document.ElementsBase)
|
||||
if (!element.IsSigned())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
4. [IIS-Konfiguration](#iis-konfiguration)
|
||||
5. [Verzeichnisstruktur nach dem Publish](#verzeichnisstruktur-nach-dem-publish)
|
||||
6. [Häufige Fehler](#häufige-fehler)
|
||||
7. [E-Mail-Vorlagen (`TBSIG_EMAIL_TEMPLATE`)](#e-mail-vorlagen-tbsig_email_template)
|
||||
|
||||
---
|
||||
|
||||
@@ -223,3 +224,49 @@ publish-output\
|
||||
| `HTTP 500.30` + `sc-win32-status: 574` | App Pool falsch oder `AspNetCoreModuleV2` fehlt | Pool prüfen + Hosting Bundle installieren |
|
||||
| App startet per `.exe`, aber nicht in IIS | `web.config` hat noch `processPath="dotnet"` | `web.config` auf `.\EnvelopeGenerator.Server.exe` korrigieren |
|
||||
| Logs-Verzeichnis fehlt → App startet nicht | `stdoutLogEnabled="true"` aber `logs\` existiert nicht | `logs\`-Ordner anlegen + IIS_IUSRS Schreibrecht geben |
|
||||
|
||||
---
|
||||
|
||||
## E-Mail-Vorlagen (`TBSIG_EMAIL_TEMPLATE`)
|
||||
|
||||
Alle Benachrichtigungs-E-Mails werden zur Laufzeit aus der Tabelle `dbo.TBSIG_EMAIL_TEMPLATE`
|
||||
der Datenbank `DD_ECM` geladen. Die Vorlagen sind **kein Bestandteil des Publish-Pakets**:
|
||||
Sie müssen in der Zieldatenbank vorhanden sein. Fehlt eine Vorlage, wird die jeweilige Mail
|
||||
nicht versendet — `EnvelopeMailService` protokolliert dann ein `DataIntegrityIssue` und
|
||||
überspringt den Versand.
|
||||
|
||||
Die Tabelle enthält aktuell **10 Vorlagen**, alle in `de-DE`. Aufgelöst werden sie über `NAME`
|
||||
(`EmailTemplateType`), nicht über `GUID`; die GUIDs 7 und 8 sind unbenutzt.
|
||||
|
||||
| GUID | `NAME` | Zweck | Empfänger |
|
||||
|---|---|---|---|
|
||||
| 1 | `DocumentReceived` | "[NAME_SENDER] hat Ihnen ein Dokument zum [SIGNATURE_TYPE] gesendet" + Dokumentlink, optional `[MESSAGE]` | Alle Empfänger bei der Envelope-Erstellung |
|
||||
| 2 | `DocumentDeleted` | Umschlag vom Absender gelöscht/zurückgezogen, inkl. `[REASON]` | Empfänger |
|
||||
| 3 | `DocumentSigned` | Bestätigung der erfolgreichen Signatur/Bestätigung (`[FINAL_STATUS]`, `[RECEIVER_ACTION]`) | Der handelnde Empfänger |
|
||||
| 4 | `DocumentCompleted` | Umschlag abgeschlossen; fertiges Dokument + Ergebnisbericht im Anhang | Empfänger |
|
||||
| 5 | `DocumentAccessCodeReceived` | Zugriffscode (`[DOCUMENT_ACCESS_CODE]`) zur Ansicht/Signatur | Der Empfänger |
|
||||
| 6 | `DocumentRejected_ADM` | Ein Empfänger hat den Umschlag abgelehnt, inkl. `[REASON]` | Absender/ADM |
|
||||
| 9 | `DocumentRejected_REC` | Bestätigung der Ablehnung; "Absender wurde informiert" | Der ablehnende Empfänger |
|
||||
| 10 | `DocumentRejected_REC_2` | "Anderer Vertragspartner hat abgelehnt; Absender meldet sich bei Bedarf" | Alle übrigen Empfänger |
|
||||
| 11 | `DocumentShared` | "[NAME_RECEIVER] hat Ihnen ein Dokument zum Ansehen gesendet" + Link | Neu freigegebener (Read-only) Empfänger |
|
||||
| 12 | `TotpSecret` | 2FA-QR-Code (`[TFA_QR_CODE]`), gültig bis `[TFA_EXPIRATION]` | Der Empfänger (TFA-Registrierung) |
|
||||
|
||||
**Wichtige Platzhalter:** `[NAME_PORTAL]`, `[NAME_SENDER]`, `[NAME_RECEIVER]`,
|
||||
`[DOCUMENT_TITLE]`, `[LINK_TO_DOCUMENT]`, `[REASON]`, `[SIGNATURE_TYPE]`,
|
||||
`[FINAL_STATUS]`, `[FINAL_ACTION]`, `[DOCUMENT_ACCESS_CODE]`, `[TFA_QR_CODE]`,
|
||||
`[TFA_EXPIRATION]`. Die Standardwerte für `[NAME_PORTAL]`, `[SIGNATURE_TYPE]` und `[REASON]`
|
||||
kommen aus `MailParams:Placeholders` in `appsettings.json`; die übrigen werden beim Versand
|
||||
gefüllt.
|
||||
|
||||
**Hinweise:**
|
||||
|
||||
- Aktiv aus diesem Repo versendet: 1, 2, 3, 5, 11. Für 4, 6, 9, 10 und 12 existieren
|
||||
Notification-Payloads unter `Application/Common/Interfaces/Services/Notification/`, aber
|
||||
kein `new ...Notification`-Aufruf im Repo — vermutlich übernimmt die Legacy-Form-App oder
|
||||
eine DB-Automatisierung den Versand.
|
||||
- Vorlagen werden zur Laufzeit über `UpdateEmailTemplateCommand` bearbeitet; die
|
||||
Standardwerte für ein Reset liegen in `ResetEmailTemplateCommand`.
|
||||
- Der DB-Trigger `TBSIG_EMAIL_TEMPLATE_AFT_UPD` ist über `DbTriggerParams.EmailTemplate`
|
||||
registriert.
|
||||
- `GUID`s nicht ändern — die Auflösung erfolgt über `NAME`, aber nachgelagerte Tools/
|
||||
Reports können auf der ID aufbauen.
|
||||
|
||||
Reference in New Issue
Block a user