API Questions on Kentico API.
Version 6.x > API > Sync task not generated immediately after node insertion View modes: 
User avatar
Member
Member
jheavner-ce - 8/24/2012 12:10:37 PM
   
Sync task not generated immediately after node insertion
I am inserting a node and I expect the sync task to be generated as soon as the node has been inserted but it seems that the current thread has to complete before the sync task is generated. I've opened SQL Profiler to verify this behavior. I've tried inserting the node both with and without UseDocumentHelper and neither generate the task in a timely manner.

How can I insert a document and immediately fetch and run the sync task? The code I have inserts the node and works fine once the task is generated but the task isn't generated for inline execution to work. Please advise.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/25/2012 5:28:14 PM
   
RE:Sync task not generated immediately after node insertion
Hi,

have you tried to enable schedule task responsible for automatic document synchronization?

See more details here:
Automatic content synchronization

Best regards,
Ivana Tomanickova

User avatar
Member
Member
jheavner-ce - 8/28/2012 8:34:43 AM
   
RE:Sync task not generated immediately after node insertion
I am aware of scheduled document syncing. That's not what I need or want. I need to be able to use the API to create and publish a new document, find the sync task, and sync the task all within the same thread.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 9/4/2012 5:10:27 AM
   
RE:Sync task not generated immediately after node insertion
Hi,

I checked the source code and in case you use method:

DocumentHelper.InsertDocument(node, parentNode, tree);


the change should be synchronized, i.e. the task should be created. In the InsertDocument method implementation is a line:

// Log synchronization task
LogDocumentChange(node, TaskTypeEnum.CreateDocument, tree);


It will create UpdateDoc task. In case you prefer to create CreateDoc, please set AllowAsyncActions in TreeProvider object to false.

In case you need to use API to create custom tasks, please take a look here:
Staging API examples

Here is a code sample which runs synchronization:


// Log the synchronization tasks
List<ISynchronizationTask> tasks = DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, true, false, tree, si.ServerID, null, false);

foreach (TaskInfo ti in tasks)
{
// Run the synchronization
StagingHelper.RunSynchronization(ti.TaskID, si.ServerID);
}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
powermouse - 10/4/2012 2:05:19 PM
   
RE:Sync task not generated immediately after node insertion
is there a way to sync to prod a forums data such as initial posts/threads?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 10/5/2012 12:42:08 AM
   
RE:Sync task not generated immediately after node insertion
Hi,

I am afraid but it is not - there is no setting for it and it would require pretty complex customization. Also, could you please explain why would you do that? The forums are in 99% of cases created by the live site users - that means on production so they do not have access to staging or development areas, so at this moment it makes no sense to me.

Best regards,
Juraj Ondrus

User avatar
Member
Member
powermouse - 10/5/2012 9:26:04 AM
   
RE:Sync task not generated immediately after node insertion
thank you for response.
our business dont have a production access. all data got filled in on staging and pushed to prod.
also business does not want regular users create posts - only replies.

based on this i have to tell them to go to production site and add posts. i probably can separate the post creation between security groups.

...and now i have to create a compley dts package to compare/move data from stage to prod

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 10/8/2012 1:26:57 AM
   
RE:Sync task not generated immediately after node insertion
Hi,

Why didn't you used e.g. the user contributions module and let the clients to create the content as a normal document and then, on the production use message boards or ad-hoc forums to let the visitors reply to that content?

Best regards,
Juraj Ondrus