Created
February 12, 2019 09:17
-
-
Save noakesey/7af4da58caf18743fe1b70e4c41067cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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