str detailsId;
str id, message, status, code, api_name, errorCode, codeDescription;
str jsonSerializedContract;
FileName localPath;
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();
str filename;
select inventTransferJour
inventTransferJour.recid == 5654675849;
if (inventTransferJour)
{
str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
PrintMgmtReportFormatName printMgmtReportFormatName = PrintMgmtDocType::construct(PrintMgmtDocumentType::TransferOrderFiscalDoc_BR).getDefaultReportFormat();
if (!WinAPI::pathExists("C:\\Temp\\Invoices\\")) WinAPI::createDirectoryPath("C:\\Temp\\Invoices\\");
filename=strfmt('C:\\Temp\\Invoices\\%1%2',inventTransferJour.VoucherId,".pdf");
InventTransferShipReceiveController InventTransferShipReceiveController = new InventTransferShipReceiveController();
InventTransferShipReceiveContract InventTransferShipReceiveContract = new InventTransferShipReceiveContract();
InventTransferShipReceiveContract.parmShowTaxInformation(false);
InventTransferShipReceiveController.parmReportName(ssrsReportStr(InventTransferReceive, Report));//printMgmtReportFormatName);
InventTransferShipReceiveController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
InventTransferShipReceiveController.parmShowDialog(false);
// InventTransferShipReceiveController.parmReportContract().parmRdpContract(salesInvoiceContract);
InventTransferShipReceiveController.parmReportContract().parmRdpContract(InventTransferShipReceiveContract);
InventTransferShipReceiveController.parmLocalExportOptions();
Query query = new Query(queryStr (InventTransfer)); // Query name.
QueryRun qr;
QueryBuildRange qbr;
QueryBuildDataSource queryBuildDataSource = query.dataSourceTable(tableNum(InventTransferJour));
InventTransferUpdateType updateType = InventTransferUpdateType::Receive;
QueryBuildRange qbrUpdateType = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, UpdateType));
qbrUpdateType.value(queryValue(updateType));
qbrUpdateType.status(RangeStatus::Locked);
QueryBuildRange qbrTransferId = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, TransferId));
QueryBuildRange qbrVoucherId = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, VoucherId));
QueryBuildRange qbrTransDate = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, TransDate));
if (inventTransferJour)
{
qbrTransferId.value(queryValue(inventTransferJour.TransferId));
qbrVoucherId.value(queryValue(inventTransferJour.VoucherId));
qbrTransDate.value(queryValue(inventTransferJour.TransDate));
}
InventTransferShipReceiveController.setRanges(query);
// printerSettings.parmFileName(@'C:\Temp\'+custInvoiceJour.InvoiceId + ext);
SRSPrintDestinationSettings printerSettings = InventTransferShipReceiveController.parmReportContract().parmPrintSettings();
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.overwriteFile(true);
printerSettings.fileName(filename);
InventTransferShipReceiveController.startOperation();
srsReportRunService.getReportDataContract( InventTransferShipReceiveController.parmreportcontract().parmReportName());
srsReportRunService.preRunReport(InventTransferShipReceiveController.parmreportcontract());
reportParametersMap= srsReportRunService.createParamMapFromContract(InventTransferShipReceiveController.parmReportContract());
parameterValueArray =SrsReportRunUtil::getParameterValueArray(reportParametersMap);
srsProxy =SRSProxy::constructWithConfiguration(InventTransferShipReceiveController.parmReportContract().parmReportServerConfig());
// Actual rendering to byte array
reportBytes =srsProxy.renderReportToByteArray(InventTransferShipReceiveController.parmreportcontract().parmreportpath(), parameterValueArray, printerSettings.fileFormat(), printerSettings.deviceinfo());
using (var stream = new System.IO.MemoryStream(reportBytes))
{
using (var fileStream = new System.IO.FileStream(filename,System.IO.FileMode::Create, System.IO.FileAccess::ReadWrite))
{
stream.CopyTo(fileStream);
}
}
}
str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
PrintMgmtReportFormatName printMgmtReportFormatName = PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderInvoice).getDefaultReportFormat();
SalesInvoiceContract salesInvoiceContract = new SalesInvoiceContract();
salesInvoiceContract.parmRecordId(_custinvoicejour.RecId);
SrsReportRunController srsReportRunController = new SrsReportRunController();
if (!WinAPI::pathExists("C:\\Temp\\Invoices\\")) WinAPI::createDirectoryPath("C:\\Temp\\Invoices\\");
filename=strfmt('C:\\Temp\\Invoices\\%1%2',_custinvoicejour.InvoiceId,".pdf");
srsReportRunController.parmReportName(printMgmtReportFormatName);
srsReportRunController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
srsReportRunController.parmShowDialog(false);
srsReportRunController.parmReportContract().parmRdpContract(salesInvoiceContract);
srsReportRunController.parmLocalExportOptions();
// printerSettings.parmFileName(@'C:\Temp\'+custInvoiceJour.InvoiceId + ext);
SRSPrintDestinationSettings printerSettings = srsReportRunController.parmReportContract().parmPrintSettings();
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.overwriteFile(true);
printerSettings.fileName(filename);
srsReportRunController.startOperation();
//srsReportRunController.startOperation();
srsReportRunService.getReportDataContract( srsReportRunController.parmreportcontract().parmReportName());
srsReportRunService.preRunReport(srsReportRunController.parmreportcontract());
reportParametersMap= srsReportRunService.createParamMapFromContract(srsReportRunController.parmReportContract());
parameterValueArray =SrsReportRunUtil::getParameterValueArray(reportParametersMap);
srsProxy =SRSProxy::constructWithConfiguration(srsReportRunController.parmReportContract().parmReportServerConfig());
// Actual rendering to byte array
reportBytes =srsProxy.renderReportToByteArray(srsReportRunController.parmreportcontract().parmreportpath(), parameterValueArray, printerSettings.fileFormat(), printerSettings.deviceinfo());
if (reportBytes)
{
using (var stream = new System.IO.MemoryStream(reportBytes))
{
using (var fileStream = new System.IO.FileStream(filename,System.IO.FileMode::Create, System.IO.FileAccess::ReadWrite))
{
stream.CopyTo(fileStream);
//stream.Close();
//stream.Dispose();
//stream.Flush();
}
}
/// var fileStream = new System.IO.FileStream(filename,System.IO.FileMode::Create, System.IO.FileAccess::ReadWrite);
}
}
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,867 Super User 2024 Season 2
Martin Dráb 229,173 Most Valuable Professional
nmaenpaa 101,156