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

C# UmbracoHelper类代码示例

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

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



UmbracoHelper类属于命名空间,在下文中一共展示了UmbracoHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Post

        // POST umbraco/api/umbcontact/post
        public HttpResponseMessage Post([FromBody]UmbContactMail message)
        {
            // Return errors if the model validation fails
            // The model defines validations for empty or invalid email addresses
            // See the UmbContactMail class below
            if (ModelState.IsValid == false)
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.First().Value.Errors.First().ErrorMessage);

            // In order to allow editors to configure the email address where contact
            // mails will be sent, we require that to be set in a property with the
            // alias umbEmailTo - This property needs to be sent into this API call
            var umbraco = new UmbracoHelper(UmbracoContext);
            var content = umbraco.TypedContent(message.SettingsNodeId);

            if (content == null)
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                          "Please provide a valid node Id on which the umbEmailTo property is defined.");

            var mailTo = content.GetPropertyValue<string>("umbEmailTo");

            if (string.IsNullOrWhiteSpace(mailTo))
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                          string.Format("The umbEmailTo property on node {0} (Id {1}) does not exists or has not been filled in.",
                          content.Name, content.Id));

            // If we have a valid email address to send the email to, we can try to
            // send it. If the is an error, it's most likely caused by a wrong SMTP configuration
            return TrySendMail(message, mailTo)
                ? new HttpResponseMessage(HttpStatusCode.OK)
                : Request.CreateErrorResponse(HttpStatusCode.ServiceUnavailable,
                          "Could not send email. Make sure the server settings in the mailSettings section of the Web.config file are configured correctly. For a detailed error, check ~/App_Data/Logs/UmbracoTraceLog.txt.");
        }
开发者ID:biapar,项目名称:Documento,代码行数:33,代码来源:UmbContactController.cs


示例2: GetListOfCommentsForPage

        public List<CommentViewModel> GetListOfCommentsForPage()
        {
            UmbracoHelper helper = new UmbracoHelper(this.UmbracoContext);

             //           IPublishedContent content = helper.TypedContent(PageId);

            IPublishedContent content = helper.TypedContentAtRoot().FirstOrDefault();

            List<CommentViewModel> ListOfComments = new List<CommentViewModel>();

            var ListOfCommentsContent = content.DescendantsOrSelf("Comment");

            foreach (var item in ListOfCommentsContent)
            {
                if (item.ContentType.Alias == "Comment")
                {
                    ListOfComments.Add(new CommentViewModel
                    {
                        Name = item.GetPropertyValue("name").ToString(),
                        Email = item.GetPropertyValue("email").ToString(),
                        Comment = item.GetPropertyValue("comment").ToString(),
                        DateAndTime = item.GetPropertyValue("dateAndTime").ToString()
                    });
                }

            }

            return ListOfComments;
        }
开发者ID:ruijosenunes,项目名称:24dentistasdelisboa,代码行数:29,代码来源:GetListOfCommentsApiController.cs


示例3: CreateMainNav

        public static IList<MenuItem> CreateMainNav(this IPublishedContent currentContent)
        {
            var items = new List<MenuItem>();
            var homeNode = currentContent.AncestorOrSelf(1);
            var umbracoConextProvider = DependencyResolver.Current.GetService<IUmbracoConextProvider>();
            var umbracoHelper = new UmbracoHelper(umbracoConextProvider.GetUmbracoContext());

            //Home Page

            //items.Add(new MenuItem
            //{
            //    Id = homeNode.Id,
            //    IsActive = homeNode.Id == currentContent.Id,
            //    Name = homeNode.Name,
            //    NodeTypeAlias = homeNode.DocumentTypeAlias,
            //    Url = homeNode.Url,
            //    SortOrder = homeNode.SortOrder,
            //    Content=homeNode,
            //    IsVisible = homeNode.IsVisible()
            //});

            items.AddRange(GetMenuItmes(homeNode, currentContent, 2, umbracoHelper));

            return items;
        }
