private Stream buildPdf(str Id)
{

    System.IO.MemoryStream stream;

    
    Contract contract = new Contract ();
    Controller controller = new Controller ();
    SRSPrintDestinationSettings settings;
    SRSReportRunService srsReportRunService = new SrsReportRunService();
    Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray;

    SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo();
    Map reportParametersMap;
    SRSProxy srsProxy;
    System.Byte[] reportBytes = new System.Byte[0]();

    

    contract.parmId("Id");

    
    controller.parmReportName(ssrsReportStr(Report, Report));
    //controller.parmDialogCaption('@IWS:IWS02036');
    //controller.parmShowDialog(false);
    //controller.parmLoadFromSysLastValue(false);
    controller.parmReportContract().parmRdpContract(contract);

    settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::PDF);

    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());

    reportBytes = srsproxy.renderReportToByteArray(
        controller.parmreportcontract().parmreportpath(),
        parameterValueArray,
        settings.fileFormat(),
        settings.deviceinfo());

    if (reportBytes)
    {
        stream = new System.IO.MemoryStream(reportBytes);
        stream.Position = 0;
    }
    return  stream;
}

标签: none

添加新评论