public IEnumerable <SearchResultItem> Search( string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null) { var textService = ApplicationContext.Current.Services.TextService; var culture = CultureInfo.CurrentCulture; var result = new List <SearchResultItem>(); var nodes = new Dictionary <string, string>() { { "1", textService.Localize("ordersMenu", culture) }, { "2", textService.Localize("productsMenu", culture) }, { "3", textService.Localize("categoriesMenu", culture) }, }; foreach (var item in nodes) { if (item.Value.ToLower().Contains(query.ToLower())) { var res = new SearchResultItem() { ParentId = -1, Icon = "icon-presentation", Id = item.Key, Name = item.Value, Score = 1, }; result.Add(res); } } totalFound = result.Count; return(result.Skip((int)pageIndex * pageSize).Take(pageSize)); }
public override void Search(object term) { YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); //query.VQ = searchString; query.Query = term.ToString(); query.OrderBy = "relevance"; query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND)); YouTubeFeed vidr = Youtube2MP.service.Query(query); SearchResult.Items.Clear(); foreach (YouTubeEntry entry in vidr.Entries) { SearchResultItem item = new SearchResultItem(); item.Id = entry.VideoId; item.Label = entry.Title.Text; item.Provider = this; item.MetaData.Add("entry", entry); SearchResult.Items.Add(item); } IsBusy = false; if (SearchDone != null) { SearchDone(this); } }
/// <summary> /// Creates a search view model according to the runtime type of <paramref name="searchResultItem"/>. /// </summary> public SearchResultItemModel GetTypedSearchResultItemModel(SearchResultItem <BaseInfo> searchResultItem) { var fields = searchResultItem.Fields; var data = (dynamic)searchResultItem.Data; return(GetViewModelForSearchItem(fields, data)); }
public static IAddress ToAddress(this SearchResultItem result) { if (result != null) { var Address = new Models.Address(); string FormattedAddress; FormattedAddress = result.FieldItems.TryGetValue("FULL_ADDRESS"); var Index = Math.Max(0, FormattedAddress.IndexOf(result.FieldItems.TryGetValue("STREET") + ",")); Address.Uprn = long.Parse(result.FieldItems.TryGetValue("UPRN") ?? null); //Address.Usrn = long.Parse(result.FieldItems.TryGetValue("USRN") ?? null); //Address.Organisation = result.FieldItems.TryGetValue("ORGANISATION"); Address.Property = (!String.IsNullOrWhiteSpace(FormattedAddress) ? FormattedAddress.Substring(0, Index) : String.Empty).Trim().TrimEnd(','); Address.Street = result.FieldItems.TryGetValue("STREET"); Address.Locality = result.FieldItems.TryGetValue("LOCALITY"); Address.Town = result.FieldItems.TryGetValue("TOWN"); Address.Area = result.FieldItems.TryGetValue("POSTTOWN"); Address.PostCode = result.FieldItems.TryGetValue("POSTCODE"); return(Address); } return(null); }
protected override async Task <CrawlingResult> CrawleInnerAsync(CrawlingRequest request) { CrawlingResult result = null; string url = string.Format("{0}?q={1}", BaseUrl, request.QueryWord); string resultHtml = null; using (var httpClient = new HttpClient()) { var response = await httpClient.GetAsync(url); resultHtml = await response.Content.ReadAsStringAsync(); var document = new HtmlDocument(); document.LoadHtml(resultHtml); var htmlNodes = document.DocumentNode.CssSelect("#b_results li h2 a"); result = new CrawlingResult(); var hodeArray = htmlNodes.ToArray(); for (int i = 0; i < request.Take; i++) { var htmlNode = hodeArray[i]; var item = new SearchResultItem(); item.SearchEngine = ESearchEngine.Bing; item.Title = htmlNode.InnerText; result.SearchResults.Add(item); } } return(result); }
private SearchResultItemViewModel(SearchResultItem item) { RegisterName = item.RegisterName; RegisterDescription = item.RegisterDescription; RegisterItemName = item.RegisterItemName; RegisterItemDescription = item.RegisterItemDescription; RegisterID = item.RegisterID; SystemID = item.SystemID; Discriminator = item.Discriminator; RegisterSeoname = item.RegisterSeoname; RegisterItemSeoname = item.RegisterItemSeoname; DocumentOwner = item.DocumentOwner; Submitter = item.Submitter; Shortname = item.Shortname; RegisteItemUrl = item.RegisteItemUrl; SubregisterUrl = item.SubregisterUrl; subregisterItemUrl = item.subregisterItemUrl; ParentRegisterName = item.ParentRegisterName; ParentRegisterDescription = item.ParentRegisterDescription; ParentRegisterUrl = item.ParentRegisterUrl; RegisteItemUrlDataset = item.RegisteItemUrlDataset; RegisteItemUrlDocument = item.RegisteItemUrlDocument; ObjektkatalogUrl = item.ObjektkatalogUrl; Type = item.Type; currentVersion = item.currentVersion; }
public SearchResultCafeItemModel(SearchResultItem resultItem, Cafe cafe) : base(resultItem, cafe) { var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext); Url = urlHelper.Action("Index", "Cafes"); }
/// <summary> /// Converts a Poco into a strongly typed Item descending from /// IStandardTemplateItem. Will return null if there is no class /// defined for the Item's TemplateID. /// </summary> /// <param name="poco">The SearchResultItem</param> /// <typeparam name="TItem">The Type of object to create, must descend from IStandardTemplateItem.</typeparam> /// <returns>An instance of TItem or null if conversion fails.</returns> public static TItem As <TItem>(this SearchResultItem poco) where TItem : class, IStandardTemplate { var item = poco.GetItem(); return(item.As <TItem>()); }
public override void handleSelection(SearchResultItem item) { try { FileInfo fInfo = (FileInfo)item.Value; System.Diagnostics.Process.Start(fInfo.FullName); } catch { } }
public void PerformSearch(SearchProvider provider) { SearchResults epResults = provider.Search(); List <SearchResultItem> collectionItems = epResults.Items.FindAll((item) => { return(item.WrapperType == "collection"); }); foreach (SearchResultItem item in epResults.Items.Except(collectionItems)) { this.episodeList.Add(new FileMetaDataInfo(item)); } if (collectionItems.Count > 0) { SearchResultItem seasonItem = collectionItems[0]; this.seasonName = seasonItem.CollectionName; this.showName = seasonItem.ArtistName; Regex seasonNumberMatcher = new Regex(@".*(\d).*"); if (seasonNumberMatcher.IsMatch(seasonName)) { this.seasonNumber = int.Parse(seasonNumberMatcher.Matches(seasonName)[0].Groups[1].Value); } // Look for the 600x600 pixel artwork. This is a hack, and // may not work properly forever. this.DownloadArtwork(seasonItem.ArtworkUrl.Replace("100x100", "600x600")); } }
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 ISearchResult Create(SearchResultItem result) { var item = result.GetItem(); var formattedResult = new SearchResult(item); FormatResultUsingFirstSupportedProvider(result, item, formattedResult); return formattedResult; }
public SearchResultProductItemModel(SearchResultItem resultItem, SKUTreeNode page, ProductCatalogPrices priceDetail, IPageUrlRetriever pageUrlRetriever) : base(resultItem, page, pageUrlRetriever) { Description = page.DocumentSKUDescription; ShortDescription = HTMLHelper.StripTags(page.DocumentSKUShortDescription, false); PriceDetail = priceDetail; }
protected override void ProcessRecord() { if (Item != null) { var itemDatabase = Item.Database.Name; var itemPath = Item.Paths.Path; var indexable = new SitecoreIndexableItem(Item); foreach (var index in WildcardFilter(Name, ContentSearchManager.Indexes, index => index.Name)) { if (!index.Crawlers.Any( c => c is SitecoreItemCrawler && ((SitecoreItemCrawler)c).Database.Is(itemDatabase))) { continue; } RefreshItem(index, indexable, itemPath); } } else if (SearchResultItem != null) { var itemPath = SearchResultItem.Path; var indexable = new SitecoreIndexableItem(SearchResultItem.GetItem()); var indexname = SearchResultItem.Fields["_indexname"].ToString(); foreach ( var index in WildcardFilter(indexname, ContentSearchManager.Indexes, index => index.Name)) { RefreshItem(index, indexable, itemPath); } } }
public SearchResult(double score, Actor actor) { Score = score; Node = new SearchResultItem { Instance = actor }; }
private void listBox1_SelectedValueChanged(object sender, EventArgs e) { SearchResultItem item = listBox1.SelectedItem as SearchResultItem; if (item == null) { return; } if (File.Exists(item.Path)) { if (item.Path != lblfilepath.Text) { richTextBox1.Text = File.ReadAllText(item.Path, code); } try { lblfilepath.Text = item.Path; richTextBox1.SelectionStart = richTextBox1.GetFirstCharIndexFromLine(item.Line); richTextBox1.SelectionLength = 0; richTextBox1.Focus(); richTextBox1.ScrollToCaret(); } catch { } } }
public SearchResult(double score, Movie movie) { Score = score; Node = new SearchResultItem { Instance = movie }; }
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 SearchResultItem GetSearchResultItem(SearchGroup searchGroup, SearchItem searchResultItem) { var result = new SearchResultItem { Name = searchResultItem.Title, Additional = new Dictionary <string, object> { { "Type", searchResultItem.EntityType }, { "imageRef", WebImageSupplier.GetAbsoluteWebPath(GetImage(searchResultItem.EntityType), ProductEntryPoint.ID) }, { "Hint", GetHint(searchResultItem.EntityType) } }, URL = GetItemPath(searchResultItem.EntityType, searchResultItem.ID, searchGroup.ProjectID) }; if (searchResultItem.EntityType != EntityType.Project) { result.Additional.Add("ProjectName", searchGroup.ProjectTitle); result.Date = searchResultItem.CreateOn; result.Description = searchResultItem.Description; } return(result); }
public static StringBuilder OneHotelTourRecord(SearchResultItem si, bool isAlternatingRecord) { var ht = si.Hotels[0]; var sb = new StringBuilder(); sb.AppendFormat(@"<tr {0}>", isAlternatingRecord ? @"class='TFS_TAltRow'" : String.Empty); var dates = si.Date.Year == si.DateTourEnd.Year && si.Date.Year == DateTime.Now.Year ? String.Format(@"{0:dd.MM} – {1:dd.MM}", si.Date, si.DateTourEnd) : String.Format(@"{0:dd.MM.yy} – {1:dd.MM.yy}", si.Date, si.DateTourEnd); sb.AppendFormat(@"<td>{0}</td>", dates); sb.AppendFormat(@"<td>{0}</td>", HttpUtility.HtmlEncode(ht.ResortName)); sb.AppendFormat(@"<td>{0}</td>", GetLinkNameHtml(HttpUtility.HtmlEncode(ht.Name), ht.Url, "HotelName", true)); sb.AppendFormat(@"<td>{0}</td>", HttpUtility.HtmlEncode(ht.Stars)); sb.AppendFormat(@"<td>{0}<br/>{1}</td>", HttpUtility.HtmlEncode(ht.RoomName), HttpUtility.HtmlEncode(ht.RoomCategoryName)); sb.AppendFormat(@"<td>{0}</td>", HttpUtility.HtmlEncode(ht.AccomodationName)); sb.AppendFormat(@"<td>{0}</td>", HttpUtility.HtmlEncode(ht.PansionName)); sb.AppendFormat(@"<td>{0}</td>", HttpUtility.HtmlEncode(ht.NightsCount)); sb.AppendFormat(@"<td class='CellPrice'>{0}</td>", GetSimpleBasketLinkHtml(si.PriceInRates, si.PriceKey, si.FilterRateCode, si.IsPriceForRoom, si.Date, true)); sb.AppendFormat(@"<td>{0}<div>{1}{2}</div></td>", GetLinkNameHtml(HttpUtility.HtmlEncode(si.TourName), si.TourUrl, "TourName", true), GetComplexAspxLinkHtml(si.FlightCityKeyFrom == null ? 0 : si.FlightCityKeyFrom.Value, si.CountryKey, si.TourKey, si.HotelKey, si.Date, si.FilterRateCode, true), GetTourDetailsHtml(si.TourHasDescription, si.TourKey)); sb = GetHotelQuotasHtml(sb, si.Hotels[0].QuotaState, 0); //todo: вынести список классов авиоперелетов в конфиг sb = GetAviaQuotasHtml(sb, 0, si.DirectFlightsInfo, si.BackFlightsInfo, si.FlightCityKeyFrom, si.FlightCityKeyTo, si.Date, si.DateTourEnd); return(sb.AppendFormat("</tr>")); }
private void Search_Click(object sender, RoutedEventArgs e) { DataList = new ObservableCollection <SearchResultItem>(); var searchHandler = new SearchHandler(clientContext); var result = searchHandler.Search(SearchTextBox.Text.ToString()); foreach (var item in result.Value) { foreach (var res in item.ResultRows) { try { var searchItem = new SearchResultItem() { Title = res["Title"].ToString(), Description = res["Description"].ToString(), ParentUrl = res["ParentLink"].ToString(), }; DataList.Add(searchItem); } catch (Exception) { } } } searchListGrid.ItemsSource = DataList; }
protected override async Task <CrawlingResult> CrawleInnerAsync(CrawlingRequest request) { string url = string.Format("{0}?q={1}", BaseUrl, request.QueryWord); var httpRequest = createHttpRequest(url); var httpResponse = (HttpWebResponse)httpRequest.GetResponse(); var streamResponse = httpResponse.GetResponseStream(); var streamRead = new StreamReader(streamResponse); var htmlString = await streamRead.ReadToEndAsync(); var document = new HtmlDocument(); document.LoadHtml(htmlString); var htmlNodes = document.DocumentNode.CssSelect(".g h3").ToArray(); var result = new CrawlingResult(); for (int i = 0; i < request.Take; i++) { var htmlNode = htmlNodes[i]; var item = new SearchResultItem(); item.SearchEngine = ESearchEngine.Google; item.Title = htmlNode.InnerText; result.SearchResults.Add(item); } return(result); }
public SearchResultHomeItemModel(SearchResultItem resultItem, CMS.DocumentEngine.Types.DancingGoatMvc.Home home, IHomeRepository homeRepository, IPageUrlRetriever pageUrlRetriever) : base(resultItem, home, pageUrlRetriever) { var homeSections = homeRepository.GetHomeSections(home.NodeAliasPath); Content = string.Join(" ", homeSections.Select(section => HTMLHelper.StripTags(section.HomeSectionText, false))); }
public static IList <SearchResultItem> ConvertCalcTourToNoSql(this MtMainDbDataContext mainDc, MtSearchDbDataContext searchDc, int tourKey) { var result = new List <SearchResultItem>(); string hashOut; var tours = searchDc.GetTPToursByKeys(new[] { tourKey }, out hashOut); TP_Tour tpTour; if (tours != null && tours.Count == 1) { tpTour = tours[0]; } else { throw new ArgumentException(String.Format("Неправильный параметр tourKey")); } var tourString = searchDc.GetTourStringsByKeys(new [] { tpTour.TO_Key }, out hashOut); var tpPrices = mainDc.TP_Prices.Where(t => t.TP_TOKey == tourKey && t.TP_Gross != null).ToList(); foreach (var tpPrice in tpPrices) { var item = new SearchResultItem(); // будет заполнен при выдаче результата в поиск item.PriceInRates = null; item.PriceKey = tpPrice.TP_Key; item.Price = tpPrice.TP_Gross.Value; item.RateCode = tpTour.TO_Rate; item.Date = tpPrice.TP_DateBegin; item.PriceFor = tpTour.TO_PriceFor == 0 ? PriceForType.PerMen : PriceForType.PerRoom; item.CountryKey = tpTour.TO_CNKey; } return(result); }
private static void FormatResultUsingFirstSupportedProvider(SearchResultItem result, Item item, ISearchResult formattedResult) { var formatter = FindFirstSupportedFormatter(item) ?? IndexingProviderRepository.DefaultSearchResultFormatter; formattedResult.ContentType = formatter.ContentType; formatter.FormatResult(result, formattedResult); }
public IEnumerable <SearchResultItem> Search(string query) { query = (query ?? "").ToLower().Trim(); if (query.Length < 3) { yield break; } string[] words = query.Split(_separator, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); foreach (var item in _cache) { var response = new SearchResultItem { Page = item.Page, MatchOnTitleWeight = item.TitleLowerCase.Contains(query) ? 20 : 0, Hits = item.Content.Split(new string[] { query }, StringSplitOptions.None).Length - 1 }; if (response.Hits < 0) { response.Hits = 0; } response.Hits *= 2; foreach (var word in words) { response.MatchOnTitleWeight += item.Title.Contains(word) ? 5 : 0; response.Hits += item.Content.Split(new string[] { word }, StringSplitOptions.None).Length - 1; } if (response.Weight > 0) { yield return(response); } } }
public async Task <SearchResultItem> CreateAsync(SearchResultItem item) { try { using (var dbConnection = new SqlConnection(ConnectionString)) { var parameters = new { Title = item.Title, SearchEngineId = (int)item.SearchEngine, EnteredDate = item.EnteredDate.ToString() }; var dbItems = await dbConnection.QueryAsync <DbSearchResultItem>( sql : "SearchResultsInsert", param : parameters, commandType : CommandType.StoredProcedure ); var dbItem = dbItems.FirstOrDefault(); if (dbItem == null) { return(null); } return(mapToEntity(dbItem)); } } catch (Exception ex) { Logger.Error(ex); return(null); } }
public override void Play(SearchResultItem resultItem) { YouTubeEntry entry = resultItem.MetaData["entry"] as YouTubeEntry; YoutubeGUIBase.SetLabels(entry, "NowPlaying"); Youtube2MP.NowPlayingEntry = entry; VideoInfo info = new VideoInfo(); g_Player.PlayVideoStream(Youtube2MP.StreamPlaybackUrl(entry, info)); if (g_Player.Playing) { if (Youtube2MP._settings.ShowNowPlaying) { GUIWindowManager.ActivateWindow(29052); } else { g_Player.ShowFullScreenWindow(); } } if (!g_Player.Playing) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlgOK != null) { dlgOK.SetHeading(25660); dlgOK.SetLine(1, "Unable to playback the item ! "); dlgOK.SetLine(2, ""); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } } }
public void Should_Map_IPublishedContent_With_Template_To_Custom_Model_If_Something_Found() { var searchResults = new List <SearchResult> { new SearchResult { Id = 123 } }; var mappedIpubishedContentResults = new List <IPublishedContent> { new Mock <IPublishedContent>().Object }; var searchResultItem = new SearchResultItem { Heading = "Heading", Description = "Description" }; var mappedToCustomResults = new List <SearchResultItem> { searchResultItem }; _siteSearchService.Setup(y => y.GetRawResults(It.IsAny <string>(), It.IsAny <bool>())).Returns(searchResults); _siteSearchService.Setup(x => x.ConvertSearchResultToPublishedContentWithTemplate(searchResults, _contentCache.Object, UmbracoContext.Current)) .Returns(mappedIpubishedContentResults); _siteSearchService.Setup(x => x.MapToCustomResults(mappedIpubishedContentResults)) .Returns(mappedToCustomResults); _controller = GetController(true); var result = _controller.GetResult(Keyword, null, TopKeywords) as PartialViewResult; SiteSearchVm vm = (SiteSearchVm)result.Model; var firstMappedResult = vm.SearcResults.First(); _siteSearchService.Verify(x => x.MapToCustomResults(mappedIpubishedContentResults), Times.Once); Assert.AreEqual(firstMappedResult.Heading, searchResultItem.Heading); Assert.AreEqual(firstMappedResult.Description, searchResultItem.Description); }
public void When_creating_search_results_item_if_the_url_has_no_scheme_included_the_link_remains_unchanged() { var expectedUrl = "test.com"; var item = new SearchResultItem("test", expectedUrl, "Google"); Assert.AreEqual(expectedUrl, item.Link); }
protected override void ProcessRecord() { if (Item != null) { var itemPath = Item.Paths.Path; var indexable = new SitecoreIndexableItem(Item); foreach (var index in WildcardFilter(Name, ContentSearchManager.Indexes, index => index.Name)) { if (IndexIsValidForItem(index, Item)) { ProcessIndexable(index, indexable, itemPath); } } } else if (SearchResultItem != null) { var itemPath = SearchResultItem.Path; var indexable = new SitecoreIndexableItem(SearchResultItem.GetItem()); var indexname = SearchResultItem.Fields["_indexname"].ToString(); foreach ( var index in WildcardFilter(indexname, ContentSearchManager.Indexes, index => index.Name)) { ProcessIndexable(index, indexable, itemPath); } } }
public SearchResultAboutUsItemModel(SearchResultItem resultItem, AboutUs aboutUs, AboutUsRepository aboutUsRepository, IPageUrlRetriever pageUrlRetriever) : base(resultItem, aboutUs, pageUrlRetriever) { var sideStories = aboutUsRepository.GetSideStories(aboutUs.NodeAliasPath); Content = string.Join(" ", sideStories.Select(story => HTMLHelper.StripTags(story.AboutUsSectionText, false))); }
public void When_creating_search_results_item_the_urls_scheme_is_removed_when_its_http() { var expectedUrl = "test.com"; var item = new SearchResultItem("test", $"http://{expectedUrl}", "Google"); Assert.AreEqual(expectedUrl, item.Link); }
public void FetchImage(SearchResultItem item) { using (WebClient client = new WebClient()) { var bytes = client.DownloadData (new Uri (item.ImageUrl)); Bitmap bitmap = BitmapFactory.DecodeByteArray (bytes, 0, bytes.Length); item.Image = bitmap; } ; }
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"; } }
private void appendFiles(DirectoryInfo dInfo) { foreach (FileInfo fInfo in dInfo.GetFiles()) { SearchResultItem item = new SearchResultItem(fInfo.Name.Replace(".lnk", ""), fInfo.FullName, fInfo); this._items.Add(item); } // foreach (DirectoryInfo childDInfo in dInfo.GetDirectories()) { this.appendFiles(childDInfo); } }
public void SearchService(string name, string type) { new Uri("?string=" + name + "&type=" + type + (IsContainsMethod.IsChecked != null && IsContainsMethod.IsChecked.Value ? "&method=contains" : ""), UriKind.Relative) .RequestString(result => { XElement xResults = XElement.Parse(result); ResultsList.Children.Clear(); SearchResultItem.items.Clear(); if(!Children.Contains(ResultsList)) Children.Add(ResultsList); foreach(var item in xResults.Elements()) { var searchItem = new SearchResultItem { Content = item.Element("name").Value, X = item }; searchItem.Click += (sender1, e1) => { var searchItemSender = sender1 as SearchResultItem; search = false; nameText.Text = searchItemSender.X.Element("name").Value; Reflected.ItemName = nameText.Text; if (NameSet != null) NameSet(); Reflected.Id = searchItemSender.X.Attribute(SNames.rdfabout).Value; if(!(searchItemSender.Selected = !searchItemSender.Selected)) Children.Remove(ResultsList); }; if(item.Element("name") != null) ResultsList.Children.Add(searchItem); } var newSearchItem = new SearchResultItem { Content = "создать" }; newSearchItem.Click += (sender1, e1) => { if(NewCreate != null) NewCreate(); }; ResultsList.Children.Add(newSearchItem); }); }
public void Add(SearchResultItem item) { Items.Add(item); }
public override void handleSelection(SearchResultItem item) { }
public override void FormatResult(SearchResultItem item, ISearchResult formattedResult) { }
public void handleSelection(SearchResultItem item, String searchValue) { SearchContext sContext = this.getSearchContext(searchValue); if (sContext.provider == null) { return; } log.Debug("handleSelection - " + searchValue + " with " + sContext.provider.ToString()); sContext.provider.handleSelection(item); }
private void handleSelection(SearchResultItem item) { lMessage.Content = "ausgewählter Eintrag wird aufgerufen"; this.Providers.handleSelection(item, txtSearch.Text); this.Visibility = Visibility.Hidden; lMessage.Content = String.Empty; }
protected void OnItemFound(Object sender, SearchResultItem item) { base.OnAlive(this, new EventArgs()); if (ItemFound != null) { ItemFound(sender, item); } }
/// Highlights the search result. private static void HighlightSearchResult(Image bm, SearchResultItem searchResultItem, Page page) { using (Graphics gr = Graphics.FromImage(bm)) { double[] rectangle; SearchResultRegion region = page.TransformRegion(searchResultItem.Region, bm.Width, bm.Height, renderingSettings); foreach (double[] item in region.Blocks) { rectangle = item; PointF[] points = new PointF[rectangle.Length / 2]; for (int i = 0; i < 4; i++) { points[i] = new PointF((float)rectangle[i * 2], (float)rectangle[(i * 2) + 1]); } gr.FillPolygon(markBrush, points); } } }
private void ProcessResultRecordForRecall(SearchResultItem data, Dictionary<string, SearchResultMapData> list) { var check = data.DistributionPattern; var states = Enum.GetNames(typeof (States)). ToList(); var nationwide = check.ToLower(). Contains("nationwide"); foreach (var state in states) { var stateEnum = Enum.Parse(typeof (States), state); var stateName = Utilities.GetEnumDescription(stateEnum); var stateCoords = Utilities.GetEnumCoordinates(stateEnum); if (check.Contains(state) || check.ToUpper(). Contains(stateName.ToUpper()) || nationwide) { SearchResultMapData listCheck = null; if (list.ContainsKey(state)) { listCheck = list[state]; } else { listCheck = new SearchResultMapData { State = state, Latitude = stateCoords.Latitude.ToString(), Longitude = stateCoords.Longitude.ToString() }; list.Add(state, listCheck); } var tooltip = string.Concat(data.Classification, " {0}"); switch (data.Classification.ToLower()) { case "class i": tooltip = string.Format(tooltip, " Class-1"); listCheck.IconSet = listCheck.IconSet | IconSet.Class1; break; case "class ii": tooltip = string.Format(tooltip, " Class-2"); listCheck.IconSet = listCheck.IconSet | IconSet.Class2; break; case "class iii": tooltip = string.Format(tooltip, " Class-3"); listCheck.IconSet = listCheck.IconSet | IconSet.Class3; break; } if (!listCheck.Tooltip.Contains(tooltip)) { if (listCheck.Tooltip.Length > 0) { listCheck.Tooltip += ", "; } listCheck.Tooltip += tooltip; } // Get the Rank var rank = 9; switch (data.Rank.ToLower()) { case "classi": rank = 1; break; case "classii": rank = 2; break; case "classiii": rank = 3; break; case "events": rank = 4; break; case "device event": rank = 5; break; default: rank = 5; break; } if (listCheck.Rank > rank) { listCheck.Rank = rank; } list[state] = listCheck; } } }
private SearchResultItem GetResultFromSchedule(FileInfo file, string phrase) { var result = new SearchResultItem(); result.Title = "Schedule"; result.Description = string.Format("... {0} ... ", phrase); result.Link = string.Format("<a href='Schedule?name={0}'>{1}</a>", file.Name, file.Name); return result; }
private SearchResultItem GetResultFromPage(FileInfo file, string title, string phrase) { var result = new SearchResultItem(); result.Title = title; result.Description = string.Format("... {0} ...", phrase); result.Link = string.Format("<a href='{0}'>{1}</a>", file.Name, title); return result; }
private SearchResultItem GetResultFromCourse(Course course) { var result = new SearchResultItem(); result.Title = "Courses"; result.Description = string.Format("Nume curs {0}, an {1}, semestru {2}, materie {3}. ", course.Name, course.Year, course.Semester, course.Subject); result.Link = string.Format("<a href='Courses?id={0}'>{1}</a>", course.Id, course.Name); return result; }
public abstract void FormatResult(SearchResultItem item, ISearchResult formattedResult);
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}]"; }
/// <summary> /// Gets a detailed list of issues. Issues are enforcements (Recalls) of food, drug and device (identified by /// classification) and events of drug and devices /// </summary> /// <param name="keyWord"></param> /// <param name="state"></param> /// <returns>FDA Result object</returns> /// <remarks></remarks> public FdaResult GetFdaResult(string keyWord, string state) { var dataYearsBack = 1; var searchResultLocal = new FdaResult() { Keyword = keyWord, Results = new List<SearchResultItemBase>() }; var mapList = new Dictionary<string, SearchResultMapData>(); var graphData = new ReportData(); var tmp = GetRecallInfo(keyWord, state); var dateInit = DateTime.Now.AddYears(-dataYearsBack); // Initialize graph data for (var i = 1; i <= 12*dataYearsBack; i++) { dateInit = dateInit.AddMonths(1); graphData.Labels.Add(dateInit.ToString("MMM-yyyy")); graphData.Data1.Add(0); graphData.Data2.Add(0); graphData.Data3.Add(0); graphData.DataE.Add(0); } // Reconstruct recall data as searchresultitem object foreach (var itm in tmp) // should be in order by newest date { var newItemDate = DateTime.ParseExact(itm.Recall_Initiation_Date, "yyyyMMdd", CultureInfo.InvariantCulture); var tmpReportDate = DateTime.ParseExact(itm.Report_Date, "yyyyMMdd", CultureInfo.InvariantCulture); var tmpSearchResultItem = new SearchResultItem() { City = itm.City, DateStarted = newItemDate.ToString("ddMMMyyyy"), Content = string.Format("{0} {1}", itm.Reason_For_Recall, itm.Code_info), DistributionPattern = itm.Distribution_Pattern, ProductDescription = itm.Product_Description, State = itm.State, Status = itm.Status, Country = itm.Country, RecallNumber = itm.Recall_Number, ProductQuantity = itm.Product_Quantity, EventId = itm.Event_Id, RecallingFirm = itm.Recalling_Firm, ReportDate = tmpReportDate.ToString("ddMMMyyyy"), CodeInfo = itm.Code_info, Classification = itm.Classification, Voluntary = itm.Voluntary_Mandated }; searchResultLocal.Results.Add(tmpSearchResultItem); } // Lets Get the Events And Mix them In. var drugee = new OpenFda(); //Get Drug Events var drugs = drugee.GetDrugEventsByDrugName(keyWord); searchResultLocal.Results.AddRange(drugs); //Get Device Events drugs = drugee.GetDeviceEventByDescription(keyWord); searchResultLocal.Results.AddRange(drugs); //'Sort for most recient at the top of the list // searchResultLocal.Results cannot be sorted because searchResultLocal.Results = ((from el in searchResultLocal.Results select el).OrderByDescending(el => el.SortDate)).ToList(); // Now that the data is combined and sorted, Process data for maps and graphs foreach (var itm in searchResultLocal.Results) { var classification = string.Empty; var reportDate = string.Empty; // Map Processing first switch (itm.GetType(). ToString()) { case "ShopAware.Core.DataObjects.SearchResultItem": ProcessResultRecordForRecall((SearchResultItem) itm, mapList); classification = ((SearchResultItemBase) itm).Classification; reportDate = ((SearchResultItemBase) itm).ReportDate; break; case "ShopAware.Core.DataObjects.SearchResultDrugEvent": ProcessResultRecordForDrugEvent((SearchResultDrugEvent) itm, mapList); classification = ((SearchResultItemBase) itm).Classification; reportDate = ((SearchResultItemBase) itm).ReportDate; break; } // Now process graph data var tmpReportDate = DateTime.ParseExact(reportDate, "ddMMMyyyy", CultureInfo.InvariantCulture); var dateForReport = tmpReportDate.ToString("MMM-yyyy"); var found = false; switch (classification) { case "Class I": for (var i = 0; i <= graphData.Labels.Count - 1; i++) { if (graphData.Labels[i] == dateForReport) { found = true; graphData.Data1[i] += 1; break; } } if (!found) { graphData.Labels.Insert(0, dateForReport); graphData.Data1.Insert(0, 1); graphData.Data2.Insert(0, 0); graphData.Data3.Insert(0, 0); graphData.DataE.Insert(0, 0); } break; case "Class II": for (var i = 0; i <= graphData.Labels.Count - 1; i++) { if (graphData.Labels[i] == dateForReport) { found = true; graphData.Data2[i] += 1; } } if (!found) { graphData.Labels.Insert(0, dateForReport); graphData.Data1.Insert(0, 0); graphData.Data2.Insert(0, 1); graphData.Data3.Insert(0, 0); graphData.DataE.Insert(0, 0); } break; case "Class III": for (var i = 0; i <= graphData.Labels.Count - 1; i++) { if (graphData.Labels[i] == dateForReport) { found = true; graphData.Data3[i] += 1; } } if (!found) { graphData.Labels.Insert(0, dateForReport); graphData.Data1.Insert(0, 0); graphData.Data2.Insert(0, 0); graphData.Data3.Insert(0, 1); graphData.DataE.Insert(0, 0); } break; case "Device Event": case "Drug Event": case "Event": for (var i = 0; i <= graphData.Labels.Count - 1; i++) { if (graphData.Labels[i] == dateForReport) { found = true; graphData.DataE[i] += 1; } } if (!found) { graphData.Labels.Insert(0, dateForReport); graphData.Data1.Insert(0, 0); graphData.Data2.Insert(0, 0); graphData.Data3.Insert(0, 0); graphData.DataE.Insert(0, 1); } break; } } searchResultLocal.MapObjects = ConvertDictionaryMapObjectsToSearchResult(mapList); searchResultLocal.GraphObjects = graphData; return searchResultLocal; }
public abstract void handleSelection(SearchResultItem item);
public void addItem(SearchResultItem item) { UISearchResultItem itemUI = new UISearchResultItem(); itemUI.Opened = this.IsShowToolBar; itemUI.Selected = false; itemUI.DataContext = item; itemUI.MouseDown += delegate(object sender, MouseButtonEventArgs e) { }; itemUI.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) { this._selectedItem = item; if (this.ItemSelected != null) { this.ItemSelected(this, new EventArgs()); } this._selectedItem = null; }; itemUI.Databind(); stackResults.Children.Add(itemUI); }
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 UISearchResultItem getItemUI(SearchResultItem item) { foreach (UIElement uiElem in stackResults.Children) { UISearchResultItem itemUI = (UISearchResultItem)uiElem; if (itemUI.DataContext.Equals(item)) { return itemUI; } } return null; }
private void ucSearchResult_updateItem(SearchResultItem item) { if (this.Dispatcher.Thread != System.Threading.Thread.CurrentThread) { ucSearchResult_updateItem_Callback bR = new ucSearchResult_updateItem_Callback(ucSearchResult_updateItem); this.Dispatcher.Invoke(bR, new Object[] { item }); return; } // ucSearchResult.updateItem(item); }
public void updateItem(SearchResultItem item) { UISearchResultItem itemUI = this.getItemUI(item); if (itemUI == null) { return; } // itemUI.DataContext = item; itemUI.Databind(); // //if (item.ImageUri != null) { // ucCoverFlow.Items.Add(new BitmapImage(item.ImageUri)); //} }
public void PropertiesGetSetTest() { var vm = new SearchResultItem(new SearchResultElement(), null, new long(), 140, GetType()); TestsHelper.TestPublicPropertiesGetSet(vm); }