如何将来自REST API或外部应用程序的Kentico更改与分段任务组相关联(How to associate Kentico changes from REST API or External A

编程入门 行业动态 更新时间:2024-10-28 10:28:14
如何将来自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 ); } } }

更多推荐

本文发布于:2023-08-03 02:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1383201.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:相关联   如何将   应用程序   Kentico   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!