📄 UploadPnc.cshtml Documentation

Path: IrbyImaging/Views/AccountingImaging/UploadPnc.cshtml


📑 Table of Contents

  1. Overview & Purpose
  2. File Structure
  3. Dependencies & Technologies
  4. Key Functional Areas
    4.1. Page Metadata & Layout
    4.2. Styles & Plugins
    4.3. Upload CSV Form
    4.4. Loading Overlay
    4.5. JavaScript & Initialization
    4.6. Dropzone Configuration (Commented)
  5. View Models & Data Flow
  6. Error Handling & User Feedback
  7. API Endpoint Overview
  8. Third‑Party Integrations
  9. Usage Example
  10. Sequence UML Diagram
  11. Conclusion

🔍 Overview & Purpose

This Razor view is part of the AccountingImaging module and provides a user interface for:

  • Uploading PNC CSV files along with specifying a Statement Month/Year.
  • Displaying feedback messages and a loading spinner during upload.
  • (Commented out) Preparing a Dropzone.js integration for drag‑and‑drop file uploads.

It is intended to be used by internal accounting or imaging teams to bulk-import PNC statements.


📂 File Structure

UploadPnc.cshtml
├── @{}             // ViewBag & Layout definitions
├── @section styles // Stylesheet includes
├── <!-- Dropzone --> (commented-out)
├── <form> UploadCsv // Main CSV upload form
├── @if(message)     // Display feedback
├── <div id="loading"> // Loading overlay
├── <style>          // Inline CSS for spinner overlay
└── <script>         // JS includes & inline scripts

⚙️ Dependencies & Technologies

Library / Framework Usage
ASP.NET MVC Razor Server‑side templating
jQuery DOM manipulation & event handling
Bootstrap Responsive layout & styling
MetisMenu Sidebar menu plugin
SimpleBar Custom scrollbars
Waves.js Ripple effect on buttons
Dropzone.js (v5.5.1) (Commented) Drag‑and‑drop uploads
Syncfusion DatePicker <ejs-datepicker> for Month/Year selection
spin.js Loading spinner animation

🔑 Key Functional Areas

4.1 Page Metadata & Layout

@{
  ViewBag.Title     = "Form File Upload";
  ViewBag.pTitle    = "Form File Upload";
  ViewBag.pageTitle = "Forms";
  Layout            = "~/Views/Shared/_AccountingLayout.cshtml";

  var category = ViewBag.category;
  var message  = ViewBag.Message;
}
  • Purpose: Sets up page titles and specifies the shared layout (_AccountingLayout.cshtml).

4.2 Styles & Plugins

@section styles {
  <!-- Dropzone CSS (if enabled) -->
  <link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
}
  • Loads Dropzone stylesheet for drag‑and‑drop area (currently not active).

4.3 Upload CSV Form

<form asp-action="UploadPncCsv" class="form-horizontal" id="csvForm" method="post" defaultbutton="searchRecords" enctype="multipart/form-data">
  <div class="card">
    <div class="card-body">
      <h4 class="card-title mb-4">Upload Csv</h4>

      <!-- Date Picker -->
      <ejs-datepicker id="monthYear"
                      format="MMMM y"
                      floatLabelType="Auto"
                      placeholder="Statement Month Year"
                      width="250"
                      start="Year"
                      depth="Year">
      </ejs-datepicker>

      <!-- File Input -->
      <div class="row mb-4">
        <i class="display-5 text-muted bx bxs-cloud-upload"></i>
        <label class="col-form-label col-lg-3">Browse or Drop Files to Upload...</label>
        <div class="col-lg-12">
          <input class="form-control" name="file" type="file" multiple />
        </div>
      </div>

      <!-- Submit Button -->
      <div class="row justify-content-end">
        <div class="col-lg-12">
          <button id="submitbtn" type="submit" class="btn btn-primary">Upload Csv</button>
        </div>
      </div>
    </div>
  </div>
</form>
  • asp-action="UploadPncCsv" posts to the UploadPncCsv action in the current controller.
  • ejs-datepicker for month/year selection (Syncfusion).
  • File input allows multiple files.

4.4 Loading Overlay

<div id="loading">
  <div id="loadingcontent">
    <p id="loadingspinner"><br/> Upload in progress. Please wait..... </p>
  </div>
</div>
<style>
  #loading { display: none; position: fixed; ... opacity: .8; }
  #loadingspinner { text-align: center; font-size: larger; padding-top: 80px; }
