Hi Juraj, Thank you. I created the custom task with below code. But after one time run, whenever there is object changes it straightaway send to other server not even log the task in staging module anymore or wait for the next schedule run time.
public string Execute(TaskInfo ti)
{
if (ti.TaskEnabled == true)
{
// Assigns a handler to the StagingEvents.LogTask.After event
// This event occurs after the system creates content staging synchronization tasks (separately for each task)
StagingEvents.LogTask.After += LogStagingTask_After;
string detail = "Staging Executed Testing";
// Logs the execution of the task in the event log.
EventLogProvider.LogInformation("CustomStagingTask", "Execute", detail);
}
return null;
}
// Automatically synchronizes staging tasks
private void LogStagingTask_After(object sender, StagingTaskEventArgs e)
{
// Gets the target server
ServerInfo targetServer = ServerInfoProvider.GetServerInfo("MyServer", SiteContext.CurrentSiteID);
if ((targetServer != null) && (e.Task != null))
{
// Synchronizes the processed staging task to the target server
StagingHelper.RunSynchronization(e.Task.TaskID, targetServer.ServerID);
}
}