Пример #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchIndexItems gets the SearchInfo Items for the Portal
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="PortalID">The Id of the Portal</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        ///     [vnguyen]   09/07/2010  Modified: Included logic to add TabId to searchItems
        /// </history>
        /// -----------------------------------------------------------------------------
        public override SearchItemInfoCollection GetSearchIndexItems(int PortalID)
        {
            var SearchItems = new SearchItemInfoCollection();
            SearchContentModuleInfoCollection SearchCollection = GetModuleList(PortalID);
            foreach (SearchContentModuleInfo ScModInfo in SearchCollection)
            {
                try
                {
                    SearchItemInfoCollection myCollection;
                    myCollection = ScModInfo.ModControllerType.GetSearchItems(ScModInfo.ModInfo);
                    if (myCollection != null)
                    {
                        foreach (SearchItemInfo searchItem in myCollection)
                        {
                            searchItem.TabId = ScModInfo.ModInfo.TabID;
                        }

                        SearchItems.AddRange(myCollection);
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.Exceptions.LogException(ex);
                }
            }
            return SearchItems;
        }
Пример #2
0
        /// <Summary>
        /// GetContent gets the Portal's content and passes it to the Indexer
        /// </Summary>
        /// <Param name="PortalID">The Id of the Portal</Param>
        /// <Param name="Indexer">
        /// The Index Provider that will index the content of the portal
        /// </Param>
        protected SearchItemInfoCollection GetContent( int PortalID, IndexingProvider Indexer )
        {
            SearchItemInfoCollection SearchItems = new SearchItemInfoCollection();

            SearchItems.AddRange(Indexer.GetSearchIndexItems(PortalID));

            return SearchItems;
        }
Пример #3
0
        private static void AddArticleSearchItems(SearchItemInfoCollection items, ModuleInfo modInfo)
        {
            //get all the updated items
            //DataTable dt = Article.GetArticlesSearchIndexingUpdated(modInfo.PortalID, modInfo.ModuleDefID, modInfo.TabID);

            //TODO: we should get articles by ModuleID and only perform indexing by ModuleID
            DataTable dt = Article.GetArticles(modInfo.PortalID);
            SearchArticleIndex(dt, items, modInfo);
        }
        /// <summary>
        /// Gets a collection of <see cref="SearchItemInfo"/> instances, describing the job openings that can be viewed in the given Job Details module.
        /// </summary>
        /// <param name="modInfo">Information about the module instance for which jobs should be returned.</param>
        /// <returns>A collection of <see cref="SearchItemInfo"/> instances</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            if (modInfo == null)
            {
                throw new ArgumentNullException("modInfo", @"modInfo must not be null.");
            }

            var searchItems = new SearchItemInfoCollection();

            // only index the JobDetail module definition (since most of this information is only viewable there,
            // and because the Guid parameter on the SearchItemInfo ("jobid=" + jobid) gets put on the querystring to make it work all automagically).  BD
            if (ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefinition.JobDetail.ToString(), modInfo.DesktopModuleID).ModuleDefID == modInfo.ModuleDefID
                && ModuleSettings.JobDetailEnableDnnSearch.GetValueAsBooleanFor(DesktopModuleName, modInfo, ModuleSettings.JobDetailEnableDnnSearch.DefaultValue))
            {
                int? jobGroupId = ModuleSettings.JobGroupId.GetValueAsInt32For(DesktopModuleName, modInfo, ModuleSettings.JobGroupId.DefaultValue);

                using (IDataReader jobs = DataProvider.Instance().GetJobs(jobGroupId, modInfo.PortalID))
                {
                    while (jobs.Read())
                    {
                        if (!(bool)jobs["IsFilled"])
                        {
                            string jobId = ((int)jobs["JobId"]).ToString(CultureInfo.InvariantCulture);
                            string searchDescription = HtmlUtils.StripWhiteSpace(HtmlUtils.Clean((string)jobs["JobDescription"], false), true);
                            string searchItemTitle = string.Format(
                                CultureInfo.CurrentCulture,
                                Utility.GetString("JobInLocation", LocalResourceFile, modInfo.PortalID),
                                (string)jobs["JobTitle"],
                                (string)jobs["LocationName"],
                                (string)jobs["StateName"]);

                            string searchedContent =
                                HtmlUtils.StripWhiteSpace(
                                    HtmlUtils.Clean(
                                        (string)jobs["JobTitle"] + " " + (string)jobs["JobDescription"] + " " + (string)jobs["RequiredQualifications"] +
                                        " " + (string)jobs["DesiredQualifications"],
                                        false),
                                    true);

                            searchItems.Add(
                                new SearchItemInfo(
                                    searchItemTitle,
                                    searchDescription,
                                    (int)jobs["RevisingUser"],
                                    (DateTime)jobs["RevisionDate"],
                                    modInfo.ModuleID,
                                    jobId,
                                    searchedContent,
                                    "jobid=" + jobId));
                        }
                    }
                }
            }

            return searchItems;
        }
