当前位置: 首页>>代码示例>>C#>>正文


C# TcmUri.ToString方法代码示例

本文整理汇总了C#中TcmUri.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TcmUri.ToString方法的具体用法?C# TcmUri.ToString怎么用?C# TcmUri.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TcmUri的用法示例。


在下文中一共展示了TcmUri.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetContent

        public string GetContent(string uri, string templateUri = "")
        {
            LoggerService.Debug(">>GetContent({0})", LoggingCategory.Performance, uri);

            TcmUri tcmUri = new TcmUri(uri);

            TcmUri templateTcmUri = new TcmUri(templateUri);

            T.ComponentPresentationFactory cpFactory = GetComponentPresentationFactory(tcmUri.PublicationId);

            T.ComponentPresentation cp = null;

            if (!String.IsNullOrEmpty(templateUri))
            {
                cp = cpFactory.GetComponentPresentation(tcmUri.ItemId, templateTcmUri.ItemId);
                if (cp != null)
                    return cp.Content;
            }

            if (!string.IsNullOrEmpty(selectByComponentTemplateId))
            {
                cp = cpFactory.GetComponentPresentation(tcmUri.ItemId, Convert.ToInt32(selectByComponentTemplateId));
                if (cp != null)
                {
                    LoggerService.Debug("<<GetContent({0}) - by ct id", LoggingCategory.Performance, uri);
                    return cp.Content;
                }
            }
            if (!string.IsNullOrEmpty(selectByOutputFormat))
            {
                cp = cpFactory.GetComponentPresentationWithOutputFormat(tcmUri.ItemId, selectByOutputFormat);
                if (cp != null)
                {
                    LoggerService.Debug("<<GetContent({0}) - by output format", LoggingCategory.Performance, uri);
                    return cp.Content;
                }
            }

            LoggerService.Debug("GetContent: about to get component presentations with Highst Priority for {0}", LoggingCategory.Performance, tcmUri.ToString());
            cp = cpFactory.GetComponentPresentationWithHighestPriority(tcmUri.ItemId);
            LoggerService.Debug("GetContent: get component presentations with Highst Priority for {0}", LoggingCategory.Performance, tcmUri.ToString());
            if (cp != null)
                return cp.Content;
            //foreach (Tridion.ContentDelivery.DynamicContent.ComponentPresentation _cp in cps)
            //{
            //    if (_cp != null)
            //    {
            //        LoggerService.Debug("<<GetContent({0}) - find all", LoggingCategory.Performance, uri);
            //        return _cp.Content;
            //    }
            //}

            LoggerService.Debug("<<GetContent({0}) - not found", LoggingCategory.Performance, uri);
            return string.Empty;
        }
开发者ID:dd4t,项目名称:DD4T.Providers.SDLTridion2013,代码行数:55,代码来源:TridionComponentPresentationProvider.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            // get the current logged in user
            string user = HttpContext.Current.User.Identity.Name;
            if (!String.IsNullOrEmpty(user))
            {
                // set LogonUser
                TridionTreeView.LogonUser = user;
            }

            // process querystring parameters
            string start = Request.QueryString["start"];
            string types = Request.QueryString["types"];
            string pubid = Request.QueryString["pubid"];

            if (!String.IsNullOrEmpty(start))
            {
                // override StartFromUri
                TridionTreeView.StartFromUri = start;
            }
            else if (!String.IsNullOrEmpty(pubid))
            {
                // override StartFromUri with current publication id
                TcmUri uri = new TcmUri(pubid);
                TridionTreeView.StartFromUri = uri.ToString();
            }

            if (!String.IsNullOrEmpty(types))
            {
                // override SelectTypes
                TridionTreeView.SelectTypes = Convert.ToInt32(types);
            }
        }
开发者ID:SGAnonymous,项目名称:sdl-tridion-world,代码行数:33,代码来源:ItemSelector.aspx.cs

示例3: ResolveLink

        public string ResolveLink(string componentUri)
        {
            TcmUri uri = new TcmUri(componentUri);

            if (!uri.Equals(emptyTcmUri))
            {
                Cache cache = HttpContext.Current.Cache;
                string cacheKey = String.Format(CACHEKEY_FORMAT, componentUri);
                if (cache[cacheKey] != null)
                {
                    return (String)cache[cacheKey];
                }
                else
                {
                    Link link = componentLink.GetLink(uri.ToString());
                    if (!link.IsResolved)
                    {
                        return null;
                    }
                    cache.Insert(cacheKey, link.Url, null, DateTime.Now.AddSeconds(30), TimeSpan.Zero); //TODO should this be configurable?
                    return link.Url;
                }
            }

            return null;
        }
开发者ID:rainmaker2k,项目名称:TridionMVCDotNet,代码行数:26,代码来源:TridionLinkFactory.cs

