public SearchResultsList Search( SearchWidgetConfiguration configuration, [Documentation(Name = "Query", Type = typeof(string)), Documentation(Name = "PageIndex", Type = typeof(int)), Documentation(Name = "PageSize", Type = typeof(int))] IDictionary options) { var provider = Provider(configuration.ProviderId); var credentials = provider.Authentication; Dictionary <string, string> parameters; string openSearchUrl; if (options != null && options["PageIndex"] == null) { var allresults = new SearchResultsList { Items = new List <SearchResult>() }; int index = 0; const int maxIndex = 10; int pageSize = 100; if (options["PageSize"] != null) { int.TryParse(options["PageSize"].ToString(), out pageSize); } options["PageSize"] = pageSize; SearchResultsList current; do { options["PageIndex"] = index; parameters = SearchParametersAdapter(options); openSearchUrl = Specification.ParseUrl(provider.OpenSearchUrl, parameters); try { current = ExecuteSearch(openSearchUrl, credentials, configuration); allresults.Items.AddRange(current.GetItems()); } catch (WebException) { // format of xml file is invalid return(allresults); } index++; }while (current.GetItems().Count >= pageSize && index < maxIndex); return(allresults); } parameters = SearchParametersAdapter(options); openSearchUrl = Specification.ParseUrl(provider.OpenSearchUrl, parameters); try { SearchResultsList results = ExecuteSearch(openSearchUrl, credentials, configuration); //this.CurrentResults = results; return(results); } catch (WebException) { // format of xml file is invalid return(null); } }
private void ShowResults() { SearchResultsList.SuspendLayout(); SearchResultsList.Items.Clear(); if (AlwaysShowList || !IsSearchBoxEmpty()) { var topResults = FilteredResults.Count() > MaxResults?FilteredResults.Take(MaxResults).ToList() : FilteredResults; bool first = true; foreach (var item in topResults) { var name = GetNameForObject(item); var hintText = GetHintForObject(item); var emphasis = GetHintEmphasisRangeForObject(item); var image = OnGetIconForItem != null?OnGetIconForItem(item) : null; var menuItem = new ToolStripButtonWithHint(name, image, hintText); menuItem.EmphasisStart = emphasis.X; menuItem.EmphasisEnd = emphasis.Y; SearchResultsList.Items.Add(menuItem); if (first) { menuItem.Select(); first = false; } menuItem.Click += MenuItemClick; } var unshownCount = FilteredResults.Count() - topResults.Count(); if (unshownCount > 0) { SearchResultsList.Items.Add(new ToolStripLabel(String.Format(" + {0} more (continue typing to filter further)", unshownCount)) { ForeColor = Color.Gray }); } SearchResultsList.ResumeLayout(); if (!SearchResultsList.Visible) { SearchResultsList.Show(new Point(Left, Bottom)); } } else { SearchResultsList.ResumeLayout(); SearchResultsList.Hide(); } }
private void UIElement_OnKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Down) { SearchResultsList.Focus(); } else if (e.Key == Key.Escape) { ViewModel.SearchText = string.Empty; } }
public SearchResultsList GetEventsList(string searchTerm, int pageNo) { ViewBag.SearchTerm = searchTerm; var indexname = $"todo_{RenderingContext.Current.ContextItem.Database.Name.ToLower()}_index"; var index = ContentSearchManager.GetIndex(indexname); using (var context = index.CreateSearchContext()) { var results = context.GetQueryable <TaskDetailsSearchItem>() .Where(i => i.Language == RenderingContext.Current.ContextItem.Language.Name) .Where(i => i["_latestversion"] == "1") .Page(pageNo, PageSize) .GetResults(); ViewBag.TotalResultCount = results.TotalSearchResults; var x = new SearchResultsList() { Tasks = results.Hits.Select(h => h.Document).ToArray(), PageSize = PageSize, TotalResultCount = results.TotalSearchResults }; return(x); } }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); SearchResultsList.Close(); }
public ActionResult Favourites() { SearchResultsList ResultList = new SearchResultsList(); try { if (!Request.IsAuthenticated) { //must be logged in to see this page, so kick em out if they arnt. TempData["Error"] = "You must be logged in to view your favourites"; return(RedirectToAction("Index", "Home")); } SmartService smartService = new SmartService(); string key, toHash, token; token = smartService.AuthToken(); if (token == "") { } else { // Create a validation key based on the current logged in username and authentication token string username = User.Identity.Name; toHash = username.ToUpper() + "|" + token; key = smartService.GetMd5Hash(MD5.Create(), toHash) + "|" + username; AccountType Account = smartService.GetAccountDetails(key, username); FullResultsType results = smartService.GetFavourites(key, Account.userId); if (results.numResults == 0) { } else { foreach (ArticleType at in results.contentTypeResults) { //do this with a model instead SearchResults SearchResults = new SearchResults(); SearchResults.articleId = at.articleId; SearchResults.reprintOpprtunityId = at.reprintOpprtunityId; SearchResults.articleTitle = at.articleTitle; SearchResults.authors = at.authors; SearchResults.journalTitle = at.journalTitle; SearchResults.publicationDate = at.publicationDate; SearchResults.citation = at.citation; SearchResults.PDFlink = at.PDFlink; SearchResults.abstractText = at.abstractText; SearchResults.keySentence = at.keySentence; ResultList.SearchResultObjList.Add(SearchResults); } } } } catch (Exception ex) // apparently not throwing the expected fault exception. handling argument exception instead. { if (ex is FaultException) { TempData["Error"] = "Error Message: " + ex.Message; //TempData["ErrorDetail"] = "Error Detail: " + ex.Detail.errorDetails; } if (ex is ArgumentException) { TempData["Error"] = "Error Message: " + ex.Message; } } return(View(ResultList)); }
private void AggregateButton_Click(object sender, EventArgs e) { var reportsheet = Globals.ThisAddIn.Application.ActiveSheet; if (NewSheetCheck.Checked) { reportsheet = Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets.Add(); reportsheet.Activate(); } var startCell = Globals.ThisAddIn.Application.ActiveCell; // normalize into entity lists companies and finance orgs; ignore others for now SearchResultsList financecompanies = new SearchResultsList(); SearchResultsList nonfincompanies = new SearchResultsList(); SearchResultsList entitiesnotfound = new SearchResultsList(); // add companies that we can't find in crunchbase to this list foreach (cbSearchResults entry in EntityList) { switch (entry.Namespace) { case "financial-organization": { financecompanies.Add(entry); break; } case "company": { nonfincompanies.Add(entry); break; } default: break; } } // output the finance org table startCell.Value2 = "Crunchbase Search on " + DateTime.Now.ToLongTimeString() + " Scope: " + ScopeDesc.Text; // move startcell one cell lower startCell = reportsheet.Cells[startCell.Row + 1, startCell.Column]; if (financecompanies.Count > 0) { // output a finance orgs table, first the headers CrunchFinancial cfh = new CrunchFinancial(); object[,] excelout = new object[financecompanies.Count + 1, cfh.headersaggregate.Count()]; // put the header in row 0 for (int i = 0; i < cfh.headersaggregate.Count(); i++) { excelout[0, i] = cfh.headersaggregate[i]; } int currrow = 1; CrunchBaseConnect cbc = new CrunchBaseConnect(); foreach (cbSearchResults f in financecompanies) { CrunchFinancial fc = cbc.GetCrunchFinanceOrg(f.permalink); if (fc != null) { for (int i = 0; i < fc.headersaggregate.Count(); i++) { excelout[currrow, i] = fc.aggregateitems[i]; } currrow++; } else { // add to not found list entitiesnotfound.Add(f); } } //now output to excel Range financerange = ThisAddIn.OutputArrayToExcel(startCell, excelout); // now move startCell below the financerange startCell = reportsheet.Cells[startCell.Row + financerange.Rows.Count + 1, startCell.Column]; } // now do companies entity if (nonfincompanies.Count > 0) { CrunchBaseConnect cbc = new CrunchBaseConnect(); CrunchBase cb = new CrunchBase(); int currow = 1; // 0 has the header object[,] excelout = new object[nonfincompanies.Count + 1, cb.aggregateheaders.Count()]; // output headers to row 0 for (int i = 0; i < cb.aggregateheaders.Count(); i++) { excelout[0, i] = cb.aggregateheaders[i]; } foreach (cbSearchResults c in nonfincompanies) { CrunchBase cp = cbc.GetCrunchCompany(c.permalink); if (cp != null) { for (int i = 0; i < cp.aggregateheaders.Count(); i++) { excelout[currow, i] = cp.aggregaterow[i]; } currow++; } else { entitiesnotfound.Add(c); } } Range companyrange = ThisAddIn.OutputArrayToExcel(startCell, excelout); this.Close(); } } //aggregate button click method