Пример #5
0
        public SearchItemInfoCollection ModuleItems(int ModuleId)
        {
            var retValue = new SearchItemInfoCollection();

            foreach (SearchItemInfo info in this)
            {
                if (info.ModuleId == ModuleId)
                {
                    retValue.Add(info);
                }
            }
            return(retValue);
        }
Пример #6
0
        protected SearchItemInfoCollection GetContent(IndexingProviderBase indexer)
        {
            var searchItems = new SearchItemInfoCollection();
            var portals     = PortalController.Instance.GetPortals();

            for (var index = 0; index <= portals.Count - 1; index++)
            {
                var portal = (PortalInfo)portals[index];
                searchItems.AddRange(indexer.GetSearchIndexItems(portal.PortalID));
            }

            return(searchItems);
        }
        /// -----------------------------------------------------------------------------
        /// <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;
        }
Пример #8
0
        protected SearchItemInfoCollection GetContent(IndexingProvider indexer)
        {
            var searchItems = new SearchItemInfoCollection();
            var objPortals  = new PortalController();
            var arrPortals  = objPortals.GetPortals();
            int intPortal;

            for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++)
            {
                var objPortal = (PortalInfo)arrPortals[intPortal];
                searchItems.AddRange(indexer.GetSearchIndexItems(objPortal.PortalID));
            }
            return(searchItems);
        }
Пример #9
0
        /// <Summary>
        /// GetContent gets all the content and passes it to the Indexer
        /// </Summary>
        /// <Param name="Indexer">
        /// The Index Provider that will index the content of the portal
        /// </Param>
        protected SearchItemInfoCollection GetContent( IndexingProvider Indexer )
        {
            SearchItemInfoCollection SearchItems = new SearchItemInfoCollection();
            PortalController objPortals = new PortalController();
            PortalInfo objPortal;

            ArrayList arrPortals = objPortals.GetPortals();
            int intPortal;
            for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++)
            {
                objPortal = (PortalInfo)arrPortals[intPortal];

                SearchItems.AddRange(Indexer.GetSearchIndexItems(objPortal.PortalID));
            }
            return SearchItems;
        }
Пример #10
0
        /// <Summary>
        /// GetContent gets all the content and passes it to the Indexer
        /// </Summary>
        /// <Param name="Indexer">
        /// The Index Provider that will index the content of the portal
        /// </Param>
        protected SearchItemInfoCollection GetContent(IndexingProvider Indexer)
        {
            SearchItemInfoCollection SearchItems = new SearchItemInfoCollection();
            PortalController         objPortals  = new PortalController();
            PortalInfo objPortal;

            ArrayList arrPortals = objPortals.GetPortals();
            int       intPortal;

            for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++)
            {
                objPortal = (PortalInfo)arrPortals[intPortal];

                SearchItems.AddRange(Indexer.GetSearchIndexItems(objPortal.PortalID));
            }
            return(SearchItems);
        }
        /// <summary>
        /// Gets a list of search items to populate the DNN search index for the given module instance
        /// </summary>
        /// <param name="ModInfo">The mod info.</param>
        /// <returns>A list of search result information for the DNN search index</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo)
        {
            SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection();
            LocationCollection colLocations = Location.GetLocations(ModInfo.PortalID, true);
            foreach (Location location in colLocations)
            {
                searchItemCollection.Add(new SearchItemInfo(
                     ModInfo.ModuleTitle,
                     location.Name,
                     1,
                     DateTime.Now,
                     ModInfo.ModuleID,
                     location.Address + " " + location.City + " " + location.RegionName + " " + location.PostalCode,
                     location.Address + " " + location.City + " " + location.RegionName + " " + location.PostalCode + " " + location.LocationDetails));
            }

            return searchItemCollection;
        }
