Changes to scheduled jobs!

New scheduled job platform that allows for easy customization

As of version 16 we've made important changes to how scheduled jobs are created and deployed. Scheduled jobs now use the recently introduced service hoster in order to have full customization support. The previous scheduled jobs have been moved from the now defunct BusinessFunctions class into the apropriately named busScheduledJobs business object.

Adding a custom scheduled job is as easy as customizing the busScheduledJobs business object and adding a new method that accepts no parameters and returns void.

Enabling customizations for a server mandant can be done by editing the tlx.ini file where the server has been installed and adding a 'CustomPath' key with the value pointing to a custom path directory, just like we do to client mandants.

Example:

# ...
[ServicePorts]
  tlsvc = 50516
[Mandant/001]
  Mandant = Neo16
  DmsMailImport = Off
  DMSImportConfiguration = 
  ConnectionString = Provider=SAOLEDB.17;ENG=local-17;DBN=Neo16;Links=tcpip(Host=localhost);Downlevel=TRUE
  Credentials = Yq2AIIl+GMGH+rZUozxerg==
  # We apply this custom path to the server mandant called Neo16
  CustomPath = C:\Customizations\CustomServer16
# ...

Here is an example we used to have in the documentation for custom scheduled jobs, adapted to version 16. In order to create a new custom scheduled job, first create a new customization from TimeLine Developer.

A new customization for v16

The next step is to customize the busScheduledJobs business object and add our new logic.

Customizing the busScheduledJobs object

To ensure our custom methods are picked up by the service hoster we need to make sure we edit the server tlx.ini to add the custom path to our server mandant (as shown at the top of this page). Please make sure you restart the service hoster service in order for this change to take effect!

We can easily add a new custom method that can be invoked via the scheduled jobs mechanism by writing a non-static public method that returns void and has no parameters.

Generating reports from server-side scheduled jobs

Make sure you reference the TimeLine.Report assembly

public void ReportExportTest()
{
    TranslationManager.Instance.LoadCurrentCulture();
    
    var rep = new TimeLine.Report.TLListAndLabel();
    xSqlArgs args = new TimeLine.Framework.Data.xSqlArgs();
    
    rep.DoPreview("rptBeleg02", args, null, "Beleg02", null, "c:\\TMP", "ExportTest", "pdf", null, null, null, null);
}

If everything is set up correctly you should be able to see the custom added method in the scheduled job configurator dropdown:

The custom method appears in the scheduled jobs configurator

For the above example to work you need to have the Beleg02.lst report in your server installation reports directory. A succesful job run should produce the expected results:

Succesful custom job run log output
The generated report

Last updated