我有以下代码块来检索kentico中的文档节点并删除它。它会删除kentico节点,但不会删除保留在数据中的基础文档类型。帮助?!
CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);
CMS.TreeEngine.TreeNode image = provider.SelectSingleNode(new Guid(imageID), "en-US", CMS.CMSHelper.CMSContext.CurrentSite.SiteName);
if (image != null)
{
CMS.TreeEngine.TreeNode school = provider.SelectSingleNode(image.Parent.NodeID, "en-US", true, true);
if (school != null)
{
string CMSUserID = school.GetValue("CMSUserID").ToString();
if (CMSUserID == ui.UserID.ToString())
{
image.Delete(false);
}
}
}
答案 0 :(得分:8)
您需要使用CMS.WorkflowEngine命名空间中的DeleteDocument方法。它确保删除所有依赖对象。
DocumentHelper.DeleteDocument(image,provider,true,true,true);