这里说的是通过API传递参数,不是通过Viewer的URL传递参数。
API是和Server打交道,自己的应用和crystal report server进行交互完成报表的运行调度。
其实好像所有参数类型都可以用String类型的表示,数字型和字符串型的就不用说了,日期型可以用DateTime(yyyy,MM,dd,HH,
mm,ss)或者Date(yyyy,MM,dd)格式,如果是允许多个值的,只要一个一个添加就行了,或者用分号分隔组成一个字符串。
代码片断如下(不是完整的代码):
    String query = “Select SI_PROCESSINFO.SI_PROMPTS From CI_INFOOBJECTS Where SI_ID = “
        + form.getReportID();
    IInfoObjects results = query(query);
    if (results.size() == 0) {
      throw new Exception(“The report does not exist.”);
    }
    IInfoObject report = (IInfoObject) results.get(0);
    List allParameters = ((IReport) report).getReportParameters();
    IReportParameterSingleValue newSingleParameter = null;
    IReportParameter reportParameter = null;
    String[] times = CrystalReportParameter.convertTimeParameters(form
        .getStartDay(), form.getStartHour(), form.getEndDay(), form
        .getEndHour(), form.isIncludeCurrentHour());

    for (int j = 0; j < allParameters.size(); j++) {
      reportParameter = (IReportParameter) allParameters.get(j);
      reportParameter.getCurrentValues().clear();
      String parameterName = reportParameter.getParameterName();
      if (CrystalReportParameter.isMultipleValueParameter(parameterName)) {
        String[] values = (String[]) form.get(parameterName);
        for (int i = 0; i < values.length; i++) {
          newSingleParameter = reportParameter.getCurrentValues()
              .addSingleValue();
          newSingleParameter.setValue(values[i]);
        }
      } else if (parameterName.equals(CrystalReportParameter.STARTTIME)) {
        newSingleParameter = reportParameter.getCurrentValues()
            .addSingleValue();
        newSingleParameter.setValue(CrystalReportParameter
            .getParameterTime(times[0]));
      } else if (parameterName.equals(CrystalReportParameter.ENDTIME)) {
        newSingleParameter = reportParameter.getCurrentValues()
            .addSingleValue();
        newSingleParameter.setValue(CrystalReportParameter
            .getParameterTime(times[1]));
      }
    }

    ISchedulingInfo scheduleInfo = report.getSchedulingInfo();
    scheduleInfo.setType(0);
    scheduleInfo.setRightNow(true);
    iStore.schedule(results);

  private static IInfoObjects query(String query) throws Exception {
    IInfoObjects results = null;
    try {
      results = iStore.query(query);
    } catch (SDKException e) {
      logger.error(“Can not execute query:” + query, e);
      throw e;
    }
    return results;
  }

(Visited 158 times, 1 visits today)