public CommonSearchCriterionItem(string propertyName, object value, SearchModeEnum searchMode) : this() { this.Init(); this.PropertyName = propertyName; this.Value = value; this.SearchMode = searchMode; }
public virtual void SetSearch(string propertyName, object value, SearchModeEnum searchMode) { CommonSearchCriterionItem firstSearch = this.GetFirstSearch(propertyName); if (firstSearch != null) { firstSearch.Value = value; firstSearch.SearchMode = searchMode; } else { this.AddSearch(propertyName, value, searchMode); } }
private static DataSet PredictiveSearch(string searchText, string PredictiveSearchDocumentTypes, string PredictiveSearchCultureCode, string PredictiveSearchCondition, SearchOptionsEnum PredictiveSearchOptions, SearchModeEnum PredictiveSearchMode, bool PredictiveSearchCombineWithDefaultCulture, string PredictiveSearchSort, string PredictiveSearchPath, bool PredictiveSearchCheckPermissions, string PredictiveSearchIndexes, int PredictiveSearchMaxResults, bool PredictiveSearchBlockFieldOnlySearch) { // Prepare search text var docCondition = new DocumentSearchCondition(PredictiveSearchDocumentTypes, PredictiveSearchCultureCode, CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName), PredictiveSearchCombineWithDefaultCulture); var condition = new SearchCondition(PredictiveSearchCondition, PredictiveSearchMode, PredictiveSearchOptions, docCondition); string searchCondition = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Prepare parameters SearchParameters parameters = new SearchParameters() { SearchFor = searchCondition, SearchSort = PredictiveSearchSort, Path = PredictiveSearchPath, ClassNames = PredictiveSearchDocumentTypes, CurrentCulture = PredictiveSearchCultureCode, DefaultCulture = CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName), CombineWithDefaultCulture = PredictiveSearchCombineWithDefaultCulture, CheckPermissions = PredictiveSearchCheckPermissions, SearchInAttachments = false, User = MembershipContext.AuthenticatedUser, SearchIndexes = PredictiveSearchIndexes, StartingPosition = 0, DisplayResults = PredictiveSearchMaxResults, NumberOfProcessedResults = 100 > PredictiveSearchMaxResults ? PredictiveSearchMaxResults : 100, NumberOfResults = 0, AttachmentWhere = null, AttachmentOrderBy = null, BlockFieldOnlySearch = PredictiveSearchBlockFieldOnlySearch, }; // Search DataSet results = SearchHelper.Search(parameters); return(results); }
SearchModeEnum GetSearchModeEnum(string input) { SearchModeEnum result = SearchModeEnum.AllWords; if (input.ToLower() == SearchModeEnum.AnyWord.ToString().ToLower()) { result = SearchModeEnum.AnyWord; } else if (input.ToLower() == SearchModeEnum.AnyWordOrSynonyms.ToString().ToLower()) { result = SearchModeEnum.AnyWordOrSynonyms; } else if (input.ToLower() == SearchModeEnum.ExactPhrase.ToString().ToLower()) { result = SearchModeEnum.ExactPhrase; } return(result); }
public async Task FindInDocument(TextReader source, string phrase, SearchModeEnum mode, CancellationToken token, Action <int> onOffsetFound) { var dispatcher = Dispatcher.CurrentDispatcher; Action <int> onOffsetFoundUI = (int offset) => { dispatcher.Invoke(onOffsetFound, offset); // Invoked on UI thread }; switch (mode) { case SearchModeEnum.Default: var job = new SearchJob(source, phrase, onOffsetFoundUI); await JobRunner.Run(job, token); break; case SearchModeEnum.Regex: break; default: break; } }
public virtual void SetSearch(string propertyName, object value, SearchModeEnum searchMode, TypeCode type) { this.Searches.SetSearch(propertyName, value, searchMode, type); }
public virtual void AddSearch(string propertyName, object value, SearchModeEnum searchMode) { this.Searches.AddSearch(propertyName, value, searchMode); }
/// <summary> /// Perform search. /// </summary> protected override void OnPreRender(EventArgs e) { // Check whether current request is not postback if (!RequestHelper.IsPostBack()) { // Get current search text from query string string searchText = QueryHelper.GetString("searchtext", ""); // Check whether search text is defined if (!string.IsNullOrEmpty(searchText)) { // Get current search mode from query string string searchMode = QueryHelper.GetString("searchmode", ""); SearchModeEnum searchModeEnum = ISearchHelper.GetSearchModeEnum(searchMode); // Get current index id int indexId = QueryHelper.GetInteger("indexId", 0); // Get current index info object SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(indexId); // Check whether index info exists if (sii != null) { // Keep search text in search textbox //txtSearchFor.Text = searchText; searchText = SearchHelper.CombineSearchCondition(searchText, null, searchModeEnum, SearchOptionsEnum.FullSearch, null, null, null, false); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgrSearch.PageSize != 0 && pgrSearch.GroupSize != 0) { startPosition = (pgrSearch.CurrentPage - 1) * pgrSearch.PageSize; numberOfProceeded = (((pgrSearch.CurrentPage / pgrSearch.GroupSize) + 1) * pgrSearch.PageSize * pgrSearch.GroupSize) + pgrSearch.PageSize; displayResults = pgrSearch.PageSize; } // Prepare parameters SearchParameters parameters = new SearchParameters() { SearchFor = searchText, SearchSort = null, Path = null, ClassNames = null, CurrentCulture = "##ALL##", DefaultCulture = null, CombineWithDefaultCulture = false, CheckPermissions = false, SearchInAttachments = false, User = (UserInfo)CMSContext.CurrentUser, SearchIndexes = sii.IndexName, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = null, AttachmentOrderBy = null, }; // Search DataSet results = SearchHelper.Search(parameters); // Fill repeater with results repSearchResults.DataSource = results; repSearchResults.PagerForceNumberOfResults = parameters.NumberOfResults; repSearchResults.DataBind(); // Show now results found ? if (parameters.NumberOfResults == 0) { lblNoResults.Text = "<br />" + GetString("srch.results.noresults"); lblNoResults.Visible = true; Exception searchError = SearchHelper.LastSmartSearchError; if (searchError != null) { pnlError.Visible = true; lblError.Text = GetString("smartsearch.searcherror") + " " + searchError.Message; } } } } } base.OnPreRender(e); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Get current index id int indexId = QueryHelper.GetInteger("indexId", 0); // Get current index info object SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(indexId); // Show warning if indes isn't ready yet if ((sii != null) && (sii.IndexStatus == IndexStatusEnum.NEW)) { ShowWarning(GetString("srch.index.needrebuild")); } if (!RequestHelper.IsPostBack()) { // Get current search text from query string string searchText = QueryHelper.GetString("searchtext", ""); // Check whether search text is defined if (!string.IsNullOrEmpty(searchText)) { // Get current search mode from query string string searchMode = QueryHelper.GetString("searchmode", ""); SearchModeEnum searchModeEnum = searchMode.ToEnum <SearchModeEnum>(); // Check whether index info exists if (sii != null) { // Keep search text in search textbox //txtSearchFor.Text = searchText; var condition = new SearchCondition(null, searchModeEnum, SearchOptionsEnum.FullSearch); searchText = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgrSearch.CurrentPageSize != 0 && pgrSearch.GroupSize != 0) { startPosition = (pgrSearch.CurrentPage - 1) * pgrSearch.CurrentPageSize; numberOfProceeded = (((pgrSearch.CurrentPage / pgrSearch.GroupSize) + 1) * pgrSearch.CurrentPageSize * pgrSearch.GroupSize) + pgrSearch.CurrentPageSize; displayResults = pgrSearch.CurrentPageSize; } // Prepare parameters SearchParameters parameters = new SearchParameters() { SearchFor = searchText, SearchSort = null, Path = null, ClassNames = null, CurrentCulture = "##ALL##", DefaultCulture = null, CombineWithDefaultCulture = false, CheckPermissions = false, SearchInAttachments = false, User = MembershipContext.AuthenticatedUser, SearchIndexes = sii.IndexName, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = null, AttachmentOrderBy = null, }; // Search DataSet results = SearchHelper.Search(parameters); // Fill repeater with results repSearchResults.DataSource = results; repSearchResults.PagerForceNumberOfResults = parameters.NumberOfResults; repSearchResults.DataBind(); // Show now results found ? if (parameters.NumberOfResults == 0) { lblNoResults.Text = "<br />" + GetString("srch.results.noresults.preview"); lblNoResults.Visible = true; Exception searchError = SearchContext.LastError; if (searchError != null) { pnlError.Visible = true; lblError.Text = GetString("smartsearch.searcherror") + " " + searchError.Message; } } } } // Fill CMSDropDownList option with values ControlsHelper.FillListControlWithEnum <SearchModeEnum>(drpSearchMode, "srch.dialog", useStringRepresentation: true); drpSearchMode.SelectedValue = QueryHelper.GetString("searchmode", EnumHelper.GetDefaultValue <SearchModeEnum>().ToStringRepresentation()); // Set up search text txtSearchFor.Text = QueryHelper.GetString("searchtext", ""); } }
/// <summary> /// Perform search. /// </summary> protected void Search() { if (StopProcessing) { // Do nothing } else { // Get query strings string searchText = QueryHelper.GetString("searchtext", ""); bool searchTextIsNotEmptyOrRequired = (!SearchTextRequired || !String.IsNullOrEmpty(searchText)); bool searchAllowed = SearchOnEachPageLoad || QueryHelper.Contains("searchtext"); if ((searchTextIsNotEmptyOrRequired || !SearchHelper.SearchOnlyWhenContentPresent) && searchAllowed) { string searchMode = QueryHelper.GetString("searchMode", ""); SearchModeEnum searchModeEnum = CMS.ISearchEngine.SearchHelper.GetSearchModeEnum(searchMode); // Get current culture string culture = CultureCode; if (string.IsNullOrEmpty(culture)) { culture = ValidationHelper.GetString(ViewState["CultureCode"], CMSContext.PreferredCultureCode); } // Get default culture string defaultCulture = CultureHelper.GetDefaultCulture(CMSContext.CurrentSiteName); // Resolve path string path = Path; if (!string.IsNullOrEmpty(path)) { path = CMSContext.ResolveCurrentPath(Path); } if (CMSContext.ViewMode == ViewModeEnum.LiveSite) { // Log on site keywords if (AnalyticsHelper.JavascriptLoggingEnabled(CMSContext.CurrentSiteName)) { ScriptHelper.RegisterWebServiceCallFunction(Page); string script = "WebServiceCall('" + URLHelper.GetAbsoluteUrl("~/CMSPages/WebAnalyticsService.asmx") + "','LogSearch', '{\"keyword\":\"" + ScriptHelper.GetString(ScriptHelper.GetString(searchText, false), false) + "\"}')"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "logSearch", script, true); } else { AnalyticsHelper.LogOnSiteSearchKeywords(CMSContext.CurrentSiteName, CMSContext.CurrentAliasPath, culture, searchText, 0, 1); } } // Prepare search text searchText = SearchHelper.CombineSearchCondition(searchText, SearchCondition + FilterSearchCondition, searchModeEnum, SearchOptions, DocumentTypes, culture, defaultCulture, CombineWithDefaultCulture); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgr.PageSize != 0 && pgr.GroupSize != 0) { startPosition = (pgr.CurrentPage - 1) * pgr.PageSize; numberOfProceeded = (((pgr.CurrentPage / pgr.GroupSize) + 1) * pgr.PageSize * pgr.GroupSize) + pgr.PageSize; displayResults = pgr.PageSize; } if ((MaxResults > 0) && (numberOfProceeded > MaxResults)) { numberOfProceeded = MaxResults; } // Combine regular search sort with filter sort string srt = ValidationHelper.GetString(SearchSort, String.Empty).Trim(); string filterSrt = ValidationHelper.GetString(FilterSearchSort, String.Empty).Trim(); if (!String.IsNullOrEmpty(filterSrt)) { if (!String.IsNullOrEmpty(srt)) { srt += ", "; } srt += filterSrt; } // Prepare parameters SearchParameters parameters = new SearchParameters() { SearchFor = searchText, SearchSort = SearchHelper.GetSort(srt), Path = path, ClassNames = DocumentTypes, CurrentCulture = culture, DefaultCulture = defaultCulture, CombineWithDefaultCulture = CombineWithDefaultCulture, CheckPermissions = CheckPermissions, SearchInAttachments = SearchInAttachments, User = (UserInfo)CMSContext.CurrentUser, SearchIndexes = Indexes, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = AttachmentsWhere, AttachmentOrderBy = AttachmentsOrderBy, BlockFieldOnlySearch = BlockFieldOnlySearch, }; // Search DataSet results = SearchHelper.Search(parameters); int numberOfResults = parameters.NumberOfResults; if ((MaxResults > 0) && (numberOfResults > MaxResults)) { numberOfResults = MaxResults; } // Fill repeater with results repSearchResults.DataSource = results; repSearchResults.PagerForceNumberOfResults = numberOfResults; this.PagerForceNumberOfResults = numberOfResults; repSearchResults.DataBind(); // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } // Show now results found ? if (numberOfResults == 0) { if (ShowParsingErrors) { Exception searchError = SearchHelper.LastSmartSearchError; if (searchError != null) { ShowError(GetString("smartsearch.searcherror") + " " + searchError.Message); } } lblNoResults.Text = NoResultsText; lblNoResults.Visible = true; } } else { Visible = false; } // Invoke search completed event if (OnSearchCompleted != null) { OnSearchCompleted(Visible); } } }
/// <summary> /// Perform search. /// </summary> protected void Search() { if (StopProcessing) { // Do nothing } else { // Check if the search was triggered bool searchAllowed = SearchOnEachPageLoad || QueryHelper.Contains("searchtext"); // Get query strings string searchText = QueryHelper.GetString("searchtext", ""); // Check whether string passes text requirements settings bool searchTextIsNotEmptyOrNotRequired = (!SearchTextRequired || !String.IsNullOrEmpty(searchText)); // Proceed when search was triggered and search text is passing requirements settings. // Requirements setting could be overridden on this level by obsolete web.config key. The reason is backward compatibility. // Search text required web part setting was introduced after this web.config key. Key default value was at the time set to true. // This default value had the same effect as this new web part setting. When someone changed the web.config key to false and then upgraded the solution, // required web part setting with default value true would override previous behavior. That's the reason why this obsolete key can override this setting. if (searchAllowed && (searchTextIsNotEmptyOrNotRequired || !SearchHelper.SearchOnlyWhenContentPresent)) { string searchMode = QueryHelper.GetString("searchMode", ""); SearchModeEnum searchModeEnum = EnumStringRepresentationExtensions.ToEnum <SearchModeEnum>(searchMode); // Get current culture string culture = CultureCode; if (string.IsNullOrEmpty(culture)) { culture = ValidationHelper.GetString(ViewState["CultureCode"], LocalizationContext.PreferredCultureCode); } var siteName = SiteContext.CurrentSiteName; // Get default culture string defaultCulture = CultureHelper.GetDefaultCultureCode(siteName); // Resolve path string path = Path; if (!string.IsNullOrEmpty(path)) { path = MacroResolver.ResolveCurrentPath(Path); } // Prepare search text var docCondition = new DocumentSearchCondition(DocumentTypes, culture, defaultCulture, CombineWithDefaultCulture); var searchCond = SearchCondition; if (!string.IsNullOrEmpty(FilterSearchCondition) && (searchModeEnum == SearchModeEnum.AnyWordOrSynonyms)) { // Make sure the synonyms are expanded before the filter condition is applied (filter condition is Lucene syntax, cannot be expanded) searchCond = SearchSyntaxHelper.ExpandWithSynonyms(searchCond, docCondition.Culture); } var condition = new SearchCondition(searchCond + FilterSearchCondition, searchModeEnum, SearchOptions, docCondition, DoFuzzySearch); searchText = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgr.PageSize != 0 && pgr.GroupSize != 0) { // Reset pager if needed if (mResetPager) { pgr.CurrentPage = 1; } startPosition = (pgr.CurrentPage - 1) * pgr.PageSize; // Only results covered by current page group are proccessed (filtered) for performance reasons. This may cause decrease of the number of results while paging. numberOfProceeded = (((pgr.CurrentPage / pgr.GroupSize) + 1) * pgr.PageSize * pgr.GroupSize) + pgr.PageSize; displayResults = pgr.PageSize; } if ((MaxResults > 0) && (numberOfProceeded > MaxResults)) { numberOfProceeded = MaxResults; } // Combine regular search sort with filter sort string srt = ValidationHelper.GetString(SearchSort, String.Empty).Trim(); string filterSrt = ValidationHelper.GetString(FilterSearchSort, String.Empty).Trim(); if (!String.IsNullOrEmpty(filterSrt)) { if (!String.IsNullOrEmpty(srt)) { srt += ", "; } srt += filterSrt; } // Prepare parameters SearchParameters parameters = new SearchParameters { SearchFor = searchText, SearchSort = srt, Path = path, ClassNames = DocumentTypes, CurrentCulture = culture, DefaultCulture = defaultCulture, CombineWithDefaultCulture = CombineWithDefaultCulture, CheckPermissions = CheckPermissions, SearchInAttachments = SearchInAttachments, User = MembershipContext.AuthenticatedUser, SearchIndexes = Indexes, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = AttachmentsWhere, AttachmentOrderBy = AttachmentsOrderBy, BlockFieldOnlySearch = BlockFieldOnlySearch, }; // Search var results = SearchHelper.Search(parameters); int numberOfResults = parameters.NumberOfResults; if ((MaxResults > 0) && (numberOfResults > MaxResults)) { numberOfResults = MaxResults; } // Limit displayed results according to MaxPages property var maxDisplayedResultsOnMaxPages = MaxPages * PageSize; // Apply only if MaxPages and PageSize properties are set if ((maxDisplayedResultsOnMaxPages > 0) && (numberOfResults > maxDisplayedResultsOnMaxPages)) { numberOfResults = maxDisplayedResultsOnMaxPages; } // Fill repeater with results repSearchResults.DataSource = results.Items; repSearchResults.PagerForceNumberOfResults = numberOfResults; PagerForceNumberOfResults = numberOfResults; repSearchResults.DataBind(); // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } // Show no results found ? if (numberOfResults == 0) { if (ShowParsingErrors) { Exception searchError = results.LastError; if (searchError != null) { ShowError(GetString("smartsearch.searcherror") + " " + HTMLHelper.HTMLEncode(searchError.Message)); } } lblNoResults.Text = NoResultsText; lblNoResults.Visible = true; } } else { if (!String.IsNullOrEmpty(SearchTextValidationFailedText) && searchAllowed) { pnlSearchResults.AddCssClass(SearchTextValidationFailedCssClass); lblNoResults.Text = SearchTextValidationFailedText; lblNoResults.Visible = true; } else { Visible = false; } } // Invoke search completed event if (OnSearchCompleted != null) { OnSearchCompleted(Visible); } } }
public HqlCommonSearchCriterionItem(string propertyName, object value, SearchModeEnum searchMode, TypeCode type) : base(propertyName, value, searchMode) { }
/// <summary> /// Refresh the catalog based on the new aoi /// </summary> internal void FilterChanged(SearchModeEnum eMode, BoundingBox searchExtents, string strSearch, bool bAOIFilter, bool bTextFilter) { bool bChanged = false; // --- the catalog filter changed, do we need to do something --- if (m_bAOIFilter && m_oCatalogBoundingBox != searchExtents) { m_oCatalogBoundingBox = new Geosoft.Dap.Common.BoundingBox(searchExtents); bChanged = true; } if (m_bTextFilter && (m_strSearchString != m_strCurSearchString || m_eMode != m_ePrevMode)) { m_strSearchString = m_strCurSearchString; m_ePrevMode = m_eMode; bChanged = true; } if (bChanged || m_bAOIFilter != m_bPrevAOIFilter || m_bTextFilter != m_bPrevTextFilter) { ClearCatalog(); GetCatalogHierarchy(); m_bPrevAOIFilter = m_bAOIFilter; m_bPrevTextFilter = m_bTextFilter; } }
/// <summary> /// Refresh the catalog based on the new aoi /// </summary> internal virtual void AsyncFilterChanged(SearchModeEnum eMode, BoundingBox searchExtents, string strSearch, bool bAOIFilter, bool bTextFilter) { m_eMode = eMode; m_bAOIFilter = bAOIFilter; m_bTextFilter = bTextFilter; CreateSearchString(strSearch); EnqueueRequest(ServerTree.AsyncRequestType.FilterChanged, (object)ServerTree.SearchModeEnum.All, (object)searchExtents, (object)strSearch, (object)bAOIFilter, (object)bTextFilter); }
public virtual void AddSearch(string propertyName, object value, SearchModeEnum searchMode, TypeCode type) { this.Searches.Add(new CommonSearchCriterionItem(propertyName, value, searchMode, type)); }
SearchModeEnum tagschmode = SearchModeEnum.Like; // 扩展信息查询方式 #endregion #region 构造函数 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); ids = RequestData.GetList <string>("ids"); pids = RequestData.GetList <string>("pids"); code = RequestData.Get <string>("code", String.Empty); showroot = RequestData.Get <string>("showroot", String.Empty); tag = RequestData.Get <string>("tag", String.Empty); string tagschmodestr = RequestData.Get <string>("tagschmode", String.Empty); tagschmode = ObjectHelper.GetEnum <SearchModeEnum>(tagschmodestr, SearchModeEnum.Like); SysEnumeration ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SysEnumeration>(); ent.ParentID = String.IsNullOrEmpty(ent.ParentID) ? null : ent.ParentID; ent.Update(); this.SetMessage("更新成功!"); break; default: if (RequestActionString == "batchdelete") { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { SysEnumeration.DoBatchDelete(idList.ToArray()); } } else { // 构建查询表达式 SearchCriterion sc = new HqlSearchCriterion(); // sc.SetOrder("SortIndex"); sc.SetOrder("CreatedDate"); ICriterion crit = null; if (RequestActionString == "querychildren") { if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0) { if (ids != null && ids.Count > 0) { IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); crit = Expression.In(SysEnumeration.Prop_EnumerationID, distids.ToArray()); } if (pids != null && pids.Count > 0) { IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); if (crit != null) { crit = SearchHelper.UnionCriterions(crit, Expression.In(SysEnumeration.Prop_ParentID, dispids.ToArray())); } else { crit = Expression.In(SysEnumeration.Prop_ParentID, dispids.ToArray()); } } } } else { ICriterion tagCirt = null; if (!String.IsNullOrEmpty(tag)) { HqlCommonSearchCriterionItem tagCritItem = new HqlCommonSearchCriterionItem(SysEnumeration.Prop_Tag, tag, tagschmode); tagCirt = tagCritItem.GetCriterion(); } if (!String.IsNullOrEmpty(code)) { SysEnumeration tent = SysEnumeration.FindFirstByProperties(SysEnumeration.Prop_Code, code); crit = SearchHelper.IntersectCriterions( Expression.Eq(SysEnumeration.Prop_ParentID, tent.EnumerationID), tagCirt); if (!String.IsNullOrEmpty(showroot) && showroot != "0" && showroot.ToLower() != "false") { crit = SearchHelper.UnionCriterions( crit, Expression.Eq(SysEnumeration.Prop_EnumerationID, tent.EnumerationID)); } this.PageState.Add("Root", tent); } else { crit = SearchHelper.UnionCriterions(Expression.IsNull(SysEnumeration.Prop_ParentID), Expression.Eq(SysEnumeration.Prop_ParentID, String.Empty)); crit = SearchHelper.IntersectCriterions(crit, tagCirt); } } ents = SysEnumerationRule.FindAll(sc, crit); this.PageState.Add("DtList", ents); } break; } }
/// <summary> /// Perform search. /// </summary> protected void Search() { if (StopProcessing) { // Do nothing } else { // Check if the search was triggered bool searchAllowed = SearchOnEachPageLoad || QueryHelper.Contains("searchtext"); // Get query strings string searchText = QueryHelper.GetString("searchtext", ""); // Check whether string passes text requirements settings bool searchTextIsNotEmptyOrNotRequired = (!SearchTextRequired || !String.IsNullOrEmpty(searchText)); // Proceed when search was triggered and search text is passing requirements settings. // Requirements setting could be overriden on this level by obsolete web.config key. The reason is backward compatibility. // Search text required web part setting was introduced after this web.config key. Key default value was at the time set to true. // This default value had the same effect as this new web part setting. When somenone changed the web.config key to false and then upgraded the solution, // required wep part setting with default value true would override previous behaviour. That's the reason why this obsolete key can override this setting. if (searchAllowed && (searchTextIsNotEmptyOrNotRequired || !SearchHelper.SearchOnlyWhenContentPresent)) { string searchMode = QueryHelper.GetString("searchMode", ""); SearchModeEnum searchModeEnum = searchMode.ToEnum <SearchModeEnum>(); // Get current culture string culture = CultureCode; if (string.IsNullOrEmpty(culture)) { culture = ValidationHelper.GetString(ViewState["CultureCode"], LocalizationContext.PreferredCultureCode); } // Get default culture string defaultCulture = CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName); // Resolve path string path = Path; if (!string.IsNullOrEmpty(path)) { path = MacroResolver.ResolveCurrentPath(Path); } if (PortalContext.ViewMode.IsLiveSite()) { if (AnalyticsHelper.JavascriptLoggingEnabled(SiteContext.CurrentSiteName)) { ScriptHelper.RegisterWebServiceCallFunction(Page); string script = "WebServiceCall('" + URLHelper.GetAbsoluteUrl("~/CMSPages/WebAnalyticsService.asmx") + "','LogSearch', '{\"keyword\":" + // Serialize raw search text to encode '<' and similar characters, then escape '\' new JavaScriptSerializer().Serialize(searchText).Replace(@"\", @"\\") + ", \"pageGUID\":\"" + DocumentContext.CurrentPageInfo.DocumentGUID + "\"}')"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "logSearch", script, true); } else { // Log on site keywords AnalyticsHelper.LogOnSiteSearchKeywords(SiteContext.CurrentSiteName, DocumentContext.CurrentAliasPath, culture, searchText, 0, 1); } } // Prepare search text var docCondition = new DocumentSearchCondition(DocumentTypes, culture, defaultCulture, CombineWithDefaultCulture); var searchCond = SearchCondition; if (!string.IsNullOrEmpty(FilterSearchCondition) && (searchModeEnum == SearchModeEnum.AnyWordOrSynonyms)) { // Make sure the synonyms are expanded before the filter condition is applied (filter condition is Lucene syntax, cannot be expanded) searchCond = SearchSyntaxHelper.ExpandWithSynonyms(searchCond, docCondition.Culture); searchModeEnum = SearchModeEnum.AnyWord; } var condition = new SearchCondition(searchCond + FilterSearchCondition, searchModeEnum, SearchOptions, docCondition, DoFuzzySearch); searchText = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Get positions and ranges for search method int startPosition = 0; int numberOfProceeded = 100; int displayResults = 100; if (pgr.PageSize != 0 && pgr.GroupSize != 0) { // Reset pager if needed if (mResetPager) { pgr.CurrentPage = 1; } startPosition = (pgr.CurrentPage - 1) * pgr.PageSize; // Only results covered by current page group are proccessed (filtered) for performance reasons. This may cause decrease of the number of results while paging. numberOfProceeded = (((pgr.CurrentPage / pgr.GroupSize) + 1) * pgr.PageSize * pgr.GroupSize) + pgr.PageSize; displayResults = pgr.PageSize; } if ((MaxResults > 0) && (numberOfProceeded > MaxResults)) { numberOfProceeded = MaxResults; } // Combine regular search sort with filter sort string srt = ValidationHelper.GetString(SearchSort, String.Empty).Trim(); string filterSrt = ValidationHelper.GetString(FilterSearchSort, String.Empty).Trim(); if (!String.IsNullOrEmpty(filterSrt)) { if (!String.IsNullOrEmpty(srt)) { srt += ", "; } srt += filterSrt; } // Prepare parameters SearchParameters parameters = new SearchParameters { SearchFor = searchText, SearchSort = srt, Path = path, ClassNames = DocumentTypes, CurrentCulture = culture, DefaultCulture = defaultCulture, CombineWithDefaultCulture = CombineWithDefaultCulture, CheckPermissions = CheckPermissions, SearchInAttachments = SearchInAttachments, User = MembershipContext.AuthenticatedUser, SearchIndexes = Indexes, StartingPosition = startPosition, DisplayResults = displayResults, NumberOfProcessedResults = numberOfProceeded, NumberOfResults = 0, AttachmentWhere = AttachmentsWhere, AttachmentOrderBy = AttachmentsOrderBy, BlockFieldOnlySearch = BlockFieldOnlySearch, }; // Search DataSet results = SearchHelper.Search(parameters); int numberOfResults = parameters.NumberOfResults; if ((MaxResults > 0) && (numberOfResults > MaxResults)) { numberOfResults = MaxResults; } // Fill repeater with results repSearchResults.DataSource = results; repSearchResults.PagerForceNumberOfResults = numberOfResults; PagerForceNumberOfResults = numberOfResults; repSearchResults.DataBind(); // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } // Show now results found ? if (numberOfResults == 0) { if (ShowParsingErrors) { Exception searchError = SearchContext.LastError; if (searchError != null) { ShowError(GetString("smartsearch.searcherror") + " " + searchError.Message); } } lblNoResults.Text = NoResultsText; lblNoResults.Visible = true; } } else { if (!String.IsNullOrEmpty(SearchTextValidationFailedText) && searchAllowed) { pnlSearchResults.AddCssClass(SearchTextValidationFailedCssClass); lblNoResults.Text = SearchTextValidationFailedText; lblNoResults.Visible = true; } else { Visible = false; } } // Invoke search completed event if (OnSearchCompleted != null) { OnSearchCompleted(Visible); } } }
public CommonSearchCriterionItem(string propertyName, object value, SearchModeEnum searchMode, TypeCode type) : this(propertyName, value, searchMode) { this.Type = type; }
private static DataSet PredictiveSearch(string searchText, string PredictiveSearchDocumentTypes, string PredictiveSearchCultureCode, string PredictiveSearchCondition, SearchOptionsEnum PredictiveSearchOptions, SearchModeEnum PredictiveSearchMode, bool PredictiveSearchCombineWithDefaultCulture, string PredictiveSearchSort, string PredictiveSearchPath, bool PredictiveSearchCheckPermissions, string PredictiveSearchIndexes, int PredictiveSearchMaxResults, bool PredictiveSearchBlockFieldOnlySearch) { // Prepare search text var docCondition = new DocumentSearchCondition(PredictiveSearchDocumentTypes, PredictiveSearchCultureCode, CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName), PredictiveSearchCombineWithDefaultCulture); var condition = new SearchCondition(PredictiveSearchCondition, PredictiveSearchMode, PredictiveSearchOptions, docCondition); string searchCondition = SearchSyntaxHelper.CombineSearchCondition(searchText, condition); // Prepare parameters SearchParameters parameters = new SearchParameters() { SearchFor = searchCondition, SearchSort = PredictiveSearchSort, Path = PredictiveSearchPath, ClassNames = PredictiveSearchDocumentTypes, CurrentCulture = PredictiveSearchCultureCode, DefaultCulture = CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName), CombineWithDefaultCulture = PredictiveSearchCombineWithDefaultCulture, CheckPermissions = PredictiveSearchCheckPermissions, SearchInAttachments = false, User = MembershipContext.AuthenticatedUser, SearchIndexes = PredictiveSearchIndexes, StartingPosition = 0, DisplayResults = PredictiveSearchMaxResults, NumberOfProcessedResults = 100 > PredictiveSearchMaxResults ? PredictiveSearchMaxResults : 100, NumberOfResults = 0, AttachmentWhere = null, AttachmentOrderBy = null, BlockFieldOnlySearch = PredictiveSearchBlockFieldOnlySearch, }; // Search DataSet results = SearchHelper.Search(parameters); return results; }