Exemple #1
0
        /// <summary>
        /// Get all urls of published pages
        /// </summary>
        /// <param name="includeExtensions"></param>
        /// <param name="pathStarts"></param>
        /// <param name="publicationID"></param>
        /// <returns></returns>
        public string[] GetAllPublishedPageUrls(string[] includeExtensions, string[] pathStarts)
        {
            using (var pa = new Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome())
            {
                Java.Util.Collection pageCollection = pa.FindAll(PublicationId);
                var pageList = new List <Com.Tridion.Meta.PageMeta>();
                foreach (object pageMetaObject in pageCollection)
                {
                    pageList.Add((Com.Tridion.Meta.PageMeta)pageMetaObject);
                }

                using (var sqlBinMetaHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome())
                {
                    Java.Util.Collection binCollection = sqlBinMetaHome.FindAll(PublicationId);
                    var binList = new List <Com.Tridion.Meta.BinaryMeta>();
                    foreach (object binMetaObject in binCollection)
                    {
                        binList.Add((Com.Tridion.Meta.BinaryMeta)binMetaObject);
                    }
                    var pageUrls = pageList.Select(pm => pm.GetURLPath());
                    var binUrls  = binList.Select(bm => bm.GetURLPath());
                    return(pageUrls
                           .Concat(binUrls)
                           .Where(url =>
                                  includeExtensions.Contains(url.Substring(url.LastIndexOf('.') + 1)) &&
                                  pathStarts.Any(pathStart => url.StartsWith(pathStart)))
                           .ToArray());
                }
            }
        }
        /// <summary>
        /// Get all urls of published pages
        /// </summary>
        /// <param name="includeExtensions"></param>
        /// <param name="pathStarts"></param>
        /// <param name="publicationID"></param>
        /// <returns></returns>
        public string[] GetAllPublishedPageUrls(string[] includeExtensions, string[] pathStarts)
        {
            using (var pa = new Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome())
            {
                Java.Util.Collection pageCollection = pa.FindAll(PublicationId);
                var pageList = new List<Com.Tridion.Meta.PageMeta>();
                foreach (object pageMetaObject in pageCollection)
                {
                    pageList.Add((Com.Tridion.Meta.PageMeta)pageMetaObject);
                }

                using (var sqlBinMetaHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome())
                {
                    Java.Util.Collection binCollection = sqlBinMetaHome.FindAll(PublicationId);
                    var binList = new List<Com.Tridion.Meta.BinaryMeta>();
                    foreach (object binMetaObject in binCollection)
                    {
                        binList.Add((Com.Tridion.Meta.BinaryMeta)binMetaObject);
                    }
                    var pageUrls = pageList.Select(pm => pm.GetURLPath());
                    var binUrls = binList.Select(bm => bm.GetURLPath());
                    return pageUrls
                        .Concat(binUrls)
                        .Where(url =>
                            includeExtensions.Contains(url.Substring(url.LastIndexOf('.') + 1))
                            && pathStarts.Any(pathStart => url.StartsWith(pathStart)))
                        .ToArray();
                }
            }
        }
 public DateTime GetLastPublishedDate(string url)
 {
     using (Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome pa = new Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome())
     {
         Com.Tridion.Meta.PageMeta pm = pa.FindByURL(PublicationId, url);
         if (pm == null)
         {
             return(DateTime.Now);
         }
         else
         {
             return(DateTime.Parse(pm.GetLastPublicationDate().ToString()));
         }
     }
 }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {
            string retVal = string.Empty;


            //TODO: Add usings instead of fully classified names            
            using (Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome pa = new Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome())
            {
                Com.Tridion.Meta.PageMeta pm = pa.FindByURL(PublicationId, Url);
                if (pm == null) return retVal;
                using (Com.Tridion.Broker.Pages.SQLPageHome pageHome = new Com.Tridion.Broker.Pages.SQLPageHome())
                {
                    Com.Tridion.Data.CharacterData data = pageHome.FindByPrimaryKey(PublicationId, pm.GetId());
                    retVal = data.GetString();
                }
            }

            return retVal;
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        private string GetStringContentFromBrokerByUrl(string Url, int publicationId)
        {
            string retVal = string.Empty;

            //TODO: Add usings instead of fully classified names
            using (Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome pa = new Com.Tridion.Broker.Pages.Meta.SQLPageMetaHome())
            {
                Com.Tridion.Meta.PageMeta pm = pa.FindByURL(publicationId, Url);
                if (pm == null)
                {
                    return(retVal);
                }
                using (Com.Tridion.Broker.Pages.SQLPageHome pageHome = new Com.Tridion.Broker.Pages.SQLPageHome())
                {
                    Com.Tridion.Data.CharacterData data = pageHome.FindByPrimaryKey(publicationId, pm.GetId());
                    retVal = data.GetString();
                }
            }

            return(retVal);
        }