/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see>. /// </summary> /// <param name="value">The <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> to search for in the collection.</param> /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns> public bool Contains(SearchItemInfo value) { return List.Contains(value); }
/// <summary> /// Copies the collection objects to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index. /// </summary> /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param> /// <param name="index">The index of the array at which to begin inserting.</param> public void CopyTo(SearchItemInfo[] array, int index) { List.CopyTo(array, index); }
/// <summary> /// Add an element of the specified <see cref="SearchItemInfo">SearchItemInfo</see> to the end of the collection. /// </summary> /// <param name="value">An object of type <see cref="SearchItemInfo">SearchItemInfo</see> to add to the collection.</param> public int Add(SearchItemInfo value) { return List.Add(value); }
/// <summary> /// Add an element of the specified <see cref="SearchItemInfo">SearchItemInfo</see> to the collection at the designated index. /// </summary> /// <param name="index">An <see cref="System.Int32">Integer</see> to indicate the location to add the object to the collection.</param> /// <param name="value">An object of type <see cref="SearchItemInfo">SearchItemInfo</see> to add to the collection.</param> public void Insert(int index, SearchItemInfo value) { List.Insert(index, value); }
/// ----------------------------------------------------------------------------- /// <summary> /// Converts a SearchItemInfo into a SearchDocument. /// /// SearchItemInfo object was used in the old version of search. /// </summary> /// <param name="searchItem"></param> /// <returns></returns> /// <history> /// [vnguyen] 05/16/2013 created /// </history> /// ----------------------------------------------------------------------------- #pragma warning disable 0618 public SearchDocument ConvertSearchItemInfoToSearchDocument(SearchItemInfo searchItem) { var moduleController = new ModuleController(); var module = moduleController.GetModule(searchItem.ModuleId); var searchDoc = new SearchDocument { // Assigns as a Search key the SearchItems' GUID, if not it creates a dummy guid. UniqueKey = (searchItem.SearchKey.Trim() != string.Empty) ? searchItem.SearchKey : Guid.NewGuid().ToString(), QueryString = searchItem.GUID, Title = searchItem.Title, Body = searchItem.Content, Description = searchItem.Description, ModifiedTimeUtc = searchItem.PubDate, AuthorUserId = searchItem.Author, TabId = searchItem.TabId, PortalId = module.PortalID, SearchTypeId = ModuleSearchTypeId, CultureCode = module.CultureCode, //Add Module MetaData ModuleDefId = module.ModuleDefID, ModuleId = module.ModuleID }; return searchDoc; }
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); } //} } }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection(); List<QuickDocsInfo> colQuickDocss = GetQuickDocss(ModInfo.ModuleID); foreach (QuickDocsInfo objQuickDocs in colQuickDocss) { SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objQuickDocs.Content, objQuickDocs.CreatedByUser, objQuickDocs.CreatedDate, ModInfo.ModuleID, objQuickDocs.ItemId.ToString(), objQuickDocs.Content, "ItemId=" + objQuickDocs.ItemId.ToString()); SearchItemCollection.Add(SearchItem); } return SearchItemCollection; }
public static void UpdateSearchItem(SearchItemInfo item) { DataProvider.Instance().UpdateSearchItem(item.SearchItemId, item.Title, item.Description, item.Author, item.PubDate, item.ModuleId, item.SearchKey, item.GUID, item.HitCount, item.ImageFileId); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection(); List<PagesList> colListPagess = new List<PagesList>(); //GetListPagess(ModInfo.ModuleID); foreach (PagesList objListPages in colListPagess) { SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objListPages.Title, objListPages.CreatedByUser, objListPages.CreatedDate, ModInfo.ModuleID, objListPages.PageListId.ToString(), objListPages.Title, "ItemId=" + objListPages.PageListId.ToString()); SearchItemCollection.Add(SearchItem); } return SearchItemCollection; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name = "ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { var objWorkflow = new WorkflowStateController(); int WorkflowID = GetWorkflow(ModInfo.ModuleID, ModInfo.TabID, ModInfo.PortalID).Value; var SearchItemCollection = new SearchItemInfoCollection(); HtmlTextInfo objContent = GetTopHtmlText(ModInfo.ModuleID, true, WorkflowID); if (objContent != null) { //content is encoded in the Database so Decode before Indexing string strContent = HttpUtility.HtmlDecode(objContent.Content); //Get the description string string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strContent, false), MAX_DESCRIPTION_LENGTH, "..."); var SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, strDescription, objContent.LastModifiedByUserID, objContent.LastModifiedOnDate, ModInfo.ModuleID, "", strContent, "", Null.NullInteger); SearchItemCollection.Add(SearchItem); } return SearchItemCollection; }
/// <summary> /// StoreSearchItems adds the Search Item to the Data Store /// </summary> /// <param name="SearchItems">A Collection of SearchItems</param> /// <history> /// [cnurse] 11/15/2004 documented /// </history> public override void StoreSearchItems(SearchItemInfoCollection SearchItems) { int i; //Get the default Search Settings _defaultSettings = Globals.HostSettings; //For now as we don't support Localized content - set the locale to the default locale. This //is to avoid the error in GetDefaultLanguageByModule which artificially limits the number //of modules that can be indexed. This will need to be addressed when we support localized content. Hashtable Modules = new Hashtable(); for (i = 0; i <= SearchItems.Count - 1; i++) { if (!Modules.ContainsKey(SearchItems[i].ModuleId.ToString())) { Modules.Add(SearchItems[i].ModuleId.ToString(), "en-US"); } } //Process the SearchItems by Module to reduce Database hits IDictionaryEnumerator moduleEnumerator = Modules.GetEnumerator(); while (moduleEnumerator.MoveNext()) { int ModuleId = Convert.ToInt32(moduleEnumerator.Key); string Language = Convert.ToString(moduleEnumerator.Value); //Get the Indexed Items that are in the Database for this Module SearchItemInfoCollection IndexedItems = GetSearchItems(ModuleId); //Get the Module's SearchItems to compare SearchItemInfoCollection ModuleItems = SearchItems.ModuleItems(ModuleId); //As we will be potentially removing items from the collection iterate backwards for (int iSearch = ModuleItems.Count - 1; iSearch >= 0; iSearch--) { SearchItemInfo SearchItem = ModuleItems[iSearch]; bool ItemFound = false; //Iterate through Indexed Items foreach (SearchItemInfo IndexedItem in IndexedItems) { //Compare the SearchKeys if (SearchItem.SearchKey == IndexedItem.SearchKey) { //Item exists so compare Dates to see if modified if (IndexedItem.PubDate < SearchItem.PubDate) { try { //Content modified so update SearchItem and delete item's Words Collection SearchItem.SearchItemId = IndexedItem.SearchItemId; SearchDataStoreController.UpdateSearchItem(SearchItem); SearchDataStoreController.DeleteSearchItemWords(SearchItem.SearchItemId); // re-index the content AddIndexWords(SearchItem.SearchItemId, SearchItem, Language); } catch (Exception ex) { //Log Exception Exceptions.Exceptions.LogException(ex); } } //Remove Items from both collections IndexedItems.Remove(IndexedItem); ModuleItems.Remove(SearchItem); //Exit the Iteration as Match found ItemFound = true; break; } } if (!ItemFound) { try { //Item doesn't exist so Add to Index int IndexID = SearchDataStoreController.AddSearchItem(SearchItem); // index the content AddIndexWords(IndexID, SearchItem, Language); } catch (Exception) { //Log Exception //LogException(ex) ** this exception has been suppressed because it fills up the event log with duplicate key errors - we still need to understand what causes it though } } } //As we removed the IndexedItems as we matched them the remaining items are deleted Items //ie they have been indexed but are no longer present Hashtable ht = new Hashtable(); foreach (SearchItemInfo IndexedItem in IndexedItems) { try { //dedupe if (ht[IndexedItem.SearchItemId] == null) { SearchDataStoreController.DeleteSearchItem(IndexedItem.SearchItemId); ht.Add(IndexedItem.SearchItemId, 0); } } catch (Exception ex) { //Log Exception Exceptions.Exceptions.LogException(ex); } } } }
/// <summary> /// AddIndexWords adds the Index Words to the Data Store /// </summary> /// <param name="indexId">The Id of the SearchItem</param> /// <param name="searchItem">The SearchItem</param> /// <param name="language">The Language of the current Item</param> /// <history> /// [cnurse] 11/15/2004 documented /// [cnurse] 11/16/2004 replaced calls to separate content clean-up /// functions with new call to HtmlUtils.Clean(). /// replaced logic to determine whether word should /// be indexed by call to CanIndexWord() /// </history> private void AddIndexWords(int indexId, SearchItemInfo searchItem, string language) { Hashtable IndexWords = new Hashtable(); Hashtable IndexPositions = new Hashtable(); //Get the Settings for this Module _settings = SearchDataStoreController.GetSearchSettings(searchItem.ModuleId); if (_settings == null) { //Try Host Settings _settings = Globals.HostSettings; } string setting = GetSetting("MaxSearchWordLength"); if (!String.IsNullOrEmpty(setting)) { maxWordLength = int.Parse(setting); } setting = GetSetting("MinSearchWordLength"); if (!String.IsNullOrEmpty(setting)) { minWordLength = int.Parse(setting); } setting = GetSetting("SearchIncludeCommon"); if (setting == "Y") { includeCommon = true; } setting = GetSetting("SearchIncludeNumeric"); if (setting == "N") { includeNumbers = false; } string Content = searchItem.Content; // clean content Content = HtmlUtils.Clean(Content, true); Content = Content.ToLower(); //' split content into words string[] ContentWords = Content.Split(' '); // process each word int intWord = 0; string strWord; foreach (string tempLoopVar_strWord in ContentWords) { strWord = tempLoopVar_strWord; if (CanIndexWord(strWord, language)) { intWord++; if (IndexWords.ContainsKey(strWord) == false) { IndexWords.Add(strWord, 0); IndexPositions.Add(strWord, 1); } // track number of occurrences of word in content IndexWords[strWord] = Convert.ToInt32(IndexWords[strWord]) + 1; // track positions of word in content IndexPositions[strWord] = Convert.ToString(IndexPositions[strWord]) + "," + intWord.ToString(); } } // get list of words ( non-common ) Hashtable Words = GetSearchWords(); // this could be cached int WordId; //' iterate through each indexed word object objWord; foreach (object tempLoopVar_objWord in IndexWords.Keys) { objWord = tempLoopVar_objWord; strWord = Convert.ToString(objWord); if (Words.ContainsKey(strWord)) { // word is in the DataStore WordId = Convert.ToInt32(Words[strWord]); } else { // add the word to the DataStore WordId = DataProvider.Instance().AddSearchWord(strWord); Words.Add(strWord, WordId); } // add the indexword int SearchItemWordID = DataProvider.Instance().AddSearchItemWord(indexId, WordId, Convert.ToInt32(IndexWords[strWord])); DataProvider.Instance().AddSearchItemWordPosition(SearchItemWordID, Convert.ToString(IndexPositions[strWord])); } }
public static int AddSearchItem(SearchItemInfo item) { return(Null.NullInteger); }
/// <summary> /// Initializes a new instance of the <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> class containing the specified array of <see cref="SearchItemInfo">SearchItemInfo</see> objects. /// </summary> /// <param name="value">An array of <see cref="SearchItemInfo">SearchItemInfo</see> objects with which to initialize the collection. </param> public SearchItemInfoCollection(SearchItemInfo[] value) { AddRange(value); }
public static int AddSearchItem(SearchItemInfo item) { return(DataProvider.Instance().AddSearchItem(item.Title, item.Description, item.Author, item.PubDate, item.ModuleId, item.SearchKey, item.GUID, item.ImageFileId)); }
public SearchException(string message, Exception inner, SearchItemInfo searchItem) : base(message, inner) { m_SearchItem = searchItem; }
public static SearchItemInfo GetSearchItem(int ModuleId, string SearchKey) { var empty = new SearchItemInfo(); return(empty); }
public static SearchItemInfo GetSearchItem(int ModuleId, string SearchKey) { var empty=new SearchItemInfo(); return empty; }
/// <summary> /// Gets the index in the collection of the specified <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> to locate in the collection.</param> /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns> public int IndexOf(SearchItemInfo value) { return(List.IndexOf(value)); }
public static void UpdateSearchItem(SearchItemInfo item) { }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection(); List<DocumentsExchangeModuleInfo> colDocumentsExchangeModules = GetDocumentsExchangeModulesByUser(ModInfo.ModuleID, ModInfo.CreatedByUserID); foreach (DocumentsExchangeModuleInfo objDocumentsExchangeModule in colDocumentsExchangeModules) { SearchItemInfo searchItem = new SearchItemInfo(ModInfo.ModuleTitle, objDocumentsExchangeModule.Content, objDocumentsExchangeModule.CreatedByUser, objDocumentsExchangeModule.CreatedDate, ModInfo.ModuleID, objDocumentsExchangeModule.ItemId.ToString(), objDocumentsExchangeModule.Content, "ItemId=" + objDocumentsExchangeModule.ItemId.ToString()); SearchItemCollection.Add(searchItem); } return SearchItemCollection; }
/// <summary> /// Remove the specified object of type <see cref="SearchItemInfo">SearchItemInfo</see> from the collection. /// </summary> /// <param name="value">An object of type <see cref="SearchItemInfo">SearchItemInfo</see> to remove to the collection.</param> public void Remove(SearchItemInfo value) { List.Remove(value); }
/// <summary> /// Gets the index in the collection of the specified <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> to locate in the collection.</param> /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns> public int IndexOf(SearchItemInfo value) { return List.IndexOf(value); }
/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see>. /// </summary> /// <param name="value">The <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> to search for in the collection.</param> /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns> public bool Contains(SearchItemInfo value) { return(List.Contains(value)); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <param name="modInfo">The ModuleInfo for the module to be Indexed</param> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { var searchItemCollection = new SearchItemInfoCollection(); List<Article> colArticles = ArticleController.GetArticles(modInfo.ModuleID); foreach (Article objArticle in colArticles) { var searchItem = new SearchItemInfo(objArticle.Title, DotNetNuke.Common.Utilities.HtmlUtils.StripTags(HttpUtility.HtmlDecode(objArticle.Description),false), objArticle.CreatedByUserID, objArticle.LastModifiedOnDate, modInfo.ModuleID, objArticle.ArticleId.ToString(), DotNetNuke.Common.Utilities.HtmlUtils.StripTags(HttpUtility.HtmlDecode(objArticle.Body),false), "aid=" + objArticle.ArticleId); searchItemCollection.Add(searchItem); } return searchItemCollection; }
/// <summary> /// Copies the elements of the specified <see cref="SearchItemInfo">SearchItemInfo</see> array to the end of the collection. /// </summary> /// <param name="value">An array of type <see cref="SearchItemInfo">SearchItemInfo</see> containing the objects to add to the collection.</param> public void AddRange(SearchItemInfo[] value) { for (int i = 0; i <= value.Length - 1; i++) { Add(value[i]); } }
/// <summary> /// Add an element of the specified <see cref="SearchItemInfo">SearchItemInfo</see> to the end of the collection. /// </summary> /// <param name="value">An object of type <see cref="SearchItemInfo">SearchItemInfo</see> to add to the collection.</param> public int Add(SearchItemInfo value) { return(List.Add(value)); }
/// <summary> /// Creates a one-dimensional <see cref="T:System.Array">Array</see> instance containing the collection items. /// </summary> /// <returns>Array of type SearchItemInfo</returns> public SearchItemInfo[] ToArray() { var arr = new SearchItemInfo[Count]; CopyTo(arr, 0); return arr; }
/// <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; } }
public static int AddSearchItem(SearchItemInfo item) { return Null.NullInteger; }
/// <summary> /// Implements the search interface required to allow DNN to index/search the content of your /// module /// </summary> /// <param name="modInfo"></param> /// <returns></returns> public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { var searchItems = new SearchItemInfoCollection(); var infos = GetExpandableTextHtmls(modInfo.ModuleID, "ORDER BY LastUpdated"); //Add each item from the contents into the search index foreach (var info in infos) { var searchInfo = new SearchItemInfo(modInfo.ModuleTitle, info.Title, 2, info.LastUpdated, modInfo.ModuleID, info.ItemId.ToString(), info.Body); searchItems.Add(searchInfo); } return searchItems; }
/// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { Hashtable moduleSettings = Entities.Portals.PortalSettings.GetModuleSettings(ModInfo.ModuleID); int descriptionLength = 100; if (Convert.ToString(moduleSettings["descriptionLength"]) != "") { descriptionLength = int.Parse(Convert.ToString(moduleSettings["descriptionLength"])); if (descriptionLength < 1) { descriptionLength = 1950; //max length of description is 2000 char, take a bit less to make sure it fits... } } var searchItemCollection = new SearchItemInfoCollection(); IEnumerable<AnnouncementInfo> announcements = GetCurrentAnnouncements(ModInfo.ModuleID, Null.NullDate); foreach (AnnouncementInfo objAnnouncement in announcements) { var tempVar = objAnnouncement; string strContent = System.Web.HttpUtility.HtmlDecode(tempVar.Title + " " + tempVar.Description); string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(tempVar.Description), false), descriptionLength, "..."); var searchItem = new SearchItemInfo(ModInfo.ModuleTitle + " - " + tempVar.Title, strDescription, tempVar.CreatedByUserID, tempVar.PublishDate.Value, ModInfo.ModuleID, tempVar.ItemID.ToString(CultureInfo.InvariantCulture), strContent, "ItemID=" + tempVar.ItemID.ToString(CultureInfo.InvariantCulture)); searchItemCollection.Add(searchItem); } return searchItemCollection; }
public static int AddSearchItem(SearchItemInfo item) { return DataProvider.Instance().AddSearchItem(item.Title, item.Description, item.Author, item.PubDate, item.ModuleId, item.SearchKey, item.GUID, item.ImageFileId); }
/// <Summary> /// Creates a one-dimensional Array instance containing the collection items. /// </Summary> /// <Returns>Array of type SearchItemInfo</Returns> public SearchItemInfo[] ToArray() { SearchItemInfo[] arr = new SearchItemInfo[( ( this.Count - 1 ) + 1 )]; arr = ( (SearchItemInfo[])Utils.CopyArray( ( (Array)arr ), ( (Array)new SearchItemInfo[( ( this.Count - 1 ) + 1 )] ) ) ); this.CopyTo( arr, 0 ); return arr; }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection(); List<ATI_CompAdminInfo> colATI_CompAdmins = GetATI_CompAdmins(ModInfo.ModuleID); foreach (ATI_CompAdminInfo objATI_CompAdmin in colATI_CompAdmins) { if(objATI_CompAdmin != null) { SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objATI_CompAdmin.Content, objATI_CompAdmin.CreatedByUser, objATI_CompAdmin.CreatedDate, ModInfo.ModuleID, objATI_CompAdmin.ItemId.ToString(), objATI_CompAdmin.Content, "ItemId=" + objATI_CompAdmin.ItemId.ToString()); SearchItemCollection.Add(SearchItem); } } return SearchItemCollection; }
/// <summary> /// Gets the search items. /// </summary> /// <param name="modInfo">The module information.</param> /// <returns>Topics that meet the search criteria.</returns> public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { using (UnitOfWork uOw = new UnitOfWork()) { TopicBO topicBo = new TopicBO(uOw); SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection(); var topics = topicBo.GetAllByModuleID(modInfo.ModuleID); UserController uc = new UserController(); foreach (var topic in topics) { SearchItemInfo searchItem = new SearchItemInfo(); string strContent = null; string strDescription = null; string strTitle = null; if (!string.IsNullOrWhiteSpace(topic.Title)) { strTitle = topic.Title; } else { strTitle = topic.Name; } if (topic.Cache != null) { strContent = topic.Cache; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } else { strContent = topic.Content; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } int userID = 0; userID = Null.NullInteger; if (topic.UpdatedByUserID != -9999) { userID = topic.UpdatedByUserID; } searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name)); //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription, //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _ //// "topic=" & WikiMarkup.EncodeTitle(topic.Name)) searchItemCollection.Add(searchItem); } return searchItemCollection; } }
/// <summary> /// Implements the search interface required to allow DNN to index/search the content of your /// module /// </summary> /// <param name="modInfo"></param> /// <returns></returns> public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { SearchItemInfoCollection searchItems = new SearchItemInfoCollection(); List<testInfo> infos = Gettests(modInfo.ModuleID); foreach (testInfo info in infos) { SearchItemInfo searchInfo = new SearchItemInfo(modInfo.ModuleTitle, info.Content, info.CreatedByUser, info.CreatedDate, modInfo.ModuleID, info.ItemId.ToString(), info.Content, "Item=" + info.ItemId.ToString()); searchItems.Add(searchInfo); } return searchItems; }
/// ----------------------------------------------------------------------------- /// <summary> /// Implements the search interface for DotNetNuke /// </summary> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { var searchItemCollection = new SearchItemInfoCollection(); var udtController = new UserDefinedTableController(modInfo); try { var dsUserDefinedRows = udtController.GetDataSet(withPreRenderedValues: false); //Get names of ChangedBy and ChangedAt columns var colnameChangedBy = udtController.ColumnNameByDataType(dsUserDefinedRows, DataTypeNames.UDT_DataType_ChangedBy); var colnameChangedAt = udtController.ColumnNameByDataType(dsUserDefinedRows, DataTypeNames.UDT_DataType_ChangedAt); var moduleController = new ModuleController(); var settings = moduleController.GetModuleSettings(modInfo.ModuleID); var includeInSearch = !(settings[SettingName.ExcludeFromSearch].AsBoolean()); if (includeInSearch) { foreach (DataRow row in dsUserDefinedRows.Tables[DataSetTableName.Data].Rows) { var changedDate = DateTime.Today; var changedByUserId = 0; if (colnameChangedAt != string.Empty && ! Information.IsDBNull(row[colnameChangedAt])) { changedDate = Convert.ToDateTime(row[colnameChangedAt]); } if (colnameChangedBy != string.Empty && ! Information.IsDBNull(row[colnameChangedBy])) { changedByUserId = ModuleSecurity.UserId(row[colnameChangedBy].ToString(), modInfo.PortalID); } var desc = string.Empty; foreach (DataRow col in dsUserDefinedRows.Tables[DataSetTableName.Fields].Rows) { var fieldType = col[FieldsTableColumn.Type].ToString(); var fieldTitle = col[FieldsTableColumn.Title].ToString(); var visible = Convert.ToBoolean(col[FieldsTableColumn.Visible]); if (visible && (fieldType.StartsWith("Text") || fieldType == DataTypeNames.UDT_DataType_String)) { desc += string.Format("{0} • ", Convert.ToString(row[fieldTitle])); } } if (desc.EndsWith("<br/>")) { desc = desc.Substring(0, Convert.ToInt32(desc.Length - 5)); } var searchItem = new SearchItemInfo(modInfo.ModuleTitle, desc, changedByUserId, changedDate, modInfo.ModuleID, row[DataTableColumn.RowId].ToString(), desc); searchItemCollection.Add(searchItem); } } } catch (Exception ex) { Exceptions.LogException(ex); } return searchItemCollection; }