开发者ID:bgadiel,项目名称:tt,代码行数:25,代码来源:PublishedContentExtensions.cs


示例4: ToBasketViewLineItem

        ///
        /// Utility extension to map a  to a BasketViewLine item.
        /// Notice that the ContentId is pulled from the extended data. The name can either
        /// be the Merchello product name via lineItem.Name or the Umbraco content page
        /// name with umbracoHelper.Content(contentId).Name
        ///
        ///
        ///The  to be mapped
        ///
        private static BasketViewLineItem ToBasketViewLineItem(this ILineItem lineItem)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);

            var contentId = lineItem.ExtendedData.ContainsKey("umbracoContentId") ? int.Parse(lineItem.ExtendedData["umbracoContentId"]) : 0;

            var umbracoName = umbracoHelper.Content(contentId).Name;
            var merchelloProductName = lineItem.Name;

            return new BasketViewLineItem()
            {

                Key = lineItem.ExtendedData.GetProductKey(),// lineItem.Key,
                ContentId = contentId,
                ExtendedData = DictionaryToString(lineItem.ExtendedData),
                Name = merchelloProductName,
                //Name = umbracoName,
                Sku = lineItem.Sku,
                UnitPrice = lineItem.Price,
                TotalPrice = lineItem.TotalPrice,
                Quantity = lineItem.Quantity,
                Images = lineItem.ExtendedData.GetValue("images")

            };
        }
开发者ID:sychoow007,项目名称:oldlima,代码行数:34,代码来源:BasketViewModelExtensions.cs


示例5: UmbracoApiController

 protected UmbracoApiController(UmbracoContext umbracoContext)
 {
     if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
     UmbracoContext = umbracoContext;
     InstanceId = Guid.NewGuid();
     Umbraco = new UmbracoHelper(umbracoContext);
 }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:7,代码来源:UmbracoApiController.cs


示例6: Configure

 protected override void Configure()
 {
     Mapper.CreateMap<IPublishedContent, ContentInteractiveImageModel>()
           .ForMember(model => model.ExplanationsText, expression => expression.ResolveUsing(node => node.GetPropertyValue<string>("explanationsText")))
           .ForMember(model => model.FooterText, expression => expression.ResolveUsing(node => node.GetPropertyValue<string>("bodyText")))
           .ForMember(model => model.Image, expression => expression.ResolveUsing(node =>
               {
                   var helper = new UmbracoHelper(UmbracoContext.Current);
                   var imageMedia = helper.TypedMedia(node.GetPropertyValue<int>("image"));
                   if (imageMedia == null)
                       return string.Empty;
                   return imageMedia.Url;
               }))
           .ForMember(model => model.Items, expression => expression.ResolveUsing(node =>
               {
                   var items = new List<ContentInteractiveImageItemModel>();
                   foreach (var childNode in node.Children.Where(content => content.DocumentTypeAlias.Equals("InteractiveImagePopUp", StringComparison.OrdinalIgnoreCase)))
                   {
                       items.Add(new ContentInteractiveImageItemModel
                           {
                               BodyText = childNode.GetPropertyValue<string>("bodyText"),
                               Title = childNode.GetPropertyValue<string>("title"),
                               BottomRightY = childNode.GetPropertyValue<int>("bottomRightY"),
                               BottomRightX = childNode.GetPropertyValue<int>("bottomRightX"),
                               TopLeftX = childNode.GetPropertyValue<int>("topLeftX"),
                               TopLeftY = childNode.GetPropertyValue<int>("topLeftY")
                           });
                   }
                   return items;
               }));
 }
开发者ID:nicolasmetaye,项目名称:DynamicLoopCompany,代码行数:31,代码来源:ContentInteractiveImageMap.cs


示例7: Company

 public IPublishedContent Company()
 {
     var memberCompany = GetMember();
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     // DKO: získá napojení na stránku firmy z nastavení uživatele v členské sekci
     return umbracoHelper.Content(memberCompany.Properties["CompanyPage"].Value);
 }
