OZ e-Form Developer
  • OZ e-Form Concepts
  • 🌈e-Form DEVELOPER
    • Day 1: Welcome On Board
      • About Course
      • Preparations
      • OZ e-Form Overview
    • Day 2: e-Form Design
      • Designer Environments
      • e-Form Layout Structure
      • e-Form Components
      • e-Form From Documents
      • Preview / Export / Save
      • Hands-on Practice
    • Day 3: Dynamic e-Form
      • e-Form Scripting Guide
      • Hands-on Practice
      • Advanced Features
    • Day 4: e-Form Application
      • Server Deployment
      • Viewer In HTML
      • Viewer APIs
      • Prefilling e-Form
      • Submitting e-Form
      • Sending MemoryStream
    • Get Your Certificate
    • Design Guide
      • Dialogue Flow
        • Overview
        • Creating Dialogue Flow
        • Uploading e-Form to Server
        • Running Dialogue Flow
        • Group and Statement
        • Custom Styling
      • Multilingual e-Form
      • Miscellaneous
      • Videosign
        • Videosign User Guide
      • OZ Verifier
        • OZ Verifier Introduction
        • Implementation and Use
        • Requirements
      • HTML5 Editor
        • HTML5 Editor Introduction
        • HTML Editor
        • Requirements and Sample
    • Day 5. Server & Reporting
  • 🌈Server Developer
    • OZ Server Console
    • OZ Scheduler
      • Features
      • Installing OZ Scheduler
      • Scheduler Task
    • Binding & Exporting
      • Overview
      • Export API Example
        • Extract Input Data
        • Export with OZ Server
        • Export with Scheduler
        • Export with Scheduler Task
    • Repository Server
    • Sync Server
      • Overview
      • Installing Sync-Server
        • SSL configration
      • Sample Application
      • Implementation
    • QR Link Mobile Sign
  • 🌈Report Developer
    • Overview
      • About Course
      • Preparation
      • Report Designer Overview
    • Query Design
      • Database Connection
      • Designer Environment
      • Dataset Design
    • Report Design
      • Designer Environment
      • Components
      • Table
      • Master-Detail
      • ODI Parameter
      • CrossTab
      • Chart
  • 🌈MOBILE DEVELOPER
    • Android Native
    • iOS Native
    • TOTO Framework
      • TOTO Overview
      • Sample App Overview
      • Server Application
      • Android Project
  • ⬇️Product Downloads
  • 📚 Product Documentation
  • 📕Technical Guide
  • ⚛️ ReactJS Integration
Powered by GitBook
On this page
  • scheduler.createTask()
  • scheduler.getTaskResult()

Was this helpful?

  1. Server Developer
  2. Binding & Exporting
  3. Export API Example

Export with Scheduler Task

When you need to generate reports

  • periodically or

  • on a designated date-time or

  • with big data

You can create tasks to generate reports automatically as scheduled.

scheduler.createTask()

String taskID = scheduler.createTask(serverInfo, configMap, exportMap);

createTask.jsp
<%@ page language="java"
  contentType="text/html; charset=UTF-8" 
  import="oz.scheduler.*,
          oz.framework.api.*,
          oz.util.SortProperties,
          oz.framework.cp.OZCPException,
	  org.apache.log4j.*,
          java.util.*,
          java.io.*"
%><%
  request.setCharacterEncoding("UTF-8");
  String	dt		= request.getParameter("dt");
  String	serverUrl	= "http://localhost/oz/server";
  String	serverID	= "admin";
  String	serverPW	= "password";
  String	schedulerIp	= "127.0.0.1";
  int 		schedulerPort	= 9521;
  String	ozrName		= "order";
  String	odiName		= "order";
  String	exportFormat	= "pdf";
  String	exportFileName	= "order";
  int		ozrParamCnt	= 0;
  int		odiParamCnt	= 0;
  String	exYear		= dt.substring(0,4);
  String	exMonth		= dt.substring(5,7);
  String	exDay		= dt.substring(7,9);
  String	exHour		= dt.substring(10,12);
  String	exMin		= dt.substring(12,14);
  String	reportPath	= "demo/" + ozrName + ".ozr";

  Scheduler	scheduler	= new Scheduler(schedulerIp, schedulerPort);
  Publisher	publisher	= new Publisher(schedulerIp, schedulerPort);
  Service	service		= new Service(serverUrl, serverID, serverPW, false, false);
  ServerInfo	serverInfo	= new ServerInfo();
  SortProperties configMap	= new SortProperties();
  SortProperties exportMap	= new SortProperties();
