Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void run()
{
//Configure the SrsReportRunController controller
controller.parmReportName(reportName);
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
controller.parmReportContract().parmReportExecutionInfo(executionInfo);
//Associate the Rdp contract with prepopulated values if we have one
if(contract)
{
controller.parmReportContract().parmRdpContract(contract);
}
//Configure print settings to render the output to XML
SRSPrintDestinationSettings settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::Custom);
settings.fileFormat(SRSReportFileFormat::XML);
//Bootstrap the SRSReportRunService
srsReportRunService.getReportDataContract(controller.parmReportContract().parmReportName());
srsReportRunService.preRunReport(controller.parmReportContract());
//Marshall the parameters from the contract
Map reportParametersMap = srsReportRunService.createParamMapFromContract(controller.parmReportContract());
Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray =
SrsReportRunUtil::getParameterValueArray(reportParametersMap);
//Render the report to a byte array
SRSProxy srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());
System.Byte[] reportBytes = srsproxy.renderReportToByteArray(controller.parmreportcontract().parmreportpath(),
parameterValueArray,
settings.fileFormat(),
settings.deviceinfo());
if (reportBytes)
{
//Create an XMLDocument from the byte array
System.IO.MemoryStream stream = new System.IO.MemoryStream(reportBytes);
xmlDocument = XmlDocument::newFromStream(stream);
}
else
{
throw Exception::Error;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.