示例4: GetLocalUri

 public static TcmUri GetLocalUri(TcmUri uriPublication, TcmUri uriItem)
 {
    TcmUri uriReturn = new TcmUri(uriItem.ItemId, uriItem.ItemType, uriPublication.ItemId);
    TemplatingLogger log = TemplatingLogger.GetLogger(typeof(TemplateUtilities));
    log.Info("(getLocalUri)Old URI was:" + uriItem.ToString());
    log.Info("(getLocalUri)New URI is:" + uriReturn.ToString());
    return uriReturn;
 }
开发者ID:jhorsman,项目名称:DD4T.TridionTemplates,代码行数:8,代码来源:TridionUtils.cs

示例5: ResolveLink

        public string ResolveLink(string componentUri)
        {
            TcmUri uri = new TcmUri(componentUri);

            if (!uri.Equals(emptyTcmUri))
            {
                Link link = componentLink.GetLink(uri.ToString());
                return link.IsResolved ? link.Url : null;
            }
    
            return null;
        }
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:12,代码来源:TridionLinkProvider.cs

示例6: GetUriInBlueprintContext

 internal string GetUriInBlueprintContext(string itemId, string publicationId)
 {
     if (TcmUri.UriNull == itemId)
         return null;
     TcmUri itemUri = new TcmUri(itemId);
     TcmUri publicationUri = new TcmUri(publicationId);
     TcmUri inContext = new TcmUri(itemUri.ItemId, itemUri.ItemType, publicationUri.ItemId);
     return inContext.ToString();
 }
开发者ID:NunoLinhares,项目名称:TridionWebData,代码行数:9,代码来源:ContentManager.cs

示例7: PublishItem

        protected virtual void PublishItem(Item item, TcmUri itemUri)
        {
            Stream itemStream = null;
            // See if some template set itself as the applied template on this item
            TcmUri appliedTemplateUri = null;
            if (item.Properties.ContainsKey(Item.ItemPropertyTemplateUri))
            {
                appliedTemplateUri = new TcmUri(item.Properties[Item.ItemPropertyTemplateUri]);
            }

            try
            {
                string publishedPath;
                if (targetStructureGroupUri == null)
                {
                    log.Debug("no structure group defined, publishing binary with default settings");
                    Component mmComp = (Component)engine.GetObject(item.Properties[Item.ItemPropertyTcmUri]);
                    // Note: it is dangerous to specify the CT URI as variant ID without a structure group, because it will fail if you publish the same MMC from two or more CTs!
                    // So I removed the variant ID altogether (QS, 20-10-2011)
                    log.Debug(string.Format("publishing mm component {0} without variant id", mmComp.Id));
                    Binary binary = engine.PublishingContext.RenderedItem.AddBinary(mmComp);
                    publishedPath = binary.Url;
                    log.Debug(string.Format("binary is published to url {0}", publishedPath));
                }
                else
                {
                    Component mmComp = (Component)engine.GetObject(item.Properties[Item.ItemPropertyTcmUri]);

                    string fileName = ConstructFileName(mmComp, currentTemplate.Id);
                    StructureGroup targetSG = (StructureGroup)engine.GetObject(targetStructureGroupUri);
                    itemStream = item.GetAsStream();
                    if (itemStream == null)
                    {
                        // All items can be converted to a stream?
                        log.Error(String.Format("Cannot get item '{0}' as stream", itemUri.ToString()));
                    }
                    //byte[] data = new byte[itemStream.Length];
                    //itemStream.Read(data, 0, data.Length);
                    //itemStream.Close();
                    log.Debug(string.Format("publishing mm component {0} to structure group {1} with variant id {2} and filename {3}", mmComp.Id, targetStructureGroupUri.ToString(), currentTemplate.Id, fileName));
                    Binary b = engine.PublishingContext.RenderedItem.AddBinary(item.GetAsStream(), fileName, targetSG, currentTemplate.Id, mmComp, mmComp.BinaryContent.MultimediaType.MimeType);
                    publishedPath = b.Url;
                    //publishedPath = engine.AddBinary(itemUri, appliedTemplateUri, targetStructureGroupUri, data, fileName);
                    log.Debug(string.Format("binary is published to url {0}", publishedPath));
                }
                log.Debug("binary published, published path = " + publishedPath);
                item.Properties[Item.ItemPropertyPublishedPath] = publishedPath;
            }
            finally
            {
                if (itemStream != null) itemStream.Close();
            }
        }
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:53,代码来源:BinaryPublisher.cs

示例8: GetKeyword

 /// <summary>
 /// Gets a KeywordModel object.
 /// </summary>
 /// <param name="tcmUri">The TcmUri of the keyword to get.</param>
 /// <returns></returns>
 public dynamic GetKeyword(TcmUri tcmUri)
 {
     return GetKeyword(tcmUri.ToString());
 }
