Create Content staging scheduled task for objects

   —   
This article shows how to create a scheduled task for global objects.
As you may or may not know, the Content Staging module allows you to easily transfer changes made to documents or objects from one Kentico CMS instance, to another Kentico CMS instance on a separate server.  You can find more information about Content Staging on the following URL - Staging overview

You can configure these changes to be automatically synched to the target instance by enabling the Content synchronization scheduled tasks in Site Manager --> Administration --> Scheduled tasks.  However this task will only automate the synchronization of document changes, and not Object changes.  Any changes made to Objects will need to be manually synched via the Content Staging UI.

In order to achieve this, you will need to create a custom scheduled task, which basically executes the same code that is executed on the synchronize objects button in the user interface.  You can find more information on creating a custom scheduled tasks on the following URL -
Scheduling a custom code

Once you have created the scheduled task, you need to add the code that the task executes.  Please navigate to your project folder and find the following files –

~/CMSModules/Staging/Tools/Objects/Tasks.aspx(.cs)

In the code behind file you will find the "SynchronizeAll" event.  This event is fired when synchronize objects button in the user interface is pressed.  You can take the code fired from this event, use it in the scheduled task, and then enable the scheduled task to run at your desired schedule.
-eh-


Applies to: Kentico CMS 7.x.  This method can also apply to version 6.x and 5.x.
Share this article on   LinkedIn