本文整理汇总了C#中umbraco.cms.businesslogic.web.Document.UnPublish方法的典型用法代码示例。如果您正苦于以下问题:C# Document.UnPublish方法的具体用法?C# Document.UnPublish怎么用?C# Document.UnPublish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.web.Document
的用法示例。
在下文中一共展示了Document.UnPublish方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnpublishAndTrashDocument
private void UnpublishAndTrashDocument(Document document)
{
if (document.Published)
{
document.UnPublish();
umbraco.library.UnPublishSingleNode(document.Id);
}
document.delete();
}
示例2: DeletePost
private void DeletePost()
{
// Make sure we have a post id available to us
int? pId = null;
if (Request.QueryString["p"] != null)
pId = Request.QueryString["p"].ToInt32();
// get the referring page
var previouspage = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Split('?')[0];
if (pId != null && MembershipHelper.IsAuthenticated())
{
var postID = pId.ToInt32();
// great we have a postid, now check the user is allowed to delete it
var posttodelete = Mapper.MapForumPost(new Node(postID));
if (posttodelete.Owner.MemberId == CurrentMember.MemberId | CurrentMember.MemberIsAdmin)
{
// These are used either way
var topic = new Document(posttodelete.ParentId.ToInt32());
// We know we can delete this, but if its a topic starter then delete entire topic
if(posttodelete.IsTopicStarter)
{
var topicId = topic.Id;
// Its a topic starter so delete entire topic
if (topic.Published)
{
topic.UnPublish();
library.UnPublishSingleNode(topicId);
}
topic.delete();
library.RefreshContent();
// Redirect and show message
Response.Redirect(string.Concat(Settings.Url, "?nf=true&m=", library.GetDictionaryItem("DeletedText")));
}
else
{
// Its just a normal post, delete it
var p = new Document(postID);
if (p.Published)
{
p.UnPublish();
library.UnPublishSingleNode(postID);
}
p.delete();
// Little bit of a hack to update the topic with the new latest post date
Factory.UpdateTopicWithLastPostDate(topic.Id);
library.RefreshContent();
// Redirect and show message
Response.Redirect(string.Concat(previouspage, "?nf=true&m=", library.GetDictionaryItem("DeletedText")));
}
}
}
//Error so just redirect back to the page
Response.Redirect(previouspage);
}
示例3: Manager_MessageReceived
/// <summary>
/// Handles the <c>MessageReceived</c> event of the Live Editing manager.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The e.</param>
protected override void Manager_MessageReceived(object sender, MesssageReceivedArgs e)
{
switch (e.Type)
{
case "unpublishcontent":
var currentPage = new Document(int.Parse(UmbracoContext.Current.PageId.ToString()));
currentPage.UnPublish();
string redirectUrl = "/";
try
{
redirectUrl = library.NiceUrl(currentPage.Parent.Id);
}
catch
{
}
Page.Response.Redirect(redirectUrl);
break;
}
}