Incident Management — Dữ liệu & bảng đọc/ghi
Incident Management dùng SQL làm store chính, Blob cho file, và đọc thêm nhiều entity khác để enrich UI/report/notification.
Bảng/entity chính
| Bảng/entity | Ownership | Vai trò |
|---|---|---|
FormInstance | Incident owns rows có FormCategoryId = IncidentManagement | Root incident, status, fields (gồm Internal Notes internal-only), flags, metadata. |
FormTemplateVersion.PrefillBlobName | Incident type config | Trỏ blob lưu Description template mặc định của type, theo Business Unit. |
FormInstanceAttendee / related attendee records | Incident | Attendee bị ảnh hưởng, role, notes, body marker JSON. |
FormAcknowledgement | Incident | Recipient/customer acknowledgement và status. |
GeneratedAttachment | Incident | PDF report đã generate, blob name, attendee association. |
| Attachment records | Incident | File upload nội bộ/shared/attendee-specific. |
EntityHistory | Platform-owned projection | Audit timeline keyed by incident guid. |
NotificationJob / schedulers | Platform/Communication | Notification bất đồng bộ cho submitted/sent-to-customer. |
Tên bảng exact có thể nằm trong EF model; dùng code service/controller làm điểm neo khi tra.
Read dependencies
| Entity | Dùng để |
|---|---|
Org / Site | Site xảy ra incident, filter list, hiện report, site-contact context. |
TermProgramSet / course | Course/session context theo site + date. |
TermAttendance | Gợi ý attendee có mặt trong ngày/course. |
Account | Scope customer và thông tin account. |
Attendee | Tên attendee, liên kết account, report detail. |
Contact | Recipients khi send-to-customer. |
NotificationSetting | Template/recipient config cho notification worker. |
Những entity này là read/enrichment dependency; không phải aggregate root của Incident Management.
Blob storage
| Blob | Nơi tạo/đọc | Nội dung |
|---|---|---|
| Attachment blob | Staff upload/download | Ảnh, PDF, file evidence. |
| Generated document blob | GeneratePdfAsync, customer/admin download | Incident report PDF. |
| Signature blob | Customer acknowledgement submit | Signature image/base64 đã lưu. |
form-config-json prefill blob | Settings save / create-edit prefill | Description template mặc định theo type (field-prefill format). |
Khi debug file không tải được, cần kiểm tra cả SQL record và BlobName/container tương ứng.
Notification data
| Event | EventData | Ghi chú |
|---|---|---|
IncidentSubmitted | Incident id | Tạo khi submit; worker email staff/manager recipient của BU. Không recipient ⇒ hoàn tất, không gửi. |
IncidentSentToCustomer | Incident id + message/channels/recipient context | Tạo khi send approved incident; email/SMS + portal user message. |
- BU chưa có template cho event type ⇒ worker dùng built-in default template.
- Notification history staff thấy được là projection từ notification jobs liên quan incident guid/event.
Customer access scope
Customer access không dựa trên URL id đơn lẻ. Service kiểm tra:
- Customer đang ở account nào.
ackIdcó thuộc account đó không.- Acknowledgement không phải
NotificationOnlynếu là list/actionable flow. - Incident ở trạng thái customer-visible theo flow đã gửi.
Quy tắc này ngăn customer xem acknowledgement của account/contact khác.
Reporting service
Generated PDF không phải file user upload. Nó được tạo từ dataset incident:
- incident summary,
- attendee details,
- body markers,
- acknowledgements,
- generated metadata,
- eligible PDF attachments nếu cần merge.
Nếu PDF sai nội dung, debug theo hướng BuildPdfDatasetAsync trước, sau đó mới đến rendering/Blob.
Tiếp theo: Case thường gặp.