📄 IrbyImaging.DomainClasses – DocumentImage.cs Documentation
Assembly: IrbyImaging.DomainClasses
File: DocumentImage.cs
Author: kvamshi
Created: 01-11-2022
Last Modified: 06-14-2022
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Entity Framework Mapping
- Class Structure & Key Functional Areas
- 4.1. DocumentImage Properties
- 4.2. ImagingType Enum
- UML Class Diagram
- Usage Examples
- 6.1. Create & Save a DocumentImage
- 6.2. Query & Filter
- Integration with DbContext
- Common Scenarios & Workflows
- Conclusion
🔍 Overview & Purpose
DocumentImage is a domain entity representing a single page (or the entirety) of a scanned or uploaded document in the IrbyImaging system. It captures both the binary image data and related metadata (e.g., job details, indexing tags, OCR text). This class powers:
- 📁 Storage & Retrieval of document images
- 📝 Indexing & OCR pipelines
- 🔒 Access Control based on user roles and document type
⚙️ Dependencies & Technologies
| Technology | Usage |
|---|---|
| .NET Core / .NET 6+ | C# language fundamentals |
| Entity Framework Core | ORM – database mapping via [Table], [Key], [DatabaseGenerated] |
| System.ComponentModel | Data annotations for schema and validation |
🗄️ Entity Framework Mapping
[Table("DocumentImage", Schema = "irby")]
public class DocumentImage
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid DocumentImageId { get; set; }
// ... other properties ...
}
- Table:
irby.DocumentImage - Primary Key:
DocumentImageId(no auto‑increment; GUID assigned by application)
🏗️ Class Structure & Key Functional Areas
4.1 DocumentImage Properties
| Property | Type | Description |
|---|---|---|
| DocumentImageId | Guid |
Unique identifier for the document image. |
| DocumentType | string |
e.g., “Invoice”, “Permit” – high‑level classification. |
| DocumentCategory | string |
Subcategory or grouping (e.g., “Safety” / “Legal”). |
| JobDate, FiledDate | string |
Dates stored as strings (e.g., “2022‑06‑14”). |
| JobNumber, JobName | string |
Project or work order identification. |
| JobOwner, CompanyId | string |
Owning employee & company code. |
| AssignedToEmployeeId/Name | string |
Workflow assignment for review or processing. |
| JobAddress, JobKeyword | string |
Additional indexing fields for search. |
| DocumentNotes | string |
Free‑text notes or remarks. |
| FileName, ContentType | string |
Original filename & MIME type (e.g., “application/pdf”). |
| TotalPages, Page | int |
Total number of pages in the document & this page’s index (1‑based). |
| ImageContents | byte[] |
Raw binary data of the document page. |
| ImageOCRContents | byte[] |
OCR’d image (e.g., TIFF with text layer). |
| ImageOCRText | string |
Plain‑text result of OCR extraction. |
| ReferenceId, OriginalReferenceId | Guid |
Link to parent document or prior versions. |
| DocumentUploadedBy | string |
Username or agent that performed the upload. |
| DocumentUploadedDate | DateTime |
Timestamp of the upload action. |
| IsDeleted | bool |
Soft‑delete flag – excludes from active queries. |
| IsSafety, IsLegalDocument, IsHR, IsIT, IsAccounting, IsBidding | bool |
Flags for category-specific workflows and ACL. |
| SafetyDocumentType | Guid |
Specific code for safety document sub‑types. |
| LegalDocumentType | Guid |
Specific code for legal document sub‑types. |
| ITDocumentType | Guid |
Specific code for IT document sub‑types. |
| AccountingDocumentType | Guid |
Specific code for accounting document sub‑types. |
| BiddingDocumentType | Guid |
Specific code for bidding document sub‑types. |
| HRDocumentType | Guid |
Specific code for HR document sub‑types. |
| ImagingType | ImagingType |
Enum: broad classification. |
| BlobName | string |
Name/key in external blob storage (e.g., Azure Blob). |
| IndexTag | string |
Comma‑separated tags for searching/indexing. |
| RolesCanAccess | string |
Comma‑separated list of role names authorized to view this document. |
4.2 ImagingType Enum
public enum ImagingType
{
Legal,
Safety,
HR,
IT,
Accounting,
Bidding
}
- Purpose: Simplify high‑level filtering in code and UIs.
- Usage:
doc.ImagingType == ImagingType.Legal
📐 UML Class Diagram
classDiagram
class DocumentImage {
+Guid DocumentImageId
+string DocumentType
+string DocumentCategory
+string JobDate
+string FiledDate
+string JobNumber
+string JobName
+string JobOwner
+string UnitNumber
+string WorkOrder
+string CompletedBy
+string CompanyId
+string AssignedToEmployeeId
+string AssignedToEmployeeName
+string JobAddress
+string JobKeyword
+string DocumentNotes
+string FileName
+string ContentType
+int TotalPages
+int Page
+byte[] ImageContents
+byte[] ImageOCRContents
+string ImageOCRText
+Guid ReferenceId
+Guid OriginalReferenceId
+string DocumentUploadedBy
+DateTime DocumentUploadedDate
+bool IsDeleted
+bool IsSafety
+Guid SafetyDocumentType
+string DocumentIndexes
+bool IsLegalDocument
+Guid LegalDocumentType
+bool IsHR
+bool IsIT
+bool IsAccounting
+bool IsBidding
+Guid ITDocumentType
+Guid AccountingDocumentType
+Guid BiddingDocumentType
+ImagingType ImagingType
+Guid HRDocumentType
+string BlobName
+string IndexTag
+string RolesCanAccess
}
enum ImagingType {
Legal
Safety
HR
IT
Accounting
Bidding
}
🚀 Usage Examples
6.1 Create & Save a DocumentImage
using (var context = new IrbyImagingContext())
{
var img = new DocumentImage
{
DocumentImageId = Guid.NewGuid(),
DocumentType = "Invoice",
DocumentCategory = "Accounting",
JobNumber = "JOB-2022-001",
FileName = "INV_1001.pdf",
ContentType = "application/pdf",
TotalPages = 3,
Page = 1,
ImageContents = File.ReadAllBytes("page1.pdf"),
ImageOCRText = "", // filled after OCR process
ReferenceId = Guid.Parse("..."),
DocumentUploadedBy = "jdoe",
DocumentUploadedDate = DateTime.UtcNow,
IsDeleted = false,
ImagingType = ImagingType.Accounting,
AccountingDocumentType = Guid.Parse("..."),
BlobName = "invoices/2022/INV_1001_page1.pdf",
RolesCanAccess = "Accounting,Manager"
};
context.DocumentImages.Add(img);
context.SaveChanges();
}
6.2 Query & Filter
// Fetch all active safety documents uploaded last month
var lastMonth = DateTime.UtcNow.AddMonths(-1);
var safetyDocs = context.DocumentImages
.Where(d => !d.IsDeleted
&& d.IsSafety
&& d.DocumentUploadedDate >= lastMonth)
.OrderBy(d => d.DocumentUploadedDate)
.ToList();
🧩 Integration with DbContext
public class IrbyImagingContext : DbContext
{
public DbSet<DocumentImage> DocumentImages { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Fluent API can augment or override DataAnnotations
modelBuilder.Entity<DocumentImage>()
.HasKey(d => d.DocumentImageId);
modelBuilder.Entity<DocumentImage>()
.Property(d => d.DocumentImageId)
.ValueGeneratedNever();
// Additional indexes, relationships, etc.
}
}
🔄 Common Scenarios & Workflows
-
Upload Workflow
- User uploads a PDF/TIFF →
- Break into pages →
- Each page creates a DocumentImage →
- Save binary + metadata →
- Trigger OCR →
- Update
ImageOCRText&ImageOCRContents
-
Search & Retrieval
- Full‑text search on
ImageOCRText - Attribute filters (JobNumber, Date, Category)
- Role‑based filtering via
RolesCanAccess
- Full‑text search on
-
Versioning & References
ReferenceIdlinks pages to the same logical documentOriginalReferenceIdretains first‑upload chain
✅ Conclusion
The DocumentImage class is the cornerstone of IrbyImaging’s document management domain. It combines raw image data, OCR results, hierarchical indexing, and rigorous access controls—enabling:
- 📂 Robust storage in SQL (EF Core)
- 🕵️♂️ Efficient search and retrieval
- 🔒 Fine‑grained security by role and document type
- 🔄 Seamless integration with OCR, blob storage, and workflows
Next Steps:
- Extend indexing logic (full‑text search, tag normalization).
- Integrate asynchronous upload/OCR pipelines.
- Enforce stricter validation (e.g.,
DataAnnotations).
Happy Documenting! 🚀