Skip to content

Instantly share code, notes, and snippets.

@noakesey
Created February 12, 2019 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noakesey/7af4da58caf18743fe1b70e4c41067cb to your computer and use it in GitHub Desktop.
Save noakesey/7af4da58caf18743fe1b70e4c41067cb to your computer and use it in GitHub Desktop.
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