public MainWindow() { InitializeComponent(); _helper = new MainWindowHelper(); _lastSearchResult = new EmptySearchResult(); }
private void OnNewResult(ISearchResult result) { SearchResultItemViewModel itemVm = new SearchResultItemViewModel(result); Tuple<IFileHandle, int> line = new Tuple<IFileHandle, int>(itemVm.File, itemVm.LineNum); if (_uniqueLocations.Add(new Tuple<int, int>(itemVm.Result.Location.Offset, itemVm.Result.Extent))) _items.Add(itemVm); }
public void ShowSearchResults(ISearchResult result) { if (result == null) throw new ArgumentNullException("result"); // move result to top of last searches lastSearches.Remove(result); lastSearches.Insert(0, result); // limit list of last searches to 15 entries while (lastSearches.Count > 15) lastSearches.RemoveAt(15); contentPlaceholder.SetContent(result.GetControl()); toolBar.Items.Clear(); foreach (object toolBarItem in defaultToolbarItems) { toolBar.Items.Add(toolBarItem); } IList additionalToolbarItems = result.GetToolbarItems(); if (additionalToolbarItems != null) { toolBar.Items.Add(new Separator()); foreach (object toolBarItem in additionalToolbarItems) { toolBar.Items.Add(toolBarItem); } } SearchResultsShown.RaiseEvent(this, EventArgs.Empty); }
public void FormatResult(SearchResultItem item, ISearchResult formattedResult) { var contentItem = item.GetItem(); formattedResult.Title = FieldRenderer.Render(contentItem, Templates.Person.Fields.Name.ToString()); formattedResult.Description = FieldRenderer.Render(contentItem, Templates.Person.Fields.Summary.ToString()); formattedResult.ViewName = "~/Views/Person/EmployeeSearchResult.cshtml"; }
public void AddChild(int moveIndex, ISearchResult resultNode) { lock (_access) { _children.Add( new Edge {MoveIndex = moveIndex, Result = resultNode}); } }
public void ClearLastSearchesList() { lastSearches.Clear(); if (activeSearchResult != null) { activeSearchResult.OnDeactivate(); activeSearchResult = null; } SD.WinForms.SetContent(contentPlaceholder, null); }
public void FormatResult(SearchResultItem item, ISearchResult formattedResult) { var contentItem = item.GetItem(); if (contentItem != null) { formattedResult.Title = FieldRenderer.Render(contentItem, Templates.NewsArticle.Fields.Title.ToString()); formattedResult.Description = FieldRenderer.Render(contentItem, Templates.NewsArticle.Fields.Summary.ToString()); formattedResult.ViewName = "~/Views/News/NewsSearchResult.cshtml"; } }
protected override void ProcessRecord() { base.ProcessRecord(); if (FromMicrosoft) { int ssWindowsUpdate = 2; Globals.updateSearcher.ServerSelection = (ServerSelection)ssWindowsUpdate; } searchResult = Globals.updateSearcher.Search(Criteria); }
public void Highlight(ISearchResult searchResult) { if (!searchResult.Content.ContainsKey("html_content")) return; var htmlContent = searchResult.Content["html_content"]; if (htmlContent == null) return; var highlightedContent = GeneratePreviewText(htmlContentQuery, htmlContent); if (!String.IsNullOrWhiteSpace(highlightedContent)) searchResult.Content["html_content"] = highlightedContent; }
public string Generate(ISearchResult searchResults) { var sb = new StringBuilder(); foreach (var result in searchResults.Searchees) { GenerateSearchee(sb, result); } return sb.ToString(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="contentType"></param> /// <param name="oneSortOnly"></param> /// <param name="urlBuilderFactory"></param> /// <param name="defaultValueProvider"></param> public SearchContext(string contentType, bool oneSortOnly, IUrlBuilderFactory urlBuilderFactory, IDefaultValueProvider defaultValueProvider) { this.ContentType = contentType; this.m_filters = new List<IFilterPart>(); this.m_sorts = new List<ISortPart>(); this.PageSize = 20; this.PageIndex = FIRST_PAGE_INDEX; this.OneSortOnly = oneSortOnly; this.UrlBuilderFactory = urlBuilderFactory ?? new SimpleUrlBuilderFactory(); this.DefaultValueProvider = defaultValueProvider ?? new SimpleDefaultValueProvider(); this.m_result = null; }
static UpdateCollection getAutoUpdates(ISearchResult found) { Console.WriteLine("Accepting EULAs"); UpdateCollection toInstallAutomatically = new UpdateCollection(); foreach (IUpdate update in found.Updates) { if (update.AutoSelectOnWebSites == true) { if (!update.EulaAccepted) { try { update.AcceptEula(); } catch (Exception) { Console.WriteLine("Unable to accept EULA on update " + update.Title); } } //if (update.EulaAccepted && !update.InstallationBehavior.CanRequestUserInput) if (update.EulaAccepted) { toInstallAutomatically.Add(update); } // works for service packs, even though CanRequestUserInput is true. however, IE9 blocks progress. // This currently will try to install anything wtih "service pack" in the name. No bueno. // if (update.EulaAccepted && update.Title.Contains("Service Pack")) // { // toInstallAutomatically.Add(update); // Console.WriteLine("Service pack found!"); // Console.WriteLine(update.Title); // } } } if (toInstallAutomatically.Count == 1) { Console.WriteLine(String.Format("{0,5} update out of {0} can be installed automatically.", toInstallAutomatically.Count, found.Updates.Count)); } else { Console.WriteLine(String.Format("{0,5} updates out of {0} can be installed automatically.", toInstallAutomatically.Count, found.Updates.Count)); } foreach (IUpdate update in toInstallAutomatically) { Console.WriteLine(update.Title); } return toInstallAutomatically; }
private void SetSearchResults(ISearchResult result) { if (this.result != null) this.result.View = null; this.result = result; if (!listView.VirtualMode) listView.Clear(); listView.VirtualListSize = result.Count; var searchResultView = new SearchResultView(this.listView); result.View = searchResultView; result.CreateColumns(); var ctxMenuID = result.ContextMenuID; if (ctxMenuID > 0) { listView.ContextMenu = services .RequireService<IDecompilerShellUiService>() .GetContextMenu(ctxMenuID); } }
public static ISearchResult CreateSearchResult(string title, IObservable <SearchedFile> matches) { if (title == null) { throw new ArgumentNullException("title"); } if (matches == null) { throw new ArgumentNullException("matches"); } foreach (ISearchResultFactory factory in AddInTree.BuildItems <ISearchResultFactory>("/SharpDevelop/Pads/SearchResultPad/Factories", null, false)) { ISearchResult result = factory.CreateSearchResult(title, matches); if (result != null) { return(result); } } return(new DummySearchResult { Text = title }); }
private SearchResultItem MapViewModels(ISearchResult result) { if (result == null) { return(null); } var content = _umbracoHelper.Content(result.Id); if (content == null) { return(null); } var viewModel = new SearchResultItem(); _umbracoMapper.Map(content, viewModel); viewModel.ShowTeaserMediaAltText = !string.IsNullOrEmpty(viewModel.TeaserMediaAltText); return(viewModel); }
public async Task FindCharacterAsync(EventContext e) { if (!e.Arguments.Take(out string query)) { return; } e.Arguments.Take(out int page); ISearchResult <ICharacterSearchResult> result = (await anilistClient.SearchCharactersAsync(query, page)); if (result.Items.Count == 0) { if (page > result.PageInfo.TotalPages && page != 0) { await e.ErrorEmbed($"You've exceeded the total amount of pages available, might want to move back a bit!") .ToEmbed().QueueToChannelAsync(e.Channel); } else { await e.ErrorEmbed($"No characters listed containing `{e.Arguments.Pack.TakeAll()}`, try something else!") .ToEmbed().QueueToChannelAsync(e.Channel); } return; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < result.Items.Count; i++) { sb.AppendLine($"`{result.Items[i].Id.ToString().PadRight(5)}:` {result.Items[i].FirstName} {result.Items[i].LastName}"); } await new EmbedBuilder() .SetAuthor($"Search result for `{query}`", "https://anilist.co/img/logo_al.png", "") .SetDescription(sb.ToString()) .SetColor(0, 170, 255) .SetFooter($"Page {result.PageInfo.CurrentPage} of {result.PageInfo.TotalPages} | Powered by anilist.co", "") .ToEmbed().QueueToChannelAsync(e.Channel); }
private OperationResultCode SearchUpdates(CancellationToken cancellationToken) { _eventSource.InfoMessage("Search Started."); if (cancellationToken.IsCancellationRequested) { _eventSource.InfoMessage("Search Aborted."); return(OperationResultCode.orcAborted); } ISearchResult searchResult = null; long retries = 0; while (!cancellationToken.IsCancellationRequested) { searchResult = SearchUpdatesUtil(cancellationToken); if ((searchResult != null && searchResult.ResultCode == OperationResultCode.orcSucceeded) || retries >= this._serviceSettings.WUOperationRetryCount || cancellationToken.IsCancellationRequested) { break; } TimeSpan delayBetweenRetries = TimeSpan.FromMinutes(this._serviceSettings.WUDelayBetweenRetriesInMinutes); this._helper.WaitOnTask(Task.Delay(delayBetweenRetries), cancellationToken); retries++; } if (searchResult != null) { this._wuCollectionWrapper = this.GetWUCollection(searchResult.Updates); _eventSource.Message("Search finished with result : {0}. Total searched results : {1}", searchResult.ResultCode, this._wuCollectionWrapper.Collection.Count); return(searchResult.ResultCode); } else { this._wuCollectionWrapper = null; _eventSource.Message("No Search Result!"); return(OperationResultCode.orcFailed); } }
private static UpdateCollection SearchUpdates() { Logger.Write("Starting to search for Pending Updates."); UpdateCollection installableUpdates = new UpdateCollection(); UpdateCollection pendingUpdates = new UpdateCollection(); try { UpdateSession uSession = new UpdateSession(); IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher(); uSearcher.ServerSelection = ServerSelection.ssManagedServer; uSearcher.IncludePotentiallySupersededUpdates = false; uSearcher.Online = false; ISearchResult sResult = uSearcher.Search(_arguments.SearchString); if (sResult.ResultCode == OperationResultCode.orcSucceeded && sResult.Updates.Count != 0) { pendingUpdates = sResult.Updates; } Logger.Write("Found " + pendingUpdates.Count + " Pending Updates."); foreach (IUpdate update in pendingUpdates) { if (update.InstallationBehavior.RebootBehavior == InstallationRebootBehavior.irbNeverReboots || _arguments.IncludeUpdatesWithRebootRequire == true) { Logger.Write("Selecting : " + update.Title); installableUpdates.Add(update); } } } catch (Exception ex) { Logger.Write("Problem when seraching for Pending Updates. " + ex.Message); } Logger.Write("Found " + installableUpdates.Count + " Installable update(s)."); return(installableUpdates); }
private static void Search(string filePath, String8 term) { int iterations = 1; int matchCount = 0; string outputPath = Path.ChangeExtension(filePath, ".search.json"); BionSearcher searcher = null; try { using (new ConsoleWatch($"Loading {filePath}...")) { searcher = new BionSearcher(filePath, 3); } using (new ConsoleWatch($"Finding \"{term}\" [{iterations:n0}x]...", () => $"Done. Wrote {matchCount:n0} matches to {outputPath}")) { for (int iteration = 0; iteration < iterations; ++iteration) { ISearchResult result = searcher.Find(term); using (JsonTextWriter writer = new JsonTextWriter(new StreamWriter(outputPath))) { writer.Formatting = Formatting.Indented; writer.WriteStartArray(); matchCount = searcher.Write(writer, result, 0, -1); writer.WriteEndArray(); } } } } finally { searcher?.Dispose(); } }
public ISearchResult GetSearchResults(string _searchString, int _numPages) { ISearchResult result = null; if (_numPages > -1) { var tmpResult = GetSearchResults(_searchString); if (result == null) { result = new SearchResult(searchEngine); result.SearchString = tmpResult.SearchString; result.SearchResponseRaw = tmpResult.SearchResponseRaw; } for (int i = 1; i < _numPages; i++) { var tmpBaseSearchSuffix = string.Format(baseSearchStringSuffix, pageMultiplier * i); tmpResult = GetSearchResults(_searchString + tmpBaseSearchSuffix); result.SearchResponseRaw += tmpResult.SearchResponseRaw; } } return(result); }
//static void Main(string[] args) //{ // UpdateSession session = new UpdateSession(); // ISearchResult uResult; // Boolean moreUpdates = true; // while (moreUpdates) // { // uResult = CheckForUpdates(session); // getAutoUpdates(uResult); // } //} //private static ISearchResult CheckForUpdates(UpdateSession session) //{ // ISearchResult uResult; // Console.WriteLine("Checking for updates!"); // session = new UpdateSession(); // IUpdateSearcher uSearcher = session.CreateUpdateSearcher(); // //uResult = uSearcher.Search("IsInstalled = 0 and Type='Software'"); // uResult = uSearcher.Search("IsInstalled=0"); // return uResult; //} // class Foo { // public int A {get;set;} // public string B {get;set;} //} //... //Foo foo = new Foo {A = 1, B = "abc"}; //foreach(var prop in foo.GetType().GetProperties()) { // Console.WriteLine("{0}={1}", prop.Name, prop.GetValue(foo, null)); //} static void getAutoUpdates(ISearchResult found) { Console.WriteLine("Accepting EULAs"); UpdateCollection toInstallAutomatically = new UpdateCollection(); foreach (IUpdate update in found.Updates) { Console.WriteLine(update.Title); /* * Critical, Important, Moderate and Low. This field may also be blank. * Blank does not mean "optional update", it just means "not a security-critical update. Probably." */ Console.WriteLine("MsrcSeverity: " + update.MsrcSeverity); // IUpdate::AutoSelectOnWebSites property (Windows) // shows whether or not an update is selected by default? Console.WriteLine("AutoSelectOnWebSites: " + update.AutoSelectOnWebSites); Console.WriteLine("DownloadPriority: " + update.DownloadPriority); Console.WriteLine("IsMandatory: " + update.IsMandatory); Console.WriteLine("Eula Accepted: " + update.EulaAccepted); Console.WriteLine(); } }
public void checkUpdates() { try { UpdateSession uSession = new UpdateSession(); IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher(); ISearchResult uResult = uSearcher.Search("IsInstalled=0 and Type ='Software'"); Console.WriteLine("FOUND " + uResult.Updates.Count + " UPDATE/S" + Environment.NewLine); foreach (IUpdate update in uResult.Updates) { Console.WriteLine(update.Title); } } catch (Exception exception_log) { Console.Clear(); Console.Write("=======================================================================================================================\n"); Console.WriteLine(exception_log.ToString() + "\n"); Console.Write("=======================================================================================================================\n"); Console.WriteLine("FETCHING ERROR - OPERATION FAILED"); Thread.Sleep(5000); } }
/// <summary> /// Gets search grid. /// </summary> /// <param name="tenantId">Identifies website whose pages are searched.</param> /// <param name="page">1-based page index (null if not specified).</param> /// <param name="search">Search terms.</param> /// <returns>Grid view model.</returns> public Grid GetSearchGrid(long tenantId, int?page, string search) { // Get layouts that match search parameters ISearchParameters searchParameters = new SearchParameters { PageIndex = (page ?? 1) - 1, PageSize = 10, Search = search }; ISearchResult <Page> searchResult = _pageService.Search(tenantId, searchParameters); // Construct grid List <string> properties = new List <string> { "Name" }; UrlParameters urlParameters = new UrlParameters { ControllerName = "pages", ActionName = "read" }; List <RoutePropertyPair> routePropertyPairs = new List <RoutePropertyPair> { new RoutePropertyPair { PropertyName = PagePropertyNames.Id, RouteValueName = PagePropertyNames.Id } }; return(_gridService.GetGrid <Page>(searchParameters, searchResult, properties, urlParameters, routePropertyPairs, PageResource.NoPagesMessage)); }
// source; http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.interop/2007-01/msg00001.html private static int PendingUpdates() { Type stype = Type.GetTypeFromProgID("Microsoft.Update.Session"); UpdateSession session = (UpdateSession)Activator.CreateInstance(stype); Type itype = Type.GetTypeFromProgID("Microsoft.Update.Installer"); UpdateInstaller installer = (UpdateInstaller)Activator.CreateInstance(itype); IUpdate u; IUpdateSearcher us = session.CreateUpdateSearcher(); ISearchResult sr = us.Search("IsInstalled=0 and Type='Software'"); UpdateCollection updates = sr.Updates; for (int i = 0; i < updates.Count; i++) { u = updates[i]; //do something with update;show. //System.Console.WriteLine(u.Title); // System.Console.WriteLine(u.Description); //System.Console.WriteLine(" "); } Console.WriteLine("Updates:{0}", updates.Count); return(updates.Count); }
protected IEnumerable <OpeningTimes> GetOpeningTimes(ISearchResult searchResult, string aliasPrefix = "") { var monLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Monday" : "monday"; var tuesLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Tuesday" : "tuesday"; var wedLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Wednesday" : "wednesday"; var thursLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Thursday" : "thursday"; var friLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Friday" : "friday"; var satLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Saturday" : "saturday"; var sunLabel = !string.IsNullOrEmpty(aliasPrefix) ? aliasPrefix + "Sunday" : "sunday"; var openingHours = new List <OpeningTimes> { this.GetDayOpeningTimes("monday", this.GetResultValue(searchResult, monLabel)), this.GetDayOpeningTimes("tuesday", this.GetResultValue(searchResult, tuesLabel)), this.GetDayOpeningTimes("wednesday", this.GetResultValue(searchResult, wedLabel)), this.GetDayOpeningTimes("thursday", this.GetResultValue(searchResult, thursLabel)), this.GetDayOpeningTimes("friday", this.GetResultValue(searchResult, friLabel)), this.GetDayOpeningTimes("saturday", this.GetResultValue(searchResult, satLabel)), this.GetDayOpeningTimes("sunday", this.GetResultValue(searchResult, sunLabel)) }; return(openingHours); }
static void GetInstalledUpdates() { UpdateSessionClass uSession = new UpdateSessionClass(); IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher(); ISearchResult uResult = uSearcher.Search("IsInstalled=1 and Type='Software'"); List <IUpdate> results = new List <IUpdate> { }; foreach (IUpdate update in uResult.Updates) { results.Add(update); } results = results.OrderBy(x => Convert.ToInt32(x.KBArticleIDs[0])) .ToList(); PrintRow("KB Article", "Description", "Severity"); PrintLine(); foreach (IUpdate update in results) { PrintRow(update.KBArticleIDs[0], update.Title, update.MsrcSeverity); } PrintLine(); }
public static List <Application> GetInstalledUpdates() { IUpdateSession session = new UpdateSession(); Logger.Log("Retrieving list of Installed Windows Updates."); var installedUpdates = new List <Application>(); var wsusEnabled = WSUS.IsWSUSEnabled(); try { var searcher = session.CreateUpdateSearcher(); searcher.Online = false; //Assign proper WUAPI Server (WSUS or WUS) searcher.ServerSelection = wsusEnabled ? ServerSelection.ssManagedServer : ServerSelection.ssWindowsUpdate; ISearchResult searchResults = searcher.Search("IsInstalled = 1"); _allInstalledUpdatesList = searchResults.Updates; var count = searcher.GetTotalHistoryCount(); var history = count > 0 ? searcher.QueryHistory(0, count) : null; foreach (IUpdate update in _allInstalledUpdatesList) { var parsedUpdate = ConvertToApplication(update, history, wsusEnabled); installedUpdates.Add(parsedUpdate); } } catch (Exception e) { Logger.Log("Failed to find installed updates.", LogLevel.Error); Logger.LogException(e); } Logger.Log("Done."); return(installedUpdates); }
public void ShowSearchResults(ISearchResult result) { if (result == null) { throw new ArgumentNullException("result"); } // move result to top of last searches lastSearches.Remove(result); lastSearches.Insert(0, result); // limit list of last searches to 15 entries while (lastSearches.Count > 15) { lastSearches.RemoveAt(15); } contentPlaceholder.SetContent(result.GetControl()); toolBar.Items.Clear(); foreach (object toolBarItem in defaultToolbarItems) { toolBar.Items.Add(toolBarItem); } IList additionalToolbarItems = result.GetToolbarItems(); if (additionalToolbarItems != null) { toolBar.Items.Add(new Separator()); foreach (object toolBarItem in additionalToolbarItems) { toolBar.Items.Add(toolBarItem); } } SearchResultsShown.RaiseEvent(this, EventArgs.Empty); }
private void ChooseBestOffer(ISearchResult amazonOffer, ISearchResult apressOffer) { if (amazonOffer == null && apressOffer == null) { Console.WriteLine("Sorry. Could not find best offer for you. Please try with another book title."); return; } Console.WriteLine("Best offer for you:"); if (amazonOffer == null) { Console.WriteLine(apressOffer.ToString()); return; } if (apressOffer == null) { Console.WriteLine(amazonOffer.ToString()); return; } if (amazonOffer.BookPrice > apressOffer.BookPrice) { Console.WriteLine(apressOffer.ToString()); return; } if (amazonOffer.BookPrice < apressOffer.BookPrice) { Console.WriteLine(amazonOffer.ToString()); return; } Console.WriteLine("Two same price offers found:"); Console.WriteLine(apressOffer.ToString()); Console.WriteLine(amazonOffer.ToString()); }
public ISearchResult Search(string text) { lock (_lockObject) { if (text == null || text.Trim().Length == 0) { return new SearchResult { HasMoreItems = false, Items = new PartItem[0], Request = @"" } } ; var searchResult = IsReducableRequest(text) ? ReduceableSearch(text) : FullscopeSearch(text); _reduceableSearchResult = !searchResult.HasMoreItems ? searchResult : null; return(searchResult); } }
/// <summary> /// Returns all folders where a page with the specified master can be created. /// </summary> /// <param name="masterPage">The master page.</param> /// <param name="unitOfWork">Unit of work.</param> /// <returns>List of folders where pages can be created.</returns> public List <Page> ListMasterPageParentPages(MasterPage masterPage, IUnitOfWork unitOfWork = null) { // The list of parent folders List <Page> parentPages = null; // If no ancestor page or level specified, then any folder is valid if (masterPage.AncestorPageId == null || masterPage.AncestorPageLevel == null) { ISearchParameters parameters = new SearchParameters { PageIndex = 0, PageSize = 1000 }; // TODO: Need way to return all pages, not have some max bound upper limit ISearchResult <Page> result = List(masterPage.TenantId, parameters, null, PageSortBy.Name, true, true, PageType.Folder, false, unitOfWork); parentPages = result.Items.ToList(); } // If ancestor page and level specified, must restrict choice of available folders if (masterPage.AncestorPageId.HasValue && masterPage.AncestorPageLevel.HasValue) { parentPages = GetAncestorPages(masterPage, unitOfWork); } // Return result return(parentPages); }
public ResultsViewModel(string title, ISearchResult result) { Title = title; SearchResults = new List <Album>(); foreach (var album in result.AlbumList) { var albumEntry = new Album(); albumEntry.Header.Title = album.Title; foreach (var track in album.TrackList) { albumEntry.Add(new Track() { Title = track.Title, Artist = track.Artist, TrackNr = track.TrackNr, AlbumCoverSource = album.AlbumCoverSource }); albumEntry.Header.Artists.Add(track.Artist); } SearchResults.Add(albumEntry); } }
private void SetSearchResults(ISearchResult result) { if (this.result != null) { this.result.View = null; } this.result = result; if (!listView.VirtualMode) { listView.Clear(); } listView.VirtualListSize = result.Count; var searchResultView = new SearchResultView(this.listView); result.View = searchResultView; result.CreateColumns(); var ctxMenuID = result.ContextMenuID; if (ctxMenuID > 0) { var uiSvc = services.RequireService <IDecompilerShellUiService>(); uiSvc.SetContextMenu(listView, ctxMenuID); } }
protected override void ProcessRecord() { base.ProcessRecord(); UpdateSession updateSession = new UpdateSession(); IUpdateSearcher updateSearcher = updateSession.CreateUpdateSearcher(); if (FromMicrosoft) { int ssWindowsUpdate = 2; updateSearcher.ServerSelection = (ServerSelection)ssWindowsUpdate; } searchResult = updateSearcher.Search(Criteria); }
void SearchNewThread(object o) { try { var searchMsg = SearchResult.CreateMessage(filterSearcherOptions.Context, dnSpy_Resources.Searching, BoxedTextColor.Text, true); SearchingResult = searchMsg; AddSearchResultNoCheck(searchMsg); var opts = new ParallelOptions { CancellationToken = cancellationToken, MaxDegreeOfParallelism = Environment.ProcessorCount, }; if (o is IDnSpyFileNode[]) { Parallel.ForEach((IDnSpyFileNode[])o, opts, node => { try { cancellationToken.ThrowIfCancellationRequested(); var searcher = new FilterSearcher(filterSearcherOptions); searcher.SearchAssemblies(new IDnSpyFileNode[] { node }); } catch { Cancel(); throw; } }); } else if (o is SearchTypeInfo[]) { Parallel.ForEach((SearchTypeInfo[])o, opts, info => { try { cancellationToken.ThrowIfCancellationRequested(); var searcher = new FilterSearcher(filterSearcherOptions); searcher.SearchTypes(new SearchTypeInfo[] { info }); } catch { Cancel(); throw; } }); } else { throw new InvalidOperationException(); } } catch (AggregateException ex) { if (ex.InnerExceptions.Any(a => a is TooManyResultsException)) { TooManyResults = true; } else { throw; } } catch (TooManyResultsException) { TooManyResults = true; } finally { filterSearcherOptions.Dispatcher.BeginInvoke(DISPATCHER_PRIO, new Action(SearchCompleted)); } }
public override void FormatResult(SearchResultItem item, ISearchResult formattedResult) { formattedResult.Title = $"[{item.Name}]"; formattedResult.Description = $"[This item is indexed but has no content provider: {item.Path}]"; }
internal void PersistResults(ISearchResult results, string dbPath) { var matchingFiles = new List<PersistanceManager.MatchingFile>(results.Searchees.Count()); foreach (var hit in results.Searchees) { var info = new FileInfo(hit.Searchee.Path); var matchingFile = new PersistanceManager.MatchingFile(info.Name, hit.Searchee.Path, info.Length, hit.Matches); matchingFiles.Add(matchingFile); } var storedSearch = new PersistanceManager.Search(results.StartDate, results.EndDate, (uint)results.ProcessedSearcheesCount, results.Phrases, matchingFiles); new PersistanceManager.SqLitePersistanceManager(dbPath).SaveSearch(storedSearch); }
public abstract IResourceItem BuildResource(ISearchResult searchResult);
protected string GetResultValue(ISearchResult searchResult, string property) { return(searchResult.GetValues(property).FirstOrDefault()); }
/// <remarks> /// This method displays the search result in the search results pad /// </remarks> static void DisplaySearchResult(ISearchResult result) { if (result.Line != -1) { string text = result.DocumentInformation.GetLineTextAtOffset (result.DocumentOffset); searchMonitor.ReportResult (result.FileName, result.Line, result.Column, text); } else { string msg = string.Format (GettextCatalog.GetString ("Match at offset {0}"), result.DocumentOffset); searchMonitor.ReportResult (result.FileName, 0, 0, msg); } }
/// <summary> /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value. /// </summary> /// <returns> /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. /// </returns> /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param> public bool Contains(ISearchResult item) { return this.searchResults.Contains(item); }
public int run() { #region prepare System.Diagnostics.Debug.WriteLine("Search " + searchInfo.searchId); TimeSpan sleepTime = config.SearchWaitInterval; String para = ""; foreach (String s in searchInfo.include) { para += s; para += " "; } foreach (String s in searchInfo.exclude) { para += "-"; para += s; para += " "; } para = para.Substring(0, para.Length - 1); var searchParameter = Search.CreateTweetSearchParameter(para); searchParameter.TweetSearchType = TweetSearchType.OriginalTweetsOnly; searchParameter.MaximumNumberOfResults = config.searchMaximumNumberOfResults; bool finished = false; int step = 0; long tempMaxId = -1; int cycelNumber = 0; if (searchInfo.status == 1) { tempMaxId = searchInfo.maxIdOnResume - 1; } if (searchInfomation.finishedLastTwitterId > 0) { searchParameter.SinceId = searchInfomation.finishedLastTwitterId + 1; } #endregion while (!finished) { if (cycelNumber++ >= config.searchCycleNumber) { searchInfo.maxIdOnResume = tempMaxId; return(0); } searchInfo.status = 1; dataBase.updateSearchStatus(this); if (tempMaxId > 0) { searchParameter.MaxId = tempMaxId; } if (deleteNotify == true)//check if this search is deleted before a long running part of this code { return(-1); } ISearchResult tweets = null; try { tweets = Search.SearchTweetsWithMetadata(searchParameter); } catch (System.Net.WebException ex) { System.Diagnostics.Debug.WriteLine("Error"); throw ex; } if (!tweets.Tweets.IsEmpty()) { step = 0;//reset step if (searchInfomation.finishedLastTwitterId == -1) { if (searchInfo.firstTwitterDate == null) { searchInfo.firstTwitterDate = tweets.Tweets.Last().CreatedAt; } if (searchInfo.firstTwitterDate > tweets.Tweets.Last().CreatedAt) { searchInfo.firstTwitterDate = tweets.Tweets.Last().CreatedAt; } } if (tempMaxId < 0) { searchInfo.tempLastTwitterDate = tweets.Tweets.First().CreatedAt; searchInfomation.tempLastTwitterId = tweets.Tweets.First().Id; // the end of twitter of this search occurs at the first cycle updateOnTemp(); } tempMaxId = tweets.Tweets.Last().Id - 1; if (deleteNotify == true)//check if this search is deleted before a long running part of this code { return(-1); } Twitters tws = new Twitters(this, tweets, dataBase); tws.saveBasicTweets(); System.Diagnostics.Debug.WriteLine("finished" + cycelNumber + " cycle"); } #region finished if (tweets.Tweets.IsEmpty() && tweets.NumberOfQueriesUsedToCompleteTheSearch != 0) { searchInfo.status = 2; searchInfo.finishedLastTwitterId = searchInfo.tempLastTwitterId; searchInfo.finishedLastTwitterDate = searchInfo.tempLastTwitterDate; updateOnFinish(); // will update return(1); // finished } #endregion if (tweets.NumberOfQueriesUsedToCompleteTheSearch == 0) { step++; if (step == 2) { return(-1); //error } System.Diagnostics.Debug.WriteLine("waiting"); Thread.Sleep(sleepTime); } else { step = 0; } } return(1); }
public override void FormatResult(SearchResultItem item, ISearchResult formattedResult) { var contentItem = item.GetItem(); formattedResult.Title = FieldRenderer.Render(contentItem, Templates.HasPageContent.Fields.Title.ToString()); formattedResult.Description = FieldRenderer.Render(contentItem, Templates.HasPageContent.Fields.Summary.ToString()); }
public static void InstalledUpdates() { UpdateSession UpdateSession = new UpdateSession(); IUpdateSearcher UpdateSearchResult = UpdateSession.CreateUpdateSearcher(); UpdateSearchResult.Online = true;//checks for updates online ISearchResult SearchResults = UpdateSearchResult.Search("IsInstalled=1 AND IsHidden=0"); Console.WriteLine("The following updates are installed"); // Convert ISearchResult collection to list List <IUpdate5> resultIUpdateList = new List <IUpdate5>(); foreach (IUpdate5 x in SearchResults.Updates) { resultIUpdateList.Add(x); } // Display Update info to terminal foreach (IUpdate5 x in resultIUpdateList.OrderByDescending(o => o.LastDeploymentChangeTime)) { // Update General Info Console.WriteLine($"\nTitle: [{x.Title}], Installed: [{x.IsInstalled}]"); if (0 != x.KBArticleIDs.Count) { foreach (var kbids in x.KBArticleIDs) { Console.WriteLine($" KB {kbids}"); } } // Superceeded Updates if (0 != x.SupersededUpdateIDs.Count) { MSCatalogHelper MSCatalog = new MSCatalogHelper(); foreach (var ssids in x.SupersededUpdateIDs) { Console.Write($" SupersededUpdateID: [{ssids}] (Doing MSCatalog search...)\r"); string result = MSCatalog.SearchMSCatalogue(ssids.ToString()); ClearCurrentConsoleLine(); Console.WriteLine($" Supersedes: {result}"); } } // Cve Common Vulnerabilities & Exposures // https://cve.mitre.org/ if (0 != x.CveIDs.Count) { foreach (var cveid in x.CveIDs) { Console.WriteLine($" CveID: [{cveid}]"); } } // Security Bulletins if (0 != x.SecurityBulletinIDs.Count) { foreach (var sbids in x.SecurityBulletinIDs) { Console.WriteLine($" Security BulletinsID: [{sbids}]"); } } // Bundled Updates if (x.BundledUpdates.Count > 0) { foreach (IUpdate bu in x.BundledUpdates) { Console.WriteLine($" BundledUpdate: Title: [{bu.Title}], Installed: [{bu.IsInstalled}]"); foreach (var kbids in bu.KBArticleIDs) { Console.WriteLine($" KB {kbids}"); } } } } }
/// <summary> /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>. /// </summary> /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception> public void Add(ISearchResult item) { this.searchResults.Add(item); }
public void FollowResult(ISearchResult searchResult, bool newTab) { var @ref = searchResult == null ? null : searchResult.Reference; if (@ref != null) { fileTabManager.FollowReference(@ref, newTab, true, a => { if (!a.HasMovedCaret && a.Success) { var bodyResult = searchResult.ObjectInfo as BodyResult; if (bodyResult != null) a.HasMovedCaret = GoTo(a.Tab, searchResult.Object as MethodDef, bodyResult.ILOffset); } }); } }
internal List<MatchingFile> BuildSearchSummary(ISearchResult result) { var q = from r in result.Searchees select new MatchingFile() { accuracy = 1, fileInfo = new FileInfo(r.Searchee.Path), fileReader = new StreamReader(r.Searchee.Path, Encoding.Default), searchResults = r.Matches.GroupBy(m => m.Value).ToDictionary(g => g.Key, g => g.Select(m => m.Index)) }; return q.ToList(); }
public void ShowSearchResults(ISearchResult result) { SetSearchResults(result); Frame?.Show(); }
public void ShowSearchResults(ISearchResult result) { SetSearchResults(result); services.RequireService<IWindowFrame>().Show(); }
/// <summary> /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>. /// </summary> /// <returns> /// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>. /// </returns> /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param><exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.</exception> public bool Remove(ISearchResult item) { return this.searchResults.Remove(item); }
private static void FormatResultUsingFirstSupportedProvider(SearchResultItem result, Item item, ISearchResult formattedResult) { var formatter = FindFirstSupportedFormatter(item) ?? IndexContentProviderRepository.Default; formattedResult.ContentType = formatter.ContentType; formatter.FormatResult(result, formattedResult); }
private void textEdit1_EditValueChanged(object sender, EventArgs e) { this.searchString = this.txtFindWhat.Text; this.searchResult = null; }
protected bool GetResultBooleanValue(ISearchResult searchResult, string property) { return(searchResult.GetValues(property).FirstOrDefault() == "1"); }
public void ResultToLegacyCode(out string code, ISearchResult result) { code = "2 " + result.Address.ToString("X" + (result.Address > uint.MaxValue ? "16" : "8")) + " " + _host.ActiveCommunicator.PlatformBitConverter.ToSingle(result.Value, 0).ToString("G"); }
private string GetDocumentTypeIcon(ISearchResult searchResult) { var icon = this.GetResultValue(searchResult, "icon"); return(this.GetFaIcon(icon)); }
internal void GenerateSearchSummary(List<MatchingFile> searchResults, ISearchResult result) { var inputPaths = from p in result.Searchees select p.Searchee.Path; var summaryGenerator = SummaryGeneratorFactory.Create(); var searchQuery = string.Join(" ", result.Phrases); summaryGenerator.Generate(searchQuery, inputPaths, searchResults); }
private void Highlight(ISearchResult singleResult) { if (highlighter != null) highlighter.Highlight(singleResult); }
private static bool SearchFilter(ISearchResult window, string text) { return(window.IsShown(text)); }
private void searchButton_Click(object sender, EventArgs e) { var searchees = _helper.GetSearcheeProvider(searchFileTextBox.Text); var phrases = searchPhraseTextBox.Text.Split(' '); var searcher = _helper.Searcher; var resultTextGenerator = _helper.ResultTextGenerator; _lastSearchResult = searcher.Search(searchees, phrases); resultsTextBox.Text = resultTextGenerator.Generate(_lastSearchResult); exportResultsButton.Enabled = _lastSearchResult.Searchees.Any(); }
/// <summary> /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index. /// </summary> public void CopyTo(ISearchResult[] array, int arrayIndex) { this.searchResults.CopyTo(array, arrayIndex); }