Пример #12
0
        /// <summary>
        /// GetSearchIndexItems gets the SearchInfo Items for the Portal
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="PortalID">The Id of the Portal</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        /// </history>
        public override SearchItemInfoCollection GetSearchIndexItems(int PortalID)
        {
            SearchItemInfoCollection          SearchItems      = new SearchItemInfoCollection();
            SearchContentModuleInfoCollection SearchCollection = GetModuleList(PortalID);

            foreach (SearchContentModuleInfo ScModInfo in SearchCollection)
            {
                try
                {
                    SearchItemInfoCollection myCollection;
                    myCollection = ScModInfo.ModControllerType.GetSearchItems(ScModInfo.ModInfo);
                    if (myCollection != null)
                    {
                        SearchItems.AddRange(myCollection);
                    }
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
            }

            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 SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo)
        {
            RotatorSettings.Init(new DnnConfiguration());
            RotatorSettings settings = new RotatorSettings();
            settings.LoadFromDB(ModInfo.ModuleID.ToString());

            var SearchItemCollection = new SearchItemInfoCollection();

            foreach (SlideInfo slide in settings.Slides)
                SearchItemCollection.Add(IndexSlide(ModInfo, slide));

            return SearchItemCollection;
        }
Пример #15
0
 protected SearchItemInfoCollection GetContent(int portalId, IndexingProvider indexer)
 {
     var searchItems = new SearchItemInfoCollection();
     searchItems.AddRange(indexer.GetSearchIndexItems(portalId));
     return searchItems;
 }
        /// ----------------------------------------------------------------------------- 
        /// <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;
        }
 public abstract void StoreSearchItems(SearchItemInfoCollection searchItems);
Пример #18
0
        /// -----------------------------------------------------------------------------
        /// <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;
        }
Пример #19
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// StoreSearchItems adds the Search Item to the Data Store
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name="searchItems">A Collection of SearchItems</param>
 /// <history>
 ///		[cnurse]	11/15/2004	documented
 ///     [vnguyen]   09/07/2010  Modified: Added a date comparison for LastModifiedDate on the Tab
 ///     [vnguyen]   16/04/2013  Modified: Now uses Lucene indexing
 ///     [galatrash] 23/05/2013  Modified: moved indexing methods into the internal namespace.
 /// </history>
 /// -----------------------------------------------------------------------------
 public override void StoreSearchItems(SearchItemInfoCollection searchItems)
 {
     var moduleController = new ModuleController();
     var indexer = new ModuleIndexer();
     
     var modulesDic = new Dictionary<int, string>();
     foreach (SearchItemInfo item in searchItems)
     {                
         if (!modulesDic.ContainsKey(item.ModuleId))
         {
             var module = moduleController.GetModule(item.ModuleId);
             modulesDic.Add(item.ModuleId, module.CultureCode);
             
             //Remove all indexed items for this module
             InternalSearchController.Instance.DeleteSearchDocumentsByModule(module.PortalID, module.ModuleID, module.ModuleDefID);
         }
     }
   
     //Process the SearchItems by Module to reduce Database hits
     foreach (var kvp in modulesDic)
     {
         //Get the Module's SearchItems
         var moduleSearchItems = searchItems.ModuleItems(kvp.Key);
         
         //Convert SearchItemInfo objects to SearchDocument objects
         var searchDocuments = (from SearchItemInfo item in moduleSearchItems select indexer.ConvertSearchItemInfoToSearchDocument(item)).ToList();
         
         //Index
         InternalSearchController.Instance.AddSearchDocuments(searchDocuments);                
     }
 } 
        /// -----------------------------------------------------------------------------
        /// <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} &bull; ", 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;
        }
 public SearchItemInfoCollection ModuleItems(int ModuleId)
 {
     var retValue = new SearchItemInfoCollection();
     foreach (SearchItemInfo info in this)
     {
         if (info.ModuleId == ModuleId)
         {
             retValue.Add(info);
         }
     }
     return retValue;
 }
