/// <summary> /// This method is called when the site index is rebuilt /// </summary> /// <param name="pageSettings"></param> /// <param name="indexPath"></param> public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if (pageSettings == null) { if (log.IsErrorEnabled) { log.Error("pageSettings object passed to OfferSearchIndexBuilder.RebuildIndex was null"); } return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info(Resources.WebStoreResources.WebStoreName + " indexing page - " + pageSettings.PageName); Guid webStoreFeatureGuid = new Guid("0cefbf18-56de-11dc-8f36-bac755d89593"); ModuleDefinition webStoreFeature = new ModuleDefinition(webStoreFeatureGuid); List <PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); // adding a try catch here because this is invoked even for non-implemented db platforms and it causes an error try { DataTable dataTable = Offer.GetBySitePage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"], CultureInfo.InvariantCulture); Hashtable moduleSettings = ModuleSettings.GetModuleSettings(indexItem.ModuleId); WebStoreConfiguration config = new WebStoreConfiguration(); if (moduleSettings != null) { config = new WebStoreConfiguration(moduleSettings); } if (!config.IndexOffersInSearch) { continue; } indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = webStoreFeatureGuid.ToString(); indexItem.FeatureName = webStoreFeature.FeatureName; indexItem.FeatureResourceFile = webStoreFeature.ResourceFile; indexItem.ItemKey = row["Guid"].ToString(); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Name"].ToString(); indexItem.ViewPage = row["Url"].ToString().Replace("/", string.Empty); if (indexItem.ViewPage.Length > 0) { indexItem.UseQueryStringParams = false; } else { indexItem.ViewPage = "WebStore/OfferDetail.aspx"; } indexItem.PageMetaDescription = row["MetaDescription"].ToString(); indexItem.PageMetaKeywords = row["MetaKeywords"].ToString(); indexItem.CreatedUtc = Convert.ToDateTime(row["Created"]); indexItem.LastModUtc = Convert.ToDateTime(row["LastModified"]); indexItem.Content = row["Abstract"].ToString() + " " + row["Description"].ToString() + " " + row["MetaDescription"].ToString() + " " + row["MetaKeywords"].ToString(); // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) { log.Debug("Indexed " + indexItem.Title); } } } catch { } }
/// <summary> /// This method is called when the site index is rebuilt /// </summary> /// <param name="pageSettings"></param> /// <param name="indexPath"></param> public override void RebuildIndex( PageSettings pageSettings, string indexPath) { if (WebConfigSettings.DisableSearchIndex) { return; } if (pageSettings == null) { if (log.IsErrorEnabled) { log.Error("pageSettings object passed to OfferSearchIndexBuilder.RebuildIndex was null"); } return; } //don't index pending/unpublished pages if (pageSettings.IsPending) { return; } log.Info("ProductSearchIndexBuilder indexing page - " + pageSettings.PageName); Guid webStoreFeatureGuid = new Guid("0cefbf18-56de-11dc-8f36-bac755d89593"); ModuleDefinition webStoreFeature = new ModuleDefinition(webStoreFeatureGuid); List<PageModule> pageModules = PageModule.GetPageModulesByPage(pageSettings.PageId); // adding a try catch here because this is invoked even for non-implemented db platforms and it causes an error try { DataTable dataTable = Offer.GetBySitePage( pageSettings.SiteId, pageSettings.PageId); foreach (DataRow row in dataTable.Rows) { mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); indexItem.ModuleId = Convert.ToInt32(row["ModuleID"], CultureInfo.InvariantCulture); Hashtable moduleSettings = ModuleSettings.GetModuleSettings(indexItem.ModuleId); WebStoreConfiguration config = new WebStoreConfiguration(); if (moduleSettings != null) { config = new WebStoreConfiguration(moduleSettings); } if (!config.IndexOffersInSearch) { continue; } indexItem.SiteId = pageSettings.SiteId; indexItem.PageId = pageSettings.PageId; indexItem.PageName = pageSettings.PageName; indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = row["ViewRoles"].ToString(); indexItem.FeatureId = webStoreFeatureGuid.ToString(); indexItem.FeatureName = webStoreFeature.FeatureName; indexItem.FeatureResourceFile = webStoreFeature.ResourceFile; indexItem.ItemKey = row["Guid"].ToString(); indexItem.ModuleTitle = row["ModuleTitle"].ToString(); indexItem.Title = row["Name"].ToString(); indexItem.ViewPage = row["Url"].ToString().Replace("/", string.Empty); if (indexItem.ViewPage.Length > 0) { indexItem.UseQueryStringParams = false; } else { indexItem.ViewPage = "WebStore/OfferDetail.aspx"; } indexItem.PageMetaDescription = row["MetaDescription"].ToString(); indexItem.PageMetaKeywords = row["MetaKeywords"].ToString(); indexItem.CreatedUtc = Convert.ToDateTime(row["Created"]); indexItem.LastModUtc = Convert.ToDateTime(row["LastModified"]); indexItem.Content = row["Abstract"].ToString() + " " + row["Description"].ToString() + " " + row["MetaDescription"].ToString() + " " + row["MetaKeywords"].ToString(); // lookup publish dates foreach (PageModule pageModule in pageModules) { if (indexItem.ModuleId == pageModule.ModuleId) { indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; } } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath); if (debugLog) log.Debug("Indexed " + indexItem.Title); } } catch { } }