C# 使用控制台应用程序操作umbraco内容
这是一个noob问题,但我正在搜索一些时间,找不到任何有用的信息 我需要开发一个rotine(控制台应用程序),将读写内容到umbraco网站。我已经读到,您可以通过web表单和mvc应用程序来实现这一点 但我需要像使用外部源一样使用umbraco。我需要做一些类似于Word文档的事情。例如:打开文件,读取文件,写一些东西并保存 我已经使用安装了API PM>安装软件包UmbracoCms-预安装 我已经读过一些东西:C# 使用控制台应用程序操作umbraco内容,c#,console-application,umbraco,C#,Console Application,Umbraco,这是一个noob问题,但我正在搜索一些时间,找不到任何有用的信息 我需要开发一个rotine(控制台应用程序),将读写内容到umbraco网站。我已经读到,您可以通过web表单和mvc应用程序来实现这一点 但我需要像使用外部源一样使用umbraco。我需要做一些类似于Word文档的事情。例如:打开文件,读取文件,写一些东西并保存 我已经使用安装了API PM>安装软件包UmbracoCms-预安装 我已经读过一些东西: 实现这一目标的最佳方法是什么?我不知道该怎么做…您可以创建一个Umbrac
实现这一目标的最佳方法是什么?我不知道该怎么做…您可以创建一个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);
//通过其别名和应该是文档创建者的用户获取要使用的类型
DocumentType dt=DocumentType.GetByAlias(“文本页”);
用户作者=User.GetUser(0);
//创建具有名称、类型、umbraco用户和文档父页面ID的文档。要在umbraco的根目录下创建文档,请使用id-1
Document doc=Document.MakeNew(“我的新文档”,dt,作者,1018);
//通过别名获取要修改的属性并设置其值
doc.getProperty(“bodyText”).Value=“您的正文””;
doc.getProperty(“articleDate”).Value=DateTime.Now;
//创建文档后,准备发布文档
文件出版(作者);
//告诉umbraco发布文档
umbraco.library.UpdateDocumentCache(文档Id);
见:
只是为了帮助有同样问题的人。我想在umbraco中找到一个web服务,我目前正在使用它(到目前为止,它只用于阅读信息,但据我所知,我们也可以编写信息)。虽然没有什么易于使用的文档。 但要使用该选项,您需要在umbracoSettings.config中设置
。此fie位于umbraco内的文件夹Config中。
我们还必须在webservices节点中设置用户权限,以允许用户使用web服务
DocumentServiceReference.documentServiceSoapClient client = new DocumentServiceReference.documentServiceSoapClient();
client.WebservicesEnabled();
DocumentServiceReference.ArrayOfDocumentCarrier documents = client.readList(parentId, username, password);
foreach (DocumentServiceReference.documentCarrier doc in documents)
{
DocumentServiceReference.ArrayOfDocumentProperty properties = doc.DocumentProperties;
foreach (DocumentServiceReference.documentProperty property in properties)
{
string key = property.Key;
string value = property.PropertyValue.ToString();
}
}
谢谢你的帮助,但我已经决定使用umbraco网络服务。没问题。但请谨慎行事,并查看此安全简报,因为Umbraco最近建议删除web服务dll。@amelvin您确定此代码在控制台应用程序中有效吗?我面临着这个问题-