Пример #22
0
 /// -----------------------------------------------------------------------------
 /// <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 searchItemCollection = new SearchItemInfoCollection();
     return searchItemCollection;
 }
Пример #23
0
 protected SearchItemInfoCollection GetContent(IndexingProvider indexer)
 {
     var searchItems = new SearchItemInfoCollection();
     var portals = PortalController.Instance.GetPortals();
     for (var index = 0; index <= portals.Count - 1; index++)
     {
         var portal = (PortalInfo) portals[index];
         searchItems.AddRange(indexer.GetSearchIndexItems(portal.PortalID));
     }
     return searchItems;
 }
Пример #24
0
        /// <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;
            }
        }
Пример #25
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// StoreSearchItems adds the Search Item to the Data Store
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="SearchItems">A Collection of SearchItems</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        ///     [vnguyen]   09/07/2010  Modified: Added a date comparison for LastModifiedDate on the Tab
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void StoreSearchItems(SearchItemInfoCollection SearchItems)
        {
            //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.
            var Modules = new Dictionary <int, string>();

            foreach (SearchItemInfo item in SearchItems)
            {
                if (!Modules.ContainsKey(item.ModuleId))
                {
                    Modules.Add(item.ModuleId, "en-US");
                }
            }

            var objTabs   = new TabController();
            var objModule = new ModuleInfo();
            var objTab    = new TabInfo();

            SearchItemInfo searchItem;
            Dictionary <string, SearchItemInfo> indexedItems;
            SearchItemInfoCollection            moduleItems;

            //Process the SearchItems by Module to reduce Database hits
            foreach (KeyValuePair <int, string> kvp in Modules)
            {
                indexedItems = SearchDataStoreController.GetSearchItems(kvp.Key);

                //Get the Module's SearchItems to compare
                moduleItems = SearchItems.ModuleItems(kvp.Key);

                //remove deleted indexed items
                var moduleItemList = moduleItems.Cast <SearchItemInfo>().ToList();
                indexedItems.Values
                .Where(i => moduleItemList.All(s => s.SearchKey != i.SearchKey))
                .ToList().ForEach(i => SearchDataStoreController.DeleteSearchItem(i.SearchItemId));

                //As we will be potentially removing items from the collection iterate backwards
                for (int iSearch = moduleItems.Count - 1; iSearch >= 0; iSearch += -1)
                {
                    searchItem = moduleItems[iSearch];

                    //Get item from Indexed collection
                    SearchItemInfo indexedItem = null;
                    if (indexedItems.TryGetValue(searchItem.SearchKey, out indexedItem))
                    {
                        //Get the tab where the search item resides -- used in date comparison
                        objModule = new ModuleController().GetModule(searchItem.ModuleId);
                        objTab    = objTabs.GetTab(searchItem.TabId, objModule.PortalID, false);

                        //Item exists so compare Dates to see if modified
                        if (indexedItem.PubDate < searchItem.PubDate || indexedItem.PubDate < objModule.LastModifiedOnDate || indexedItem.PubDate < objTab.LastModifiedOnDate)
                        {
                            try
                            {
                                if (searchItem.PubDate < objModule.LastModifiedOnDate)
                                {
                                    searchItem.PubDate = objModule.LastModifiedOnDate;
                                }
                                if (searchItem.PubDate < objTab.LastModifiedOnDate)
                                {
                                    searchItem.PubDate = objTab.LastModifiedOnDate;
                                }


                                //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, kvp.Value);
                            }
                            catch (Exception ex)
                            {
                                //Log Exception
                                Exceptions.Exceptions.LogException(ex);
                            }
                        }

                        //Remove Items from both collections
                        indexedItems.Remove(searchItem.SearchKey);
                        SearchItems.Remove(searchItem);
                    }
                    else
                    {
                        try
                        {
                            //Item doesn't exist so Add to Index
                            int indexID = SearchDataStoreController.AddSearchItem(searchItem);
                            //index the content
                            AddIndexWords(indexID, searchItem, kvp.Value);
                        }
                        catch (Exception ex)
                        {
                            //Exception is probably a duplicate key error which is probably due to bad module data
                            Exceptions.Exceptions.LogSearchException(new SearchException(ex.Message, ex, searchItem));
                        }
                    }
                }
            }
        }
