// =============================================================================
// GB5 Framework — Report Orchestration Enums
// Namespace : GB5Shared.Enums.ReportOrchestration
// Purpose : Shared enum definitions used across orchestrator, resolver,
// endpoints, and DAL layers. Values align with DB TINYINT columns.
// =============================================================================
namespace GB5Shared.Enums.ReportOrchestration
{
// -------------------------------------------------------------------------
// DataSourceType — maps to MREPORTCONFIG.DATASOURCETYPE (TINYINT)
// and MSERVERCONFIG resolution logic.
// -------------------------------------------------------------------------
///
/// Identifies which physical database the query should execute against.
/// Mirrors MREPORTCONFIG.DATASOURCETYPE column values.
///
public enum DataSourceType : byte
{
/// Live OLTP database. Uses LoginDTO.ServerConfigId directly.
Oltp = 0,
///
/// Dedicated reporting/analytics database (pre-aggregated, denormalised).
/// Resolved via MSERVERCONFIG.REPORTSERVERCONFIGID.
/// Falls back to OLTP when REPORTSERVERCONFIGID = -1.
///
ReportDb = 1,
///
/// Historical archive database (partitioned, immutable after write).
/// Resolved via MSERVERCONFIG.ARCHIVESERVERCONFIGID.
/// Falls back to OLTP when ARCHIVESERVERCONFIGID = -1.
///
ArchiveDb = 2,
///
/// Orchestrator selects the source automatically based on
/// MREPORTDATASOURCERULE entries for this report.
/// Evaluated in RULEPRIORITY order; defaults to OLTP if no rule matches.
///
Auto = 3
}
// -------------------------------------------------------------------------
// ReportCallType — identifies which path the orchestrator takes
// -------------------------------------------------------------------------
///
/// Discriminates the call path so the orchestrator applies the correct
/// resolution, execution, and export strategy.
/// Derived from MMenu.REPORTTYPE.
///
public enum ReportCallType : byte
{
///
/// Standard report: MREPORT → MWEBSERVICE URI → module endpoint.
/// Supports full orchestration (datasource, async, export, cache).
/// MMenu REPORTTYPE = 1 or 2.
///
StandardReport = 1,
///
/// Analysis report: MANALYSIS → MANALYSISQUERY → dynamic SQL.
/// Executed directly by AnalysisDAL against resolved connection.
/// MMenu REPORTTYPE = 0 or 3.
///
AnalysisReport = 0,
///
/// Direct API call (select list, get-record, interactive form data).
/// Bypasses orchestration entirely — zero overhead path.
///
Direct = 99
}
// -------------------------------------------------------------------------
// AsyncMode — maps to MREPORTCONFIG.ASYNCMODE (TINYINT)
// -------------------------------------------------------------------------
///
/// Controls whether a report executes synchronously (stream to browser)
/// or asynchronously (submitted as SysJob; result delivered to My Reports).
/// Mirrors MREPORTCONFIG.ASYNCMODE column values.
///
public enum AsyncMode : byte
{
///
/// Orchestrator decides: if request date range in days exceeds
/// MREPORTCONFIG.ASYNCTHRESHOLDDAYS → async; otherwise sync.
///
Auto = 0,
/// Always submit as SysJob regardless of date range.
AlwaysAsync = 1,
/// Always execute synchronously. Use for small reference reports.
AlwaysSync = 2,
///
/// Apply tenant/module/role policy rules from MREPORTPOLICY.
/// Falls back to Auto if no policy matches.
///
PolicyBased = 3
}
// -------------------------------------------------------------------------
// ExportFormat — maps to MREPORTCONFIG.ALLOWEDEXPORTFORMATS values
// -------------------------------------------------------------------------
///
/// Supported export formats. Stored as TINYINT; comma-separated list
/// in MREPORTCONFIG.ALLOWEDEXPORTFORMATS controls which are available
/// for each report.
///
public enum ExportFormat : byte
{
/// In-browser grid (no file generated).
Grid = 0,
/// PDF via Puppeteer/shared browser instance.
Pdf = 1,
/// Excel (.xlsx) via EPPlus/ClosedXML.
Excel = 2,
/// Comma-separated values (.csv).
Csv = 3,
/// JSON payload (for API consumers / embeddable widgets).
Json = 4
}
// -------------------------------------------------------------------------
// PivotEngine — maps to MREPORTCONFIG.PIVOTENGINE (TINYINT)
// -------------------------------------------------------------------------
///
/// Controls where pivot transformation occurs.
/// Mirrors MREPORTCONFIG.PIVOTENGINE column values.
///
public enum PivotEngine : byte
{
/// No pivot. Flat grid data returned as-is.
None = 0,
///
/// Server-side pivot via DataPivotEngine before export.
/// Required when exporting to PDF/Excel (client cannot pivot).
///
Backend = 1,
///
/// Raw flat data returned to Angular frontend; pivot rendered in browser.
/// Only valid for Grid export format.
///
Frontend = 2
}
// -------------------------------------------------------------------------
// ReportCategory — maps to MREPORTCONFIG.REPORTCATEGORY (TINYINT)
// -------------------------------------------------------------------------
///
/// Semantic categorisation of a report. Drives UI grouping, icon selection,
/// and default datasource suggestions during configuration.
///
public enum ReportCategory : byte
{
/// Day-to-day transactional report. Default datasource: OLTP.
Operational = 0,
/// Trend, variance, or drill-down report. Default datasource: ReportDB.
Analytical = 1,
/// KPI / scorecard report. Default datasource: ReportDB.
Kpi = 2,
/// Historical data report. Default datasource: ArchiveDB.
Archive = 3,
/// Recurring scheduled report. Executed via SysJob.
Scheduled = 4
}
// -------------------------------------------------------------------------
// DatabaseProviderType — derived from LoginDTO.DatabaseType (byte)
// and MSERVERCONFIG.DATABASETYPE (TINYINT)
// -------------------------------------------------------------------------
///
/// The RDBMS provider. Used by IReportConnectionResolver to instantiate
/// the correct IDbConnection implementation.
/// Values align with MSERVERCONFIG.DATABASETYPE column.
///
public enum DatabaseProviderType : byte
{
/// Microsoft SQL Server (SqlConnection).
SqlServer = 0,
/// Oracle Database (OracleConnection).
Oracle = 1,
/// PostgreSQL (NpgsqlConnection).
PostgreSql = 2,
/// MySQL / MariaDB (MySqlConnection).
MySql = 3
}
}