Render an SSRS report¶
Loads an SSRS catalog report, applies any accumulated parameters, and renders it to the format selected via Format, returning the rendered bytes. Execution always runs under the hosting process's default Windows credentials rather than any caller-supplied identity.
| Field | Value |
|---|---|
| Operation ID | OP-12 |
| Trigger | clsRSPrint.PreviewDocument invoked |
| Inputs | ReportPath, Format (enum-driven), accumulated parameters via AddParameter |
| Outputs | Rendered bytes (Byte()) |
| Primary components | clsRSPrint.PreviewDocument, clsRSPrint.Format setter, BuildParameters, SharepointReporting.ReportExecutionService |
| Entry point | Public Function PreviewDocument() As Byte() |
Steps¶
- Caller sets
Format(aFormatsenum) before callingPreviewDocument; the setter maps the enum to both an SSRS format string (m_Format) and a fixed extension (m_Extension): CSV→csv, Excel→xls, HTML→html, Image→jpeg, PDF→pdf, Word→doc, XML→xml (BR-PRT-011). PreviewDocument()setsm_RS.Credentials = System.Net.CredentialCache.DefaultCredentials, so the SSRS call executes under the hosting process's Windows identity rather than any caller-supplied credential (BR-PRT-020).- Calls
m_RS.LoadReport2(ReportPath, HistoryID), deliberately passing aHistoryIDlocal variable that is never initialized before the call — the code contains an explicit comment warning that initializing it makes the call fail with an invalidSnapshotId. - On failure: no
Try/Catchsurrounds this call; anySoapExceptionpropagates unhandled to the caller. - If any parameters were added via
AddParameter: builds aSharepointReporting.ParameterValue()array viaBuildParameters(one entry per accumulated name/value pair) and callsm_RS.SetExecutionParameters(ReportParameters, Nothing). - If no parameters were added: this step is skipped entirely.
- Calls
m_RS.Render2(m_Format, devinfo, PageCountMode.Actual, m_Extension, encoding, mimeType, Warnings, streamIDs), passing the format/extension pair established in step 1 so they agree (BR-PRT-011). - On failure: no
Try/Catchsurrounds this call either; anySoapExceptionpropagates unhandled to the caller. - Returns the rendered byte array from
Render2directly to the caller.
Process flow¶
The following diagram visualizes this operation's control flow, from format selection through the unhandled SSRS calls to the returned bytes.
flowchart TD
Start(["PreviewDocument called"]) --> FormatMap["Format already set:<br>format-to-extension map"]
FormatMap --> Creds["Set DefaultCredentials"]
Creds --> Load["LoadReport2(ReportPath,<br>uninitialized HistoryID)"]
Load --> ParamCheck{"Parameters added?"}
ParamCheck -->|Yes| Build["BuildParameters,<br>SetExecutionParameters"]
ParamCheck -->|No| Render
Build --> Render["Render2 with format/extension"]
Render --> End(["Return rendered bytes"])
Failure and edge-case behavior¶
- No
Try/Catchblocks exist anywhere inPreviewDocument; anySoapExceptionraised byLoadReport2,SetExecutionParameters, orRender2propagates unhandled to the caller. clsRSPrint.DistributeDocumentunconditionally throwsNotImplementedException— SSRS distribution is not supported (BR-PRT-012).- The
ImageFormatproperty setsm_ImageFormatvia its own independent switch statement, butm_ImageFormatis never referenced anywhere inPreviewDocumentor in theRender2call — onlym_Format/m_Extension(driven by the separateFormatproperty) are actually used.ImageFormatcurrently has no observable effect on rendering output.* - The private, environment-service-accepting constructor (
Private Sub New(envSvc As EnvironmentServiceBase)) is reachable only through the public parameterlessNew(), which always resolvesAppGlobal.EnvironmentService— mirroring theclsPrint/ReportBase.xPrintenvironment-service propagation gap present elsewhere in this library.*
Related documentation¶
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/clsRSPrint.vb