コード例 #1
0
        public static void RemoveComponentPresentation(this PageData page, ComponentPresentationData cp)
        {
            var list = page.ComponentPresentations.ToList();

            list.Remove(cp);
            page.ComponentPresentations = list.ToArray();
        }
コード例 #2
0
        public string AddToPage(string sg, Article article)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            string foldername;

            if (article.Date.Month < 10)
            {
                foldername = "0" + article.Date.Month;
            }
            else
            {
                foldername = article.Date.Month.ToString(CultureInfo.InvariantCulture);
            }
            foldername += " " + article.Date.ToString("MMMM");
            PageData page = (PageData)_client.Read(GetPage(sg, foldername), _readOptions);
            //if (!page.IsEditable.GetValueOrDefault())
            //{
            //    page = (PageData)_client.CheckOut(page.Id, true, _readOptions);
            //}

            List <ComponentPresentationData> componentPresentations = page.ComponentPresentations.ToList();
            string articleId = GetUriInBlueprintContext(article.Id, ResolveUrl(Constants.WebSitePublication));
            string ctId      = GetUriInBlueprintContext(ResolveUrl(Constants.ArticleComponentTemplateUrl),
                                                        ResolveUrl(Constants.WebSitePublication));
            ComponentPresentationData cp = new ComponentPresentationData();

            if (articleId != null && articleId != TcmUri.UriNull)
            {
                cp.Component = new LinkToComponentData {
                    IdRef = articleId
                };
                cp.ComponentTemplate = new LinkToComponentTemplateData {
                    IdRef = ctId
                };
                componentPresentations.Add(cp);
                page.ComponentPresentations = componentPresentations.ToArray();
            }
            page = (PageData)_client.Update(page, _readOptions);
            // Looks like it's still checked out at the end of this...
            if (page.IsEditable.HasValue && page.IsEditable == true)
            {
                _client.CheckIn(GetVersionlessUri(page.Id), null);
            }

            watch.Stop();
            Console.WriteLine("Added component presentation in " + watch.ElapsedMilliseconds + " milliseconds");
            return(page.Id);
        }
コード例 #3
0
        public string AddToPage(string sg, Article article)
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();
            string foldername;
            if (article.Date.Month < 10)
                foldername = "0" + article.Date.Month;
            else
                foldername = article.Date.Month.ToString(CultureInfo.InvariantCulture);
            foldername += " " + article.Date.ToString("MMMM");
            PageData page = (PageData)_client.Read(GetPage(sg, foldername), _readOptions);
            //if (!page.IsEditable.GetValueOrDefault())
            //{
            //    page = (PageData)_client.CheckOut(page.Id, true, _readOptions);
            //}

            List<ComponentPresentationData> componentPresentations = page.ComponentPresentations.ToList();
            string articleId = GetUriInBlueprintContext(article.Id, ResolveUrl(Constants.WebSitePublication));
            string ctId = GetUriInBlueprintContext(ResolveUrl(Constants.ArticleComponentTemplateUrl),
                                                   ResolveUrl(Constants.WebSitePublication));
            ComponentPresentationData cp = new ComponentPresentationData();
            if (articleId != null && articleId != TcmUri.UriNull)
            {
                cp.Component = new LinkToComponentData { IdRef = articleId };
                cp.ComponentTemplate = new LinkToComponentTemplateData { IdRef = ctId };
                componentPresentations.Add(cp);
                page.ComponentPresentations = componentPresentations.ToArray();
            }
            page = (PageData)_client.Update(page, _readOptions);
            // Looks like it's still checked out at the end of this...
            if (page.IsEditable.HasValue && page.IsEditable == true)
                _client.CheckIn(GetVersionlessUri(page.Id), null);

            watch.Stop();
            Console.WriteLine("Added component presentation in " + watch.ElapsedMilliseconds + " milliseconds");
            return page.Id;
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentPresentation" /> class.
 /// </summary>
 /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
 /// <param name="componentPresentationData"><see cref="T:Tridion.ContentManager.CoreService.Client.ComponentPresentationData" /></param>
 internal ComponentPresentation(Client client, ComponentPresentationData componentPresentationData)
     : base(client)
 {
     mComponentPresentationData = componentPresentationData;
 }
コード例 #5
0
 //TODO
 public static void AddComponentPresentation(this PageData page, ComponentPresentationData cp)
 {
     page.ComponentPresentations.Concat(new[] { cp });
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentPresentation" /> class.
 /// </summary>
 /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
 /// <param name="componentPresentationData"><see cref="T:Tridion.ContentManager.CoreService.Client.ComponentPresentationData" /></param>
 internal ComponentPresentation(Client client, ComponentPresentationData componentPresentationData) : base(client)
 {
     mComponentPresentationData = componentPresentationData;
 }