</style>
  • Hidden by default. Shown during AJAX/form submission.
  • Provides user feedback with semi‑transparent overlay.

4.5 JavaScript & Initialization

  1. Library Includes

    <script src="~/assets/libs/jquery/jquery.min.js"></script>
    <script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="~/assets/libs/metismenu/metisMenu.min.js"></script>
    <script src="~/assets/libs/simplebar/simplebar.min.js"></script>
    <script src="~/assets/libs/node-waves/waves.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/dropzone.js"></script>
    <script src="~/assets/js/app.js"></script>
    <script src="~/assets/js/spin.js"></script>
    
  2. Form Validation & Spinner

    $(function() {
      $("#submitbtn").click(function () {
        $("#loading").fadeIn();
    
        // Validation rules
        var options = {
          rules: {
            'monthYear': { required: true }
          },
          customPlacement: (input, error) => {
            input.parentElement.parentElement.appendChild(error);
          }
        };
        var formValidator = new ej.inputs.FormValidator('#csvForm', options);
    
        if (formValidator.allowSubmit) {
          // Start spinner
          var opts = {/* spinner configuration */};
          var target = document.getElementById('loading');
          new Spinner(opts).spin(target);
        } else {
          $("#loading").fadeOut();
        }
      });
    });
    
    • Uses Syncfusion FormValidator for client‑side validation.
    • Uses spin.js to show a customizable spinner.

4.6 Dropzone Configuration (Commented)

Note: This section is commented-out in the HTML, but the JS remains for future use.

Dropzone.options.dropzoneForm = {
  paramName: "file",
  autoDiscover: false,
  autoProcessQueue: false,
  uploadMultiple: true,
  parallelUploads: 100,
  init: function() {
    var dz = this;
    $("#uploadfile").click(() => dz.processQueue());
    dz.on("complete", (file) => {
      dz.removeAllFiles();
      window.location.href = '@Url.Action("DocPreview","Imaging")?fileName=' + file.name;
    });
  }
};
  • Auto‑process disabled; triggered manually by #uploadfile button.
  • On completion, navigates to a document preview.

🤝 View Models & Data Flow

  • Model: No strongly-typed model; uses ViewBag for:
    • ViewBag.category
    • ViewBag.Message
  • Form Fields:
    • monthYear (string, “MMMM yyyy” format)
    • file (IFormFileCollection)

⚠️ Error Handling & User Feedback

  • Client-Side Validation: Syncfusion FormValidator ensures monthYear is provided.
  • Server Feedback:
    @if (!string.IsNullOrEmpty(message)) {
      <h2>@message</h2>
    }
    
    Displays any message set by the controller via ViewBag.Message.

🔗 API Endpoint Overview

HTTP Method Route Purpose
POST /AccountingImaging/UploadPncCsv Processes uploaded CSV files

Note: Actual route may vary based on controller naming conventions.


🔌 Third‑Party Integrations

  • Syncfusion DatePicker (<ejs-datepicker>)
  • Dropzone.js (drag & drop uploads)
  • spin.js (loading spinner)
  • jQuery, Bootstrap, MetisMenu, SimpleBar, Waves.js

🚀 Usage Example

  1. Navigate to the PNC upload page:
    https://<host>/AccountingImaging/UploadPnc

  2. Select the Statement Month/Year via the date picker.

  3. Browse or Drag one or more CSV files into the file input.

  4. Click Upload Csv.

  5. Observe the spinner overlay indicating progress.

  6. Review success or error message on completion.


📊 Sequence UML Diagram

sequenceDiagram
  participant U as User
  participant B as Browser
  participant S as Server

  U->>B: GET /UploadPnc
  B->>S: Render View
  S->>B: HTML + JS
  B->>U: Display Form

  U->>B: Fill MonthYear & Files
  U->>B: Click Upload
  B->>S: POST /UploadPncCsv
  S->>S: Validate & Process CSV
  alt Success
    S->>B: Return Success Message / Redirect
  else Failure
    S->>B: Return View with Error
  end
  B->>U: Display Result

📝 Conclusion

UploadPnc.cshtml is a versatile Razor view tailored for PNC CSV ingestion by accounting teams. It combines Syncfusion UI elements, robust client‑side validation, and visual feedback mechanisms (loading overlay & spinner). The commented Dropzone integration hints at future drag‑and‑drop enhancements. Developers can customize styles, extend the JS logic, or hook into additional server‑side processing in the UploadPncCsv action to meet evolving business needs.