/// <summary> /// Main search /// </summary> /// <param name="data"></param> /// <param name="pTotalRows"></param> /// <returns></returns> public static List <OrganizationSummary> DoSearch(MainSearchInput data, ref int pTotalRows) { string where = ""; int userId = 0; AppUser user = AccountServices.GetCurrentUser(); if (user != null && user.Id > 0) { userId = user.Id; } //only target full entities where = " ( base.EntityStateId = 3 ) "; SetKeywordFilter(data.Keywords, true, ref where); //SetAuthorizationFilter( user, ref where ); SearchServices.HandleCustomFilters(data, 59, ref where); SetPropertiesFilter(data, ref where); SearchServices.SetRolesFilter(data, ref where); SetBoundariesFilter(data, ref where); SetFrameworksFilter(data, ref where); SetOrgServicesFilter(data, ref where); //check for org category (credentially, or QA). Only valid if one item //SetOrgCategoryFilter( data, ref where ); //Not updated - I'm not sure we're still using this. - NA 5/12/2017 LoggingHelper.DoTrace(5, thisClassName + ".Search(). Filter: " + where); return(EntityMgr.MainSearch(where, data.SortOrder, data.StartPage, data.PageSize, ref pTotalRows)); }
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 async void Instance() { try { apiService = new ApiServices(); this.Imagen = "ic_nodispon"; this.IdIdentifica = 0; this.NameClient = string.Empty; this.imgByte = null; this.Descripcion = string.Empty; this.Identification = string.Empty; this.withData = false; this.WithClientSelected = false; this.newClient = false; this.SiglaTypeDoc = string.Empty; this.file = null; SearchServices searchService = new SearchServices(); ItemListSelected = new EvidenciasModel(); LstEvidClients = null; LstEvidClients = new ObservableCollection <EvidenciasModel>(); Evidences = new EvidenciasModel(); EvidenceSave = new ObservableCollection <EvidenciasModel>(); ClientSelected = new EvidenciasModel(); TypesDoc = await searchService.GetTypeDoc(); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture Instance", ex.ToString(), "Ok"); } }
public static List <ThisEntity> DoSearch(MainSearchInput data, ref int totalRows) { string where = ""; List <string> competencies = new List <string>(); int userId = 0; AppUser user = AccountServices.GetCurrentUser(); if (user != null && user.Id > 0) { userId = user.Id; } //only target full entities where = " ( base.EntityStateId = 3 ) "; SetKeywordFilter(data.Keywords, false, ref where); SearchServices.SetSubjectsFilter(data, CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE, ref where); SearchServices.HandleCustomFilters(data, 60, ref where); SetPropertiesFilter(data, ref where); SearchServices.SetRolesFilter(data, ref where); SearchServices.SetBoundariesFilter(data, ref where); //CIP SetFrameworksFilter(data, ref where); //Competencies SetCompetenciesFilter(data, ref where, ref competencies); LoggingHelper.DoTrace(5, "AssessmentServices.Search(). Filter: " + where); return(EntityMgr.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows)); }
public static SearchResult LoadPageContent(string pageURL, int parentID, int siteIndexID) { SearchResult searchResult = null; searchResult = new SearchResult(); //check if this page has been indexed BEFORE getting the content. try { searchResult.ParentID = parentID; searchResult.PageName = GetFilenameFromURL(pageURL); searchResult.IndexedSiteID = siteIndexID; searchResult.PageURL = pageURL; if (!SearchServices.IsPageContentIndexed(pageURL, searchResult.PageName)) { searchResult.SearchContent = GetPageContent(pageURL); } return(searchResult); } catch (AggregateException) { return(searchResult); } catch (Exception) { return(searchResult); } }
private ApiResponse DoAutoComplete(AutoCompleteQuery query) { query = query ?? new AutoCompleteQuery() { SearchType = "credential" }; try { //HttpContext.Current.Response.Clear(); //HttpContext.Current.Response.BufferOutput = true; //HttpContext.Current.Response.AppendHeader( "Access-Control-Allow-Origin", "*" ); //string contentType = "application/json"; //HttpContext.Current.Response.ContentType = contentType; //HttpContext.Current.Response.ContentEncoding = contentType == "application/json" ? Encoding.UTF8 : HttpContext.Current.Response.ContentEncoding; var results = SearchServices.DoAutoComplete(query.SearchType, query.FilterURI, query.Text, query.WidgetId); var acr = new AutoCompleteResponse(); acr.Items = results.Select(m => new FilterItem() { Label = m.ToString(), Text = m.ToString(), URI = query.FilterURI, InterfaceType = "interfaceType:Text" }).ToList(); return(new ApiResponse(acr, true, null)); } catch (Exception ex) { return(new ApiResponse(null, false, new List <string>() { "Error processing autocomplete request: " + ex.Message })); } }
public static string GetDirectoryForFile(string pageURL, int parentID) { string fixedURL = RemoveEndingSlash(pageURL); if (!fixedURL.Contains("http")) { PageContentVM pg = SearchServices.GetPageInfo(parentID); return(pg.PageDirectory); } else { //the URL might contain only a # or only the domain name. //handle the case where it is a root folder. Regex domainMatch; string protocolPart = @"^(http(s)?(:\/\/))?(www\.)?"; string domainPart = @"[a-zA-Z0-9-_\.]+"; string paramsPart = @"/([-a-zA-Z0-9:%_\+.~#?&//=]*)/"; string fullURLMatch = string.Join("", protocolPart, domainPart, paramsPart); domainMatch = new Regex(fullURLMatch); string leftOver = domainMatch.Replace(fixedURL, ""); if (leftOver.Length < 2) { return(fixedURL); } else { var myRequest = new Uri(fixedURL); string lastPart = myRequest.Segments.Last() + myRequest.Query; string parentFolder = fixedURL.Replace(lastPart, ""); return(parentFolder); } } }
/// <summary>GetLinksAndKeywords /// the content of the page is loaded. So extract the links and text from a single page. /// //then load all of them into the main container= SearchResult ///Main Object-SearchResult: Container object for all the properties. /////This method loads and then passes the container to the save method later. //Extracts links, title, and converts html to text content /// then counts up the keywords from the content. /// </summary> /// <param name="SearchResult"></param> public static void GetLinksAndKeywords(SearchResult sr) { //check if this page has been indexed BEFORE getting the content. try { if (!SearchServices.IsPageContentIndexed(sr.PageURL, sr.PageName)) { sr.Title = GetPageTitle(sr.SearchContent, sr.PageName); sr.ParentDirectory = GetDirectoryForFile(sr.PageURL, sr.ParentID); sr.PageURL = sr.PageURL; sr.TextContent = GetTextFromHTML(sr.SearchContent); //use the full page content to extract the links sr.Links = GetLinks(sr.SearchContent); //use ONLY the cleaned text to find the keyword ranking. sr.KeyWordRankingList = GetKeywordCounts(sr.TextContent); } } catch (DbEntityValidationException) { } catch (Exception) { } }
// public static List <ConceptSchemeSummary> Search(MainSearchInput data, ref int totalRows) { string where = ""; List <string> messages = new List <string>(); List <string> competencies = new List <string>(); //int userId = 0; //AppUser user = AccountServices.GetCurrentUser(); //if ( user != null && user.Id > 0 ) // userId = user.Id; //only target records with a ctid where = " (len(Isnull(base.Ctid,'')) = 39) "; SetKeywordFilter(data.Keywords, false, ref where); //SearchServices.SetLanguageFilter( data, CodesManager.ENTITY_TYPE_CONCEPT_SCHEME, ref where ); //// //SearchServices.SetAuthorizationFilter( user, "ConceptScheme_Summary", ref where ); //SearchServices.HandleCustomFilters( data, 60, ref where ); // //can this be replaced by following SearchServices.SetRolesFilter(data, ref where); //owned/offered //SearchServices.SetOrgRolesFilter( data, 3, ref where ); //probably N/A SearchServices.SetBoundariesFilter(data, ref where); LoggingHelper.DoTrace(5, "ConceptSchemeServices.Search(). Filter: " + where); return(Manager.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows)); }
private async void Instance() { try { this.apiService = new ApiServices(); this.NewClient = new ClientesModel(); this.IdIdentifica = 0; this.Identification = string.Empty; this.FirstName = string.Empty; this.SecondName = string.Empty; this.FirstLastName = string.Empty; this.SecondLastName = string.Empty; this.NameClient = string.Empty; this.Gustos = string.Empty; this.withData = false; this.DataNewClient = false; this.IdTypeDoc = 0; SearchServices searchService = new SearchServices(); Evidences = new EvidenciasModel(); ClientSave = new ClientesModel(); TypesDoc = await searchService.GetTypeDoc(); TypeDocSelected = TypesDoc.FirstOrDefault(x => x.id == IdTypeDoc); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("AddClient Instance", ex.ToString(), "Ok"); } }
public void SearchAdsFromUrl_CategoryIsSelected_ReturnParentCategoryLabelUrlPartAsImagePath() { // Given Category cat = new Category { Id = 12, LabelUrlPart = "cat-url-label", Label = "Label", ImageName = "image" }; var adRepoMock = new Moq.Mock <ISearchRepository>(); adRepoMock.Setup(r => r.SearchAds(null, null, It.Is <int[]>(x => x[0] == cat.Id))).Returns(new List <SearchAdCache>()); var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(r => r.Get <Category>(cat.Id)).Returns(cat); var catRepoMock = new Moq.Mock <ICategoryRepository>(); catRepoMock.Setup(r => r.GetCategoryFromUrlPart("cat-url-label")).Returns(cat); SearchServices service = new SearchServices(repoMock.Object, catRepoMock.Object, adRepoMock.Object, null, null, null); // When AdSearchResultModel result = service.SearchAdsFromUrl(null, "cat-url-label"); // Then Assert.IsNull(result.SearchString); Assert.IsNull(result.CitySelectedId); Assert.AreEqual(12, result.CategorySelectedId); Assert.AreEqual("image", result.CategoryImagePath); Assert.AreEqual("Label", result.CategorySelectedLabel); adRepoMock.VerifyAll(); }
public static List <ThisEntity> DoSearch(MainSearchInput data, ref int totalRows) { string where = ""; List <string> competencies = new List <string>(); //only target full entities where = " ( base.EntityStateId = 3 ) "; SearchServices.HandleCustomFilters(data, 61, ref where); SetKeywordFilter(data.Keywords, false, ref where); SearchServices.SetSubjectsFilter(data, CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE, ref where); SetPropertiesFilter(data, ref where); SearchServices.SetRolesFilter(data, ref where); SearchServices.SetBoundariesFilter(data, ref where); //SetBoundariesFilter( data, ref where ); //CIP SetFrameworksFilter(data, ref where); //Competencies SetCompetenciesFilter(data, ref where, ref competencies); LoggingHelper.DoTrace(5, "LearningOpportunityServices.Search(). Filter: " + where); return(EntityMgr.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows, ref competencies)); }
public BoardController( ForumServices forumServices, SearchServices searchServices, ThreadServices threadServices, PostServices postServices, PollServices pollServices, GlobalServices globalServices, IRepository <OnlineUser> onlineUserRepository, IRepository <OnlineGuest> onlineGuestRepository, IRepository <User> userRepository, UserServices usersServices, RoleServices roleServices, MessageServices messageServices, PermissionServices permissionServices, FileServices fileServices, User currentUser, Theme currentTheme) { _forumServices = forumServices; _searchServices = searchServices; _threadServices = threadServices; _postServices = postServices; _pollServices = pollServices; _onlineUserRepository = onlineUserRepository; _onlineGuestRepository = onlineGuestRepository; _userRepository = userRepository; _userServices = usersServices; _roleServices = roleServices; _messageServices = messageServices; _permissionServices = permissionServices; _fileServices = fileServices; _currentUser = currentUser; _currentTheme = currentTheme; SetTopBreadCrumb("Board"); }
// private static void SetKeywordFilter(string keywords, bool isBasic, ref string where) { if (string.IsNullOrWhiteSpace(keywords)) { return; } //trim trailing (org) if (keywords.IndexOf("('") > 0) { keywords = keywords.Substring(0, keywords.IndexOf("('")); } //OR base.Description like '{0}' string text = " (base.name like '{0}' OR base.SubjectWebpage like '{0}' OR base.Organization like '{0}' ) "; bool isCustomSearch = false; //use Entity.SearchIndex for all //string indexFilter = " OR (base.Id in (SELECT c.id FROM [dbo].[Entity.SearchIndex] a inner join Entity b on a.EntityId = b.Id inner join TransferValue c on b.EntityUid = c.RowId where (b.EntityTypeId = 3 AND ( a.TextValue like '{0}' OR a.[CodedNotation] like '{0}' ) ))) "; //for ctid, needs a valid ctid or guid if (keywords.IndexOf("ce-") > -1 && keywords.Length == 39) { text = " ( CTID = '{0}' ) "; isCustomSearch = true; } else if (ServiceHelper.IsValidGuid(keywords)) { text = " ( CTID = 'ce-{0}' ) "; isCustomSearch = true; } else if (keywords.ToLower() == "[hascredentialregistryid]") { text = " ( len(Isnull(CredentialRegistryId,'') ) = 36 ) "; isCustomSearch = true; } string AND = ""; if (where.Length > 0) { AND = " AND "; } keywords = ServiceHelper.HandleApostrophes(keywords); if (keywords.IndexOf("%") == -1 && !isCustomSearch) { keywords = SearchServices.SearchifyWord(keywords); } //skip url OR base.Url like '{0}' if (isBasic || isCustomSearch) { where = where + AND + string.Format(" ( " + text + " ) ", keywords); } else { where = where + AND + string.Format(" ( " + text + " ) ", keywords); } }
public async void CallSearchData() { LstEvidClients.Clear(); EvidenciasModel SearchEvidences = new EvidenciasModel(); SearchServices searchService = new SearchServices(); try { if (TypeDocSelected == null && TypeDocSelected.id < 0) { await Application.Current.MainPage.DisplayAlert("", "Seleccione un tipo de documento", "Ok"); isProcessing = false; return; } if (string.IsNullOrEmpty(Identification)) { await Application.Current.MainPage.DisplayAlert("", "Ingrese la identificación del cliente", "Ok"); isProcessing = false; return; } SearchEvidences.typeDoc = TypeDocSelected.id; SearchEvidences.identifClient = this.Identification; Evidences = await searchService.SearchData(SearchEvidences); this.NameClient = Evidences.nameClient; if (Evidences.idTercero > 0) { LstEvidClients.Add(new EvidenciasModel { nameClient = Evidences.nameClient, identifClient = Evidences.identifClient, idTercero = Evidences.idTercero, sigla = TypeDocSelected.nameAux, holder = true }); } else { MainViewModel.GetInstance().AddClient = new AddClientViewModel(); MainViewModel.GetInstance().AddClient.IdTypeDoc = TypeDocSelected.id; MainViewModel.GetInstance().AddClient.Identification = this.Identification; MainViewModel.GetInstance().AddClient.DataNewClient = true; await Application.Current.MainPage.Navigation.PushModalAsync(new AddClientPage()); } withData = true; isProcessing = false; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture SearchData", ex.Message, "Ok"); } }
public void SearchAds_CategoryGroupIsSelected_CallAdRepoWithSubCategoriesIds() { // Given IList <SearchAdCache> searchResult = new List <SearchAdCache>(); searchResult.Add(new SearchAdCache { Title = "ship", City = new City() { Label = "the city" }, Category = new Bea.Domain.Categories.Category() }); Category group = new Category(); group.AddCategory(new Category { Id = 12 }); group.AddCategory(new Category { Id = 17 }); var adRepoMock = new Moq.Mock <ISearchRepository>(); adRepoMock.Setup(r => r.SearchAds(new string[] { "ship" }, null, new int[] { 12, 17 })).Returns(searchResult); var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(r => r.Get <Category>(12)).Returns(group); AdvancedAdSearchModel model = new AdvancedAdSearchModel() { SearchString = "ship", CategorySelectedId = 12 }; SearchServices service = new SearchServices(repoMock.Object, null, adRepoMock.Object, null, null, null); // When AdSearchResultModel result = service.LightSearchAds(model); // Then Assert.AreEqual("ship", result.SearchString); Assert.IsNull(result.CitySelectedId); Assert.AreEqual(12, result.CategorySelectedId); Assert.AreEqual(1, result.SearchResult.Count); Assert.AreEqual(1, result.SearchResultTotalCount); Assert.AreEqual("ship", result.SearchResult[0].Title); adRepoMock.VerifyAll(); }
// //Get Tag Item data public JsonResult GetTagItemData(string searchType, string entityType, int recordID, int maxRecords = 10) { try { var data = SearchServices.GetTagSet(searchType, (SearchServices.TagTypes)Enum.Parse(typeof(SearchServices.TagTypes), entityType, true), recordID, maxRecords); return(JsonHelper.GetJsonWithWrapper(data, true, "", null)); } catch { return(JsonHelper.GetJsonWithWrapper(null, false, "Invalid entity type", null)); } }
// public JsonResult GetOrganizationDataForSelectedMicrosearchItems(List <int> organizationIDs) { var rawResults = new List <OrganizationSummary>(); var results = new List <MainSearchResult>(); foreach (var id in organizationIDs) { rawResults.Add(SimpleMap <OrganizationSummary>(OrganizationServices.GetBasic(id))); } results = new SearchServices().ConvertOrganizationResults(rawResults, 0, "organization").Results; return(JsonResponse(results, true, "", null)); }
public async Task TestSearchServiceFindsItemsInSpecificHtmlFile() { var mockLogger = new Mock <ILogger <SearchServices> >(); var mockConfiguration = new Mock <IConfiguration>(); mockConfiguration.Setup(x => x.GetSection(It.IsAny <string>())[It.IsAny <string>()]).Returns(@"<div class=""ZINbbc xpd O9g5cc uUPGi"">"); var searchServices = new SearchServices(GoogleSearch, mockLogger.Object, mockConfiguration.Object); var result = await searchServices.SearchAsync("www.infotrack.com.au", "online title search"); Assert.NotNull(result); Assert.DoesNotContain("0", result); }
public void AdvancedSearchAds_SearchThroughMotorBoatEngineAds_CallSearchRepoOnMotorBoatEngineAds() { // Given Category cat = new Category { Id = 1, LabelUrlPart = "cat-url-label", Label = "Label", Type = AdTypeEnum.MotorBoatEngineAd }; AdvancedAdSearchModel model = new AdvancedAdSearchModel() { CategorySelectedId = 1, SearchString = "moteur", MinHp = 12, MaxHp = 38, SelectedMotorTypeId = 2 }; IList <SearchAdCache> searchResult = new List <SearchAdCache>(); searchResult.Add(new SearchAdCache { Title = "moteur", City = new City() { Label = "the city" }, Category = cat }); var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(r => r.Get <Category>(cat.Id)).Returns(cat); var searchRepoMock = new Moq.Mock <ISearchRepository>(); searchRepoMock.Setup(r => r.AdvancedSearchAds <MotorBoatEngineAd>( It.Is <AdSearchParameters>(p => p.AndSearchStrings[0].Equals("moteur") && p.MinHp == 12 && p.MaxHp == 38 && p.MotorEngineTypeId == 2))).Returns(searchResult); SearchServices service = new SearchServices(repoMock.Object, null, searchRepoMock.Object, null, null, null); // When AdSearchResultModel result = service.AdvancedSearchAds(model); // Then Assert.AreEqual(1, result.SearchResultTotalCount); }
public void SearchAds_2SearchString_CallAdRepoWithSeveralWords() { // Given IList <SearchAdCache> searchResult = new List <SearchAdCache>(); searchResult.Add(new SearchAdCache { Title = "ship", City = new City() { Label = "the city" }, Category = new Bea.Domain.Categories.Category() }); searchResult.Add(new SearchAdCache { Title = "computer", City = new City() { Label = "the city" }, Category = new Bea.Domain.Categories.Category() }); var adRepoMock = new Moq.Mock <ISearchRepository>(); adRepoMock.Setup(r => r.SearchAds(new string[] { "ship", "computer" }, 98, null)).Returns(searchResult); AdvancedAdSearchModel model = new AdvancedAdSearchModel() { SearchString = "ship computer", CitySelectedId = 98 }; SearchServices service = new SearchServices(null, null, adRepoMock.Object, null, null, null); // When AdSearchResultModel result = service.LightSearchAds(model); // Then Assert.AreEqual("ship computer", result.SearchString); Assert.AreEqual(98, result.CitySelectedId); Assert.AreEqual(2, result.SearchResult.Count); Assert.AreEqual(2, result.SearchResultTotalCount); Assert.AreEqual("ship", result.SearchResult[0].Title); Assert.AreEqual("computer", result.SearchResult[1].Title); adRepoMock.VerifyAll(); }
public void SearchAdsFromUrl_CategoryIsSelected_RunSearchWithCategory() { // Given Category cat = new Category { Id = 12, LabelUrlPart = "cat-url-label", Label = "Label" }; IList <SearchAdCache> searchResult = new List <SearchAdCache>(); searchResult.Add(new SearchAdCache { Title = "ship", City = new City() { Label = "the city" }, Category = cat }); var adRepoMock = new Moq.Mock <ISearchRepository>(); adRepoMock.Setup(r => r.SearchAds(null, null, It.Is <int[]>(x => x[0] == cat.Id))).Returns(searchResult); var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(r => r.Get <Category>(cat.Id)).Returns(cat); var catRepoMock = new Moq.Mock <ICategoryRepository>(); catRepoMock.Setup(r => r.GetCategoryFromUrlPart("cat-url-label")).Returns(cat); SearchServices service = new SearchServices(repoMock.Object, catRepoMock.Object, adRepoMock.Object, null, null, null); // When AdSearchResultModel result = service.SearchAdsFromUrl(null, "cat-url-label"); // Then Assert.IsNull(result.SearchString); Assert.IsNull(result.CitySelectedId); Assert.AreEqual(12, result.CategorySelectedId); Assert.AreEqual("Label", result.CategorySelectedLabel); Assert.AreEqual(1, result.SearchResult.Count); Assert.AreEqual(1, result.SearchResultTotalCount); Assert.AreEqual("ship", result.SearchResult[0].Title); adRepoMock.VerifyAll(); }
private static void SetBoundariesFilter(MainSearchInput data, ref string where) { string AND = ""; if (where.Length > 0) { AND = " AND "; } string template = " ( base.Id in ( SELECT [EntityBaseId] FROM [dbo].[Entity_AddressSummary] where EntityTypeId = 2 AND [Longitude] < {0} and [Longitude] > {1} and [Latitude] < {2} and [Latitude] > {3} ) ) "; var boundaries = SearchServices.GetBoundaries(data, "bounds"); if (boundaries.IsDefined) { where = where + AND + string.Format(template, boundaries.East, boundaries.West, boundaries.North, boundaries.South); } }
public JsonResult StartCrawler(int parentID, int siteIndexID) { IndexResultVM finalCount; try { //this method runs recursively until the limit is reached. ConcurrentBag <SearchResult> searchResults = new ConcurrentBag <SearchResult>(); // get the links from the saved links bool MaximumDepthReached = SearchServices.CanReachMaxDepth(CRAWLER_DEPTH, siteIndexID); if (!MaximumDepthReached) { List <PageContentVM> pageLinksMain = SearchServices.GetLinkDataForSiteIndexID(siteIndexID); //put the links into a list so that they can be run in Parallel. Parallel.ForEach(pageLinksMain, (sr) => { string fullURL = string.Join("", sr.PageDirectory, sr.PageName); SearchResult csr = SearchUtils.LoadPageContent(fullURL, sr.ParentID, siteIndexID); searchResults.Add(csr); }); // now that all the links have content, do a regular loop for the parsing and saving . foreach (SearchResult csr in searchResults) { SearchUtils.GetLinksAndKeywords(csr); csr.PageID = SearchServices.SaveSearchResults(csr); StartCrawler(csr.PageID, siteIndexID); } } } catch (DbEntityValidationException) { Server.ClearError(); } catch (Exception) { Server.ClearError(); } finally { finalCount = SearchServices.GetIndexedPagesTotals(siteIndexID); } return(Json(finalCount, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Credential autocomplete /// Needs to check authorization level for credential /// </summary> /// <param name="keyword"></param> /// <param name="maxTerms"></param> /// <returns></returns> public static List <object> Autocomplete(string keywords, int maxTerms = 25) { int userId = 0; string where = " base.EntityStateId = 3 "; string AND = ""; int pTotalRows = 0; AppUser user = AccountServices.GetCurrentUser(); if (user != null && user.Id > 0) { userId = user.Id; } if (UtilityManager.GetAppKeyValue("usingElasticCredentialAutocomplete", false)) { return(ElasticHelper.CredentialAutoComplete(keywords, maxTerms, ref pTotalRows)); } else { bool usingLinqAutocomplete = true; if (usingLinqAutocomplete) { return(CredentialManager.AutocompleteInternal(keywords, 1, maxTerms, ref pTotalRows)); } else { string text = " (base.name like '{0}' OR base.AlternateName like '{0}' OR OwningOrganization like '{0}' ) "; //SetKeywordFilter( keywords, true, ref where ); keywords = ServiceHelper.HandleApostrophes(keywords); if (keywords.IndexOf("%") == -1) { keywords = SearchServices.SearchifyWord(keywords); } if (where.Length > 0) { AND = " AND "; } where = where + AND + string.Format(" ( " + text + " ) ", keywords); return(CredentialManager.AutocompleteDB(where, 1, maxTerms, ref pTotalRows)); } // return new List<string>(); } }
public async void CallSearchData() { EvidenciasModel SearchEvidences = new EvidenciasModel(); SearchServices searchService = new SearchServices(); try { if (TypeDocSelected == null && TypeDocSelected.id < 0) { await Application.Current.MainPage.DisplayAlert("", "Seleccione un tipo de documento", "Ok"); isProcessing = false; return; } if (string.IsNullOrEmpty(Identification)) { await Application.Current.MainPage.DisplayAlert("", "Ingrese la identificación del cliente", "Ok"); isProcessing = false; return; } SearchEvidences.typeDoc = TypeDocSelected.id; SearchEvidences.identifClient = this.Identification; Evidences = await searchService.SearchData(SearchEvidences); this.NameClient = Evidences.nameClient; this.IdIdentifica = Evidences.idTercero; if (Evidences.idTercero == 0) { this.DataNewClient = true; this.withData = false; } else { withData = true; isProcessing = false; } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture SearchData", ex.Message, "Ok"); } }
// private static void SetPropertiesFilter(MainSearchInput data, ref string where) { string AND = ""; string searchCategories = UtilityManager.GetAppKeyValue("asmtSearchCategories", "21,37,"); SearchServices.SetPropertiesFilter(data, 1, searchCategories, ref where); //string template = " ( base.Id in ( SELECT [EntityBaseId] FROM [dbo].[EntityProperty_Summary] where EntityTypeId= 3 AND {0} )) "; //string template1 = " ( base.Id in ( SELECT [EntityBaseId] FROM [dbo].[EntityProperty_Summary] where EntityTypeId= 3 AND [PropertyValueId] in ({0}) )) "; //string properyListTemplate = " ( [PropertyValueId] in ({0}) ) "; //string filterList = ""; //int prevCategoryId = 0; ////Updated to use FiltersV2 //string next = ""; //if (where.Length > 0) // AND = " AND "; //foreach (var filter in data.FiltersV2.Where(m => m.Type == MainSearchFilterV2Types.CODE)) //{ // var item = filter.AsCodeItem(); // if (searchCategories.Contains(item.CategoryId.ToString())) // { // //18-03-27 mp - these are all property values, so using an AND with multiple categories will always fail - removing prevCategoryId check // //if (item.CategoryId != prevCategoryId) // //{ // // if (prevCategoryId > 0) // // { // // next = next.Trim(','); // // filterList += (filterList.Length > 0 ? " AND " : "") + string.Format(properyListTemplate, next); // // } // // prevCategoryId = item.CategoryId; // // next = ""; // //} // next += item.Id + ","; // } //} //next = next.Trim(','); //if (!string.IsNullOrWhiteSpace(next)) //{ // //where = where + AND + string.Format( template, next ); // filterList += (filterList.Length > 0 ? " AND " : "") + string.Format(properyListTemplate, next); // where = where + AND + string.Format(template, filterList); //} } //
public void AdvancedSearchAds_SearchThroughAds_CallSearchRepoOnAds() { // Given Category cat = new Category { Id = 1, LabelUrlPart = "cat-url-label", Label = "Label", Type = AdTypeEnum.Ad }; AdSearchModel model = new AdSearchModel(); model.CategorySelectedId = 1; model.SearchString = "toto"; model.CitySelectedId = 12; IList <SearchAdCache> searchResult = new List <SearchAdCache>(); searchResult.Add(new SearchAdCache { Title = "ship", City = new City() { Label = "the city" }, Category = cat }); var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(r => r.Get <Category>(cat.Id)).Returns(cat); var searchRepoMock = new Moq.Mock <ISearchRepository>(); searchRepoMock.Setup(r => r.SearchAds(It.Is <String[]>(x => x[0] == "toto"), 12, It.Is <int[]>(x => x[0] == 1))).Returns(searchResult); SearchServices service = new SearchServices(repoMock.Object, null, searchRepoMock.Object, null, null, null); // When AdSearchResultModel result = service.LightSearchAds(model); // Then Assert.AreEqual(1, result.SearchResultTotalCount); }
public void PopulateSearchCombo(Guid languageID) { try { //Populate Countries, Regions, Sectors this.Country_Languages = CountryService.GetCountries(languageID); this.Region_Languages = RegionService.GetRegions(languageID); //Populate Variables this.Variable_Languages = SearchServices.GetVariables(languageID); this.LanguageID = languageID; //Populate Record Variables PopulateRecordVariables(); } catch (Exception ex) { ErrorLog.WriteLog("ManageRecordModel", "Populate", ex, string.Empty); } }
} // public static List <PathwaySetSummary> DoPathwaySetSearch(MainSearchInput data, ref int totalRows) { string where = ""; //only target full entities where = " ( base.EntityStateId = 3 ) "; //need to create a new category id for custom filters //SearchServices.HandleCustomFilters( data, 61, ref where ); SetKeywordFilter(data.Keywords, false, ref where); SearchServices.SetSubjectsFilter(data, CodesManager.ENTITY_TYPE_PATHWAY, ref where); //SetPropertiesFilter( data, ref where ); SearchServices.SetRolesFilter(data, ref where); SearchServices.SetBoundariesFilter(data, ref where); LoggingHelper.DoTrace(5, "PathwayServices.DoPathwaySetSearch(). Filter: " + where); return(PathwaySetManager.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows)); }