• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# web.Document类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中umbraco.cms.businesslogic.web.Document的典型用法代码示例。如果您正苦于以下问题:C# Document类的具体用法?C# Document怎么用?C# Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Document类属于umbraco.cms.businesslogic.web命名空间,在下文中一共展示了Document类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
        }
开发者ID:PeteDuncanson,项目名称:census,代码行数:26,代码来源:Content.cs


示例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;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:29,代码来源:ModifyPageProperty.cs


示例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;
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:29,代码来源:page.cs


示例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)
                {

                }
            }
        }
开发者ID:kgiszewski,项目名称:uNews,代码行数:26,代码来源:uNewsEvents.cs


示例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");
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:28,代码来源:BitLyUrlShorteningTask.cs


示例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();
            }
        }
开发者ID:jeppe-andreasen,项目名称:Umbraco-Public,代码行数:35,代码来源:FixNewsPaths.aspx.cs


示例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);
     }
 }
开发者ID:williamchang,项目名称:umbraco-labs,代码行数:8,代码来源:CmsDocumentHelper.cs


示例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;
                    }

                }
            }
        }
开发者ID:1508,项目名称:upac-for-umbraco,代码行数:29,代码来源:SettingsHelper.cs


示例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");
        } 
开发者ID:elrute,项目名称:Triphulcas,代码行数:34,代码来源:nForumBaseExtensions.cs


示例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;
            }
        }
开发者ID:ZeeshanShafqat,项目名称:Aspose_Imaging_NET,代码行数:34,代码来源:ImageResizerHelper.cs


示例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")));
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:34,代码来源:ForumMoveTopic.ascx.cs


示例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());
        }
开发者ID:tocsoft,项目名称:Umbraco-DeveloperFriendly,代码行数:7,代码来源:ContentPickerConverter.cs


示例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);
        }
开发者ID:BarryFogarty,项目名称:ubootstrap,代码行数:30,代码来源:UpdateFeed.cs


示例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;
     }
 }
开发者ID:kgiszewski,项目名称:BabelFish,代码行数:7,代码来源:BabelFishCreateTranslation.aspx.cs


示例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);
 }
开发者ID:rubenski,项目名称:Tekstenuitleg,代码行数:7,代码来源:BlogBo.cs


示例16: Index

        public override ActionResult Index(RenderModel model)
        {
            if (model.Content.TemplateId.Equals(Template.GetTemplateIdFromAlias("ProjectCreate")))
            {
                var member = Member.GetCurrentMember();
                if (member != null)
                {
                    if (Request.HttpMethod.Equals("GET"))
                        return CurrentTemplate(model);

                    var project = CreateProject(member);
                    if (project != null) return this.Redirect(umbraco.library.NiceUrl(project.Id));
                }

                return this.Redirect(Request.UrlReferrer.AbsoluteUri);
            }
            else
            {
                var id = Convert.ToInt32(Request.Params["id"]);
                var project = new Document(id);

                var member = Member.GetCurrentMember();
                var authorId = project.getProperty("author").Value;
                if (member != null && member.Id.Equals(authorId))
                {
                    if (Request.HttpMethod.Equals("GET"))
                        return base.View(model);

                    SaveProject(project, member);
                }

                return this.Redirect(umbraco.library.NiceUrl(id));
            }
        }
开发者ID:v-five,项目名称:upgradeit,代码行数:34,代码来源:ProjectController.cs


示例17: Run

        public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime)
        {
            // Cast to Umbraco worklow instance.
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance) workflowInstance;

            var count = 0;
            var newCmsNodes = new List<int>();

            foreach(var nodeId in umbracoWorkflowInstance.CmsNodes)
            {
                var n = new CMSNode(nodeId);
                if(!n.IsDocument()) continue;

                var d = new Document(nodeId);
                if (!DocumentTypes.Contains(d.ContentType.Id)) continue;
                
                newCmsNodes.Add(nodeId);
                count++;
            }

            umbracoWorkflowInstance.CmsNodes = newCmsNodes;

            var transition = (count > 0) ? "contains_docs" : "does_not_contain_docs";
            runtime.Transition(workflowInstance, this, transition);
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:25,代码来源:FilterDocumentsWorkflowTask.cs


示例18: 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);
        }
开发者ID:v-five,项目名称:upgradeit,代码行数:29,代码来源:ProjectController.cs


示例19: Document_AfterPublish

        void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e) {
            if (sender.ContentType.Alias == "BlogPost") {
                string urls = GetValueRecursively("pingServices", sender.Id);

                if (!string.IsNullOrEmpty(urls)) {
                    string blogUrl;
                    XmlDocument xd = new XmlDocument();

                    try { xd.LoadXml(urls); }
                    catch { }

                    string blogName = GetValueRecursively("blogName", sender.Id);
                    string currentDomain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();
                    library.UpdateDocumentCache(sender.Id);
                    try {
                        blogUrl = library.NiceUrlFullPath(sender.Id);
                        if (!UmbracoSettings.UseDomainPrefixes) blogUrl = "http://" + currentDomain + blogUrl;
                    } catch (Exception) {
                        Log.Add(LogTypes.Debug, sender.Id, "Cound not get 'NiceUrlFullPath' from current application");
                        blogUrl = "http://" + currentDomain + "/" + library.NiceUrl(sender.Id);
                    }

                    foreach (XmlNode link in xd.SelectNodes("//link [@type = 'external']")) {
                        string ping = link.Attributes["link"].Value;
                        //Log.Add(LogTypes.Debug, sender.Id, ping + " n:" + blogName + " u:" + blogUrl);
                        PingService(ping, blogName, blogUrl);
                    }
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:30,代码来源:Autoping.cs


示例20: OnInit

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx"))
				return;

			_lblOrderInfo = new Label();

			var documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]);
			var orderDoc = new Document(documentId);

			var orderGuidValue = orderDoc.getProperty("orderGuid").Value;
			if (orderGuidValue != null && !string.IsNullOrEmpty(orderGuidValue.ToString()))
			{
				var orderGuid = Guid.Parse(orderDoc.getProperty("orderGuid").Value.ToString());

				var orderInfoXml = OrderHelper.GetOrderXML(orderGuid);

				var parameters = new Dictionary<string, object>(1) {{"uniqueOrderId", orderGuid.ToString()}};

				var transformation = macro.GetXsltTransformResult(orderInfoXml, macro.getXslt("uwbsOrderInfo.xslt"), parameters);

				_lblOrderInfo.Text = transformation ?? "uwbsOrderInfo.xslt render issue";
			}
			else
			{
				_lblOrderInfo.Text = "Unique Order ID not found. Republish might solve this issue";
			}


			if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblOrderInfo);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:33,代码来源:OrderInfoViewerDataEditor.cs



注:本文中的umbraco.cms.businesslogic.web.Document类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# web.DocumentType类代码示例发布时间:2022-05-26
下一篇:
C# template.Template类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap