C# CognosV11SDK参数传递

C# CognosV11SDK参数传递,c#,sdk,cognos,C#,Sdk,Cognos,我有一个网页,用户可以选择(n)条记录进行打印。有没有办法向Cognos发送一个Id数组 还是最好将它们保存在一个表或xml文件中,并让cognos将其用作数据源 所以您只需创建多个simpleParmValueItems parameterValue[] parameters = new parameterValue[1]; parameters[0] = new parameterValue(); parameters[0].name = "variableName"; parmValue

我有一个网页,用户可以选择(n)条记录进行打印。有没有办法向Cognos发送一个Id数组


还是最好将它们保存在一个表或xml文件中,并让cognos将其用作数据源

所以您只需创建多个simpleParmValueItems

parameterValue[] parameters = new parameterValue[1];
parameters[0] = new parameterValue();
parameters[0].name = "variableName";

parmValueItem[] pvi = new parmValueItem[2];
simpleParmValueItem item = new simpleParmValueItem();
item.use = "value1";
pvi[0] = item;
item = new simpleParmValueItem();
item.use = "value2";
pvi[1] = item;

parameters[0].value = pvi;

下面是我如何解决的

public AsynchReply runReport(final String reportSearchPath, final String format,
        final String param) {

    AsynchReply response;

    BaseParameter params[] = new Parameter[] {};
    final ParameterValue[] parameters = new ParameterValue[1];

    final SearchPathSingleObject reportPathObj = new SearchPathSingleObject();
    reportPathObj.set_value(reportSearchPath);
    try {
        // Get the report parameters name.
        response = this.getReportService().getParameters(reportPathObj, new ParameterValue[] {},
                new Option[] {});
        // If response is not immediately complete, call wait until complete
        if (!response.getStatus().equals(AsynchReplyStatusEnum.conversationComplete)) {
            while (!response.getStatus().equals(AsynchReplyStatusEnum.conversationComplete)) {
                response = this.getReportService().wait(response.getPrimaryRequest(),
                        new ParameterValue[] {}, new Option[] {});
            }
        }

        for (int i = 0; i < response.getDetails().length; i++) {
            if (response.getDetails()[i] instanceof AsynchDetailParameters) {
                params = ((AsynchDetailParameters) response.getDetails()[i]).getParameters();
            }
        }

        final SimpleParmValueItem item = new SimpleParmValueItem();
        item.setUse(param); // hard coded value for the parameter.
        item.setDisplay(param);
        item.setInclusive(true);

        final ParmValueItem[] paramValueItem = new ParmValueItem[1];
        paramValueItem[0] = item;
        parameters[0] = new ParameterValue();
        parameters[0].setName(params[0].getName());
        parameters[0].setValue(paramValueItem);

        final Option[] runOptions = new Option[4];

        final RunOptionBoolean saveOutput = new RunOptionBoolean();
        saveOutput.setName(RunOptionEnum.saveOutput);
        saveOutput.setValue(false);
        runOptions[0] = saveOutput;

        // Specify the output format.
        final RunOptionStringArray outputFormat = new RunOptionStringArray();
        outputFormat.setName(RunOptionEnum.outputFormat);
        outputFormat.setValue(new String[] {format});
        runOptions[1] = outputFormat;

        // Set the report not to prompt as we pass the parameters if any
        final RunOptionBoolean rop = new RunOptionBoolean();
        rop.setName(RunOptionEnum.prompt);
        rop.setValue(false);
        runOptions[2] = rop;

        final RunOptionInt maxRows = new RunOptionInt();
        maxRows.setName(RunOptionEnum.verticalElements);
        maxRows.setValue(0);
        runOptions[3] = maxRows;

        // Run the report
        response = this.getReportService().run(reportPathObj, parameters, runOptions);

        // If response is not immediately complete, call wait until complete
        if (!response.getStatus().equals(AsynchReplyStatusEnum.complete)
                && !response.getStatus().equals(AsynchReplyStatusEnum.conversationComplete)) {
            while (!response.getStatus().equals(AsynchReplyStatusEnum.complete) && !response
                    .getStatus().equals(AsynchReplyStatusEnum.conversationComplete)) {
                // before calling wait, double check that it is okay
                if (ExecuteReportService.hasSecondaryRequest(response, "wait")) {
                    response = this.getReportService().wait(response.getPrimaryRequest(),
                            new ParameterValue[] {}, new Option[] {});
                } else {
                    System.out.println("Error: Wait method not available as expected.");
                    return null;
                }
            }
            // check if output is ready
            int i;
            for (i = 0; i < response.getDetails().length; i++) {
                if ((response.getDetails()[i] instanceof AsynchDetailReportStatus)
                        && (((AsynchDetailReportStatus) response.getDetails()[i])
                                .getStatus() == AsynchDetailReportStatusEnum.responseReady)
                        && (this.hasSecondaryRequest(response, "getOutput"))) {
                    response = this.getReportService().getOutput(response.getPrimaryRequest(),
                            new ParameterValue[] {}, new Option[] {});
                    break;
                }
            }
            // if output is not ready return to main
            if (i == 3) {
                System.out.println("Output was not generated");
                return null;
            }
        }

        // release the conversation to free resources.
        if (ExecuteReportService.hasSecondaryRequest(response, "release")) {
            // System.out.println("Releasing resources");
            this.getReportService().release(response.getPrimaryRequest());
        }
        return response;

    } catch (final Exception ex) {
        System.out.println(ex);
        ex.printStackTrace();
    }

    return null;
}
public AsynchReply runReport(最终字符串报告searchpath,最终字符串格式,
最终字符串参数){
异步分层响应;
BaseParameter参数[]=新参数[]{};
最终参数值[]参数=新参数值[1];
final SearchPathSingleObject ReportPathBj=新的SearchPathSingleObject();
reportPathBj.set_值(reportSearchPath);
试一试{
//获取报表参数名称。
response=this.getReportService().getParameters(ReportPathBj,新参数值[]{},
新选项[]{});
//如果响应未立即完成,请调用“等待完成”
如果(!response.getStatus().equals(AsynchReplyStatusEnum.conversationComplete)){
而(!response.getStatus().equals(AsynchReplyStatusEnum.conversationComplete)){
response=this.getReportService().wait(response.getPrimaryRequest(),
新参数值[]{},新选项[]{});
}
}
for(int i=0;i
对此表示感谢。我也在努力遵循同样的原则。我目前的例子要简单得多——我只想传入一个参数。但是,当我运行此操作时,将呈现参数页,而不是底层报告。这是我的代码:ParameterValue参数[]=新的ParameterValue[1];参数[0]=新参数值();参数[0]。集合名称(“pFundingDescription”);ParmValueItem[]pvi=新的ParmValueItem[1];SimpleParmValueItem项=新的SimpleParmValueItem();项目.setUse(“自动付款”);pvi[0]=物料;参数[0]。设置值(pvi);aj,看起来不错。。我不确定您是如何处理用户名/密码的,但我们必须