Exemplo n.º 1
0
        /// <summary>
        /// GetModuleList gets a collection of SearchContentModuleInfo Items for the Portal
        /// </summary>
        /// <remarks>
        /// Parses the Modules of the Portal, determining whetehr they are searchable.
        /// </remarks>
        /// <param name="PortalID">The Id of the Portal</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        /// </history>
        protected SearchContentModuleInfoCollection GetModuleList( int PortalID )
        {
            SearchContentModuleInfoCollection Results = new SearchContentModuleInfoCollection();

            ModuleController objModules = new ModuleController();
            ArrayList arrModules = objModules.GetSearchModules( PortalID );
            Hashtable businessControllers = new Hashtable();
            Hashtable htModules = new Hashtable();

            ModuleInfo objModule;
            foreach( ModuleInfo tempLoopVar_objModule in arrModules )
            {
                objModule = tempLoopVar_objModule;
                if( ! htModules.ContainsKey( objModule.ModuleID ) )
                {
                    try
                    {
                        //Check if the business controller is in the Hashtable
                        object objController = businessControllers[objModule.BusinessControllerClass];

                        //If nothing create a new instance
                        if( objController == null )
                        {
                            objController = Framework.Reflection.CreateObject( objModule.BusinessControllerClass, objModule.BusinessControllerClass );

                            //Add to hashtable
                            businessControllers.Add( objModule.BusinessControllerClass, objController );
                        }

                        //Double-Check that module supports ISearchable
                        if( objController is ISearchable )
                        {
                            SearchContentModuleInfo ContentInfo = new SearchContentModuleInfo();
                            ContentInfo.ModControllerType = (ISearchable)objController;
                            ContentInfo.ModInfo = objModule;
                            Results.Add( ContentInfo );
                        }
                    }
                    catch( Exception ex )
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                    }
                    finally
                    {
                        htModules.Add( objModule.ModuleID, objModule.ModuleID );
                    }
                }
            }

            return Results;
        }