%><%			
try {
  if (!service.ping()) {
    out.println("ERROR: Cannot connect to OZ Server [" + serverUrl + "]");
    if (true) return ;
  }
  if (!scheduler.ping()) {
    out.println("ERROR: Cannot connect to OZ Scheduler [" + schedulerIp + ":" + schedulerPort + "]");
    if (true) return ;
  }
  // OZ Server connection
  serverInfo.setURL(serverUrl);
  serverInfo.setID(serverID);
  serverInfo.setPWD(serverPW);
  serverInfo.setIsDaemon(false);
  // Task parameters
  configMap.setProperty("launch_type", "once"); // Task schedule option: 'immediately', 'once', 'periodically'
  configMap.setProperty("cfg.type", "new"); // Task type option: 'new', 'edit'
  configMap.setProperty("task_type", "viewerTag"); // Use Viewer parameters for task run option
  // Export parameters
  exportMap.setProperty("connection.servlet", serverUrl); // OZ Server connection
  exportMap.setProperty("connection.reportname", reportPath); // OZR file name (full path)
  exportMap.setProperty("viewer.mode", "export");
  exportMap.setProperty("export.mode", "silent");
  exportMap.setProperty("export.confirmsave", "false");
  exportMap.setProperty("export.format", exportFormat);
  exportMap.setProperty(exportFormat + ".filename", exportFileName + "." + exportFormat);
  /* Form Parameters
  exportMap.setProperty("connection.pcount", pcount);		
  export.setProperty("connection.args1", "param1=value");
  */
  /* ODI Parameters
  exportMap.setProperty("odi.odinames", odiName);
  exportMap.setProperty("odi." + odiName + ".pcount", pcount);
  exportMap.setProperty("odi.odiName.args1", "param1=value");
  */
  // schedule 
  configMap.setProperty("execution_year", exYear);
  configMap.setProperty("execution_month", exMonth);
  configMap.setProperty("execution_day", exDay);
  configMap.setProperty("execution_hour", exHour);
  configMap.setProperty("execution_min", exMin);
  // request Scheduler to create a task
  String taskID = scheduler.createTask(serverInfo, configMap, exportMap);
  out.println("taskID=" + taskID);
}
catch (Exception e) {
  out.println("Exception: " + e.getMessage());
  return;
}
%>

scheduler.getTaskResult()

TaskResult[] taskList = scheduler.getTaskResult(serverInfo, from, to, taskID);

Member variables:

  • String taskID

  • String taskName

  • String taskGroupName

  • String completedTime

  • Boolean isSuccessfulCode : 400001(Succeeded), etc.

  • Boolean isSuccessful : Failed, Succeeded, Export

  • String formFileName

  • String Parameter

  • String schedulingType : immediately, once, periodically

  • String formCategoryName

  • String exportFileList

  • int pageCount

  • String errorMsg

getTaskResult.jsp
<%@ page language="java"
  contentType="text/html; charset=UTF-8" 
  import="oz.scheduler.*,
          oz.framework.api.*,
          oz.util.SortProperties,
          oz.framework.cp.OZCPException,
	  org.apache.log4j.*,
          java.util.*,
          java.io.*"
%><%
  request.setCharacterEncoding("UTF-8");
  String	taskID		= request.getParameter("taskID");
  String	serverUrl	= "http://localhost/oz/server";
  String	serverID	= "admin";
  String	serverPW	= "password";
  String	schedulerIp	= "127.0.0.1";
  int 		schedulerPort	= 9521;
  String	exportFormat	= "pdf";
  String	exportPath 	= "C:\\Program Files\\Apache Software Foundation\\Tomcat 9.0\\webapps\\exported\\demo\\";
%>
<%
  Scheduler	scheduler	= new Scheduler(schedulerIp, schedulerPort);
  Publisher	publisher	= new Publisher(schedulerIp, schedulerPort);
  Service	service		= new Service(serverUrl, serverID, serverPW, false, false);
  ServerInfo	serverInfo	= new ServerInfo();
  
  if (taskID == "") { out.println("taskID is required"); return; }

  try {
      if (!service.ping()) {
	  out.println("ERROR: Cannot connect to OZ Server [" + serverUrl + "]");
	  if (true) return ;
      }
      if (!scheduler.ping()) {
	  out.println("ERROR: Cannot connect to OZ Scheduler [" + schedulerIp + ":" + schedulerPort + "]");
	  if (true) return ;
      }
      // OZ Server connection
      serverInfo.setURL(serverUrl);
      serverInfo.setID(serverID);
      serverInfo.setPWD(serverPW);
      serverInfo.setIsDaemon(false);
      // Rresult of task
      TaskResult[] taskList = scheduler.getTaskResult(serverInfo, "", "", taskID);
      if (taskList.length == 0) {
          out.println("Task not found.");
	  return;
      }
      // a single task can have multiple documents
      for (int i = 0; i < taskList.length; i++) {
          TaskResult result = taskList[i];
          if ("Succeeded".equals(result.isSuccessful)) {
              out.println("getTaskResult: " + result.isSuccessfulCode +", "+ result.isSuccessful +", "+ result.taskID);
          }
          else {
              out.println("errorMsg : " + new String(taskList[i].errorMsg.getBytes("8859_1"),"UTF-8"));
	  }  
      }
  }
  catch (Exception e) {
      out.println("Exception: " + e.getMessage());
      return;
}
%>
PreviousExport with SchedulerNextRepository Server

Last updated 2 years ago

Was this helpful?

-

🌈
http://localhost/oz/export/createTask.jsp?dt=2022-0713
http://localhost/oz/export/getTaskResult.jsp?taskID=