Database Umbraco ContentService未更新文档缓存中的checboxlist
我正在一个新的Umbraco v6.1.6网站上使用我编写的导入脚本创建大约500个页面。我正在使用ContentServiceAPI创建新页面。它们是被创造出来的,似乎保存得很好。但是,如果我从一个新页面请求checbox列表的值,我会得到一个空字符串 我已经验证了umbraco.config文件中的属性为空,但是如果我从umbraco后台手动保存页面。缓存将更新为正确的值,我突然得到了正确的返回值 是否有办法强制缓存更新或其他形式的修复此问题 这是我正在使用的CreateContent方法:Database Umbraco ContentService未更新文档缓存中的checboxlist,database,caching,content-management-system,umbraco,Database,Caching,Content Management System,Umbraco,我正在一个新的Umbraco v6.1.6网站上使用我编写的导入脚本创建大约500个页面。我正在使用ContentServiceAPI创建新页面。它们是被创造出来的,似乎保存得很好。但是,如果我从一个新页面请求checbox列表的值,我会得到一个空字符串 我已经验证了umbraco.config文件中的属性为空,但是如果我从umbraco后台手动保存页面。缓存将更新为正确的值,我突然得到了正确的返回值 是否有办法强制缓存更新或其他形式的修复此问题 这是我正在使用的CreateContent方法:
public static IContent CreateContent(string name, string documentTypeAlias, int parentId, Dictionary properties, bool publish = false, int author = 0)
{
IContent document = null;
ContentService contentService = new ContentService();
document = contentService.CreateContent(
name, // the name of the document
parentId, // the parent id should be the id of the group node
documentTypeAlias, // the alias of the Document Type
author);
foreach (string property in properties.Keys)
{
document.SetValue(property, properties[property]);
}
// If publish is true, then save and publish the document
if (publish)
{
contentService.SaveAndPublish(document);
}
// Else, just save it
else
{
contentService.Save(document);
}
return document;
}
编辑:
查看数据库后,我可以看到cmsContentXml具有该属性,但其中的数据与umbraco.config相同。我查看了cmsPropertyData,数据已经存在。所以我想问题是如何将数据从cmsPropertyData获取到cmsContentXml
我的问题与此类似:但是它没有回复。来自
cmsContentXml
的数据被直接转储到umbraco.config
文件中,谢天谢地,它们是相同的
为了使代码更加干爽(您总是在if和else中保存文档,请尝试此操作,并将SaveAndPublish
方法更新为Publish
(在v7中,您可以使用PublishWithResult
获得发布操作的详细结果):
在v7中,您可以查看publishResult。如果有什么错误,那么这将告诉您它是什么。但很可能通过这种方式工作正常(这可能意味着SaveAndPublish已损坏,但让我们看看publishResult是否有错误).“contentService”不包含PublishWithResult的定义。有什么想法吗?我将答案中的“var publishresult=…”一行替换为“contentService.Publish(document)”这是个谜,因为PublishWithResult和SaveAndPublish都使用了相同的方法“SaveAndPublishDo”,但我不能说我对Umbraco。希望尽快转到v7。可能至少要再等一次发布。值(用于复选框列表)在属性字典中的格式如何?如果导入的值未显示在XML缓存中,但从后台保存,则在导入过程中,您的复选框属性似乎未正确保存。
contentService.Save(document);
// If publish is true, then save and publish the document
if (publish)
{
contentService.Publish(document);
}