开发者ID:sandarina,项目名称:JobsplusUmbraco,代码行数:7,代码来源:JobTemplatesController.cs


示例8: VideoService

 // private readonly IMemberService _memberService;
 public VideoService(IContentService content)
 {
     _content = content;
     _context = new UmbracoContextProvider();
     //var umbracoConextProvider = DependencyResolver.Current.GetService<IUmbracoConextProvider>();
     _umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
 }
开发者ID:bgadiel,项目名称:tt,代码行数:8,代码来源:VIdeoService.cs


示例9: GetSiteMap

 /// <summary>
 /// Возвращает дерево узлов для вывода человеческой карты сайта.
 /// Каждый объект в коллекции представляет собой дублет, где
 /// Item1 — узел документа (IPublishedContent),
 /// Item2 — поддерево аналогичной структуры (пустое для листьев).
 /// </summary>
 /// <returns></returns>
 public static Tuple<IPublishedContent, dynamic> GetSiteMap()
 {
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     var mainPage = umbracoHelper.TypedContentSingleAtXPath("/root/pubMainPage");
     if (mainPage == null) throw new Exception("Не найдена главная страница сайта.");
     return Tuple.Create<IPublishedContent, dynamic>(mainPage, GetBranch(mainPage));
 }
开发者ID:AzarinSergey,项目名称:UmbracoE-commerceBadPractic_1,代码行数:14,代码来源:Unico.Etechno.SiteMapHelper.cs


示例10: Crawl

        /// <summary>
        /// The crawl.
        /// </summary>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="doc">
        /// The doc.
        /// </param>
        public void Crawl(UmbracoContext site, XmlDocument doc)
        {
            /*
             *  We're going to crawl the site layer-by-layer which will put the upper levels
             *  of the site nearer the top of the sitemap.xml document as opposed to crawling
             *  the tree by parent/child relationships, which will go deep on each branch before
             *  crawling the entire site.
             */

            var helper = new UmbracoHelper(UmbracoContext.Current);
            var siteRoot = helper.TypedContentAtRoot().First();
            var node = SitemapGenerator.CreateNode(siteRoot, site);
            if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
            {
                SitemapGenerator.AppendUrlElement(doc, node);
            }

            var items = siteRoot.Descendants();
            if (items != null)
            {
                foreach (var item in items)
                {
                    node = SitemapGenerator.CreateNode(item, site);

                    if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
                    {
                        SitemapGenerator.AppendUrlElement(doc, node);
                    }
                }
            }
        }
开发者ID:MattSchroer,项目名称:constellation.umbraco.seo,代码行数:40,代码来源:DefaultCrawler.cs


示例11: RenderDocTypeGridEditorItem

        public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
            IPublishedContent content,
            string viewPath = "",
            string actionName = "",
            object model = null)
        {
            if (content == null)
                return new HtmlString(string.Empty);

            var controllerName = content.DocumentTypeAlias + "Surface";

            if (!string.IsNullOrWhiteSpace(viewPath))
                viewPath = viewPath.TrimEnd('/') + "/";

            if (string.IsNullOrWhiteSpace(actionName))
                actionName = content.DocumentTypeAlias;

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            if (umbracoHelper.SurfaceControllerExists(controllerName, actionName, true))
            {
                return helper.Action(actionName, controllerName, new
                {
                    dtgeModel = model ?? content,
                    dtgeViewPath = viewPath
                });
            }

            if (!string.IsNullOrWhiteSpace(viewPath))
                return helper.Partial(viewPath + content.DocumentTypeAlias + ".cshtml", content);

            return helper.Partial(content.DocumentTypeAlias, content);
        }
开发者ID:nvisage-gf,项目名称:umbraco-doc-type-grid-editor,代码行数:32,代码来源:HtmlHelperExtensions.cs


