📄 DocumentsDirectory.cshtml Documentation
File Path:
IrbyImaging/Views/AccountingImaging/DocumentsDirectory.cshtml
Last Updated: [Date]
Author: Irby Imaging Team
📑 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Page Layout & Structure
- Key Functional Areas
- JavaScript Handlers & Utilities
- API Endpoints Overview
- Error Handling & Return Types
- Sample Usage & Code Snippets
- UML Sequence Diagram
- Conclusion
🎯 1. Overview & Purpose
This Razor View integrates Syncfusion EJ2 controls to present a unified file management and document viewing/editing experience within the Accounting Imaging module.
- Browse files and folders
- Upload, Download, Rename, Delete, Sort
- Preview/Edit Word‑type documents (DOCX, RTF, TXT, etc.)
- View PDF files
- Open/Save Excel spreadsheets
🛠️ 2. Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET Core MVC (Razor) | Server‑side view rendering |
| Syncfusion EJ2 FileManager | File browsing & operations |
| Syncfusion EJ2 DocumentEditorContainer | In‑browser document editor/viewer |
| Syncfusion EJ2 PdfViewer | PDF viewing |
| Syncfusion EJ2 Spreadsheet | Spreadsheet display & editing |
| jQuery (v3.x) | AJAX calls & DOM manipulation |
| Bootstrap 4 (Grid & Cards) | Responsive layout |
| Custom CSS | Container visibility & styling |
Emoji Legend:
📂 File Management | 📝 Document Editing | 📊 Spreadsheet | 📖 PDF Viewing
📐 3. Page Layout & Structure
@{
ViewData["Title"] = "Irby Legal";
}
<div class="row">
<div class="col-lg-14">
<div class="card">
<div class="card-body">
<h4 class="card-title mb-4">Manage Documents</h4>
<div class="sample-container file-container">
<!-- EJ2 FileManager here -->
</div>
<!-- Hidden viewer containers -->
<div class="doc-container"> … </div>
<div class="pdf-container"> … </div>
<div class="excel-container"> … </div>
</div>
</div>
</div>
</div>
.file-container: Houses the Syncfusion FileManager.doc-container,.pdf-container,.excel-container: Hidden by default; toggled when a file is opened
🔑 4. Key Functional Areas
4.1 File Manager Component 📂
<ejs-filemanager
id="file"
fileOpen="fileOpen"
created="addTooltip"
allowMultiSelection="true"
view="Details"
showThumbnail="true"
allowDragAndDrop="true"
fileDragStart="onFileDragStart"
fileDragStop="onFileDragStop"
fileDragging="onFileDragging"
fileDropped="onFileDropped"
height="650px"
enablePersistence="true">
<e-filemanager-ajaxsettings
url="/AccountingImaging/FileOperations"
downloadUrl="/AccountingImaging/Download"
uploadUrl="/AccountingImaging/UploadFiles"
getImageUrl="/AccountingImaging/GetImage">
</e-filemanager-ajaxsettings>
<e-filemanager-contextmenusettings visible="true"></e-filemanager-contextmenusettings>
<e-filemanager-navigationpanesettings visible="true"></e-filemanager-navigationpanesettings>
<e-filemanager-toolbarsettings visible="true"></e-filemanager-toolbarsettings>
</ejs-filemanager>
- CRUD Operations handled via
/AccountingImaging/FileOperations - Download/Upload endpoints specified
- Context Menu, Toolbar, and Navigation Pane enabled
4.2 Document Editor Container 📝
<ejs-documenteditorcontainer
id="document"
enableToolbar="true"
style="display:block;height:calc(100% - 22px)">
</ejs-documenteditorcontainer>
- Opens DOCX, RTF, TXT, HTML, XML
- Uses Syncfusion’s cloud Document Editor Service (
serviceUrlinside JS)
4.3 PDF Viewer Container 📖
<ejs-pdfviewer
id="pdfViewer"
serviceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer"
style="height:calc(100% - 22px);display:block">
</ejs-pdfviewer>
- Renders PDF in‑browser
- Leverages Syncfusion’s public PDF web‑service
4.4 Spreadsheet Container 📊
<ejs-spreadsheet
id="spreadsheet"
openUrl="/IrbyForms/OpenExcel"
saveUrl="/IrbyForms/SaveExcel"
allowOpen="true"
select="onSelect"
openComplete="onOpenComplete">
</ejs-spreadsheet>
<div id="customvalue"></div>
- Opens & saves .xlsx via custom endpoints
- Reports cell selection events to display custom metadata
🖥️ 5. JavaScript Handlers & Utilities
5.1 File Manager Events
function onFileDragStart() { console.log("Drag start"); }
function onFileDragStop() { console.log("Drag stop"); }
function onFileDragging() { console.log("File Dragging"); }
function onFileDropped() { console.log("File Dropped"); }
Logs internal drag‑and‑drop lifecycle for debugging.
5.2 Tooltip Customization
addTooltip: Attaches Syncfusion Tooltip to toolbar buttonsonTooltipBeforeRender: Switches on button ID to display helpful descriptions.
var tooltip = new ej.popups.Tooltip({
target: '#' + fileObj.element.id + '_toolbar [title]',
beforeRender: onTooltipBeforeRender
});
tooltip.appendTo('#' + fileObj.element.id + '_toolbar');
5.3 File Loading & Opening
function fileOpen(args) {
var fileType = args.fileDetails.type.toLowerCase();
var filePath = args.fileDetails.filterPath.replace(/\\/g, "/") + args.fileDetails.name;
if ([".docx",".txt",".html",".rtf",".xml"].includes(fileType)) {
getFileStream(filePath, false);
} else if (fileType === ".pdf") {
getFileStream(filePath, true);
} else if (fileType === ".xlsx") {
getBlob(args.fileDetails.name, filePath);
}
}
- Routes open event to the appropriate handler:
- 📄 getFileStream for docs / PDFs
- 📊 getBlob for Excel
5.4 Viewer Management Functions
// Show/hide containers
function showDocViewer(name) { … }
function showPDFViewer(name) { … }
function showExcelViewer(name) { … }
function onClicked() {
// Reset visibility back to file manager
}
- Toggles
.file-containervs..doc-container/.pdf-container/.excel-container.
5.5 Excel Interaction Functions
function onOpenComplete(args) {
customArgs = args.response.data.customArgs;
}
function onSelect(args) {
var sheetIndex = document.getElementById("spreadsheet").ej2_instances[0].activeSheetTab - 1;
// Display custom metadata for selected cell
}
- Displays custom values in
#customvaluewhen a cell is selected.
🔌 6. API Endpoints Overview
| Endpoint | HTTP Verb | Description |
|---|---|---|
/AccountingImaging/FileOperations |
POST | Rename, Move, Copy, Delete, etc. |
/AccountingImaging/UploadFiles |
POST | Upload one or more files |
/AccountingImaging/Download |
GET | Download a selected file |
/AccountingImaging/GetImage |
GET | Fetch thumbnails |
/AccountingImaging/GetDocuments |
POST | Return Base64 streams for DOC/PDF |
/IrbyForms/OpenExcel |
GET/POST | Open Excel files |
/IrbyForms/SaveExcel |
POST | Save modified spreadsheets |
🚨 7. Error Handling & Return Types
- AJAX
successcallbacks open new windows with embedded viewers. - AJAX
errorhandler alerts the user:
error: function (msg) {
alert('Exception: ' + msg.responseText);
}
- Return Types:
- Documents: Base64‑encoded string
- Excel: Blob binary stream
- FileManager: JSON payload conforming to EJ2 schema
🔧 8. Sample Usage & Code Snippets
Opening a Word Document
fileOpen({
fileDetails: {
name: "Contract.docx",
filterPath: "\\Legal\\Contracts\\",
type: ".docx"
}
});
- Triggers
getFileStream("\\Legal\\Contracts\\Contract.docx", false) - New browser tab displays Syncfusion DocumentEditor
Viewing a PDF
fileOpen({
fileDetails: {
name: "Policy.pdf",
filterPath: "\\Policies\\",
type: ".pdf"
}
});
- Calls
getFileStream(...)withisPDF = true - Syncfusion PdfViewer is instantiated in a popup tab
📊 9. UML Sequence Diagram
sequenceDiagram
participant U as User
participant FM as FileManager
participant JS as JavaScript
participant C as Controller API
participant V as NewViewerTab
U->>FM: Click on "Report.xlsx"
FM->>JS: fileOpen(args)
JS->>JS: onFileOpen interprets .xlsx
JS->>C: GET /Home/GetExcel?FileName=… (Blob)
C-->>JS: Blob data
JS->>V: window.open() + EJ2.Spreadsheet.open(blob)
V-->>U: Render Excel grid
🏁 10. Conclusion
This view implements a rich document‐management interface within the Accounting Imaging module by leveraging Syncfusion EJ2 controls. Users can seamlessly browse, upload, download, and preview a variety of document types without leaving the browser:
- 🔍 Browse & Organize: Sort, rename, delete, drag‑and‑drop
- 📝 Edit & Preview: Word / text documents
- 📖 View: PDF files
- 📊 Analyze: Excel spreadsheets
By centralizing all common file operations in one cohesive UI, IrbyImaging delivers an efficient, user‑friendly experience for legal / accounting workflows.
Happy Documenting! 📂✨