Render report¶
ReportBase.Render is the shared production step behind the IReport workflow: it ensures report XML exists, resolves a default printer appropriate to the current execution platform, and calls the xPression preview service to obtain the rendered byte array that later print, distribute, and save operations reuse. Rendering is skipped when cached bytes already exist and the caller does not request a refresh.
| Field | Value |
|---|---|
| Operation ID | OP-PRT-04 |
| Trigger | Caller invokes Render(overwrite) on a ReportBase-derived report, or Print/Distribute/Save invoke it internally |
| Inputs | overwrite flag; the report's own ReportPackage, report XML (via Create), and OutputProfile |
| Outputs | Boolean success; cached rendered bytes (ReportFile) on success; an ErrorDetail entry in Errors on failure |
| Primary components | Reporting.ReportBase.Render, Reporting.ReportBase.Create (overridden by derived report classes), SAIF.Framework.Security.clsSecurityPrincipal |
| Entry point | Services\SAIF.Services.Printing\Reporting\ReportBase.vb |
Steps¶
- Check the cache.
Rendertests whether rendered bytes (m_reportFile) are missing oroverwriteisTrue(BR-004). - If bytes already exist and
overwriteisFalse: skip rendering and returnTrueimmediately. - Create or refresh report XML. When rendering is needed,
RendercallsCreate(overwrite). The baseCreateimplementation only clearsErrorsand returns the existingm_reportXml; derived report classes overrideCreateto build the actual report XML tree.* - Validate readiness.
Renderchecks thatm_reportXmlis notNothingand thatm_ReportPackagehas a non-zero length. - If either condition fails: rendering is skipped and the method falls through without setting
result = True, soRenderreturnsFalse. - Resolve the execution platform.
Renderdefaults the platform toWindows, then switches toWebwhen_environmentService.IsWebisTrue(BR-003). - Resolve the default printer.
Renderconstructs aSAIF.Framework.Security.clsSecurityPrincipalfor the resolved platform and assignsxPrint.Printer = x.GetDefaultPrinter()(BR-003). - Call the preview service.
RendercallsxPrint.previewDocument(m_ReportPackage, m_reportXml.ToXpression, OutputProfile)— the profile-based preview path described in Preview document via xPression — and stores the returned bytes inm_reportFile. - Return success. After a successful preview call,
resultis set toTrueand returned. - On exception: any exception raised during steps 2–6 is caught, wrapped in an
ErrorDetail("An error occurred while rendering the report.", ex), and appended toErrors;RenderreturnsFalse.
Process flow¶
The following diagram visualizes the render decision and preview call.
flowchart TD
Start([Render called]) --> Cache{Bytes cached and<br>overwrite = False?}
Cache -->|Yes| ReturnTrue([Return True, reuse cached bytes])
Cache -->|No| Create[Call Create overwrite]
Create --> Valid{XML present and<br>ReportPackage set?}
Valid -->|No| ReturnFalse([Return False, no render attempted])
Valid -->|Yes| Platform[Resolve Windows or Web platform]
Platform --> Printer[Resolve default printer<br>via clsSecurityPrincipal]
Printer --> Preview[Call xPrint.previewDocument]
Preview --> Store[Store bytes in ReportFile]
Store --> ReturnTrue
Create -.->|Exception| Err[Add ErrorDetail, return False]
Preview -.->|Exception| Err
Failure and edge-case behavior¶
- If
Create(overwrite)does not populatem_reportXmlor leavesm_ReportPackageempty,Rendersilently returnsFalsewithout adding an error toErrors— only exceptions add anErrorDetail.* - The base
Createimplementation performs no XML construction itself; its behavior depends entirely on the derived report class overriding it, soRenderon an unmodifiedReportBaseinstance always fails the readiness check in step 3.* - Exceptions from printer resolution or the preview SOAP call are caught and converted into a generic
ErrorDetailmessage that does not distinguish printer-resolution failures from xPression service failures.
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.
Related documentation¶
Sources¶
Services\SAIF.Services.Printing\Reporting\ReportBase.vbServices\SAIF.Services.Printing\clsPrint.vb