πŸ“„ IrbyImaging/Models/DocumentImaging.cs Documentation


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Key Functional Areas
  4. Data Models
  5. Usage Examples & Code Snippets
  6. UML Class Diagram
  7. Conclusion

πŸ” Overview & Purpose

DocumentImaging.cs defines view- and data-models used by the IrbyImaging UI for uploading, indexing, searching and previewing scanned documents. These classes:

  • Represent the metadata (job, customer, dates) and binary content (images, OCR text) of documents.
  • Support file uploads (IFormFile), batch operations, OCR searches, and client-side preview.
  • Provide lightweight lists for display and filtering in MVC views.

πŸ›  Dependencies & Technologies

Technology / Namespace Purpose
Microsoft.AspNetCore.Http IFormFile, file uploads
Microsoft.AspNetCore.Mvc FileContentResult, model binding
Microsoft.AspNetCore.Mvc.Rendering SelectListItem for dropdowns
System.ComponentModel.DataAnnotations Metadata & display attributes
System / System.Collections.Generic Core types (Guid, List<T>, DateTime)
IrbyImaging.DomainClasses Domain entities (e.g., DocumentImage)
IrbyImaging.UI.Models Reusable UI view models (e.g., DocumentAttributeViewDetail)

πŸ”‘ Key Functional Areas

  • Metadata Storage
    • Job, customer, unit, owner, dates, keywords, document type/category.
  • File Handling
    • Single or multiple uploads (File, Files).
    • Preview (Preview flag) & download (result: FileContentResult).
  • Batch & Temporary Workflows
    • BatchIds, TempDocumentId, ReferenceId, OriginalReferenceId.
  • OCR & Search
    • ImageOCRContents (raw bytes), ImageOCRText, SearchResults.
    • Toggle OcrSearch.
  • Indexing & Dropdown Data
    • IndexList: dynamic attributes.
    • DocumentTypes, DocumentCategories, EmployeeData, JobData, CustomerData, StateData.
  • Categorization Flags & IDs
    • IsLegalDocument, LegalDocumentType (and similar for Safety, HR, IT, Accounting, Bidding).
  • Lightweight Lists
    • ShortDocumentImageList for overviews.
    • DocumentImagingList for detailed lists.

πŸ—‚ Data Models

1. DocumentImaging

This is the primary ViewModel used for:

  • Upload / Preview
  • Editing document metadata
  • OCR indexing and search
Property Type Description
DocumentImageId Guid Unique identifier for the document image.
DocumentType, DocumentCategory string Classification fields.
JobDate, FiledDate string Dates (displayed/formatted).
JobNumber, JobName, ... string Job & customer metadata.
FileName, FilePath, ContentType string Underlying file details.
TotalPages, Page int Pagination support.
ImageContents, ImageOCRContents byte[] Binary content for image & OCR.
ImageOCRText string Extracted text.
BatchIds List<Guid> For multi-file batch operations.
File, Files IFormFile, List<IFormFile> File upload binding.
result FileContentResult MVC action result for content download.
Preview bool Toggle preview pane.
OcrSearch bool Enables OCR indexing & search.
Dropdown Collections List<SelectListItem> DocumentTypes, EmployeeData, etc.
Indexing & Categories List<DocumentAttributeViewDetail>, various Guid flags Dynamic indexing & category filters.
public class DocumentImaging
{
    public Guid DocumentImageId { get; set; }
    public string DocumentType { get; set; }
    public string DocumentCategory { get; set; }
    public string JobDate { get; set; }
    public string FiledDate { get; set; }
    public string JobNumber { get; set; }
    public string JobName { get; set; }
    public string JobOwner { get; set; }
    public string CustomerNumber { get; set; }
    public string CustomerName { get; set; }
    public string UnitNumber { get; set; }
    public string WorkOrder { get; set; }
    public string CompletedBy { get; set; }
    public string CompanyId { get; set; }
    public string AssignedToEmployeeId { get; set; }
    public string AssignedToEmployeeName { get; set; }
    public string JobAddress { get; set; }
    public string JobKeyword { get; set; }
    public string DocumentNotes { get; set; }
    public string FileName { get; set; }
    public string FilePath { get; set; }
    public string ContentType { get; set; }
    public int TotalPages { get; set; }
    public int Page { get; set; }
    public byte[] ImageContents { get; set; }
    public byte[] ImageOCRContents { get; set; }
    public string ImageOCRText { get; set; }
    public Guid ReferenceId { get; set; }
    public List<DocumentImage> SearchResults { get; set; }
    public List<Guid> BatchIds { get; set; }
    public Guid TempDocumentId { get; set; }
    public IFormFile File { get; set; }
    public List<IFormFile> Files { get; set; }
    public FileContentResult result { get; set; }
    public bool Preview { get; set; }
    public string DocumentUploadedBy { get; set; }
    public DateTime DocumentUploadedDate { get; set; }
    public bool DeleteFiles { get; set; }
    public int DocCount { get; set; }
    public bool SinglePageUpload { get; set; }
    public List<SelectListItem> DocumentTypes { get; set; }
    public List<SelectListItem> DocumentCategories { get; set; }
    public List<DocumentAttributeViewDetail> IndexList { get; set; }
    public List<DocumentImagingList> ImagingList { get; set; }
    public Guid OriginalReferenceId { get; set; }
    public List<ShortDocumentImageList> ImgResults { get; set; }
    public string IndexTag { get; set; }
    public bool IsLegalDocument { get; set; }
    public bool IsSafety { get; set; }
    public bool IsHR { get; set; }
    public bool IsIT { get; set; }
    public bool IsAccounting { get; set; }
    public bool IsBidding { get; set; }
    public Guid LegalDocumentType { get; set; }
    public Guid SafetyDocumentType { get; set; }
    public Guid ITDocumentType { get; set; }
    public Guid AccountingDocumentType { get; set; }
    public Guid BiddingDocumentType { get; set; }
    public ImagingType ImagingType { get; set; }
    public Guid HRDocumentType { get; set; }
    public List<SelectListItem> EmployeeData { get; set; }
    public List<SelectListItem> JobData { get; set; }
    public List<SelectListItem> CustomerData { get; set; }
    public List<SelectListItem> CustomerData1 { get; set; }
    public List<SelectListItem> StateData { get; set; }
    public string BlobName { get; set; }
    [Display(Name = "OCR Search")] public bool OcrSearch { get; set; }
}

