Scheduling a Report Task
The properties for scheduling reports are available in jet.cs.util.APIConst in the Logi JReport Server Javadoc which is located in <install_root>\help\api
.
Below is a list of the sections covered in this topic:
Scheduling a Report Task Using Time Condition
There is an API sample of scheduling a report which is APIDemoPublishRpt.java in <install_root>\help\samples\APIServer
for your reference.
The following introduces how to schedule a report task in your program using time condition:
- Connect to Logi JReport Server as follows:
RptServer server = null; server = HttpUtil.getHttpRptServer();
- Set scheduling task properties. The following example publishes the report CustomerAnalysis.cls in the Public Reports > SampleReports folder to PDF to disk:
// Set task properties Properties props = new Properties(); props.put(APIConst.TAG_TASK_CLASS, APIConst.TASK_TO_RPT); props.put(APIConst.TAG_LAUNCH_TYPE, String.valueOf(APIConst.IMMEDIATELY));
props.put(APIConst.TAG_CATALOG, "/SampleReports/SampleReports.cat"); props.put(APIConst.TAG_REPORT, "CustomerAnalysis.cls"); props.put(APIConst.TAG_TO_DISK, "true");// TO Disk // Set the value of PDF for TO_DISK props.put(APIConst.TAG_TO_PDF, "true");
props.put(APIConst.TAG_PDF, "CustomerAnalysis.pdf");props.put(APIConst.TAG_REPORT_LANGUAGE, "en_US"); String today = DateFormat.getDateInstance(DateFormat.LONG, new Locale("en", "US")).format(new Date());
props.put(APIConst.TAG_PDF_DIR, "/SampleReports");
- Submit and trigger the task as follows:
String taskID = server.submitScheduledTask("admin", props);
- Get the task result:
CompletedTaskTable completeTable = server.getCompletedTaskTable();
- Shut down the server:
server.shutdown();
Scheduling a Report Task Using Trigger
There is an API sample of scheduling a report using trigger which is DemoTrigger.java in <install_root>\help\samples\APIServer
for your reference.
The following introduces how to schedule a report task using trigger in your program:
- Connect to Logi JReport Server as follows:
// get instance of RptServer
RptServer svr = RemoteReportServerToolkit.getRemoteWrappedRptServer("127.0.0.1", "1129"); TriggerManager trigMan = svr.getTriggerManager(); String exTriggerName = "exTriggerDemo";
if (!trigMan.contains(exTriggerName)) { trigMan.createTrigger(exTriggerName, "an external trigger demo"); } - Set scheduling task properties. The following example publishes the report Banded_Link.cls in the Public Reports > SampleReports folder to PDF to the versioning system:
Properties props = new Properties(); props.put(APIConst.TAG_TASK_CLASS, APIConst.TASK_TO_RPT); props.put(APIConst.TAG_LAUNCH_TYPE, String.valueOf(APIConst.IMMEDIATELY)); props.put(APIConst.TAG_TRIGGERS_LOGIC, "ONLY"); props.put(APIConst.TAG_TRIGGERS_ARRAY, "exTriggerDemo"); props.put(APIConst.TAG_CATALOG, "/SampleReports/SampleReports.cat"); props.put(APIConst.TAG_REPORT, "/SampleReports/Banded_Link.cls"); props.put(APIConst.TAG_TO_VERSION, "true"); props.put(APIConst.TAG_TO_VERSION_PDF, "true");
- Submit the task as follows:
taskID = svr.submitScheduledTask("admin", props);
- Trigger the task as follows:
Properties userData = new Properties();
trigMan.fire(exTriggerName, userData);