Пример #26
0
        /// ----------------------------------------------------------------------------- 
        /// <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 abstract void StoreSearchItems(SearchItemInfoCollection searchItems);
 /// <summary>
 /// Adds the contents of another <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> to the end of the collection.
 /// </summary>
 /// <param name="value">A <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> containing the objects to add to the collection. </param>
 public void AddRange(SearchItemInfoCollection value)
 {
     for (int i = 0; i <= value.Count - 1; i++)
     {
         Add((SearchItemInfo) value.List[i]);
     }
 }
Пример #29
0
        /// <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>
 /// Initializes a new instance of the <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> class containing the elements of the specified source collection.
 /// </summary>
 /// <param name="value">A <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> with which to initialize the collection.</param>
 public SearchItemInfoCollection(SearchItemInfoCollection value)
 {
     AddRange(value);
 }
Пример #31
0
 public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
 {
     var items = new SearchItemInfoCollection();
     AddArticleSearchItems(items, modInfo);
     return items;
 }
        /// <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;
        }
Пример #33
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);
                    }
                //}
            }
        }
Пример #34
0
        /// -----------------------------------------------------------------------------
        /// <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>
 /// Initializes a new instance of the <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> class containing the elements of the specified source collection.
 /// </summary>
 /// <param name="value">A <see cref="SearchItemInfoCollection">SearchItemInfoCollection</see> with which to initialize the collection.</param>
 public SearchItemInfoCollection(SearchItemInfoCollection value)
 {
     AddRange(value);
 }
Пример #36
0
        public override SearchItemInfoCollection GetSearchIndexItems(int portalId)
        {
            var searchItems = new SearchItemInfoCollection();
            var searchCollection = GetModuleList(portalId);
            foreach (SearchContentModuleInfo scModInfo in searchCollection)
            {
                try
                {
                    var myCollection = scModInfo.ModControllerType.GetSearchItems(scModInfo.ModInfo);
                    if (myCollection != null)
                    {
                        foreach (SearchItemInfo searchItem in myCollection)
                        {
                            searchItem.TabId = scModInfo.ModInfo.TabID;
                        }

                        Logger.Trace("ModuleIndexer: " + myCollection.Count + " search documents found for module [" + scModInfo.ModInfo.DesktopModule.ModuleName + " mid:" + scModInfo.ModInfo.ModuleID + "]");

                        searchItems.AddRange(myCollection);
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.Exceptions.LogException(ex);
                }
            }
            return searchItems;
        }
Пример #37
0
 protected SearchItemInfoCollection GetContent(IndexingProvider indexer)
 {
     var searchItems = new SearchItemInfoCollection();
     var objPortals = new PortalController();
     var arrPortals = objPortals.GetPortals();
     int intPortal;
     for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++)
     {
         var objPortal = (PortalInfo) arrPortals[intPortal];
         searchItems.AddRange(indexer.GetSearchIndexItems(objPortal.PortalID));
     }
     return searchItems;
 }
Пример #38
0
        /// <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;
        }
Пример #39
0
        /// ----------------------------------------------------------------------------- 
        /// <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;
        }