Esempio n. 1
0
        private static void SearchArticleIndex(DataTable dt, SearchItemInfoCollection items, ModuleInfo modInfo)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row             = dt.Rows[i];
                var     searchedContent = new StringBuilder(8192);
                //article name
                string name = HtmlUtils.Clean(row["Name"].ToString().Trim(), false);

                if (Utility.HasValue(name))
                {
                    searchedContent.AppendFormat("{0}{1}", name, " ");
                }
                else
                {
                    //do we bother with the rest?
                    continue;
                }

                //article text
                string articleText = row["ArticleText"].ToString().Trim();
                if (Utility.HasValue(articleText))
                {
                    searchedContent.AppendFormat("{0}{1}", articleText, " ");
                }

                //article description
                string description = row["Description"].ToString().Trim();
                if (Utility.HasValue(description))
                {
                    searchedContent.AppendFormat("{0}{1}", description, " ");
                }

                //article metakeyword
                string keyword = row["MetaKeywords"].ToString().Trim();
                if (Utility.HasValue(keyword))
                {
                    searchedContent.AppendFormat("{0}{1}", keyword, " ");
                }

                //article metadescription
                string metaDescription = row["MetaDescription"].ToString().Trim();
                if (Utility.HasValue(metaDescription))
                {
                    searchedContent.AppendFormat("{0}{1}", metaDescription, " ");
                }

                //article metatitle
                string metaTitle = row["MetaTitle"].ToString().Trim();
                if (Utility.HasValue(metaTitle))
                {
                    searchedContent.AppendFormat("{0}{1}", metaTitle, " ");
                }

                string itemId = row["ItemId"].ToString();
                var    item   = new SearchItemInfo
                {
                    Title       = name,
                    Description = HtmlUtils.Clean(description, false),
                    Author      = Convert.ToInt32(row["AuthorUserId"], CultureInfo.InvariantCulture),
                    PubDate     = Convert.ToDateTime(row["LastUpdated"], CultureInfo.InvariantCulture),
                    ModuleId    = modInfo.ModuleID,
                    SearchKey   = "Article-" + itemId,
                    Content     =
                        HtmlUtils.StripWhiteSpace(
                            HtmlUtils.Clean(searchedContent.ToString(), false), true),
                    GUID = "itemid=" + itemId
                };

                items.Add(item);

                //Check if the Portal is setup to enable venexus indexing
                if (ModuleBase.AllowVenexusSearchForPortal(modInfo.PortalID))
                {
                    string indexUrl = Utility.GetItemLinkUrl(Convert.ToInt32(itemId, CultureInfo.InvariantCulture), modInfo.PortalID, modInfo.TabID, modInfo.ModuleID);

                    //UpdateVenexusBraindump(IDbTransaction trans, string indexTitle, string indexContent, string indexWashedContent)
                    Data.DataProvider.Instance().UpdateVenexusBraindump(Convert.ToInt32(itemId, CultureInfo.InvariantCulture), name, articleText, HtmlUtils.Clean(articleText, false), modInfo.PortalID, indexUrl);
                }
                //}
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the search items for the module's articles.
        /// </summary>
        /// <returns>The collection of search items for the <see cref="Module"/>'s articles</returns>
        private IEnumerable <SearchItemInfo> GetSearchItemsImpl()
        {
            var articlesTable = Article.GetArticlesByModuleId(this.Module.ModuleID, true);

            foreach (DataRow row in articlesTable.Rows)
            {
                var searchedContent = new StringBuilder(8192);

                // article name
                string name = HtmlUtils.Clean(row["Name"].ToString().Trim(), false);

                if (Engage.Utility.HasValue(name))
                {
                    searchedContent.AppendFormat("{0}{1}", name, " ");
                }
                else
                {
                    // do we bother with the rest?
                    continue;
                }

                // article text
                string articleText = row["ArticleText"].ToString().Trim();
                if (Engage.Utility.HasValue(articleText))
                {
                    searchedContent.AppendFormat("{0}{1}", articleText, " ");
                }

                // article description
                string description = row["Description"].ToString().Trim();
                if (Engage.Utility.HasValue(description))
                {
                    searchedContent.AppendFormat("{0}{1}", description, " ");
                }

                // article metakeyword
                string keyword = row["MetaKeywords"].ToString().Trim();
                if (Engage.Utility.HasValue(keyword))
                {
                    searchedContent.AppendFormat("{0}{1}", keyword, " ");
                }

                // article metadescription
                string metaDescription = row["MetaDescription"].ToString().Trim();
                if (Engage.Utility.HasValue(metaDescription))
                {
                    searchedContent.AppendFormat("{0}{1}", metaDescription, " ");
                }

                // article metatitle
                string metaTitle = row["MetaTitle"].ToString().Trim();
                if (Engage.Utility.HasValue(metaTitle))
                {
                    searchedContent.AppendFormat("{0}{1}", metaTitle, " ");
                }

                string itemId = row["ItemId"].ToString();
                var    item   = new SearchItemInfo
                {
                    Title       = name,
                    Description = HtmlUtils.Clean(description, false),
                    Author      = Convert.ToInt32(row["AuthorUserId"], CultureInfo.InvariantCulture),
                    PubDate     = Convert.ToDateTime(row["LastUpdated"], CultureInfo.InvariantCulture),
                    ModuleId    = this.Module.ModuleID,
                    SearchKey   = "Article-" + itemId,
                    Content     = HtmlUtils.StripWhiteSpace(HtmlUtils.Clean(searchedContent.ToString(), false), true),
                };

                if (this.SetGuid)
                {
                    item.GUID = "itemid=" + itemId;
                }

                if (ModuleBase.AllowVenexusSearchForPortal(this.Module.PortalID))
                {
                    string indexUrl = UrlGenerator.GetItemLinkUrl(
                        Convert.ToInt32(itemId, CultureInfo.InvariantCulture),
                        Utility.GetPortalSettings(this.Module.PortalID),
                        this.Module.TabID,
                        this.Module.ModuleID);

                    // UpdateVenexusBraindump(IDbTransaction trans, string indexTitle, string indexContent, string indexWashedContent)
                    DataProvider.Instance().UpdateVenexusBraindump(
                        Convert.ToInt32(itemId, CultureInfo.InvariantCulture),
                        name,
                        articleText,
                        HtmlUtils.Clean(articleText, false),
                        this.Module.PortalID,
                        indexUrl);
                }

                yield return(item);
            }
        }