Skip to content

Instantly share code, notes, and snippets.

@noakesey
Created January 25, 2019 16:13
Show Gist options
  • Save noakesey/86c902476035b24b67fc351edf1cb7fb to your computer and use it in GitHub Desktop.
Save noakesey/86c902476035b24b67fc351edf1cb7fb to your computer and use it in GitHub Desktop.
protected XmlDocument xmlDocument;
protected Object contract;
protected str reportName;
protected SRSReportRunService srsReportRunService = new SrsReportRunService();
protected SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo();
protected SRSReportRunController controller = new SRSReportRunController();
public void run()
{
controller.parmReportName(reportName);
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
controller.parmReportContract().parmReportExecutionInfo(executionInfo);
if(contract)
{
controller.parmReportContract().parmRdpContract(contract);
}
SRSPrintDestinationSettings settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::Custom);
settings.fileFormat(SRSReportFileFormat::XML);
srsReportRunService.getReportDataContract(controller.parmReportContract().parmReportName());
srsReportRunService.preRunReport(controller.parmReportContract());
Map reportParametersMap = srsReportRunService.createParamMapFromContract(controller.parmReportContract());
Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray =
SrsReportRunUtil::getParameterValueArray(reportParametersMap);
SRSProxy srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());
System.Byte[] reportBytes = srsproxy.renderReportToByteArray(controller.parmreportcontract().parmreportpath(),
parameterValueArray,
settings.fileFormat(),
settings.deviceinfo());
if (reportBytes)
{
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