开发者ID:alex-klock,项目名称:razor-mediator-4-tridion,代码行数:9,代码来源:ModelUtilities.cs

示例9: GetPage

 public dynamic GetPage(TcmUri tcmUri)
 {
     return GetPage(tcmUri.ToString());
 }
开发者ID:alex-klock,项目名称:razor-mediator-4-tridion,代码行数:4,代码来源:ModelUtilities.cs

示例10: Save

 public void Save(bool checkOutIfNeeded = false)
 {
     if (checkOutIfNeeded)
     {
         if (!Content.IsEditable.GetValueOrDefault())
         {
             Client.CheckOut(Content.Id, true, null);
         }
     }
     if (string.IsNullOrEmpty(Content.Title))
         Content.Title = "No title specified!";
     // Item titles cannot contain backslashes :)
     if (Content.Title.Contains("\\")) Content.Title = Content.Title.Replace("\\", "/");
     Content.Content = _fields.ToString();
     TcmUri contentId = new TcmUri(Content.Id);
     if(!contentId.IsVersionless)
     {
         contentId = new TcmUri(contentId.ItemId, contentId.ItemType, contentId.PublicationId);
         Content.Id = contentId.ToString();
     }
     try
     {
         Content = (ComponentData)Client.Save(Content, ReadOptions);
         Client.CheckIn(Content.Id, null);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Ooops, something went wrong saving component " + Content.Title);
         Console.WriteLine(ex.Message);
     }
 }
开发者ID:NunoLinhares,项目名称:TridionWebData,代码行数:31,代码来源:ContentItem.cs

示例11: GetComponentTemplate

 /// <summary>
 /// Gets a ComponentTemplateModel object.
 /// </summary>
 /// <param name="tcmUri"></param>
 /// <returns></returns>
 public dynamic GetComponentTemplate(TcmUri tcmUri)
 {
     return GetComponentTemplate(tcmUri.ToString());
 }
开发者ID:alex-klock,项目名称:razor-mediator-4-tridion,代码行数:9,代码来源:ModelUtilities.cs

示例12: GetStructureGroup

 public dynamic GetStructureGroup(TcmUri tcmUri)
 {
     return GetStructureGroup(tcmUri.ToString());
 }
开发者ID:alex-klock,项目名称:razor-mediator-4-tridion,代码行数:4,代码来源:ModelUtilities.cs

示例13: GetFolder

 /// <summary>
 /// Gets a FolderModel object.
 /// </summary>
 /// <param name="tcmUri"></param>
 /// <returns></returns>
 public dynamic GetFolder(TcmUri tcmUri)
 {
     return GetFolder(tcmUri.ToString());
 }
开发者ID:alex-klock,项目名称:razor-mediator-4-tridion,代码行数:9,代码来源:ModelUtilities.cs

示例14: GetBinaryByUrl

        public byte[] GetBinaryByUrl(string url)
        {
            string encodedUrl = HttpUtility.UrlPathEncode(url); // ?? why here? why now?


            IList metas = null;
            BinaryMeta binaryMeta = null;
            if (this.PublicationId == 0)
            {
                metas = BinaryMetaFactory.GetMetaByUrl(encodedUrl);
                if (metas.Count == 0)
                {
                    throw new BinaryNotFoundException();
                }
                binaryMeta = metas[0] as BinaryMeta;
            }
            else
            {
                binaryMeta = BinaryMetaFactory.GetMetaByUrl(this.PublicationId, encodedUrl);
                if (binaryMeta == null)
                    throw new BinaryNotFoundException();
            }
            TcmUri uri = new TcmUri(binaryMeta.PublicationId,binaryMeta.Id,16,0);

            Tridion.ContentDelivery.DynamicContent.BinaryFactory factory = new BinaryFactory();

            BinaryData binaryData = string.IsNullOrEmpty(binaryMeta.VariantId) ? factory.GetBinary(uri.ToString()) : factory.GetBinary(uri.ToString(),binaryMeta.VariantId);
            return binaryData == null ? null : binaryData.Bytes;
        }
开发者ID:flaithbheartaigh,项目名称:dynamic-delivery-4-tridion,代码行数:29,代码来源:TridionBinaryProvider.cs

示例15: GetVersionlessUri

 public string GetVersionlessUri(string id)
 {
     TcmUri uri = new TcmUri(id);
     if (uri.IsVersionless) return id;
     uri = new TcmUri(uri.ItemId, uri.ItemType, uri.PublicationId);
     return uri.ToString();
 }
开发者ID:NunoLinhares,项目名称:TridionWebData,代码行数:7,代码来源:ContentManager.cs


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