Hi Mirko,
I'd agree with Juraj, a custom scheduled task will be the right approach here. Please consider the following logic:
- To support incremental import, your scheduled task would require storing the history of executions. In particular, date-time of task run, status (successful or not), maybe textual log of the execution.
- To store the history of task executions it's better to use Module Custom Classes. Basically, create a Custom Class holding TaskStartDate, SuccessfullFlag, TaskTextLog.
-
In task code you can do the following:
- In task execution history find the most recent successful task run, and remember it's TaskStartDate - in the current task run you'd need to find all pages that have become published since that date and time.
- Query the database to find these pages (query example below)
- Execute export to third-party system.
- Save the current task run time, successful flag and log as your Custom Class instance, so that on the next run of the scheduled task the date you need to query your pages will shift.
Here is the query example:
var docsToExport = DocumentHelper.GetDocuments()
// only published document will be retrieved
.Published()
// exclude unpublished changes if you use workflow
.LatestVersion(false)
// Simple pages created without versioning or workflow
.WhereGreaterThan(nameof(TreeNode.DocumentModifiedWhen), lastSuccessfullRunTime)
.And()
.WhereNull(nameof(TreeNode.DocumentPublishFrom))
.Or()
// Pages created with versioning enabled
.WhereGreaterThan(nameof(TreeNode.DocumentPublishFrom), lastSuccessfullRunTime)
.And()
.WhereLessThan(nameof(TreeNode.DocumentPublishFrom), currentTaskStartTime)
.ToList();
For pages under workflow this query may become more complicated.