示例12: GetStoreRoot

 /// <summary>
 /// The get store root.
 /// </summary>
 /// <returns>
 /// The <see cref="IPublishedContent"/>.
 /// </returns>
 public static IPublishedContent GetStoreRoot()
 {
     if (StoreRoot != null) return StoreRoot;
     var umbraco = new UmbracoHelper(UmbracoContext.Current);
     StoreRoot = umbraco.TypedContentSingleAtXPath(WebConfigurationManager.AppSettings["Bazaar:XpathToStore"]);
     return StoreRoot;
 }
开发者ID:drpeck,项目名称:Merchello,代码行数:13,代码来源:BazaarContentHelper.cs


示例13: GetImageUrl

 public static string GetImageUrl(this UmbracoContext context, IPublishedContent node, string propertyName)
 {
     var helper = new UmbracoHelper(context);
     var imageId = node.GetPropertyValue<int>(propertyName);
     var typedMedia = helper.TypedMedia(imageId);
     return typedMedia != null ? typedMedia.Url : null;
 }
开发者ID:kenballard,项目名称:NuthinButNet,代码行数:7,代码来源:ImageHelpers.cs


示例14: GetAllUrlsForWildCardUrls

        public IEnumerable<string> GetAllUrlsForWildCardUrls(IEnumerable<string> wildCardUrls, UmbracoHelper uh)
        {
            List<string> resolvedUrls = new List<string>();

            if (wildCardUrls == null || !wildCardUrls.Any())
            {
                return resolvedUrls;
            }

            IEnumerable<string> allContentUrls = GetAllContentUrls(uh);

            foreach(string wildCardUrl in wildCardUrls)
            {
                if(!wildCardUrl.Contains('*'))
                {
                    //it doesnt even contain a wildcard.
                    continue;
                }

                //Make one for modifing
                string mutableWildCardUrl = wildCardUrl;

                //take off the trailing slash if there is one
                mutableWildCardUrl = mutableWildCardUrl.TrimEnd('/');

                //take off the *
                mutableWildCardUrl = mutableWildCardUrl.TrimEnd('*');

                //We can get wild cards by seeing if any of the urls start with the mutable wild card url
                resolvedUrls.AddRange(allContentUrls.Where(x => x.StartsWith(mutableWildCardUrl)));
            }

            return resolvedUrls;
        }
开发者ID:scyllagroup,项目名称:UmbracoFlare,代码行数:34,代码来源:UmbracoUrlWildCardManager.cs


示例15: XmlRssHandler

 public XmlRssHandler()
 {
     umbContext = UmbracoContext.Current;
     appContext = ApplicationContext.Current;
     services = appContext.Services;
     helper = new UmbracoHelper( umbContext );
 }
开发者ID:rasmuseeg,项目名称:UmbracoFeed,代码行数:7,代码来源:XmlRssHandler.cs


示例16: UmbracoEvents

        private List<BannerItem> UmbracoEvents()
        {
            var helper = new UmbracoHelper(UmbracoContext.Current);
            List<BannerItem> ue = new List<BannerItem>();
            IPublishedContent root = helper.Content(1068);
            IPublishedContent eventRoot = helper.Content(Convert.ToInt32(root.GetProperty("seminars").Value));
            foreach (var itm in eventRoot.Children.Where("Visible").Where("end >= DateTime.Now.Date").OrderBy("start"))
            {
                string input = itm.GetProperty("end").Value.ToString();
                DateTime dateTime;
                if (DateTime.TryParse(input, out dateTime))
                {
                    if (dateTime > DateTime.Now)
                    {
                        var bi = new BannerItem();
                        bi.title = itm.HasValue("subHeader") ? itm.GetProperty("subHeader").Value.ToString() : itm.Name;
                        if (itm.HasValue("country"))
                            bi.Country = itm.GetProperty("country").ToString();
                        bi.link = new entryLink
                        {
                            href = itm.Url,
                            target = "_self"
                        };
                        bi.published = bi.StartDateTime = "Seminar starts "+itm.GetProperty("start").Value.ToString().ToDate().ToShortDateString();

                        bi.updated = itm.UpdateDate.ToShortDateString();
                        bi.TypeOfContent = Enum.GetName(typeof(TypeOfContent),TypeOfContent.UmbracoEvent);

                        ue.Add(bi);
                    }
                }
            }
            return ue;
        }
