public void OnPostPublish(Asset asset, PostPublishContext context) { context.RenderPublishLinks = true; using (var Logger = new CrownPeak.CMSAPI.CustomLibrary.UtilLogLogger("SitemapIndex.OnPostPublish", asset)) { foreach (var panel in asset.GetPanels("sitemap_roots")) { var sitemapAssetsList = new List <Asset>(); if (string.IsNullOrEmpty(panel["sitemap_asset"]) == false) { Asset sitemapAsset = Asset.Load(panel["sitemap_asset"]); if (sitemapAsset.IsLoaded == true) { sitemapAssetsList.Add(sitemapAsset); } } if (string.IsNullOrEmpty(panel["multi_sitemap_root_path"]) == false && string.IsNullOrEmpty(panel["multi_sitemap_template_id"]) == false) { try { FilterParams fp = new FilterParams(); fp.Add(AssetPropertyNames.TemplateId, Comparison.Equals, int.Parse(panel["multi_sitemap_template_id"])); Asset rootfolder = Asset.Load(panel["multi_sitemap_root_path"]); var foundAssets = rootfolder.GetFilterList(fp); sitemapAssetsList.AddRange(foundAssets); } catch (Exception) { } } Logger.Info("sitemapAssetsList count is '{0}'.", sitemapAssetsList.Count); foreach (var sitemapAsset in sitemapAssetsList) { if (sitemapAsset.IsLoaded) { sitemapAsset.Publish(publishDependencies: false); string sitemapUrl = sitemapAsset.GetLink(addDomain: true, protocolType: ProtocolType.Https); Logger.Info("Ping search engines for '{0}'.", sitemapUrl); var sitemapsPinger = new CPContrib.SiteMap.SitemapsPinger(Logger); sitemapsPinger.Ping(sitemapUrl); } } } } //Logger.Flush(); }
public void OnPostPublish(Asset asset, PostPublishContext context) { Log = new UtilLogLogger("SiteMap_PostPublish", asset); Log.Info("Beginning post_publish"); Asset sitemapAsset = asset; if (asset.Raw["sitemap_usedbyindex"] != "") { sitemapAsset = Asset.Load(asset.Raw["sitemap_usedbyindex"]); } string sitemapUrl = sitemapAsset.GetLink(addDomain: true, protocolType: ProtocolType.Https); var sitemapsPinger = new CPContrib.SiteMap.SitemapsPinger(Log); sitemapsPinger.Ping(sitemapUrl); Log.Flush(); }