1

大家好,从过去的几个小时开始,我正在尝试发布一个文档,并且我正在设置一些自定义数据类型值,因为我正在保存序列化值:在 umbraco 中,数据类型值仅在数据库和 umbraco.config 文件中可用发布文档,所以在我的自定义文档类型中,我有一个名为添加用户的按钮,我想在调用此按钮时将其保存在数据库中,我需要发布我正在使用的文档:

//Get the document by it's ID
Document d = new Document(currentDocID);

//Mark it ready for publishing
d.Publish(new umbraco.BusinessLogic.User(0));

//Tell the runtime to update the document cache
umbraco.library.UpdateDocumentCache(d.Id);

//call republishing from the api:
umbraco.library.RefreshContent();

//Server.ScriptTimeout = 100000;
//umbraco.cms.businesslogic.web.Document.RePublishAll();
//umbraco.library.RefreshContent();

但它无法更改 Umbraco.config 文件和数据库文件,而如果通过单击在 umbraco 中发布,数据将保存在 umbraco db 和配置文件中。我无法弄清楚我错过了什么..

4

1 回答 1

1

代码示例看起来很适合以编程方式保存节点,所缺少的只是更新已更改字段的行,如果它在文档类型中别名为“myField”,则意味着更改为:

var myValue = "[{ serialized value that might need escaping }]";

Document d = new Document(currentDocID);
d.getProperty("myField").Value = myValue;
d.Publish(new umbraco.BusinessLogic.User(0));
umbraco.library.UpdateDocumentCache(d.Id);
于 2012-11-26T14:57:47.080 回答