如何将来自REST API或外部应用程序的Kentico更改与分段任务组相关联(How to associate Kentico changes from REST API or External Application to a staging task group)
如何将来自REST API或外部应用程序的Kentico更改( 如Windows控制台应用程序 )与临时任务组相关联
static void Main ( string [ ] args ) { UserInfo userInfo = UserInfoProvider.GetUserInfo ( "User1" ); using ( new CMSActionContext ( userInfo ) ) { TreeProvider treeProvider = new TreeProvider ( userInfo ); NodeSelectionParameters nodeSelectionParameters = new NodeSelectionParameters { AliasPath = "Path" }; TreeNode parentPage = treeProvider.SelectSingleNode ( nodeSelectionParameters ); TreeNode newPage = TreeNode.New ( "Class", treeProvider ); newPage.DocumentName = "Test Title"; newPage.DocumentCulture = "en-us"; newPage.DocumentUrlPath = "Path"; newPage.Insert ( parentPage ); } }上面的代码正确地创建了文档和用户上下文的分段任务。 我如何将本文档的分段任务与分段任务组相关联?
How to associate Kentico changes from REST API or External Application (like windows console application) to a staging task group
static void Main ( string [ ] args ) { UserInfo userInfo = UserInfoProvider.GetUserInfo ( "User1" ); using ( new CMSActionContext ( userInfo ) ) { TreeProvider treeProvider = new TreeProvider ( userInfo ); NodeSelectionParameters nodeSelectionParameters = new NodeSelectionParameters { AliasPath = "Path" }; TreeNode parentPage = treeProvider.SelectSingleNode ( nodeSelectionParameters ); TreeNode newPage = TreeNode.New ( "Class", treeProvider ); newPage.DocumentName = "Test Title"; newPage.DocumentCulture = "en-us"; newPage.DocumentUrlPath = "Path"; newPage.Insert ( parentPage ); } }The above code is properly creating the document and the staging tasks with the user context. How can I associate the staging tasks for this document to a staging task group?
最满意答案
首先,我要确保您正在更改的对象位于内容分段支持的项目列表中。 您可以在此处看到该列表: 内容分段 - 可以同步的内容
只要您最终使用Kentico的API,并启用了Content Staging ,那么Kentico应该为您创建这些任务。 如果您不使用API直接更新Kentico数据库,则可能会遇到麻烦,可能需要手动创建登台任务或使用API执行同步 。
We can use the SynchronizationActionContext class to associate API changes to a staging task group.
static void Main ( string [ ] args ) { List<TaskGroupInfo> taskGroups = TaskGroupInfoProvider.GetTaskGroups ( ).WhereEquals ( "TaskGroupCodeName", "MyTaskGroup" ).ToList ( ); using ( new SynchronizationActionContext ( ) { TaskGroups = taskGroups } ) { UserInfo userInfo = UserInfoProvider.GetUserInfo ( "User1" ); using ( new CMSActionContext ( userInfo ) ) { TreeProvider treeProvider = new TreeProvider ( userInfo ); NodeSelectionParameters nodeSelectionParameters = new NodeSelectionParameters { AliasPath = "Path" }; TreeNode parentPage = treeProvider.SelectSingleNode ( nodeSelectionParameters ); TreeNode newPage = TreeNode.New ( "Class", treeProvider ); newPage.DocumentName = "Test Title"; newPage.DocumentCulture = "en-us"; newPage.DocumentUrlPath = "Path"; newPage.Insert ( parentPage ); } } }更多推荐
发布评论