Showing posts with label CF8. Show all posts
Showing posts with label CF8. Show all posts

Friday, 5 June 2015

CFSCHEDULE & Scheduled Taks

Hi,

I came to know some nice functions of Scheduled Tasks and  CFSHEDULE.

I had a task like the Records will get fetch from DB, there will be a huge number of records. Have to send records through HTTP, but the records sending should be as fast as possible. With one file I couldn't make that so I used 3 files which gets Query result from parent page and executes. I used the chained task feature in CF Admin Scheduled Tasks and CFSHEDULE run action.

cfschedule

The task should be set up in CFADMIN before using through CFSCHEDULE.

Used to run the already defined scheduled task. It will run in real time.
 <cfschedule action="run" task="scheduledTask2" >  

To pause all the task, only 'pause' can be used to pause a specific task.
 <cfschedule action="pauseall">  

To update the existing task we can use UPDATE action. We can set most of the settings through Update action.
 <cfschedule action="update" repeat="2" onmisfire="FIRE_NOW" url='http://localhost/ColdfusionDemo/Practise/scheduledTask1.cfm'   
      startdate="#createDate(2015,6,05)#" starttime="10:00 PM" enddate="#createDate(2015,6,05)#" endtime="11:00 PM" interval="once" task="scheduledTask1">  

To list Scheduled task we can use LIST action, we get query object as a result having all settings.
 <cfschedule action="list" task="scheduledTask1,scheduledTask2" result="res">  
 <cfdump var="#res#" >  

Other actions are DELETE,RESUME,RESMUE ALL

Note:
1. The paused tasks can't be run through RUN action.
2. The chained tasks cannot be paused or resumed through PAUSE ALL, PAUSE, RESUME or               RESUME  ALL action.
3. Except On Chained, On Complete and Daily Every sections other sections can be set through UPDATE action.

Scheduled Tasks



We can set Scheduled tasks in Admin Server Settings->Scheduled Tasks.

Scheduled Task panel












In this we can set Task Name,URL and other settings.














The Most of Options in Settings are self explanatory.


  • ScheduledTask1 is a child Task of ScheduledTask2. ScheduledTask1 will run after completion of ScheduledTask2. 
  • We can publish the output in .txt or .log file. By choosing Publish.
  • Cluster is for Enabling to Execute tasks in Cluster Setup.

One can refer through each settings in detail at Right Side Upper Help Button in CF Admin.


Tuesday, 10 March 2015

Reading DOC file and writing in PDF using HWPF,LOWAGIE objects

Hi,

I came across writing into PDF using HWPF,LOWAGIE  objects in CF as well as in JAVA. Here I am reading a DOC file and copying contents to a PDF. It can be used alternate to CFDOCUMENT for CF8 below versions.

Required JARS are




 <cfscript>  
      // Creating JAVA fileinput stream object  
      fileinput = CreateObject("java", "java.io.FileInputStream");  
      // Calling InputStream constructor  
      fileinput.init("C:\Users\admin\Adobe ColdFusion Builder workspace\Practise\word.doc");  
      //Creating HWPF object  
      document = CreateObject("java", "org.apache.poi.hwpf.HWPFDocument");  
      // Calling HWPF constructor  
      document.init(fileinput);  
      // Creating a WordExtractor Object  
      reader = CreateObject("java", "org.apache.poi.hwpf.extractor.WordExtractor");  
      // Calling WordExtractor constructor  
      reader.init(document);  
      //Each line is captured in docfile as an array  
      docfile = reader.getParagraphText();  
      //Dumpingto see Docfile in array format  
      writeDump(docfile);  
      docfilefull = '';  
      //convertingarray to string  
      for(a in docfile)  
      {  
           docfilefull = docfilefull & a & chr(13) & chr(10);  
      }  
      //Creating lowagie object  
      document = CreateObject("java", "com.lowagie.text.Document");  
      // Calling lowagie constructor  
      document.init();  
      // Creating FileOutputStream object  
      fileIO = CreateObject("java", "java.io.FileOutputStream");  
      // Calling FileOutputStream constructor with path/name of file to written  
      fileIO.init("C:\Users\admin\Desktop\word19.pdf");  
      // Creating PdfWriter object  
      writer = CreateObject("java", "com.lowagie.text.pdf.PdfWriter");  
      //Calling getInstance method  
      writer.getInstance(document, fileIO);  
      //Calling open method of lowgie object  
      document.open();  
      // Creating Paragraph object  
      paragraph = CreateObject("java", "com.lowagie.text.Paragraph");  
      //Calling paragraph constructor passing the string which have the doc file content  
      paragraph.init(docfilefull);  
      //Writing the PDF document with DOC contents  
      document.add(paragraph);  
      //Closing document  
      document.close();  
 </cfscript>