c# – 使用控制台应用程序处理umbraco内容
作者:互联网
这是一个noob问题,但我正在寻找一些时间,但找不到任何有用的信息.
我需要开发一个将内容读写到umbraco站点的rotine(控制台应用程序).我已经读过你可以用web表单和mvc应用程序来做到这一点.
但我需要像外部资源一样使用umbraco.我需要像使用Word文档那样做.例如:打开文件,读取文件,写一些东西并保存.
我已经使用了安装API
PM>安装包UmbracoCms -Pre
我已经阅读过的一些内容:
http://nishantwork.wordpress.com/2012/09/27/umbraco-create-custom-content-node-in-umbraco-by-c/
https://github.com/sitereactor/umbraco-console-example
实现这一目标的最佳方法是什么?我不知道该怎么做……
解决方法:
您可以创建Umbraco节点(文档),写入它并从控制台应用程序保存它. Umbraco基本上是一堆.Net库:
//Get the type you would like to use by its alias and the user who should be the creator of the document
DocumentType dt = DocumentType.GetByAlias("Textpage");
User author = User.GetUser(0);
//create a document with a name, a type, an umbraco user, and the ID of the document's parent page. To create a document at the root of umbraco, use the id -1
Document doc = Document.MakeNew("My new document", dt, author, 1018);
// Get the properties you wish to modify by it's alias and set their value
doc.getProperty("bodyText").Value = "<p>Your body text</p>";
doc.getProperty("articleDate").Value = DateTime.Now;
//after creating the document, prepare it for publishing
doc.Publish(author);
//Tell umbraco to publish the document
umbraco.library.UpdateDocumentCache(doc.Id);
看到:
http://our.umbraco.org/wiki/reference/api-cheatsheet/creating-a-document
http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties
标签:c,console-application,umbraco 来源: https://codeday.me/bug/20190625/1284417.html