Skip to content

ReportBase

ReportBase is the abstract implementation of IReport and the single content-orchestration point for the Reporting framework: it drives the report lifecycle (build → render → print/distribute/save), resolves the default printer and security platform for rendering, and captures non-throwing failures into Errors. It is MustInherit; concrete reports in consuming libraries subclass it and override Create to build their xPression data document. No concrete subclass exists in this repository's built projects — the only sample is in a test project excluded from the solution.*

Purpose

  • Implement the render/print/distribute/save orchestration defined by IReport, delegating actual rendering and transport to an internally held clsPrint instance
  • Cache a rendered report so repeated calls avoid another xPression round trip unless the caller requests an overwrite (BR-PRT-007)
  • Enforce that render/distribute only proceed once the report's data document and package are both present (BR-PRT-008)
  • Select the rendering printer from the caller's security principal, choosing the Web or Windows platform based on EnvironmentServiceBase.IsWeb (BR-PRT-009)
  • Record render/distribute exceptions as ErrorDetail entries instead of throwing (BR-PRT-010)

Context

  • Namespace: SAIF.Services.Printing.Reporting
  • Assembly/package: SAIF.Services.Printing (embedded library, project reference)

Public members

Member Signature Purpose
XpressoEnvironments Public Enum XpressoEnvironments {Production, Test, NotSpecified} (nested) Declares xPression environment tokens
XpressoEnvironment Public Property As XpressoEnvironments Settable but not read by any logic in this library — has no observed effect on rendering**
New() Public Sub New() Resolves the ambient AppGlobal.EnvironmentService and delegates to the parameterised constructor
New(envSvc) Public Sub New(envSvc As EnvironmentServiceBase) Initialises the report with the supplied environment service
Errors ReadOnly Property Errors As List(Of ErrorDetail) (IReport implementation) Accumulated render/distribute failures (BR-PRT-010)
xPrint ReadOnly Property xPrint As clsPrint (IReport implementation) The clsPrint instance this report renders/prints/distributes through; constructed with clsPrint's parameterless constructor, so the report's own injected environment service is not propagated to it*
DestinationFileName Property DestinationFileName As String (IReport implementation) File path used by Save
OutputProfile Property OutputProfile As String (IReport implementation) Output profile applied on render; defaulted via SetDefaultProfile/SetDraftProfile
ReportPackage Property ReportPackage As String (IReport implementation) xPression package name required for render/distribute (BR-PRT-008)
ReportFile Property ReportFile As Byte() (IReport implementation) Cached rendered bytes populated by Render
ReportXml Property ReportXml As XDesignXDocument (IReport implementation) The data document produced by the subclass's Create override
Create Overridable Function Create(overwrite As Boolean) As XDesignXDocument Clears Errors and returns the subclass-built data document; the only member concrete report subclasses are expected to override
Render Function Render(overwrite As Boolean) As Boolean Skips re-rendering when a report file exists and overwrite is False (BR-PRT-007); otherwise calls Create, checks the data-document/package precondition (BR-PRT-008), resolves the default printer and security platform (BR-PRT-009), serializes with ToXpression, and calls xPrint.previewDocument; failures populate Errors and return False (BR-PRT-010)
Print Function Print(printer As String, overwrite As Boolean) As Boolean Renders when needed (OP-06 caching), sets xPrint.Printer to the caller-supplied printer, and calls xPrint.printPDF
Distribute Function Distribute(overwrite As Boolean) As Boolean Calls Create when needed, checks the precondition (BR-PRT-008), and calls xPrint.distributeDocument with the raw XDocument.ToString output rather than ToXpression, unlike Render*; failures populate Errors and return False
Save Function Save(overwrite As Boolean) As Boolean Renders when the destination file does not exist or overwrite is set and a destination name is present, writes ReportFile to a new FileStream, and returns whether the destination file now exists (BR-PRT-014)
SetDefaultProfile Sub SetDefaultProfile() Sets OutputProfile to the private constant PDF (BR-PRT-015)
SetDraftProfile Sub SetDraftProfile() Sets OutputProfile to the private constant PDF_Draft_Watermark (BR-PRT-015)

Behavioral notes

  • Render chooses clsSecurityPrincipal.Platform.Web when EnvironmentServiceBase.IsWeb is true and .Windows otherwise, then takes GetDefaultPrinter() from that principal as the printer used for the underlying clsPrint call (BR-PRT-009).
  • Distribute checks m_reportFile to decide whether to re-build, but calls Create (not Render) — so a distribute-only flow never populates ReportFile via the render path.*
  • xPrint is constructed with clsPrint's parameterless constructor regardless of which environment service ReportBase itself received, so the two could resolve different environment services within one report lifecycle.*

Constraints and usage notes

  • Subclasses should override only Create; the remaining lifecycle members are not designed to be overridden.
  • Callers that need render results without the "already rendered" cache skip must pass overwrite = True.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Services.Printing/Reporting/ReportBase.vb