Example #1
0
        /// <summary>
        /// This method
        /// </summary>
        /// <param name="channelName"></param>
        /// <param name="userName"></param>
        /// <remarks></remarks>
        protected override void PopulateChannel(string channelName, string userName)
        {
            var        objModules = new ModuleController();
            ModuleInfo objModule;

            if (Request == null || Settings == null || Settings.ActiveTab == null || ModuleId == Null.NullInteger)
            {
                return;
            }
            Channel["title"] = Settings.PortalName;
            Channel["link"]  = Globals.AddHTTP(Globals.GetDomainName(Request));
            if (!String.IsNullOrEmpty(Settings.Description))
            {
                Channel["description"] = Settings.Description;
            }
            else
            {
                Channel["description"] = Settings.PortalName;
            }
            Channel["language"]  = Settings.DefaultLanguage;
            Channel["copyright"] = !string.IsNullOrEmpty(Settings.FooterText) ?
                                   Settings.FooterText.Replace("[year]", DateTime.Now.Year.ToString()) : string.Empty;
            Channel["webMaster"] = Settings.Email;
            SearchResultsInfoCollection searchResults = null;

            try
            {
                searchResults = SearchDataStoreProvider.Instance().GetSearchItems(Settings.PortalId, TabId, ModuleId);
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
            }
            if (searchResults != null)
            {
                foreach (SearchResultsInfo objResult in searchResults)
                {
                    if (TabPermissionController.CanViewPage())
                    {
                        if (Settings.ActiveTab.StartDate < DateTime.Now && Settings.ActiveTab.EndDate > DateTime.Now)
                        {
                            objModule = objModules.GetModule(objResult.ModuleId, objResult.TabId);
                            if (objModule != null && objModule.DisplaySyndicate && objModule.IsDeleted == false)
                            {
                                if (ModulePermissionController.CanViewModule(objModule))
                                {
                                    if (Convert.ToDateTime(objModule.StartDate == Null.NullDate ? DateTime.MinValue : objModule.StartDate) < DateTime.Now &&
                                        Convert.ToDateTime(objModule.EndDate == Null.NullDate ? DateTime.MaxValue : objModule.EndDate) > DateTime.Now)
                                    {
                                        Channel.Items.Add(GetRssItem(objResult));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private SearchResultsInfoCollection Search(int categoryId, string criteria)
        {
            SearchResultsInfoCollection results = null;

            try
            {
                //this will apply thenormal security search,
                //filtering out anything that shouldn't be displayed based on permissions
                results = SearchDataStoreProvider.Instance().GetSearchResults(PortalId, criteria);

                //will contain all the articles beneath the given category or subcategory
                IDictionary articles = new Hashtable();

                DataTable dt;
                if (categoryId == -1)
                {
                    dt = Article.GetArticles(PortalId);
                }
                else
                {
                    DataSet ds = Item.GetAllChildren(ItemType.Article.GetId(), categoryId, Util.RelationshipType.ItemToParentCategory.GetId(), Util.RelationshipType.ItemToRelatedCategory.GetId(), PortalId);
                    dt = ds.Tables[0];
                }
                foreach (DataRow row in dt.Rows)
                {
                    int articleId = Convert.ToInt32(row["ItemId"], CultureInfo.InvariantCulture);
                    if (articles.Contains(articleId) == false)
                    {
                        articles.Add(articleId, null);
                    }
                }

                //now filter out anything not in the list of articles beneath the given category
                var al = new ArrayList();
                foreach (SearchResultsInfo result in results)
                {
                    int articleId = Utility.GetArticleId(result);
                    if (articles.Contains(articleId) == false || articleId == 0)
                    {
                        //remove this row from the results
                        al.Add(result);
                    }
                }

                foreach (SearchResultsInfo result in al)
                {
                    results.Remove(result);
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }

            return(results);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Indexes content within the given time farame
        /// </summary>
        /// -----------------------------------------------------------------------------
        internal void IndexContent()
        {
            //Index TAB META-DATA
            TabIndexer tabIndexer                 = new TabIndexer();
            int        searchDocsCount            = GetAndStoreSearchDocuments(tabIndexer);
            int        indexedSearchDocumentCount = searchDocsCount;

            AddIdexingResults("Tabs Indexed", searchDocsCount);

            //Index MODULE META-DATA from modules that inherit from ModuleSearchBase
            ModuleIndexer moduleIndexer = new ModuleIndexer(true);

            searchDocsCount             = GetAndStoreModuleMetaData(moduleIndexer);
            indexedSearchDocumentCount += searchDocsCount;
            AddIdexingResults("Modules (Metadata) Indexed", searchDocsCount);

            //Index MODULE CONTENT from modules that inherit from ModuleSearchBase
            searchDocsCount             = GetAndStoreSearchDocuments(moduleIndexer);
            indexedSearchDocumentCount += searchDocsCount;

            //Index all Defunct ISearchable module content
#pragma warning disable 0618
            SearchItemInfoCollection searchItems = GetContent(moduleIndexer);
            SearchDataStoreProvider.Instance().StoreSearchItems(searchItems);
#pragma warning restore 0618
            indexedSearchDocumentCount += searchItems.Count;

            //Both ModuleSearchBase and ISearchable module content count
            AddIdexingResults("Modules (Content) Indexed", searchDocsCount + searchItems.Count);

            if (!HostController.Instance.GetBoolean("DisableUserCrawling", false))
            {
                //Index User data
                UserIndexer userIndexer = new UserIndexer();
                int         userIndexed = GetAndStoreSearchDocuments(userIndexer);
                indexedSearchDocumentCount += userIndexed;
                AddIdexingResults("Users", userIndexed);
            }

            SchedulerItem.AddLogNote("<br/><b>Total Items Indexed: " + indexedSearchDocumentCount + "</b>");
        }
        private int BindSearchResults(DataTable dt)
        {
            SearchResultsInfoCollection Results = SearchDataStoreProvider.Instance().GetSearchResults(PortalId, _SearchQuery);

            //Get the maximum items to display
            int maxItems = 0;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["maxresults"])))
            {
                maxItems = int.Parse(Convert.ToString(Settings["maxresults"]));
            }
            else
            {
                maxItems = Results.Count;
            }
            if (Results.Count < maxItems || maxItems < 1)
            {
                maxItems = Results.Count;
            }

            //Get the titlelength/descriptionlength
            int titleLength = 0;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["titlelength"])))
            {
                titleLength = int.Parse(Convert.ToString(Settings["titlelength"]));
            }
            int descLength = 0;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["descriptionlength"])))
            {
                descLength = int.Parse(Convert.ToString(Settings["descriptionlength"]));
            }
            int i = 0;
            SearchResultsInfo ResultItem;

            for (i = 0; i <= maxItems - 1; i++)
            {
                ResultItem = Results[i];
                DataRow dr = dt.NewRow();
                dr["TabId"] = ResultItem.TabId;
                dr["Guid"]  = ResultItem.Guid;
                if (titleLength > 0 && titleLength < ResultItem.Title.Length)
                {
                    dr["Title"] = ResultItem.Title.Substring(0, titleLength);
                }
                else
                {
                    dr["Title"] = ResultItem.Title;
                }
                dr["Relevance"] = ResultItem.Relevance;
                if (descLength > 0 && descLength < ResultItem.Description.Length)
                {
                    dr["Description"] = ResultItem.Description.Substring(0, descLength);
                }
                else
                {
                    dr["Description"] = ResultItem.Description;
                }
                dr["PubDate"] = ResultItem.PubDate;
                dt.Rows.Add(dr);
            }
            return(Results.Count);
        }
        /// <summary>
        /// BindData binds the Search Results to the Grid
        /// </summary>
        /// <history>
        ///     [cnurse]	12/13/2004	created
        /// </history>
        private void BindData()
        {
            SearchResultsInfoCollection Results = SearchDataStoreProvider.Instance().GetSearchResults(PortalId, _searchQuery);

            DataTable  dt = new DataTable();
            DataColumn dc = new DataColumn("TabId");

            dt.Columns.Add(new DataColumn("TabId", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Guid", typeof(String)));
            dt.Columns.Add(new DataColumn("Title", typeof(String)));
            dt.Columns.Add(new DataColumn("Relevance", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Description", typeof(String)));
            dt.Columns.Add(new DataColumn("PubDate", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("SearchKey", typeof(String)));

            //Get the maximum items to display
            int maxItems = 0;

            if (Convert.ToString(Settings["maxresults"]) != "")
            {
                maxItems = int.Parse(Convert.ToString(Settings["maxresults"]));
            }
            else
            {
                maxItems = Results.Count;
            }
            if (Results.Count < maxItems || maxItems < 1)
            {
                maxItems = Results.Count;
            }

            //Get the items/page to display
            int itemsPage = 10;

            if (Convert.ToString(Settings["perpage"]) != "")
            {
                itemsPage = int.Parse(Convert.ToString(Settings["perpage"]));
            }

            //Get the titlelength/descriptionlength
            int titleLength = 0;

            if (Convert.ToString(Settings["titlelength"]) != "")
            {
                titleLength = int.Parse(Convert.ToString(Settings["titlelength"]));
            }
            int descLength = 0;

            if (Convert.ToString(Settings["descriptionlength"]) != "")
            {
                descLength = int.Parse(Convert.ToString(Settings["descriptionlength"]));
            }

            int i = 0;
            SearchResultsInfo ResultItem;

            for (i = 0; i <= maxItems - 1; i++)
            {
                ResultItem = Results[i];
                DataRow dr = dt.NewRow();
                dr["TabId"]     = ResultItem.TabId;
                dr["Guid"]      = ResultItem.Guid;
                dr["SearchKey"] = ResultItem.SearchKey;
                if (titleLength > 0 && titleLength < ResultItem.Title.Length)
                {
                    dr["Title"] = ResultItem.Title.Substring(0, titleLength);
                }
                else
                {
                    dr["Title"] = ResultItem.Title;
                }
                dr["Relevance"] = ResultItem.Relevance;
                if (descLength > 0 && descLength < ResultItem.Description.Length)
                {
                    dr["Description"] = ResultItem.Description.Substring(0, descLength);
                }
                else
                {
                    dr["Description"] = ResultItem.Description;
                }
                dr["PubDate"] = ResultItem.PubDate;
                dt.Rows.Add(dr);
            }

            //Bind Search Results Grid
            DataView dv = new DataView(dt);

            dv.Sort              = "Relevance DESC";
            dgResults.PageSize   = itemsPage;
            dgResults.DataSource = dv;
            dgResults.DataBind();

            if (Results.Count == 0)
            {
                dgResults.Visible = false;
            }
            if (Results.Count <= dgResults.PageSize)
            {
                dgResults.PagerStyle.Visible = false;
            }
            else
            {
                dgResults.PagerStyle.Visible = true;
            }
        }
Example #6
0
        /// <summary>
        /// Builds RSS Channel
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// ---Corrected link elment to use prefix 'http://' & current request context.
        /// </remarks>
        /// <history>Sat, 26 Feb 2005 Phil Guerra
        /// </history>
        private string BuildRSS(int PortalId, int TabId, int ModuleId)
        {
            ModuleController objModules = new ModuleController();
            ModuleInfo       objModule;

            StringBuilder sb = new StringBuilder(1024);

            // build header
            sb.Append("<?xml version=\"1.0\" ?>" + "\r\n");
            sb.Append("<rss version=\"2.0\"");
            sb.Append(" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">" + "\r\n");
            // build channel
            sb.Append(WriteElement("channel", 1));
            sb.Append(WriteElement("title", PortalSettings.PortalName, 2));
            // pmg - This line was updated to correct the link item.
            // We are making the assumption that the current context of the
            // request has the desired link to the Portal.  Even though there
            // may be more than 1 portalAlias, this should be correct. If not,
            // we'll have to revisit.
            // sb.Append(WriteElement("link", Request.Url.Host, 2))
            sb.Append(WriteElement("link", Globals.AddHTTP(Globals.GetDomainName(HttpContext.Current.Request)), 2));
            if (!String.IsNullOrEmpty(PortalSettings.Description))
            {
                sb.Append(WriteElement("description", PortalSettings.Description, 2));
            }
            else
            {
                sb.Append(WriteElement("description", PortalSettings.PortalName, 2));
            }
            sb.Append(WriteElement("language", PortalSettings.DefaultLanguage, 2));
            sb.Append(WriteElement("copyright", PortalSettings.FooterText, 2));
            sb.Append(WriteElement("webMaster", PortalSettings.Email, 2));
            // build items
            SearchResultsInfoCollection objResults = SearchDataStoreProvider.Instance().GetSearchItems(PortalId, TabId, ModuleId);
            SearchResultsInfo           objResult;

            foreach (SearchResultsInfo tempLoopVar_objResult in objResults)
            {
                objResult = tempLoopVar_objResult;
                if (PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AuthorizedRoles))
                {
                    if (PortalSettings.ActiveTab.StartDate < DateTime.Now && PortalSettings.ActiveTab.EndDate > DateTime.Now)
                    {
                        objModule = objModules.GetModule(objResult.ModuleId, objResult.TabId);
                        if (objModule.DisplaySyndicate == true && objModule.IsDeleted == false)
                        {
                            if (PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) == true)
                            {
                                if (Convert.ToDateTime(objModule.StartDate == Null.NullDate ? DateTime.MinValue : objModule.StartDate) < DateTime.Now && Convert.ToDateTime(objModule.EndDate == Null.NullDate ? DateTime.MaxValue : objModule.EndDate) > DateTime.Now)
                                {
                                    sb.Append(BuildItem(objResult, 2));
                                }
                            }
                        }
                    }
                }
            }

            // close document
            sb.Append(WriteElement("/channel", 1));
            sb.Append("</rss>");

            return(sb.ToString());
        }
Example #7
0
        // public static SearchResultsInfoCollection2 GetSearchResults(int PortalID, string Word)
        //{
        //    return new DotNetNuke.Services.Search.SearchResultsInfoCollection2(CBO.FillCollection(DataProvider.Instance().GetSearchResults(PortalID, Word), typeof(SearchResultsInfo2)));
        // }



        private int BindSearchResults(DataTable dt)
        {
            //StaffBroker.StaffBrokerDataContext d = new StaffBroker.StaffBrokerDataContext();

            //SearchResultsInfoCollection2 Results = SearchDataStore2.Instance().GetSearchResults(PortalId, _SearchQuery);



            SearchResultsInfoCollection Results = SearchDataStoreProvider.Instance().GetSearchResults(PortalId, _SearchQuery);

            //Get the maximum items to display
            int maxItems = 0;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["maxresults"])))
            {
                maxItems = int.Parse(Convert.ToString(Settings["maxresults"]));
            }
            else
            {
                maxItems = Results.Count;
            }
            if (Results.Count < maxItems || maxItems < 1)
            {
                maxItems = Results.Count;
            }

            //Get the titlelength/descriptionlength
            int titleLength = 0;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["titlelength"])))
            {
                titleLength = int.Parse(Convert.ToString(Settings["titlelength"]));
            }
            int descLength = 0;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["descriptionlength"])))
            {
                descLength = int.Parse(Convert.ToString(Settings["descriptionlength"]));
            }
            int i = 0;



            SearchResultsInfo ResultItem;


            // for (i = 0; i <= maxItems - 1; i++)
            while (dt.Rows.Count < maxItems && i < Results.Count)
            {
                ResultItem = Results[i];
                string filter = "";
                if (Request.Params["Filter"] != null)
                {
                    filter = Request.Params["Filter"];
                }
                if (filter == "" || (filter.ToLower() == "stories" && ResultItem.SearchKey.StartsWith("S")) || (filter.ToLower() == "docs" && ResultItem.SearchKey.StartsWith("D")))
                {
                    DataRow dr = dt.NewRow();
                    dr["TabId"] = ResultItem.TabId;
                    dr["Guid"]  = ResultItem.Guid;
                    if (titleLength > 0 && titleLength < ResultItem.Title.Length)
                    {
                        dr["Title"] = ResultItem.Title.Substring(0, titleLength);
                    }
                    else
                    {
                        dr["Title"] = ResultItem.Title;
                    }
                    dr["Relevance"] = ResultItem.Relevance;
                    if (descLength > 0 && descLength < ResultItem.Description.Length)
                    {
                        dr["Description"] = ResultItem.Description.Substring(0, descLength);
                    }
                    else
                    {
                        dr["Description"] = ResultItem.Description;
                    }
                    dr["PubDate"] = ResultItem.PubDate;
                    dr["Image"]   = "";
                    try
                    {
                        if (ResultItem.Image > 0)
                        {
                            var img = DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(ResultItem.Image);
                            if (!(img == null))
                            {
                                var imgURL = DotNetNuke.Services.FileSystem.FileManager.Instance.GetUrl(img);
                                dr["Image"] = imgURL;
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }


                    dr["SearchKey"] = ResultItem.SearchKey;

                    dr["AuthorName"] = ResultItem.AuthorName;


                    dt.Rows.Add(dr);
                }
                i++;
            }
            return(Results.Count);
        }