Save report¶
ReportBase.Save persists a rendered report to a file path the caller has configured through DestinationFileName. It checks whether the file already exists before deciding whether to render and write, so repeat calls without overwrite do not regenerate an existing file.
| Field | Value |
|---|---|
| Operation ID | OP-PRT-07 |
| Trigger | Caller invokes ReportBase.Save(overwrite) after setting DestinationFileName |
| Inputs | DestinationFileName; optional overwrite flag |
| Outputs | A file written to DestinationFileName; boolean result reflecting whether the file exists after the call |
| Primary components | Reporting.ReportBase.Save, Reporting.ReportBase.Render |
| Entry point | Services\SAIF.Services.Printing\Reporting\ReportBase.vb |
Steps¶
Savechecks whether a file already exists atDestinationFileNameusingIO.File.Exists.- If the file does not exist, or
overwriteisTrue: Savechecks thatDestinationFileNamehas a non-zero length.- If a destination is configured:
SavecallsRender(overwrite)— see Render report — to ensure rendered bytes are available (BR-004). SaveopensDestinationFileNamewithIO.FileStreaminCreatemode and writes the fullm_reportFilebyte array to it.
- If a destination is configured:
- If
DestinationFileNameis empty: no render or write is attempted. SavereturnsIO.File.Exists(DestinationFileName)as the final result, re-checking the file system rather than returning a cached success flag.
Process flow¶
The following diagram visualizes the exists-check, render, and write sequence.
flowchart TD
Start([Save called with overwrite]) --> Exists{File already<br>exists at destination?}
Exists -->|Yes, overwrite = False| Skip[Skip render and write]
Exists -->|No, or overwrite = True| HasDest{DestinationFileName<br>non-empty?}
HasDest -->|No| Skip
HasDest -->|Yes| Render[Call Render overwrite]
Render --> Write[Write ReportFile bytes<br>to DestinationFileName]
Write --> Recheck
Skip --> Recheck[Re-check IO.File.Exists]
Recheck --> End([Return existence result])
Failure and edge-case behavior¶
- If
Render(overwrite)fails and leavesm_reportFileasNothing, the subsequentfs.Write(m_reportFile, 0, m_reportFile.Length)call would raise aNullReferenceException;Savedoes not check for aNothingReportFilebefore writing, and noTry/Catchwraps this step.** Savereturns the file system's current existence state rather than a flag captured at write time, so a file removed by another process between the write and the return would still be reflected accurately, but aSavecall that skipped rendering entirely (because the file already existed) returnsTrueeven though no new content was written.*- A destination path with an existing file and
overwrite = Falseresults inSavetreating the call as a no-op success without attempting to render or verify the existing file's content matches the current report state.*
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.vb