开发者ID:Aikidokan,项目名称:www_marcbachraty_com,代码行数:34,代码来源:FbController.cs


示例17: Init

        public bool Init(int CurrentNodeId, string PropertyData, out object instance)
        {
			//we're going to send the string through the macro parser and create the output string.
			if (UmbracoContext.Current != null)
			{
				var sb = new StringBuilder();
				var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
				MacroTagParser.ParseMacros(
					PropertyData,
					//callback for when text block is found
					textBlock => sb.Append(textBlock),
					//callback for when macro syntax is found
					(macroAlias, macroAttributes) => sb.Append(umbracoHelper.RenderMacro(
						macroAlias,
						//needs to be explicitly casted to Dictionary<string, object>
						macroAttributes.ConvertTo(x => (string)x, x => (object)x)).ToString()));
				instance = new HtmlString(sb.ToString());
			}			
			else
			{
				//we have no umbraco context, so best we can do is convert to html string
				instance = new HtmlString(PropertyData);
			}			
            return true;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:25,代码来源:HtmlStringDataTypeModel.cs


示例18: GetImagesUrl

        /// <summary>
        /// Gets images url list.
        /// 
        /// Gets crops if cropname specified
        /// </summary>
        /// <param name="post"></param>
        /// <param name="cropName"></param>
        /// <returns></returns>
        public static IEnumerable<String> GetImagesUrl(IPublishedContent post, String cropName = "", String fieldAlias = "images")
        {
            List<string> result = new List<string>();

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);

            try
            {
                var pictureIDsVal = post.GetPropertyValue<String>(fieldAlias);
                if (!String.IsNullOrEmpty(pictureIDsVal))
                {
                    var pictureIDs = pictureIDsVal.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var pictureIDstr in pictureIDs)
                    {
                        if (!String.IsNullOrEmpty(pictureIDstr))
                        {
                            int id = Int32.Parse(pictureIDstr);
                            var url = GetImageUrl(id, cropName);
                            result.Add(url);
                        }
                    }

                }
            }
            catch (Exception e)
            {
                if (UmbracoContext.Current.IsDebug)
                {
                    //throw e;
                }
            }

            return result;
        }
开发者ID:pawelgur,项目名称:UmbracoExtensions,代码行数:42,代码来源:ImageHelpers.cs


示例19: UpdateProjectExamineIndex

 private void UpdateProjectExamineIndex(IEntity item)
 {
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     var content = umbracoHelper.TypedContent(item.Id);
     var downloads = Utils.GetProjectTotalDownloadCount(content.Id);
     UpdateProjectExamineIndex(content, downloads);
 }
开发者ID:KerwinMa,项目名称:OurUmbraco,代码行数:7,代码来源:ProjectIndexer.cs


示例20: CreateController

        protected override ApiController CreateController(Type controllerType, HttpRequestMessage msg, UmbracoHelper helper, ITypedPublishedContentQuery qry, ServiceContext serviceContext, BaseSearchProvider searchProvider)
        {
            _onServicesCreated(msg, helper.UmbracoContext, qry, serviceContext, searchProvider);

            //Create the controller with all dependencies
            var ctor = controllerType.GetConstructor(new[]
                {
                    typeof(UmbracoContext),
                    typeof(UmbracoHelper),
                    typeof(BaseSearchProvider)
                });

            if (ctor == null)
            {
                throw new MethodAccessException("Could not find the required constructor for the controller");
            }

            var created = (ApiController)ctor.Invoke(new object[]
                    {
                        //ctor args
                        helper.UmbracoContext,
                        helper,
                        searchProvider
                    });

            return created;
        }
开发者ID:robertjf,项目名称:UmbracoRestApi,代码行数:27,代码来源:TestControllerActivator.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UnLocode类代码示例发布时间:2022-05-24
下一篇:
C# UmbracoContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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