2. ShortDocumentImageList

A slim summary for listing / search results:

Field Type Description
DocumentImageId Guid Unique ID.
DocumentType string Type of document.
JobNumber,... string Key job/customer info.
IsDeleted bool Soft‐delete flag.
OriginalReferenceId Guid Link to parent batch.
BlobName string Storage identifier (e.g., Azure blob).
public class ShortDocumentImageList
{
    public Guid DocumentImageId { get; set; }
    public string DocumentType {get; set;}
    public string JobNumber { get; set;}
    public bool IsDeleted {get; set;}
    public DateTime DocumentUploadedDate { get; set;}
    public string BlobName { get; set;}
    // ... other summary fields
}

3. DocumentImagingList

A detailed list‐model for admin / batch operations. It mirrors many DocumentImaging properties but tailored for tabular display.

public class DocumentImagingList
{
    public Guid DocumentImageId { get; set; }
    public string DocumentType { get; set; }
    public string DocumentCategory { get; set; }
    public string JobDate { get; set; }
    // ... replicate key fields
    public List<Guid> BatchIds { get; set; }
    public FileContentResult result { get; set; }
    public bool SinglePageUpload { get; set; }
}

πŸš€ Usage Examples & Code Snippets

1. Instantiating & Populating

var model = new DocumentImaging
{
    DocumentImageId     = Guid.NewGuid(),
    DocumentType        = "Safety Report",
    DocumentCategory    = "Monthly",
    JobNumber           = "JOB-2023-001",
    CustomerName        = "Acme Corp",
    UploadedDate        = DateTime.UtcNow,
    File                = formFile,       // from HTTP POST
    Preview             = true,
    OcrSearch           = true,
    DocumentTypes       = GetDocumentTypeList(),  // utility method
    EmployeeData        = GetEmployeeSelectList()
};

2. Rendering in Razor View

@model IrbyImaging.Models.DocumentImaging

<form asp-action="UploadDocument" enctype="multipart/form-data">
  <div class="form-group">
    <label asp-for="DocumentType"></label>
    <select asp-for="DocumentType"
            asp-items="Model.DocumentTypes"
            class="form-control"></select>
  </div>

  <div class="form-group">
    <label asp-for="File">Upload File</label>
    <input asp-for="File" type="file" class="form-control" />
  </div>

  <button type="submit" class="btn btn-primary">Upload</button>
</form>

3. Returning a Preview

public IActionResult Preview(Guid id)
{
    var doc = _service.GetDocument(id);
    return File(doc.ImageContents, doc.ContentType);
}

πŸ—Ž UML Class Diagram

classDiagram
    class DocumentImaging {
        +Guid DocumentImageId
        +string DocumentType
        +string DocumentCategory
        +string JobDate
        +IFormFile File
        +List<IFormFile> Files
        +FileContentResult result
        +bool Preview
        +bool OcrSearch
        +List<SelectListItem> DocumentTypes
        +List<SelectListItem> EmployeeData
        +List<DocumentAttributeViewDetail> IndexList
        +List<ShortDocumentImageList> ImgResults
        +Guid OriginalReferenceId
        +ImagingType ImagingType
    }
    class ShortDocumentImageList {
        +Guid DocumentImageId
        +string DocumentType
        +string JobNumber
        +bool IsDeleted
        +string BlobName
    }
    class DocumentImagingList {
        +Guid DocumentImageId
        +string DocumentType
        +string DocumentCategory
        +string JobDate
        +List<Guid> BatchIds
        +bool SinglePageUpload
    }

    DocumentImaging --> ShortDocumentImageList : uses
    DocumentImaging --> DocumentImagingList : lists

βœ… Conclusion

The DocumentImaging.cs file is the backbone of the document management UI in IrbyImaging:

  • 🎯 Purpose: Capture metadata & binary content, support OCR and previews.
  • πŸ”— Integration: Tightly coupled with ASP.NET Core MVC features (IFormFile, FileContentResult, SelectListItem).
  • βš™οΈ Extensibility: Flags & GUIDs facilitate dynamic categorization (Legal, Safety, HR, etc.).
  • πŸ’‘ Recommendation: Use the DocumentImaging model for create/edit workflows, DocumentImagingList / ShortDocumentImageList for listing.

By following the patterns above, developers can seamlessly integrate file uploads, preview, search and indexing into their MVC applications.


Happy coding! πŸš€