本文整理汇总了C#中umbraco.cms.businesslogic.web.Document.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Publish方法的具体用法?C# Document.Publish怎么用?C# Document.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.web.Document
的用法示例。
在下文中一共展示了Document.Publish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BtnMoveClick
protected void BtnMoveClick(object sender, EventArgs e)
{
if (Category.Id != ddlCategories.SelectedValue.ToInt32())
{
// Get the document you will move by its ID
var doc = new Document(Topic.Id);
// Create a user we can use for both
var user = new User(0);
// The new parent ID
var newParentId = ddlCategories.SelectedValue.ToInt32();
// Now update the topic parent category ID
doc.getProperty("forumTopicParentCategoryID").Value = newParentId;
// publish application node
doc.Publish(user);
// Move the document the new parent
doc.Move(newParentId);
// update the document cache so its available in the XML
umbraco.library.UpdateDocumentCache(doc.Id);
// Redirect and show message
Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicHasBeenMovedText")));
}
else
{
// Can't move as they have selected the category that the topic is already in
Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicAlreadyInThisCategory")));
}
}
示例2: MarkAsSolution
public static string MarkAsSolution(string pageId)
{
if (MembershipHelper.IsAuthenticated())
{
var m = Member.GetCurrentMember();
var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(pageId)));
if (forumPost != null)
{
var forumTopic = _mapper.MapForumTopic(new Node(forumPost.ParentId.ToInt32()));
// If this current member id doesn't own the topic then ignore, also
// if the topic is already solved then ignore.
if (m.Id == forumTopic.Owner.MemberId && !forumTopic.IsSolved)
{
// Get a user to save both documents with
var usr = new User(0);
// First mark the post as the solution
var p = new Document(forumPost.Id);
p.getProperty("forumPostIsSolution").Value = 1;
p.Publish(usr);
library.UpdateDocumentCache(p.Id);
// Now update the topic
var t = new Document(forumTopic.Id);
t.getProperty("forumTopicSolved").Value = 1;
t.Publish(usr);
library.UpdateDocumentCache(t.Id);
return library.GetDictionaryItem("Updated");
}
}
}
return library.GetDictionaryItem("Error");
}
示例3: 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.Publish(new BusinessLogic.User(0));
d.NewValue = Value;
d.TaskExecutionStatus = TaskExecutionStatus.Completed;
}
else
d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;
}
else
d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;
return d;
}
示例4: Run
public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
{
// Cast to Umbraco worklow instance.
var umbracoWorkflowInstance = (UmbracoWorkflowInstance) workflowInstance;
foreach(var nodeId in umbracoWorkflowInstance.CmsNodes)
{
var n = new CMSNode(nodeId);
if(!n.IsDocument()) continue;
var d = new Document(nodeId);
d.Publish(User.GetUser(0));
umbraco.library.UpdateDocumentCache(d.Id);
}
runtime.Transition(workflowInstance, this, "done");
}
示例5: ProcessRequest
public void ProcessRequest(HttpContext context)
{
//TODO: Authorize this request!!!
HttpPostedFile file = context.Request.Files["Filedata"];
string userguid = context.Request.Form["USERGUID"];
string nodeguid = context.Request.Form["NODEGUID"];
string fileType = context.Request.Form["FILETYPE"];
string fileName = context.Request.Form["FILENAME"];
string umbraoVersion = context.Request.Form["UMBRACOVERSION"];
string dotNetVersion = context.Request.Form["DOTNETVERSION"];
List<UmbracoVersion> v = new List<UmbracoVersion>() { UmbracoVersion.DefaultVersion() };
if (!string.IsNullOrEmpty(umbraoVersion))
{
v.Clear();
v = WikiFile.GetVersionsFromString(umbraoVersion);
}
if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(nodeguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName)) {
Document d = new Document( Document.GetContentFromVersion(new Guid(nodeguid)).Id );
Member mem = new Member(new Guid(userguid));
if (d.ContentType.Alias == "Project" && d.getProperty("owner") != null && (d.getProperty("owner").Value.ToString() == mem.Id.ToString() || Utils.IsProjectContributor(mem.Id,d.Id))) {
WikiFile.Create(fileName, new Guid(nodeguid), new Guid(userguid), file, fileType, v, dotNetVersion);
//the package publish handler will make sure we got the right versions info on the package node itself.
//ProjectsEnsureGuid.cs is the handler
if (fileType.ToLower() == "package")
{
d.Publish(new umbraco.BusinessLogic.User(0));
umbraco.library.UpdateDocumentCache(d.Id);
}
} else {
umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner");
}
}
}
示例6: 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.Publish(new User(username));
library.UpdateDocumentCache(doc.Id);
}
return true;
}
else
{
return false;
}
}
示例7: Action_AfterPerform
void Action_AfterPerform(object sender, ActionEventArgs e)
{
uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;
if (a.Alias == "ProjectUp")
{
Document d = new Document(e.ItemId);
if (d.getProperty("approved").Value != null &&
d.getProperty("approved").Value.ToString() != "1" &&
uPowers.Library.Xslt.Score(d.Id, "powersProject") >= 15)
{
//set approved flag
d.getProperty("approved").Value = true;
d.Save();
d.Publish(new umbraco.BusinessLogic.User(0));
umbraco.library.UpdateDocumentCache(d.Id);
umbraco.library.RefreshContent();
}
}
}
示例8: ChangeCollabStatus
public static string ChangeCollabStatus(int projectId, bool status)
{
int _currentMember = umbraco.presentation.umbracobase.library.library.CurrentMemberId();
if (_currentMember > 0)
{
Document p = new Document(projectId);
if ((int)p.getProperty("owner").Value == _currentMember)
{
p.getProperty("openForCollab").Value = status;
p.Publish(new User(0));
umbraco.library.UpdateDocumentCache(p.Id);
return "true";
}
else
{
return "false";
}
}
return "false";
}
示例9: Move
public string Move(int wikiId, int target)
{
var currentMemberId = Members.GetCurrentMember().Id;
if (Xslt.IsMemberInGroup("admin", currentMemberId) || Xslt.IsMemberInGroup("wiki editor", currentMemberId))
{
Document document = new Document(wikiId);
Document documentTarget = new Document(target);
if (documentTarget.ContentType.Alias == "WikiPage")
{
Document o = new Document(document.Parent.Id);
document.Move(documentTarget.Id);
document.Save();
document.Publish(new umbraco.BusinessLogic.User(0));
documentTarget.Publish(new umbraco.BusinessLogic.User(0));
o.Publish(new umbraco.BusinessLogic.User(0));
umbraco.library.UpdateDocumentCache(document.Id);
umbraco.library.UpdateDocumentCache(documentTarget.Id);
umbraco.library.UpdateDocumentCache(o.Id);
umbraco.library.RefreshContent();
return umbraco.library.NiceUrl(document.Id);
}
}
return "";
}
示例10: InstallStore
/// <summary>
/// Install a new uWebshop store
/// </summary>
/// <param name="storeAlias">the store alias to use</param>
/// <param name="storeDocument">the document of the store</param>
/// <param name="cultureCode"> </param>
/// <param name="preFillRequiredItems"></param>
internal static void InstallStore(string storeAlias, Document storeDocument, string cultureCode = null, bool preFillRequiredItems = false)
{
var reg = new Regex(@"\s*");
storeAlias = reg.Replace(storeAlias, "");
if (cultureCode == null)
{
var languages = Language.GetAllAsList();
var firstOrDefaultlanguage = languages.FirstOrDefault();
if (firstOrDefaultlanguage == null)
return;
cultureCode = firstOrDefaultlanguage.CultureAlias;
}
var installStoreSpecificPropertiesOnDocumentTypes = WebConfigurationManager.AppSettings["InstallStoreDocumentTypes"];
if (installStoreSpecificPropertiesOnDocumentTypes == null || installStoreSpecificPropertiesOnDocumentTypes != "false")
{
if (DocumentType.GetAllAsList().Where(x => x.Alias.StartsWith(Store.NodeAlias)).All(x => x.Text.ToLower() != storeAlias.ToLower()))
{
IO.Container.Resolve<IUmbracoDocumentTypeInstaller>().InstallStore(storeAlias);
}
else
{
// todo: return message that store already existed?
return;
}
}
var admin = new User(0);
var uwbsStoreDt = DocumentType.GetByAlias(Store.NodeAlias);
var uwbsStoreRepositoryDt = DocumentType.GetByAlias(Store.StoreRepositoryNodeAlias);
var uwbsStoreRepository = Document.GetDocumentsOfDocumentType(uwbsStoreRepositoryDt.Id).FirstOrDefault(x => !x.IsTrashed);
if (storeDocument == null)
{
if (uwbsStoreRepository != null)
if (uwbsStoreDt != null)
{
storeDocument = Document.MakeNew(storeAlias, uwbsStoreDt, admin, uwbsStoreRepository.Id);
if (storeDocument != null && preFillRequiredItems)
{
storeDocument.SetProperty("orderNumberPrefix", storeAlias);
storeDocument.SetProperty("globalVat", "0");
storeDocument.SetProperty("countryCode", "DK");
storeDocument.SetProperty("storeEmailFrom", string.Format("[email protected]{0}.com", storeAlias));
storeDocument.SetProperty("storeEmailTo", string.Format("[email protected]{0}.com", storeAlias));
storeDocument.SetProperty("storeEmailFromName", storeAlias);
storeDocument.Save();
storeDocument.Publish(new User(0));
}
}
}
var language = Language.GetByCultureCode(cultureCode);
if (storeDocument == null)
{
return;
}
if (language != null) storeDocument.SetProperty("currencyCulture", language.id.ToString());
storeDocument.Save();
//InstallProductUrlRewritingRules(storeAlias);
}
示例11: 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.Publish(UmbracoEnsuredPage.CurrentUser);
library.UpdateDocumentCache(NodeId.Value);
publishedDocuments.Add(NodeId.Value);
}
}
示例12: handlePublishing
private void handlePublishing(Document doc, documentCarrier carrier, umbraco.BusinessLogic.User user)
{
switch (carrier.PublishAction)
{
case documentCarrier.EPublishAction.Publish:
doc.Publish(user);
umbraco.library.PublishSingleNode(doc.Id);
break;
case documentCarrier.EPublishAction.Unpublish:
doc.Publish(user);
umbraco.library.UnPublishSingleNode(doc.Id);
break;
case documentCarrier.EPublishAction.Ignore:
if (doc.Published)
{
doc.Publish(user);
umbraco.library.PublishSingleNode(doc.Id);
}
else
{
doc.Publish(user);
umbraco.library.UnPublishSingleNode(doc.Id);
}
break;
}
}
示例13: UpdateTopicWithLastPostDate
/// <summary>
/// This updates a topic with the current latest post date
/// </summary>
/// <param name="topicId"></param>
public void UpdateTopicWithLastPostDate(int topicId)
{
// This is a bit shite, but its the best way to keep performance on some of the larger select queries.
// Especially if you have 10000's of nodes
// Get the topic to update and get generic user
var u = new User(0);
var topic = new Document(topicId);
// Now get the latest post in this topic, we do this with the node API to make 100%
// sure that its correct as Examine takes a few seconds to update
var postList = new Node(topicId).ChildrenAsList;
var lastPost = (from p in postList
orderby p.CreateDate descending
select p).FirstOrDefault();
// Update the topic
if(lastPost != null)
{
topic.getProperty("forumTopicLastPostDate").Value = lastPost.CreateDate;
}
else
{
topic.getProperty("forumTopicLastPostDate").Value = null;
}
// Finally save it all
topic.sortOrder = 0;
// publish application node
topic.Publish(u);
// update the document cache so its available in the XML
umbraco.library.UpdateDocumentCache(topicId);
}
示例14: UnSubScribeToTopic
public static string UnSubScribeToTopic(string topicId)
{
if (!String.IsNullOrEmpty(Helpers.SafePlainText(topicId).Trim()) && MembershipHelper.IsAuthenticated())
{
var tID = topicId.ToInt32();
// Get the topic from factory, as we'll use this to remove the member from the topics
// to make sure there are no mistakes
var forumTopic = _mapper.MapForumTopic(new Node(tID));
// Create the token user
var u = new User(0);
// Get the current logged in member
var m = Member.GetCurrentMember();
// Remove this member ID from the list
var remainingMembers = forumTopic.SubscriberIds.Where(x => x != m.Id).ToList();
var remainingMembersFormatted = string.Empty;
foreach (var id in remainingMembers)
{
remainingMembersFormatted += (id + "|");
}
// Get the topic
var t = new Document(tID);
// Add the document properties
t.getProperty("forumTopicSubscribedList").Value = remainingMembersFormatted;
// publish application node
t.Publish(u);
// update the document cache so its available in the XML
library.UpdateDocumentCache(tID);
return library.GetDictionaryItem("Success");
}
return library.GetDictionaryItem("Error");
}
示例15: SaveDoc
private INode SaveDoc(Document doc)
{
doc.Save();
doc.Publish(User.GetAllByLoginName("visitor", false).FirstOrDefault());
umbraco.library.UpdateDocumentCache(doc.Id);
return new Node(doc.Id);
}