本文整理汇总了C#中umbraco.cms.businesslogic.web.Document.SaveAndPublish方法的典型用法代码示例。如果您正苦于以下问题:C# Document.SaveAndPublish方法的具体用法?C# Document.SaveAndPublish怎么用?C# Document.SaveAndPublish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.web.Document
的用法示例。
在下文中一共展示了Document.SaveAndPublish方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishDocument
public JsonResult PublishDocument(int documentId, bool publishDescendants, bool includeUnpublished)
{
var content = Services.ContentService.GetById(documentId);
var doc = new Document(content);
//var contentService = (ContentService) Services.ContentService;
if (publishDescendants == false)
{
//var result = contentService.SaveAndPublishInternal(content);
var result = doc.SaveAndPublish(UmbracoUser.Id);
return Json(new
{
success = result.Success,
message = GetMessageForStatus(result.Result)
});
}
else
{
/*var result = ((ContentService) Services.ContentService)
.PublishWithChildrenInternal(content, UmbracoUser.Id, includeUnpublished)
.ToArray();*/
var result = doc.PublishWithSubs(UmbracoUser.Id, includeUnpublished);
return Json(new
{
success = result.All(x => x.Success),
message = GetMessageForStatuses(result.Select(x => x.Result), content)
});
}
}
示例2: Execute
public override TaskExecutionDetails Execute(string Value)
{
TaskExecutionDetails d = new TaskExecutionDetails();
if (HttpContext.Current != null && HttpContext.Current.Items["pageID"] != null)
{
string id = HttpContext.Current.Items["pageID"].ToString();
Document doc = new Document(Convert.ToInt32(id));
if (doc.getProperty(PropertyAlias) != null)
{
d.OriginalValue = doc.getProperty(PropertyAlias).Value.ToString();
doc.getProperty(PropertyAlias).Value = Value;
doc.SaveAndPublish(new BusinessLogic.User(0));
d.NewValue = Value;
d.TaskExecutionStatus = TaskExecutionStatus.Completed;
}
else
d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;
}
else
d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;
return d;
}
示例3: editPost
public object editPost(
string postid,
string username,
string password,
Post post,
bool publish)
{
if (validateUser(username, password))
{
Channel userChannel = new Channel(username);
Document doc = new Document(Convert.ToInt32(postid));
doc.Text = HttpContext.Current.Server.HtmlDecode(post.title);
// Excerpt
if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "")
doc.getProperty(userChannel.FieldExcerptAlias).Value = removeLeftUrl(post.mt_excerpt);
if (UmbracoSettings.TidyEditorContent)
doc.getProperty(userChannel.FieldDescriptionAlias).Value = library.Tidy(removeLeftUrl(post.description), false);
else
doc.getProperty(userChannel.FieldDescriptionAlias).Value = removeLeftUrl(post.description);
updateCategories(doc, post, userChannel);
if (publish)
{
doc.SaveAndPublish(new User(username));
}
return true;
}
else
{
return false;
}
}
示例4: Publish
/// <summary>
/// Publishes the update.
/// </summary>
public void Publish()
{
// keep track of documents published in this request
List<int> publishedDocuments = (List<int>)HttpContext.Current.Items["ItemUpdate_PublishedDocuments"];
if (publishedDocuments == null)
{
HttpContext.Current.Items["ItemUpdate_PublishedDocuments"] = publishedDocuments = new List<int>();
}
// publish each modified document just once (e.g. several fields are updated)
if(!publishedDocuments.Contains(NodeId.Value))
{
Document document = new Document(NodeId.Value);
document.SaveAndPublish(Umbraco.Web.UmbracoContext.Current.UmbracoUser);
publishedDocuments.Add(NodeId.Value);
}
}
示例5: SaveProject
private void SaveProject(Document project, Member user)
{
if (!string.IsNullOrWhiteSpace(Request["title"]))
{
project.getProperty("title").Value = Request["title"];
}
if (!string.IsNullOrWhiteSpace(Request["description"]))
project.getProperty("description").Value = Request["description"];
if (!string.IsNullOrWhiteSpace(Request["projectType"]))
project.getProperty("projectType").Value = Convert.ToInt32(Request["projectType"]);
if (!string.IsNullOrWhiteSpace(Request["area"]))
project.getProperty("area").Value = Convert.ToInt32(Request["area"]);
project.getProperty("allowComments").Value = !string.IsNullOrWhiteSpace(Request["allowComments"]) && Request["allowComments"].ToLower().Equals("on");
project.getProperty("author").Value = user.Id;
if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
{
var uploadedFile = Request.Files[0];
var fileName = Path.GetFileName(uploadedFile.FileName);
var fileSavePath = Server.MapPath("~/media/projects/" + fileName);
uploadedFile.SaveAs(fileSavePath);
project.getProperty("image").Value = "/media/projects/" + fileName;
}
project.SaveAndPublish(user.User);
umbraco.library.UpdateDocumentCache(project.Id);
}