public override SearchErrorInfo GetStatus(SearchId searchId, out SearchStatus searchStatus) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.GetStatus {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; searchStatus = null; SearchStatus theSearchStatus = null; SearchUtils.ExWatsonWrappedCall(delegate() { MailboxSearchWorkItem mailboxSearchWorkItem = null; if (!this.searchWorkItemMap.TryGetValue(searchId, out mailboxSearchWorkItem)) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "The search {0} is not started", searchId.SearchName); errorInfo = new SearchErrorInfo(262658, Strings.SearchNotStarted); return; } try { theSearchStatus = mailboxSearchWorkItem.GetStatus(); } catch (ExportException ex) { MailboxSearchServer.Tracer.TraceError <ExportException>((long)this.GetHashCode(), "MailboxSearchServer.GetStatus error {0}", ex); errorInfo = new SearchErrorInfo(-2147220991, ex); } }); searchStatus = theSearchStatus; if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to get the status of the search workitem", searchId, errorInfo); } return(errorInfo); }
/// <inheritdoc cref="Solver.Run"/> public override void Run() { // Search for best path to the end Vector2 <int> start = Vector2 <int> .Zero, end = (this.Grid.Width - 1, this.Grid.Height - 1); // ReSharper disable once AccessToModifiedClosure Vector2 <int>[] path = SearchUtils.Search(start, end, p => Vector2 <int> .ManhattanDistance(p, end), node => FindNeighbours(node, this.Grid), MinSearchComparer.Comparer) !; int total = path.Sum(p => this.Grid[p]); AoCUtils.LogPart1(total); // Create scaled map Grid <byte> fullMap = new(this.Data.Width * FULL_SIZE, this.Data.Height * FULL_SIZE); foreach (Vector2 <int> position in Vector2 <int> .Enumerate(this.Data.Width, this.Data.Height)) { int risk = this.Data[position]; foreach (Vector2 <int> offset in Vector2 <int> .Enumerate(FULL_SIZE, FULL_SIZE)) { Vector2 <int> pos = position + offset.Scale(this.Data.Width, this.Data.Height); int newRisk = risk + offset.X + offset.Y; fullMap[pos] = (byte)(newRisk > 9 ? newRisk - 9 : newRisk); } } // Search for new best path end = (fullMap.Width - 1, fullMap.Height - 1); path = SearchUtils.Search(start, end, p => Vector2 <int> .ManhattanDistance(p, end), node => FindNeighbours(node, fullMap), MinSearchComparer.Comparer) !; total = path.Sum(p => fullMap[p]); AoCUtils.LogPart2(total); }
public async Task <IEnumerable <Index> > Get(IEnumerable <string> keys, bool fileNameOnly, bool explicitValue) { var allIndexes = await _dbAdapter.GetAllIndexes(); LoadAllIndexes(allIndexes); return(await SearchUtils.Search(_defaultsConfig.MaxNumberOfTasks, _loadedIndexes, keys, fileNameOnly, explicitValue)); }
void Search() { string text = tbSearch.Text; try { using (WaitCursor wr = new WaitCursor(app, Locale.Get("_searching..."))) { dgSearch.BeginInit(); dgSearch.DataSource = null; dtSearch.Clear(); GType type = SelectedType; int typeId = type != null? type.Id:0; if (app.Lib.HasDb) { SearchUtils.SqlSearch(app.Lib, text, typeId, dtSearch); } else { SearchUtils.Search(app.Lib, text, typeId, dtSearch); } app.Status = string.Format("{0} records found", dtSearch.Rows.Count); dgSearch.DataSource = dtSearch; } } catch (Exception ex) { Log.Exception(ex); } finally { dgSearch.EndInit(); } }
public ActionResult Search() { DebugUtils.StartLogEvent("HomeController.Search"); var model = GetLayoutItem <IndexSearch>(); model.searchOptions = new SearchResult(); model.SavedSearches = SearchUtils.GetSavedSearches(); SearchUtils.ValidateSearchOptions(model.searchOptions, true); //Removes any Resorts the user doesn't have access Session["SearchType"] = null; Session["SearchResortId"] = null; if (Session["SearchCity"] != null) { var city = Session["SearchCity"].ToString(); if (!string.IsNullOrEmpty(city)) { var spit = city.Split(','); model.searchOptions.searchParameters.Destination = "city-" + spit[0]; } Session["SearchCity"] = null; } if (Session["SearchLOS"] != null) { var los = Convert.ToInt16(Session["SearchLOS"]); model.searchOptions.searchParameters.CheckOutDate = model.searchOptions.searchParameters.CheckInDate.AddDays(los); Session["SearchLOS"] = null; } AddBackgroundImage(model); DebugUtils.EndLogEvent("HomeController.Search"); return(View(model)); }
internal static SearchProvider CreateProvider() { var helpProvider = new SearchProvider(type, displayName) { priority = -1, filterId = "?", isExplicitProvider = true, fetchItems = (context, items, provider) => { if (m_StaticItemToAction == null) { BuildHelpItems(context, provider); } var helpItems = m_StaticItemToAction.Keys; if (string.IsNullOrEmpty(context.searchQuery) || string.IsNullOrWhiteSpace(context.searchQuery)) { items.AddRange(helpItems); return(null); } items.AddRange(helpItems.Where(item => SearchUtils.MatchSearchGroups(context, item.label) || SearchUtils.MatchSearchGroups(context, item.description))); return(null); } }; return(helpProvider); }
/* get the sql search condition of this/these type/types */ internal string GetSqlSearchCondition(MatchRule typeMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsType(Audio)) { SearchUtils.Append(sql, "Items.MimeType LIKE 'audio/%'", typeMatchRule); } if (this.ContainsType(Video)) { SearchUtils.Append(sql, "Items.MimeType LIKE 'video/%'", typeMatchRule); } if (this.ContainsType(Image)) { SearchUtils.Append(sql, "Items.MimeType LIKE 'image/%'", typeMatchRule); } if (this.ContainsType(Text)) { SearchUtils.Append(sql, "Items.MimeType LIKE 'text/%'", typeMatchRule); } if (this.ContainsType(Directory)) { SearchUtils.Append(sql, "Items.MimeType = 'x-directory/normal'", typeMatchRule); } return(sql.ToString()); }
public S FindState(ISearchProblem <S, A> problem) { _frontier.Clear(); var node = _impl.FindNode(problem, _frontier); return(SearchUtils.ToState(node)); }
private void OnGUI() { LoadResources(); searchText = SearchUtils.BeginSearchbar(this, searchText); if (SearchUtils.Button(new GUIContent("Remove All"), GUILayout.MaxWidth(CLEAR_BUTTON_WIDTH))) { list.Clear(); Repaint(); } SearchUtils.EndSearchbar(); using (var scrollView = new GUILayout.ScrollViewScope(scrollPos, false, false)) { scrollPos = scrollView.scrollPosition; for (int i = list.References.Count - 1; i >= 0; i--) { var reference = list.References[i]; if (SearchUtils.IsSearched(reference, searchText)) { if (DrawElement(reference)) { list.RemoveReference(reference); } } } list.References.RemoveAll(reference => reference == null); } DetectDragNDrop(); }
// function HILL-CLIMBING(problem) returns a state that is a local maximum public List <Action> search(Problem p) { clearInstrumentation(); outcome = SearchOutcome.FAILURE; lastState = null; // current <- MAKE-NODE(problem.INITIAL-STATE) Node current = new Node(p.getInitialState()); Node neighbor = null; // loop do while (!CancelableThread.currIsCanceled()) { List <Node> children = expandNode(current, p); // neighbor <- a highest-valued successor of current neighbor = getHighestValuedNodeFrom(children, p); // if neighbor.VALUE <= current.VALUE then return current.STATE if ((neighbor == null) || (getValue(neighbor) <= getValue(current))) { if (SearchUtils.isGoalState(p, current)) { outcome = SearchOutcome.SOLUTION_FOUND; } lastState = current.getState(); return(SearchUtils.actionsFromNodes(current.getPathFromRoot())); } // current <- neighbor current = neighbor; } return(new List <Action>()); }
public IEnumerable <A> FindActions(ISearchProblem <S, A> problem) { _frontier.Clear(); var node = _impl.FindNode(problem, _frontier); return(SearchUtils.ToActions(node)); }
/* get the sql search condition of this/these field/fields */ string IFreeTextSearchField.GetSqlSearchCondition(string searchString, TextCompareOperator compareOperator, MatchRule fieldMatchRule) { StringBuilder sql = new StringBuilder(); if (this.ContainsField(Title)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Title", searchString), fieldMatchRule); } if (this.ContainsField(LoanedTo)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Loaned_To", searchString), fieldMatchRule); } if (this.ContainsField(Description)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Description", searchString), fieldMatchRule); } if (this.ContainsField(Keywords)) { SearchUtils.Append(sql, compareOperator.GetSqlCompareString("Volumes.Keywords", searchString), fieldMatchRule); } return(sql.ToString()); }
internal static void CheckDiscoveryEnabled(IRecipientSession recipientSession, Task.TaskErrorLoggingDelegate writeErrorDelegate) { if (!SearchUtils.DiscoveryEnabled(recipientSession)) { writeErrorDelegate(new TaskException(Strings.MailboxSearchDisabled), ErrorCategory.ResourceUnavailable, null); } }
public override SearchErrorInfo Remove(SearchId searchId, bool removeLogs) { MailboxSearchServer.Tracer.TraceFunction <string>((long)this.GetHashCode(), "MailboxSearchServer.Remove on {0}", searchId.SearchName); SearchErrorInfo errorInfo = null; SearchUtils.ExWatsonWrappedCall(delegate() { lock (this) { if (this.IsShutDown) { errorInfo = new SearchErrorInfo(-2147220983, Strings.SearchServerShutdown); } else if (this.searchWorkItemMap.ContainsKey(searchId)) { MailboxSearchServer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "The search {0} is already started", searchId.SearchName); errorInfo = new SearchErrorInfo(-2147220980, Strings.ErrorRemoveOngoingSearch); } else if (this.pendingSearchIdMap.ContainsKey(searchId)) { this.pendingSearchIdMap.Remove(searchId); SearchEventLogger.Instance.LogDiscoverySearchPendingWorkItemsChangedEvent("RemovedFromPendingWorkItemsOnRemove", searchId.SearchName, searchId.MailboxDsName, this.pendingSearchIdMap.Count); } else { this.QueueSearchForDeletion(searchId, removeLogs, ref errorInfo); } } }); if (errorInfo != null && errorInfo.Failed) { MailboxSearchServer.LogErrorInfo("Error occured when trying to remove the search workitem", searchId, errorInfo); } return(errorInfo); }
// function DEPTH-LIMITED-SEARCH(problem, limit) returns a solution, or // failure/cutoff /** * Returns a list of actions to reach the goal if a goal was found, or empty. * The list itself can be empty if the initial state is a goal state. * * @return if goal found, the list of actions to the goal, empty otherwise. */ public ICollection <A> findActions(IProblem <S, A> p) { nodeExpander.useParentLinks(true); Node <S, A> node = findNode(p); return(!isCutoffResult(node) ? SearchUtils.toActions(node) : null); }
SearchValue OnPropertyFilter(GameObject go, string propertyName) { if (!go) { return(SearchValue.invalid); } if (string.IsNullOrEmpty(propertyName)) { return(SearchValue.invalid); } using (var view = SearchMonitor.GetView()) { var documentKey = SearchUtils.GetDocumentKey(go); var recordKey = PropertyDatabase.CreateRecordKey(documentKey, PropertyDatabase.CreatePropertyHash(propertyName)); if (view.TryLoadProperty(recordKey, out object data) && data is SearchValue sv) { return(sv); } foreach (var c in EnumerateSubObjects(go)) { var property = FindPropertyValue(c, propertyName); if (property.valid) { view.StoreProperty(recordKey, property); return(property); } } view.StoreProperty(recordKey, SearchValue.invalid); } return(SearchValue.invalid); }
public S findState(IProblem <S, A> p) { nodeExpander.useParentLinks(false); Node <S, A> node = findNode(p); return(!isCutoffResult(node) ? SearchUtils.toState(node) : default(S)); }
static SettingsProviderCache() { value = FetchSettingsProviders() .Select(provider => new SettingsProviderInfo() { path = provider.settingsPath, label = provider.label, scope = provider.scope, searchables = new[] { provider.settingsPath, provider.label } .Concat(provider.keywords) .Where(s => !string.IsNullOrEmpty(s)) .Select(s => Utils.FastToLower(s)).ToArray() }) .ToArray(); var iconName = "Filter Icon"; var icon = Utils.LoadIcon(iconName); var scopeValues = Enum.GetNames(typeof(SettingsScope)).Select(n => Utils.FastToLower(n)); queryEngine = new QueryEngine <SettingsProviderInfo>(); queryEngine.SetSearchDataCallback(info => info.searchables, s => Utils.FastToLower(s), StringComparison.Ordinal); queryEngine.SetFilter("scope", info => info.scope, new[] { ":", "=", "!=", "<", ">", "<=", ">=" }) .SetGlobalPropositionData(category: "Scope", priority: 0, icon: icon, color: QueryColors.typeIcon) .AddOrUpdatePropositionData(label: "Project", replacement: "scope:" + SearchUtils.GetListMarkerReplacementText("project", scopeValues, iconName, QueryColors.typeIcon), help: "Search project settings") .AddOrUpdatePropositionData(label: "User", replacement: "scope:" + SearchUtils.GetListMarkerReplacementText("user", scopeValues, iconName, QueryColors.typeIcon), help: "Search user settings"); queryEngine.AddOperatorHandler(":", (SettingsScope ev, SettingsScope fv, StringComparison sc) => ev.ToString().IndexOf(fv.ToString(), sc) != -1); queryEngine.AddOperatorHandler(":", (SettingsScope ev, string fv, StringComparison sc) => ev.ToString().IndexOf(fv, sc) != -1); queryEngine.AddOperatorHandler("=", (SettingsScope ev, SettingsScope fv) => ev == fv); queryEngine.AddOperatorHandler("!=", (SettingsScope ev, SettingsScope fv) => ev != fv); queryEngine.AddOperatorHandler("<", (SettingsScope ev, SettingsScope fv) => ev < fv); queryEngine.AddOperatorHandler(">", (SettingsScope ev, SettingsScope fv) => ev > fv); queryEngine.AddOperatorHandler("<=", (SettingsScope ev, SettingsScope fv) => ev <= fv); queryEngine.AddOperatorHandler(">=", (SettingsScope ev, SettingsScope fv) => ev >= fv); }
/// <summary> /// By Default registers all modules specified in lookupAssemblies.json in root directory which ends with Repository /// </summary> public ModuleRegistrant() { var checkedDir = SearchUtils.CheckCommonAssemblyStoresForFile(RegistrantOptions.LookupFileNames); if (string.IsNullOrEmpty(checkedDir)) { checkedDir = Directory.GetCurrentDirectory(); } var cfgBuilder = new ConfigurationBuilder() .SetBasePath(checkedDir); foreach (var fileName in RegistrantOptions.LookupFileNames) { var ext = Path.GetExtension(fileName); if (ext == ConfigurationFileTypes.Json.GetCode()) { cfgBuilder.AddJsonFile(fileName, optional: true); } if (ext == ConfigurationFileTypes.Xml.GetCode()) { cfgBuilder.AddXmlFile(fileName, optional: true); } } Cfg = cfgBuilder.Build(); }
public ActionResult Search() { DebugUtils.StartLogEvent("ResortController.Search"); if (Request.RawUrl.ToLower() != "/home") { SearchParametersManager searchParametersManager = new SearchParametersManager(); var model = GetLayoutItem <SearchResult>(); SearchUtils.ValidateSearchOptions(model); //Removes any Resorts the user doesn't have access model.SavedSearches = SearchUtils.GetSavedSearches(); var resortInfo = GetLayoutItem <ResortDetails>(); if ((model.AllResorts.FindIndex(m => m.ResortId == resortInfo.ResortId) != -1)) { model.searchParameters.ResortId = resortInfo.ResortId.ToString(); model.CurrentResortName = resortInfo.ResortName; searchParametersManager.parameter.Destination = "city-" + resortInfo.City; } DebugUtils.EndLogEvent("ResortController.Search"); return(View(model)); } DebugUtils.EndLogEvent("ResortController.Search"); return(new EmptyResult()); }
private void AddPropertyReferences(SerializedProperty p, ICollection <string> refs, int depth, int maxDepth) { if (p.propertyType != SerializedPropertyType.ObjectReference || !p.objectReferenceValue) { return; } var refValue = AssetDatabase.GetAssetPath(p.objectReferenceValue); if (String.IsNullOrEmpty(refValue)) { if (p.objectReferenceValue is GameObject go) { refValue = SearchUtils.GetTransformPath(go.transform); } } if (!String.IsNullOrEmpty(refValue)) { if (!refs.Contains(refValue)) { AddReference(p.objectReferenceValue, refValue, refs); BuildReferences(p.objectReferenceValue, refs, depth + 1, maxDepth); } } // Add custom object cases if (p.objectReferenceValue is Material material) { if (material.shader) { AddReference(material.shader, material.shader.name, refs); } } }
public JsonResult StartIndexProcess(string pageName) { try { CRAWLER_DEPTH = Int16.Parse(ConfigurationManager.AppSettings["DepthLevels"]); string Folder = SearchUtils.GetDirectoryForFile(pageName, -1); string actualPage = System.IO.Path.GetFileName(pageName); //create a record to serve as a groupID for the site or group of pages to index. int siteIndexID = SearchServices.GetNewSiteIndex(Folder, actualPage); //now save the first page so that the parallel functions have links to use. SearchResult csr = SearchUtils.LoadPageContent(pageName, -1, siteIndexID); SearchUtils.GetLinksAndKeywords(csr); csr.PageID = SearchServices.SaveSearchResults(csr); //now everything is ready to run in a loop until all pages have been indexed. return(StartCrawler(-1, siteIndexID)); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(null); }
public static IEnumerable <SearchAction> CreateActionHandlers(string providerId) { return(new SearchAction[] { new SearchAction(providerId, "select", null, "Select object(s) in scene...") { execute = (context, items) => { FrameObjects(items.Select(i => i.provider.toObject(i, typeof(GameObject))).Where(i => i).ToArray()); } }, new SearchAction(providerId, "open", null, "Select containing asset...") { handler = (item, context) => { var pingedObject = PingItem(item); if (pingedObject != null) { var go = pingedObject as GameObject; var assetPath = SearchUtils.GetHierarchyAssetPath(go); if (!String.IsNullOrEmpty(assetPath)) { Utils.FrameAssetFromPath(assetPath); } else { FrameObject(go); } } } } }); }
// function HILL-CLIMBING(problem) returns a state that is a local maximum public IList <IAction> Search(Problem p) { ClearInstrumentation(); outcome = SearchOutcome.Failure; lastState = null; // current <- MAKE-NODE(problem.INITIAL-STATE) Node current = new Node(p.InitialState); Node neighbor = null; // loop do while (!CancelableThread.CurrIsCanceled()) { IList <Node> children = ExpandNode(current, p); // neighbor <- a highest-valued successor of current neighbor = this.GetHighestValuedNodeFrom(children, p); // if neighbor.VALUE <= current.VALUE then return current.STATE if ((neighbor == null) || (this.GetValue(neighbor) <= this.GetValue(current))) { if (SearchUtils.IsGoalState(p, current)) { outcome = SearchOutcome.SolutionFound; } lastState = current.State; return(SearchUtils.ActionsFromNodes(current.GetPathFromRoot())); } // current <- neighbor current = neighbor; } return(new List <IAction>()); }
public static void IndexWordComponents(int documentIndex, string word) { foreach (var c in SearchUtils.SplitFileEntryComponents(word, SearchUtils.entrySeparators)) { index.AddWord(c.ToLowerInvariant(), 0, documentIndex); } }
private static IEnumerable <SearchItem> SearchPackages(SearchContext context, SearchProvider provider) { if (string.IsNullOrEmpty(context.searchQuery)) { yield break; } s_ListRequest = s_ListRequest ?? PackageManager.Client.List(true); s_SearchRequest = s_SearchRequest ?? PackageManager.Client.SearchAll(); if (s_SearchRequest == null || s_ListRequest == null) { yield break; } while (!s_SearchRequest.IsCompleted || !s_ListRequest.IsCompleted) { yield return(null); } if (s_SearchRequest.Result == null || s_ListRequest.Result == null) { yield break; } foreach (var p in s_SearchRequest.Result) { if (p.keywords.Contains(context.searchQuery) || SearchUtils.MatchSearchGroups(context, p.description.ToLowerInvariant(), true) || SearchUtils.MatchSearchGroups(context, p.name.ToLowerInvariant(), true)) { yield return(provider.CreateItem(context, p.packageId, String.IsNullOrEmpty(p.resolvedPath) ? 0 : 1, FormatLabel(p), FormatDescription(p), null, p)); } } }
private static void BuildParentQueryConstraint(CollectionMatchingResultWrapper matchingResultWrapper, AttributeHolder[] attributeHolders, EntityAssociationAttribute lookupAttribute, SearchRequestDto searchRequestDto) { var searchValues = new List <string>(); var enumerable = attributeHolders as AttributeHolder[] ?? attributeHolders.ToArray(); var hasMainEntity = enumerable.Any(); foreach (var entity in attributeHolders) { var key = matchingResultWrapper.FetchKey(entity); var searchValue = SearchUtils.GetSearchValue(lookupAttribute, entity); if (!String.IsNullOrWhiteSpace(searchValue) && lookupAttribute.To != null) { searchValues.Add(searchValue); key.AppendEntry(lookupAttribute.To, searchValue); } } if (searchValues.Any()) { searchRequestDto.AppendSearchEntry(lookupAttribute.To, searchValues); } else if (hasMainEntity && lookupAttribute.Primary) { //if nothing was provided, it should return nothing, instead of all the values --> //if the main entity had a null on a primary element of the composition, nothing should be seen searchRequestDto.AppendSearchEntry(lookupAttribute.To, new[] { "-1231231312" }); } }
internal static SearchProvider CreateProvider() { return(new SearchProvider(type, displayName) { filterId = "q:", isExplicitProvider = true, isEnabledForContextualSearch = () => true, fetchItems = (context, items, provider) => { var queryItems = SearchQuery.GetAllSearchQueryItems(context); if (string.IsNullOrEmpty(context.searchQuery)) { items.AddRange(queryItems); } else { foreach (var qi in queryItems) { if (SearchUtils.MatchSearchGroups(context, qi.label, true) || SearchUtils.MatchSearchGroups(context, ((SearchQuery)qi.data).searchQuery, true)) { items.Add(qi); } } } return null; } }); }
private static IEnumerable <string> SplitComponents(string path, char[] entrySeparators, int maxIndexCharVariation) { var nameTokens = path.Split(entrySeparators).Reverse().ToArray(); var scc = nameTokens.SelectMany(s => SearchUtils.SplitCamelCase(s)).Where(s => s.Length > 0); return(nameTokens.Concat(scc) .Select(s => s.Substring(0, Math.Min(s.Length, maxIndexCharVariation)).ToLowerInvariant()) .Distinct()); }
public void SearchWithQueryParameter() { var searchRequestDto = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions); searchRequestDto.SetFromSearchString(_assetSchema, "computername".Split(','), "test%"); var actual = SearchUtils.GetWhere(searchRequestDto, "asset"); Assert.AreEqual("( UPPER(COALESCE(CASE WHEN LOCATE('//',asset.Description) > 0 THEN LTRIM(RTRIM(SUBSTR(asset.Description,1,LOCATE('//',asset.Description)-1))) ELSE LTRIM(RTRIM(asset.Description)) END,'')) like :computername )", actual); }