public static Str getReportBase64Str(RecId _RecId)
{
SrsReportRunController controller = new SrsReportRunController();
NW_GeneralContract contract = new NW_GeneralContract();
SRSPrintDestinationSettings settings;
System.Byte[] reportBytes = new System.Byte[0]();
SRSProxy srsProxy;
SRSReportRunService srsReportRunService = new SrsReportRunService();
Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray;
Map reportParametersMap;
SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo();
PurchTable Table;
System.IO.Stream stream;
str Base64Str;
changecompany("SHC")
{
select firstonly Table where Table.RecId == _RecId;
if(Table)
{
Filename filename = strfmt("%1.pdf",Table.PurchId);
str reportnameLocal = ssrsReportStr(NW_PurchaseOrderReport, PrecisionDesign1);
if(!reportnameLocal)
{
error("The request Type not Exist in thee request please select it " );
}
controller.parmReportName(reportnameLocal);
controller.parmShowDialog(false);
contract.parmRecordId(Table.RecId);
controller.parmReportContract().parmRdpContract(contract);
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
settings.overwriteFile(true);
settings.fileName(filename);
controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
controller.parmReportContract().parmReportExecutionInfo(executionInfo);
srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());
srsReportRunService.preRunReport(controller.parmreportcontract());
reportParametersMap = srsReportRunService.createParamMapFromContract(controller.parmReportContract());
parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());
// Actual rendering to byte array
reportBytes = srsproxy.renderReportToByteArray(controller.parmreportcontract().parmreportpath(),
parameterValueArray,
settings.fileFormat(),
settings.deviceinfo());
if (reportBytes)
{
stream = new System.IO.MemoryStream(reportBytes);
//Save the file
//var fileStream = new System.IO.FileStream(filename, System.IO.FileMode::Create, System.IO.FileAccess::ReadWrite);
//stream.CopyTo(fileStream);
Base64Str= System.Convert::ToBase64String(reportBytes);
}
}
// end if
}
// end change company
return Base64Str;
}