2012-11-23 45 views
1

大家好,从最后几个小时我想发布一个文档,并在其中设置一些自定义数据类型值,因为我正在保存序列化值:在umbraco数据类型值将在数据库中可用和在umbraco.config文件中,只有在发布文档后如此在我的自定义文档类型中我有一个按钮称为添加用户,我想将它保存在数据库中,当此按钮被调用时,我需要发布我正在使用的文档:在umbraco发布文档

//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发布数据保存在数据库一把umbraco以及在配置文件中做它不能够改变Umbraco.config文件和数据库文件。我无法弄清楚我是否错过了一些东西..

+0

你可以编辑你的问题添加一些句号/逗号?很难理解你在问什么。你是否试图以编程方式设置文档属性?如果是这样,你的代码示例中就缺少了这个。 – Digbyswift

回答

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);