Class ReportGenerationResponse
Represent a report identifier used in cluster communication context. Used for pipe communication.
public sealed class ReportGenerationResponse
- Inheritance
-
ReportGenerationResponse
- Inherited Members
Constructors
ReportGenerationResponse(string, string, Guid, bool, byte[]?, string?, string?)
Initializes a new instance of the ReportGenerationResponse class used for inter-process communication.
public ReportGenerationResponse(string templateName, string filenameToUse, Guid generationIdentifier, bool generationSucceeded, byte[]? reportContent = null, string? reportContentInBase64 = null, string? errorMessage = null)
Parameters
templateNamestringName of the original template.
filenameToUsestringSuggested filename to use when saving the content of the report.
generationIdentifierGuidGeneration identifier.
generationSucceededboolIndicates if the report generation succeed.
reportContentbyte[]Raw report content as bytes.
reportContentInBase64stringBase64-encoded report content (versions prior to 2.4.0, or legacy mode).
errorMessagestringError message.
Remarks
THIS IS NOT INTENDED TO BE USED BY CLIENT CODE (EXCEPT IN UNIT-TESTS, FOR MOCKING A RESPONSE).
ReportGenerationResponse(string, string, string?, bool, string?)
Initializes a new instance of the ReportGenerationResponse class used for inter-process communication.
[Obsolete("Use the constructor with the generation identifier and the raw content instead.")]
public ReportGenerationResponse(string templateName, string filenameToUse, string? reportContentInBase64 = null, bool generationSucceeded = true, string? errorMessage = null)
Parameters
templateNamestringName of the original template.
filenameToUsestringSuggested filename to use when saving the content of the report.
reportContentInBase64stringReport content in encoded to base64 (versions prior to 2.4.0).
generationSucceededboolIndicates if the report generation succeed.
errorMessagestringError message.
Remarks
THIS IS NOT INTENDED TO BE USED BY CLIENT CODE (EXCEPT IN UNIT-TESTS, FOR MOCKING A RESPONSE).
Properties
ErrorMessage
Gets the error message.
public string? ErrorMessage { get; }
Property Value
FilenameToUse
Gets the recommended filename to use when saving the report (retrieved from StiReport.ReportAlias).
public string FilenameToUse { get; }
Property Value
GenerationIdentifier
Gets the generation identifier.
public Guid GenerationIdentifier { get; }
Property Value
GenerationSucceed
Gets a value indicating whether the report generation succeed.
public bool GenerationSucceed { get; }
Property Value
IsLegacyStorageMode
Gets a value indicating whether the generated report was transmitted within the message instead of being persisted separately (without size limit) in an attached network storage (e.g. S3 bucket) shared by the reporting service and the application cluster.
public bool IsLegacyStorageMode { get; }
Property Value
Remarks
In the new mode (since v2.4.0), the content is still added to this message (see the SetReportContent method on ReportGenerationResponseInternal), but it is stored as raw bytes in the GroupeIsa.Neos.Shared.Reports.ReportGenerationResponse._reportContent field.
As a result, the presence of a non-null value in the GroupeIsa.Neos.Shared.Reports.ReportGenerationResponse._reportContentInBase64 field indicates the use of the legacy mode (i.e. absence of ad-hoc persistence).
WARNING: As a result, this field IS NOT APPLICABLE and SHOULD NOT BE USED when GenerationSucceed is false.
ASSERTION: When this property is true, the size of the overall payload is necessarily inferior to the Dapr body limit applies (4MB by default) otherwise we would be unable to transmit this response.
ReportContent
Gets the raw report content.
public byte[]? ReportContent { get; }
Property Value
- byte[]
ReportContentInBase64
Gets the Base64-encoded report content. Starting from v2.4.0, this property may not be available in the PubSub message anymore. For backward compatibility, starting from v2.4.2, we still make sure it is being populated.
public string? ReportContentInBase64 { get; }
Property Value
Remarks
The alternative ReportContent property (not Base64-encoded) can be use for improved performance (when the file is persisted directly on disk and does not need Base64 encoding/decoding) (REF. pbi/28963).
ReportName
Gets the name of the original template.
This is different from StiReport.ReportName (which tends to be used as a human-readable title text).
This is also different from StiReport.ReportAlias (which tends to be used as the name of the PDF file).
It is however called ReportName for backward compatibility of this message (used in business callbacks).
If you ever want to also export the content of the StiReport.ReportName property,
you might want to create and use a "ReportTitle" property for that.
public string ReportName { get; }
Property Value
Methods
ForgeSuccessfulGenerationResponse(string, byte[])
Factory method creating a new instance of the ReportGenerationResponse resembling to a response that the reporting service could have emitted.
public static ReportGenerationResponse ForgeSuccessfulGenerationResponse(string filenameToUse, byte[] documentContent)
Parameters
filenameToUsestringSuggested filename to use when saving the document. In the original implementation, it does not include the '.pdf' file extension because, by default, FilenameToUse = the Stimulsoft ReportAlias property = the name of the template (unless it is redefined inside the template, during the Export event).
documentContentbyte[]Raw document content as bytes.
Returns
- ReportGenerationResponse
A new instance of a response.
Remarks
In this first version, this is achieved thanks to the reporting legacy mode capabilities
of the framework. When using this forged response, the APIs will store the document as a
temporary file in the $NeosFile table of the business database.
ForgeSuccessfulGenerationResponseFromBase64Content(string, string)
Factory method creating a new instance of the ReportGenerationResponse resembling to a response that the report service could have emitted.
public static ReportGenerationResponse ForgeSuccessfulGenerationResponseFromBase64Content(string filenameToUse, string documentContentInBase64)
Parameters
filenameToUsestringSuggested filename to use when saving the document. In the original implementation, it does not include the '.pdf' file extension because, by default, FilenameToUse = the Stimulsoft ReportAlias property = the name of the template (unless it is redefined inside the template, during the Export event).
documentContentInBase64stringBase64-encoded document content.
Returns
- ReportGenerationResponse
A new instance of a response.
Remarks
IMPORTANT: To prevent useless Base64 encoding and decoding, and unless for some reason your content is already base64-encoded, prefer using the other overload and directly passing the raw bytes.
GetDownloadIdentifierAsync(ITemporaryFileStorage?, INeosLogger?, CancellationToken)
Retrieves the identifier for the generated report file, storing it in temporary file storage if necessary.
public Task<Guid> GetDownloadIdentifierAsync(ITemporaryFileStorage? temporaryFileStorage, INeosLogger? logger = null, CancellationToken cancellationToken = default)
Parameters
temporaryFileStorageITemporaryFileStorageThe temporary file storage service used to store the report file in legacy storage mode.
loggerINeosLoggerNeos logger service.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
In non-legacy storage mode, the identifier corresponds directly to the GenerationIdentifier.
In legacy storage mode, the report file is stored in the provided storage,
and the returned identifier corresponds to the stored file.
ValidateConstructorArguments(bool, byte[]?, string?)
Performs validation of constructor arguments related to report generation diagnostics.
public static void ValidateConstructorArguments(bool generationSucceeded, byte[]? reportContent, string? reportContentInBase64)
Parameters
generationSucceededboolA value indicating whether the report generation was successful.
reportContentbyte[]The raw report content as a byte array, or null if not provided.
reportContentInBase64stringThe Base64-encoded report content as a string, or null if not provided.
Exceptions
- ArgumentException
Thrown when the combination of arguments is invalid.