Skip to main content

Pattern: Component-Based Reporting

Description

Component-Based Reporting is an approach where report generation logic is encapsulated in dedicated "Handler" classes (ReportHandler, ExportBiz), rather than being embedded directly in Controllers or dispersed in generic services.

These components typically handle:

  1. Data Fetching: Optimised queries for the specific report.
  2. Transformation: Aggregating raw rows into KPIs (Sum, Avg, YTD).
  3. Formatting: Generating the output format (Excel, PDF, CSV).

Context in WepNG

  • Modules: WA (Work & Travel), MNT (ExportBiz).
  • Example: WAYTDFeeder can be seen as a report component that output to a table instead of a file.

Pro & Cons

  • Pro:
    • Encapsulation: Keeps the "Heavy Lifting" of reporting out of the transactional Service Layer.
    • Reusability: Different controllers can invoke the same Report Component.
  • Con (Risk):
    • If these components run synchronously on the main thread, they block the Web Server (IIS).
    • They often reinvent the wheel (e.g., manual CSV string building vs using a library).

Evolution

This pattern is a stepping stone.

  • Short Term: Keep them but ensure they run Async or in a Background Job (Hangfire/Quartz).
  • Long Term: Replace with Zoho Analytics (See System Landscape).