本文整理汇总了C#中umbraco.cms.businesslogic.web.Document类的典型用法代码示例。如果您正苦于以下问题:C# Document类的具体用法?C# Document怎么用?C# Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Document类属于umbraco.cms.businesslogic.web命名空间,在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFriendlyPathForDocument
private static string GetFriendlyPathForDocument(Document document)
{
const string separator = "->";
var nodesInPath = document.Path.Split(',').Skip(1);
var retVal = new StringBuilder();
foreach (var nodeId in nodesInPath)
{
var currentDoc = new Document(int.Parse(nodeId));
var displayText = "";
if (currentDoc == null || string.IsNullOrEmpty(currentDoc.Path))
continue;
if (nodeId == "-20" || nodeId == "-21")
displayText = "Recycle Bin";
else
displayText = currentDoc.Text;
retVal.AppendFormat("{0} {1} ", displayText, separator);
}
return retVal.ToString().Substring(0, retVal.ToString().LastIndexOf(separator)).Trim();
}
示例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.Publish(new BusinessLogic.User(0));
d.NewValue = Value;
d.TaskExecutionStatus = TaskExecutionStatus.Completed;
}
else
d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;
}
else
d.TaskExecutionStatus = TaskExecutionStatus.Cancelled;
return d;
}
示例3: page
/// <summary>
/// Initializes a new instance of the <see cref="page"/> class for a yet unpublished document.
/// </summary>
/// <param name="document">The document.</param>
public page(Document document)
{
var docParentId = -1;
try
{
docParentId = document.Parent.Id;
}
catch (ArgumentException)
{
//ignore if no parent
}
populatePageData(document.Id,
document.Text, document.ContentType.Id, document.ContentType.Alias,
document.User.Name, document.Creator.Name, document.CreateDateTime, document.UpdateDate,
document.Path, document.Version, docParentId);
foreach (Property prop in document.GenericProperties)
{
string value = prop.Value != null ? prop.Value.ToString() : String.Empty;
_elements.Add(prop.PropertyType.Alias, value);
}
_template = document.Template;
}
示例4: BaseTree_BeforeNodeRender
private void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
{
if (node.TreeType.ToLower() == "content")
{
try
{
Document document = new Document(Convert.ToInt32(node.NodeID));
//this changes the create action b/c of the UI.xml entry
if (CreateDocTypes.Contains(document.ContentType.Alias))
{
node.NodeType = "uNews";
}
if (RemoveCreateDocTypes.Contains(document.ContentType.Alias))
{
node.Menu.Remove(ActionNew.Instance);
}
}
catch (Exception e2)
{
}
}
}
示例5: Run
// Implement the Run method of IRunnableWorkflowTask
public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
{
// In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance
var wf = (UmbracoWorkflowInstance) workflowInstance;
// UmbracoWorkflowInstance has a list of node Ids that are associated with the workflow in the CmsNodes property
foreach(var nodeId in wf.CmsNodes)
{
// We'll assume that only documents are attached to this workflow
var doc = new Document(nodeId);
var property = doc.getProperty(DocumentTypeProperty);
if (!String.IsNullOrEmpty((string) property.Value)) continue;
var host = HttpContext.Current.Request.Url.Host;
var pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId);
var shortUrl = API.Bit(BitLyLogin, BitLyApiKey, pageUrl, "Shorten");
property.Value = shortUrl;
}
// The run method of a workflow task is responsible for informing the runtime of the outcome.
// The outcome should be one of the items in the AvailableTransitions list.
runtime.Transition(workflowInstance, this, "done");
}
示例6: Page_Load
protected void Page_Load(object s, EventArgs e)
{
var user = global::umbraco.BusinessLogic.User.GetUser(0);
using (CmsContext.Editing)
{
var result = new StringBuilder();
foreach (var newspage in CmsService.Instance.SelectItems<NewsPage>("/Content//*{NewsPage}"))
{
var sender = new Document(newspage.Id.IntValue);
if (newspage.Date.HasValue)
{
var newsArchivePart = CmsService.Instance.GetSystemPath("NewsArchivePage");
var yearPart = newspage.Date.Value.Year.ToString();
var monthPart = Urls.MonthArray.Split('|')[newspage.Date.Value.Month - 1];
var truePath = Paths.Combine(newsArchivePart, yearPart, monthPart, sender.Text);
if (truePath != newspage.Path)
{
var yearPage = CmsService.Instance.GetItem<NewsListPage>(Paths.Combine(newsArchivePart, yearPart));
if (yearPage == null)
{
var archivePage = CmsService.Instance.GetItem<NewsListPage>(newsArchivePart);
yearPage = CmsService.Instance.CreateEntity<NewsListPage>(yearPart, archivePage);
}
var monthPage = CmsService.Instance.GetItem<NewsListPage>(Paths.Combine(newsArchivePart, yearPart, monthPart));
if (monthPage == null)
monthPage = CmsService.Instance.CreateEntity<NewsListPage>(monthPart, yearPage);
sender.Move(monthPage.Id.IntValue);
}
}
}
library.RefreshContent();
litOutput.Text = result.ToString();
}
}
示例7: CopyDocument
/// <summary>Copy document under another document.</summary>
public static void CopyDocument(Document cmsSourceDocument, int cmsTargetDocumentId, bool relateToOriginal = false)
{
// Validate dependencies.
if(cmsSourceDocument != null && cmsTargetDocumentId >= 0) {
cmsSourceDocument.Copy(cmsTargetDocumentId, cmsSourceDocument.User, relateToOriginal);
}
}
示例8: Save
public void Save()
{
string[] keys = Page.Request.Form.AllKeys;
foreach (string key in keys)
{
if (key.StartsWith("DictionaryHelper"))
{
string strDocId = key.Substring(key.IndexOf("docId_") + 6);
string property = key.Remove(key.IndexOf("docId_") - 1).Substring(17);
string value = Page.Request.Form[key];
Document doc = new Document(int.Parse(strDocId));
if (property == "Text" || property == "Default" || property == "Help")
{
Property prop = doc.getProperty(property);
if (prop != null)
{
prop.Value = value;
}
}
else if (property == "Key")
{
doc.Text = value;
}
}
}
}
示例9: 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");
}
示例10: GetOriginalUrl
/// <summary>
/// Gets the image property.
/// </summary>
/// <returns></returns>
internal static string GetOriginalUrl(int nodeId, ImageResizerPrevalueEditor imagePrevalueEditor)
{
Property imageProperty;
var node = new CMSNode(nodeId);
if (node.nodeObjectType == Document._objectType)
{
imageProperty = new Document(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
}
else if (node.nodeObjectType == Media._objectType)
{
imageProperty = new Media(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
}
else
{
if (node.nodeObjectType != Member._objectType)
{
throw new Exception("Unsupported Umbraco Node type for Image Resizer (only Document, Media and Members are supported.");
}
imageProperty = new Member(nodeId).getProperty(imagePrevalueEditor.PropertyAlias);
}
try
{
return imageProperty.Value.ToString();
}
catch
{
return string.Empty;
}
}
示例11: 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")));
}
}
示例12: GetProperty
public System.Xml.Linq.XElement GetProperty(umbraco.cms.businesslogic.property.Property prop)
{
//get access to media item based on some path.
var itm = new Document(int.Parse(prop.Value.ToString()));
return new XElement(prop.PropertyType.Alias, itm.ConfigPath());
}
示例13: ClearFeedCache
private void ClearFeedCache(Document sender)
{
int rootId;
if (sender.Level <= 1)
{
return;
}
if (sender.ContentType.Alias == "Newslist")
{
rootId = sender.Id;
}
else if (new Document(sender.ParentId).ContentType.Alias == "Newslist")
{
rootId = sender.ParentId;
}
else
{
return;
}
var cacheName = string.Format(MainHelper.FeedCache, rootId);
var cache = HttpRuntime.Cache[cacheName];
if (cache == null)
{
return;
}
HttpRuntime.Cache.Remove(cacheName);
}
示例14: CopyProperties
private void CopyProperties(Document fromDoc, Document toDoc)
{
foreach (umbraco.cms.businesslogic.propertytype.PropertyType propertyType in ParentDocument.ContentType.PropertyTypes)
{
toDoc.getProperty(propertyType.Alias).Value = fromDoc.getProperty(propertyType.Alias).Value;
}
}
示例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);
}