/// <summary>
        /// Creates a one-dimensional <see cref="T:System.Array">Array</see> instance containing the collection items.
        /// </summary>
        /// <returns>Array of type SearchResultsInfo</returns>
        public SearchResultsInfo[] ToArray()
        {
            var arr = new SearchResultsInfo[Count];

            CopyTo(arr, 0);
            return(arr);
        }
예제 #2
0
 /// <Summary>
 /// Creates a one-dimensional Array instance containing the collection items.
 /// </Summary>
 /// <Returns>Array of type SearchResultsInfo</Returns>
 public SearchResultsInfo[] ToArray()
 {
     SearchResultsInfo[] searchResultsInfoArray1 = new SearchResultsInfo[((this.Count - 1) + 1)];
     searchResultsInfoArray1 = ((SearchResultsInfo[])Utils.CopyArray(searchResultsInfoArray1, new SearchResultsInfo[((this.Count - 1) + 1)]));
     this.CopyTo(searchResultsInfoArray1, 0);
     return(searchResultsInfoArray1);
 }
예제 #3
0
 /// <Summary>
 /// Gets a value indicating whether the collection contains the specified SearchResultsInfoCollection.
 /// </Summary>
 /// <Param name="value">
 /// The SearchResultsInfoCollection to search for in the collection.
 /// </Param>
 /// <Returns>
 /// true if the collection contains the specified object; otherwise, false.
 /// </Returns>
 public bool Contains(SearchResultsInfo value)
 {
     return(this.List.Contains(value));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchResultsInfoCollection">SearchResultsInfoCollection</see> class containing the specified array of <see cref="SearchResultsInfo">SearchResultsInfo</see> objects.
 /// </summary>
 /// <param name="value">An array of <see cref="SearchResultsInfo">SearchResultsInfo</see> objects with which to initialize the collection. </param>
 public SearchResultsInfoCollection(SearchResultsInfo[] value)
 {
     AddRange(value);
 }
 /// <summary>
 /// Creates a one-dimensional <see cref="T:System.Array">Array</see> instance containing the collection items.
 /// </summary>
 /// <returns>Array of type SearchResultsInfo</returns>
 public SearchResultsInfo[] ToArray()
 {
     var arr = new SearchResultsInfo[Count];
     CopyTo(arr, 0);
     return arr;
 }
 /// <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(SearchResultsInfo[] array, int index)
 {
     List.CopyTo(array, index);
 }
예제 #7
0
        /// <summary>
        /// Builds RSS Item
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// ---Corrected pubDate elment name.
        /// ---Corrected formatting of pubDate value to RFC-822 spec.
        /// ---Correction for guid element '&' replaced with '?' to correct linkage issues.
        /// </remarks>
        /// <history>Sat, 29 Jan 2005 Phil Guerra
        /// </history>
        private string BuildItem( SearchResultsInfo objResult, int Indent )
        {
            StringBuilder sb = new StringBuilder( 1024 );

            string URL = Globals.NavigateURL(objResult.TabId);
            if( URL.IndexOf( Request.Url.Host ) == - 1 )
            {
                URL = Globals.AddHTTP(Request.Url.Host) + URL;
            }

            sb.Append( WriteElement( "item", Indent ) );
            sb.Append( WriteElement( "title", objResult.Title, Indent + 1 ) );
            sb.Append( WriteElement( "description", objResult.Description, Indent + 1 ) );
            sb.Append( WriteElement( "link", URL, Indent + 1 ) );
            sb.Append( WriteElement( "dc:creator", objResult.AuthorName, Indent + 1 ) );
            // Commented out <author> element - RSSv2.0 specs call for an email used here,
            // not just a simple name.
            // sb.Append(WriteElement("author", objResult.AuthorName, Indent + 1))
            sb.Append( WriteElement( "pubDate", objResult.PubDate.ToUniversalTime().ToString( "r" ), Indent + 1 ) );
            sb.Append( WriteElement( "guid", URL + Convert.ToString( !String.IsNullOrEmpty(objResult.Guid) ? "?" + objResult.Guid : "" ), Indent + 1 ) );
            sb.Append( WriteElement( "/item", Indent ) );

            return sb.ToString();
        }
예제 #8
0
 /// <Summary>
 /// Add an element of the specified SearchResultsInfo to the end of the collection.
 /// </Summary>
 /// <Param name="value">
 /// An object of type SearchResultsInfo to add to the collection.
 /// </Param>
 public int Add(SearchResultsInfo value)
 {
     return(this.List.Add(value));
 }
예제 #9
0
 /// <Summary>
 /// Add an element of the specified SearchResultsInfo to the collection at the designated index.
 /// </Summary>
 /// <Param name="index">
 /// An Integer to indicate the location to add the object to the collection.
 /// </Param>
 /// <Param name="value">
 /// An object of type SearchResultsInfo to add to the collection.
 /// </Param>
 public void Insert(int index, SearchResultsInfo value)
 {
     this.List.Insert(index, value);
 }
 /// <summary>
 /// Add an element of the specified <see cref="SearchResultsInfo">SearchResultsInfo</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="SearchResultsInfo">SearchResultsInfo</see> to add to the collection.</param>
 public void Insert(int index, SearchResultsInfo value)
 {
     List.Insert(index, value);
 }
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="SearchResultsInfoCollection">SearchResultsInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="SearchResultsInfoCollection">SearchResultsInfoCollection</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(SearchResultsInfo value)
 {
     return List.IndexOf(value);
 }
 /// <summary>
 /// Add an element of the specified <see cref="SearchResultsInfo">SearchResultsInfo</see> to the end of the collection.
 /// </summary>
 /// <param name="value">An object of type <see cref="SearchResultsInfo">SearchResultsInfo</see> to add to the collection.</param>
 public int Add(SearchResultsInfo value)
 {
     return List.Add(value);
 }
 /// <Summary>
 /// Copies the collection objects to a one-dimensional Array instance beginning at the specified index.
 /// </Summary>
 /// <Param name="array">
 /// The one-dimensional Array 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( SearchResultsInfo[] array, int index )
 {
     this.List.CopyTo( ( (Array)array ), index );
 }
 /// <Summary>
 /// Creates a one-dimensional Array instance containing the collection items.
 /// </Summary>
 /// <Returns>Array of type SearchResultsInfo</Returns>
 public SearchResultsInfo[] ToArray()
 {
     SearchResultsInfo[] searchResultsInfoArray1 = new SearchResultsInfo[( ( this.Count - 1 ) + 1 )];
     searchResultsInfoArray1 = ( (SearchResultsInfo[])Utils.CopyArray( searchResultsInfoArray1, new SearchResultsInfo[( ( this.Count - 1 ) + 1 )] ) );
     this.CopyTo( searchResultsInfoArray1, 0 );
     return searchResultsInfoArray1;
 }
예제 #15
0
 /// <Summary>
 /// Gets the index in the collection of the specified SearchResultsInfoCollection, if it exists in the collection.
 /// </Summary>
 /// <Param name="value">
 /// The SearchResultsInfoCollection to locate in the collection.
 /// </Param>
 /// <Returns>
 /// The index in the collection of the specified object, if found; otherwise, -1.
 /// </Returns>
 public int IndexOf(SearchResultsInfo value)
 {
     return(this.List.IndexOf(value));
 }
 /// <summary>
 /// Remove the specified object of type <see cref="SearchResultsInfo">SearchResultsInfo</see> from the collection.
 /// </summary>
 /// <param name="value">An object of type <see cref="SearchResultsInfo">SearchResultsInfo</see> to remove to the collection.</param>
 public void Remove(SearchResultsInfo value)
 {
     List.Remove(value);
 }
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="SearchResultsInfoCollection">SearchResultsInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="SearchResultsInfoCollection">SearchResultsInfoCollection</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(SearchResultsInfo value)
 {
     return List.Contains(value);
 }
예제 #18
0
 /// <Summary>
 /// Remove the specified object of type SearchResultsInfo from the collection.
 /// </Summary>
 /// <Param name="value">
 /// An object of type SearchResultsInfo to remove to the collection.
 /// </Param>
 public void Remove(SearchResultsInfo value)
 {
     this.List.Remove(value);
 }
 /// <summary>
 /// Copies the elements of the specified <see cref="SearchResultsInfo">SearchResultsInfo</see> array to the end of the collection.
 /// </summary>
 /// <param name="value">An array of type <see cref="SearchResultsInfo">SearchResultsInfo</see> containing the objects to add to the collection.</param>
 public void AddRange(SearchResultsInfo[] value)
 {
     for (int i = 0; i <= value.Length - 1; i++)
     {
         Add(value[i]);
     }
 }
예제 #20
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchResults gets the search results for a passed in criteria string
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="portalId">A Id of the Portal</param>
        /// <param name="criteria">The criteria string</param>
        /// -----------------------------------------------------------------------------
        public override SearchResultsInfoCollection GetSearchResults(int portalId, string criteria)
        {
            bool hasExcluded  = Null.NullBoolean;
            bool hasMandatory = Null.NullBoolean;

            var portal = PortalController.Instance.GetPortal(portalId);

            //Get the Settings for this Portal
            var portalSettings = new PortalSettings(portal);

            //We will assume that the content is in the locale of the Portal
            Hashtable commonWords = GetCommonWords(portalSettings.DefaultLanguage);

            //clean criteria
            criteria = criteria.ToLower();

            //split search criteria into words
            var searchWords = new SearchCriteriaCollection(criteria);

            var searchResults = new Dictionary <string, SearchResultsInfoCollection>();

            //dicResults is a Dictionary(Of SearchItemID, Dictionary(Of TabID, SearchResultsInfo)
            var dicResults = new Dictionary <int, Dictionary <int, SearchResultsInfo> >();

            //iterate through search criteria words
            foreach (SearchCriteria criterion in searchWords)
            {
                if (commonWords.ContainsKey(criterion.Criteria) == false || portalSettings.SearchIncludeCommon)
                {
                    if (!searchResults.ContainsKey(criterion.Criteria))
                    {
                        searchResults.Add(criterion.Criteria, SearchDataStoreController.GetSearchResults(portalId, criterion.Criteria));
                    }
                    if (searchResults.ContainsKey(criterion.Criteria))
                    {
                        foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                        {
                            //Add results to dicResults
                            if (!criterion.MustExclude)
                            {
                                if (dicResults.ContainsKey(result.SearchItemID))
                                {
                                    //The Dictionary exists for this SearchItemID already so look in the TabId keyed Sub-Dictionary
                                    Dictionary <int, SearchResultsInfo> dic = dicResults[result.SearchItemID];
                                    if (dic.ContainsKey(result.TabId))
                                    {
                                        //The sub-Dictionary contains the item already so update the relevance
                                        SearchResultsInfo searchResult = dic[result.TabId];
                                        searchResult.Relevance += result.Relevance;
                                    }
                                    else
                                    {
                                        //Add Entry to Sub-Dictionary
                                        dic.Add(result.TabId, result);
                                    }
                                }
                                else
                                {
                                    //Create new TabId keyed Dictionary
                                    var dic = new Dictionary <int, SearchResultsInfo>();
                                    dic.Add(result.TabId, result);

                                    //Add new Dictionary to SearchResults
                                    dicResults.Add(result.SearchItemID, dic);
                                }
                            }
                        }
                    }
                }
            }
            foreach (SearchCriteria criterion in searchWords)
            {
                var mandatoryResults = new Dictionary <int, bool>();
                var excludedResults  = new Dictionary <int, bool>();
                if (searchResults.ContainsKey(criterion.Criteria))
                {
                    foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                    {
                        if (criterion.MustInclude)
                        {
                            //Add to mandatory results lookup
                            mandatoryResults[result.SearchItemID] = true;
                            hasMandatory = true;
                        }
                        else if (criterion.MustExclude)
                        {
                            //Add to exclude results lookup
                            excludedResults[result.SearchItemID] = true;
                            hasExcluded = true;
                        }
                    }
                }
                foreach (KeyValuePair <int, Dictionary <int, SearchResultsInfo> > kvpResults in dicResults)
                {
                    //The key of this collection is the SearchItemID,  Check if the value of this collection should be processed
                    if (hasMandatory && (!mandatoryResults.ContainsKey(kvpResults.Key)))
                    {
                        //1. If mandatoryResults exist then only process if in mandatoryResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                    else if (hasExcluded && (excludedResults.ContainsKey(kvpResults.Key)))
                    {
                        //2. Do not process results in the excludedResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                }
            }

            //Process results against permissions and mandatory and excluded results
            var results = new SearchResultsInfoCollection();

            foreach (KeyValuePair <int, Dictionary <int, SearchResultsInfo> > kvpResults in dicResults)
            {
                foreach (SearchResultsInfo result in kvpResults.Value.Values)
                {
                    if (!result.Delete)
                    {
                        //Check If authorised to View Tab
                        TabInfo objTab = TabController.Instance.GetTab(result.TabId, portalId, false);
                        if (TabPermissionController.CanViewPage(objTab))
                        {
                            //Check If authorised to View Module
                            ModuleInfo objModule = ModuleController.Instance.GetModule(result.ModuleId, result.TabId, false);
                            if (ModulePermissionController.CanViewModule(objModule))
                            {
                                results.Add(result);
                            }
                        }
                    }
                }
            }

            //Return Search Results Collection
            return(results);
        }
예제 #21
0
파일: RssHandler.cs 프로젝트: biganth/Curt
        /// <summary>
        /// Creates an RSS Item
        /// </summary>
        /// <param name="SearchItem"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private GenericRssElement GetRssItem(SearchResultsInfo SearchItem)
        {
            var item = new GenericRssElement();
            string URL = Globals.NavigateURL(SearchItem.TabId);
            if (URL.ToLower().IndexOf(HttpContext.Current.Request.Url.Host.ToLower()) == -1)
            {
                URL = Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + URL;
            }
            item["title"] = SearchItem.Title;
            item["description"] = SearchItem.Description;
            //TODO:  JMB: We need to figure out how to persist the dc prefix in the XML output.  See the Render method below.
            //item("dc:creator") = SearchItem.AuthorName
            item["pubDate"] = SearchItem.PubDate.ToUniversalTime().ToString("r");

            if (!string.IsNullOrEmpty(SearchItem.Guid))
            {
                if (URL.Contains("?"))
                {
                    URL += "&" + SearchItem.Guid;
                }
                else
                {
                    URL += "?" + SearchItem.Guid;
                }
            }
            item["link"] = URL;
            item["guid"] = URL;
            return item;
        }