gpt4 book ai didi

c# - 使用控制台应用程序操作 umbraco 内容

转载 作者:太空狗 更新时间:2023-10-30 01:21:10 25 4
gpt4 key购买 nike

这是一个菜鸟问题,但我搜索了一些时间,找不到任何有用的信息。

我需要开发一个 rotine(控制台应用程序)来读取内容并将内容写入 umbraco 站点。我已经读过,您可以使用 Web 表单和 MVC 应用程序来做到这一点。

但我需要像外部资源一样使用umbraco。我需要像处理 Word 文档那样做一些事情。例如:打开文件,读取文件,写入一些东西并保存。

我已经使用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# - 使用控制台应用程序操作 umbraco 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16490006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com