Exemplo n.º 2
0
        protected IEnumerable<ModuleInfo> GetSearchModules(int portalId, bool allModules)
        {
            var tabController = new TabController();
            var moduleController = new ModuleController();
            var businessControllers = new Hashtable();
            var searchModuleIds = new HashSet<int>();
            var searchModules = new List<ModuleInfo>();
            //Only get modules that are set to be Indexed.
            var modules = moduleController.GetSearchModules(portalId).Cast<ModuleInfo>().Where(m => m.TabModuleSettings["AllowIndex"] == null || bool.Parse(m.TabModuleSettings["AllowIndex"].ToString()));

            foreach (var module in modules.Where(module => !searchModuleIds.Contains(module.ModuleID)))
            {
                try
                {
                    var tab = tabController.GetTab(module.TabID, portalId, false);
                    //Only index modules on tabs that are set to be Indexed.
                    if (tab.TabSettings["AllowIndex"] == null || (tab.TabSettings["AllowIndex"] != null && bool.Parse(tab.TabSettings["AllowIndex"].ToString())))
                    {
                        //Check if the business controller is in the Hashtable
                        var controller = businessControllers[module.DesktopModule.BusinessControllerClass];
                        if (!String.IsNullOrEmpty(module.DesktopModule.BusinessControllerClass))
                        {
                            //If nothing create a new instance
                            if (controller == null)
                            {
                                //Add to hashtable
                                controller = Reflection.CreateObject(module.DesktopModule.BusinessControllerClass, module.DesktopModule.BusinessControllerClass);
                                businessControllers.Add(module.DesktopModule.BusinessControllerClass, controller);
                            }
                        }

                        //Check if module inherits from ModuleSearchBase or include all modules to index module metadata.
                        if (controller is ModuleSearchBase || allModules) searchModules.Add(module);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    ThrowLogError(module, ex);
                }
                finally
                {
                    searchModuleIds.Add(module.ModuleID);
                }
            }
            return searchModules;
        }
Exemplo n.º 3
0
        protected SearchContentModuleInfoCollection GetModuleList(int portalId)
        {
            var results = new SearchContentModuleInfoCollection();
            var objModules = new ModuleController();
            var arrModules = objModules.GetSearchModules(portalId);
            var businessControllers = new Hashtable();
            var htModules = new Hashtable();
            
            foreach (var module in arrModules.Cast<ModuleInfo>().Where(module => !htModules.ContainsKey(module.ModuleID)))
            {
                try
                {
                    //Check if the business controller is in the Hashtable
                    var controller = businessControllers[module.DesktopModule.BusinessControllerClass];
                    if (!String.IsNullOrEmpty(module.DesktopModule.BusinessControllerClass))
                    {
                        //If nothing create a new instance
                        if (controller == null)
                        {
                            //Add to hashtable
                            controller = Reflection.CreateObject(module.DesktopModule.BusinessControllerClass, module.DesktopModule.BusinessControllerClass);                              
                            businessControllers.Add(module.DesktopModule.BusinessControllerClass, controller);
                        }                            
                        //Double-Check that module supports ISearchable

                        //Check if module inherits from ModuleSearchBase                        
                        if (controller is ISearchable && !(controller is ModuleSearchBase))
                        {
                            var contentInfo = new SearchContentModuleInfo {ModControllerType = (ISearchable) controller, ModInfo = module};
                            results.Add(contentInfo);
                        }                           
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    ThrowLogError(module, ex);
                }
                finally
                {
                    htModules.Add(module.ModuleID, module.ModuleID);
                }
            }
            return results;
        }
        internal virtual object SearchContentSourceCallback(CacheItemArgs cacheItem)
        {
            var searchTypes = CBO.FillCollection<SearchType>(DataProvider.GetAllSearchTypes());

            var results = new List<SearchContentSource>();

            foreach (var crawler in searchTypes)
            {
                switch (crawler.SearchTypeName)
                {
                    case "module": // module crawler

                        // get searchable module definition list
                        var portalId = int.Parse(cacheItem.CacheKey.Split('-')[1]);
                        var moduleController = new ModuleController();
                        var modules = moduleController.GetSearchModules(portalId);
                        var modDefIds = new HashSet<int>();

                        foreach (ModuleInfo module in modules)
                        {
                            if (!modDefIds.Contains(module.ModuleDefID)) modDefIds.Add(module.ModuleDefID);
                        }
                        
                        var list = modDefIds.Select(ModuleDefinitionController.GetModuleDefinitionByID).ToList();

                        foreach (var def in list)
                        {
                            var text = Localization.Localization.GetSafeJSString("Module_" + def.DefinitionName, LocalizedResxFile);
                            if (string.IsNullOrEmpty(text))
                            {
                                text = def.FriendlyName;
                            }
                            var result = new SearchContentSource
                            {
                                SearchTypeId = crawler.SearchTypeId,
                                SearchTypeName = crawler.SearchTypeName,
                                IsPrivate = crawler.IsPrivate,
                                ModuleDefinitionId =  def.ModuleDefID,
                                LocalizedName = text
                            };

                            results.Add(result);
                        }

                        break;

                    default:

                        var localizedName = Localization.Localization.GetSafeJSString("Crawler_" + crawler.SearchTypeName, LocalizedResxFile);
                        if (string.IsNullOrEmpty(localizedName))
                        {
                            localizedName = crawler.SearchTypeName;
                        }

                        results.Add(new SearchContentSource
                        {
                            SearchTypeId = crawler.SearchTypeId,
                            SearchTypeName = crawler.SearchTypeName,
                            IsPrivate = crawler.IsPrivate,
                            ModuleDefinitionId = 0,
                            LocalizedName = localizedName
                        });
                        break;
                }
            }

            return results;

        }
Exemplo n.º 5
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetModuleList gets a collection of SearchContentModuleInfo Items for the Portal
        /// </summary>
        /// <remarks>
        /// Parses the Modules of the Portal, determining whetehr they are searchable.
        /// </remarks>
        /// <param name="PortalID">The Id of the Portal</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        /// </history>
        /// -----------------------------------------------------------------------------
        protected SearchContentModuleInfoCollection GetModuleList(int PortalID)
        {
            var Results = new SearchContentModuleInfoCollection();
            var objModules = new ModuleController();
            ArrayList arrModules = objModules.GetSearchModules(PortalID);
            var businessControllers = new Hashtable();
            var htModules = new Hashtable();
            foreach (ModuleInfo objModule in arrModules)
            {
                if (!htModules.ContainsKey(objModule.ModuleID))
                {
                    try
                    {
                        //Check if the business controller is in the Hashtable
                        object objController = businessControllers[objModule.DesktopModule.BusinessControllerClass];
                        if (!String.IsNullOrEmpty(objModule.DesktopModule.BusinessControllerClass))
                        {
							//If nothing create a new instance
                            if (objController == null)
                            {
                                objController = Reflection.CreateObject(objModule.DesktopModule.BusinessControllerClass, objModule.DesktopModule.BusinessControllerClass);
                                
								//Add to hashtable
								businessControllers.Add(objModule.DesktopModule.BusinessControllerClass, objController);
                            }
                            
							//Double-Check that module supports ISearchable
							if (objController is ISearchable)
                            {
                                var ContentInfo = new SearchContentModuleInfo();
                                ContentInfo.ModControllerType = (ISearchable) objController;
                                ContentInfo.ModInfo = objModule;
                                Results.Add(ContentInfo);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Instrumentation.DnnLog.Error(ex);

                        try
                        {
                            string strMessage = string.Format("Error Creating BusinessControllerClass '{0}' of module({1}) id=({2}) in tab({3}) and portal({4}) ",
                                                              objModule.DesktopModule.BusinessControllerClass,
                                                              objModule.DesktopModule.ModuleName,
                                                              objModule.ModuleID,
                                                              objModule.TabID,
                                                              objModule.PortalID);
                            throw new Exception(strMessage, ex);
                        }
                        catch (Exception ex1)
                        {
                            Exceptions.Exceptions.LogException(ex1);
                        }
                    }
                    finally
                    {
                        htModules.Add(objModule.ModuleID, objModule.ModuleID);
                    }
                }
            }
            return Results;
        }