Example #1
0
        public void PopulateWarmupSettings()
        {
            this.SiteSettings = new List <WarmupSiteSetting>();
            try
            {
                var warmupSettingsFolderItem = Sitecore.Context.Database.GetItem(SitecoreSystemSettingsWarmupWarmupSettings);
                foreach (var siteSettingItem in warmupSettingsFolderItem.GetChildren()
                         .Cast <Data.Items.Item>().ToArray())
                {
                    var siteSetting = new WarmupSiteSetting
                    {
                        Sitename = siteSettingItem.Fields[FieldName]?.Value.ToString(),
                        SitemapDownloadTimeout   = string.IsNullOrEmpty(siteSettingItem.Fields[SitemapDownloadTimeout]?.Value) ? 3600 : System.Convert.ToInt32(siteSettingItem.Fields[SitemapDownloadTimeout]?.Value),
                        PercentageOfSiteToWarmup = string.IsNullOrEmpty(siteSettingItem.Fields[PercentageOfSiteToWarmUp]?.Value) ? 100 : System.Convert.ToInt32(siteSettingItem.Fields[PercentageOfSiteToWarmUp]?.Value),
                        SitemapURL = siteSettingItem.Fields[SitemapUrl]?.Value.ToString(),
                        OnlyVisitUrlsContainsTheFollowingKeywords = siteSettingItem.Fields[OnlyVisitUrlsContainsTheFollowingKeywords]?.Value.ToString(),
                        VerboseLogging = ((Data.Fields.CheckboxField)siteSettingItem.Fields[VerboseLogging]).Checked
                    };

                    Data.Fields.MultilistField warmupItemsField = siteSettingItem.Fields[WarmupItems];
                    siteSetting.WarmupItems = warmupItemsField.GetItems().ToList();

                    this.SiteSettings.Add(siteSetting);
                }
            }
            catch (Exception e)
            {
                var message = WarmupThereWasAnErrorWhileRetrievingTheWarmupSettings + e.Message;
                Diagnostics.Log.Error(message, this);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contextItem"></param>
        /// <returns></returns>
        public IEnumerable <Item> GetRelatedArticle(Item contextItem)
        {
            if (contextItem == null)
            {
                Log.Error("Item not found", contextItem);
                throw new ArgumentNullException(nameof(contextItem));
            }
            Data.Fields.MultilistField relatedArticles = contextItem?.Fields[Constants.Fields.RelatedArticlesField];
            Item[] items = relatedArticles?.GetItems();

            // return selected articles' details
            return(items.OrderBy(x => x.Name));
        }