Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SitemapConfigurationViewModel"/> class.
        /// </summary>
        /// <param name="sitemapConfigManager">
        /// The _sitemap config manager.
        /// </param>
        public SitemapConfigurationViewModel()
        {
            this.sitemapConfigData = this.sitemapConfigManager.Service.GetFirstData() ?? new SitemapConfigurationDataStore();

            // Load data from DB
            this.RestrictedTypes = this.LoadCurrentPageTypes();
            this.RestrictedSites = this.LoadCurrentSites();
            this.SearchEngines   = this.sitemapConfigData.SearchEngines?.ToList() ?? new List <SearchEngine>();
        }
Exemplo n.º 2
0
        /// <summary>
        /// The generate sitemap.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult GenerateSitemap(SitemapConfigurationViewModel model)
        {
            var data =
                new SitemapConfigurationDataStore()
            {
                RestrictedSites = model.RestrictedSites,
                RestrictedTypes = model.RestrictedTypes,
                SearchEngines   = model.SearchEngines
            };

            this.generator.RefreshSitemapTask(data);
            return(this.Json("Sitemaps generated succesfully!!!", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        /// <summary>
        /// The refresh sitemap task.
        /// </summary>
        /// <param name="dataBase">
        /// The data base.
        /// </param>
        public void RefreshSitemapTask(SitemapConfigurationDataStore dataBase = null)
        {
            LogHelper.Information("START: SitemapHandler.RefreshSitemap", typeof(SitemapGenerator));

            this.sitemapManager.GenerateSiteMaps(dataBase);
            this.sitemapManager.SubmitSitemapToSearchEnginesByHttp();

            var outPutRobots = ConfigurationManager.AppSettings["SiteMap_OutPutRobots_txt"].Trim();

            if (outPutRobots == "1")
            {
                this.sitemapManager.RegisterToRobotsFields();
            }

            LogHelper.Information("END: SitemapHandler.RefreshSitemap", typeof(SitemapGenerator));
        }
Exemplo n.º 4
0
        /// <summary>
        /// The get sites.
        /// </summary>
        /// <param name="dataBase">
        /// The data base.
        /// </param>
        /// <returns>
        /// The <see cref="StringDictionary"/>.
        /// </returns>
        public static StringDictionary GetSites(SitemapConfigurationDataStore dataBase)
        {
            var sites = new StringDictionary();

            if (dataBase.RestrictedSites != null)
            {
                foreach (var site in dataBase.RestrictedSites)
                {
                    if (!site.Restricted && !string.IsNullOrEmpty(site.SiteName) &&
                        !string.IsNullOrEmpty(site.SiteMapFileName))
                    {
                        sites.Add(site.SiteName, site.SiteMapFileName);
                    }
                }
            }

            return(sites);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The generate site maps.
        /// </summary>
        /// <param name="currentDataBase">
        /// The current data base.
        /// </param>
        public void GenerateSiteMaps(SitemapConfigurationDataStore currentDataBase = null)
        {
            LogHelper.Information("START: SitemapManager.SitemapManager", typeof(SitemapGenerator));

            this.dataFromBase = currentDataBase ?? this.sitemapManagerConfigurator.GetFirstData() ?? new SitemapConfigurationDataStore();

            this.sites                         = SitemapManagerConfiguration.GetSites(this.dataFromBase);
            this.maxUrls                       = int.Parse(ConfigurationManager.AppSettings["SiteMap_MAX_URLS"]);
            this.showLocalizedUrls             = bool.Parse(ConfigurationManager.AppSettings["Show_Localized_URLS"]);
            this.displayLocalizedUrlsSeparated = bool.Parse(ConfigurationManager.AppSettings["Display_Localized_URLS_Separated"]);
            this.showTrailingSlash             = bool.Parse(ConfigurationManager.AppSettings["Show_Trailing_Slash"]);

            var languageRep = ServiceLocator.Current.GetInstance <ILanguageBranchRepository>();

            this.defaultLanguage = languageRep.LoadFirstEnabledBranch();

            LogHelper.Information("SitemapManager.SitemapManager: # Sites: " + this.sites.Count, typeof(SitemapGenerator));
            foreach (DictionaryEntry site in this.sites)
            {
                this.BuildSiteMap(site.Key.ToString(), site.Value.ToString());
            }

            LogHelper.Information("END: SitemapManager.SitemapManager", typeof(SitemapGenerator));
        }