public static IWebElement FindElement(SearchBy by, string locator) { loggerInfo.Instance.LogInfo("Find By [ " + by + " ]" + " Locator [ " + locator + " ]"); IWebElement parentElement = null; return(FindElement(by, locator, 2, parentElement));//TODO: Ideally we should be using 0 but for now its 2 sec }
public static bool ClickElement(SearchBy by, string locator, bool teardownTestIfFail, string logMessage) { IWebElement element = FindElement(by, locator, string.Empty); if (element != null) { try { loggerInfo.Instance.Message(logMessage); loggerInfo.Instance.Message("Click on " + locator); return(ClickElement(element, teardownTestIfFail)); } catch (Exception e) { loggerInfo.Instance.LogAppErro(e, "Unable to Click on Element : [ " + locator + " ]", LogLevel.Error); return(false); } } else { Exception e = new Exception("Click Element with By [ " + by + " ]" + " Locator [ " + locator + " ]"); loggerInfo.Instance.LogAppErro(e, "", LogLevel.Error); return(false); } }
public SearchEmployeeQuery(SearchBy searchBy, string searchTerm, int page, int pageSize) { _searchBy = searchBy; _searchTerm = searchTerm; _page = page; _pageSize = pageSize; }
public static UnityEngine.Object[] FindAll(SearchBy search, string query) { switch (search) { case SearchBy.Nothing: return(ArrayUtil.Empty <UnityEngine.Object>()); case SearchBy.Tag: return(GameObjectUtil.FindGameObjectsWithMultiTag(query)); case SearchBy.Name: { using (var tmp = com.spacepuppy.Collections.TempCollection.GetList <UnityEngine.GameObject>()) { GameObjectUtil.FindAllByName(query, tmp); return(tmp.ToArray()); } } case SearchBy.Type: return(ObjUtil.FindObjectsOfType(TypeUtil.FindType(query))); default: return(null); } }
// Ищем продукт по Коду в прайс-листах public static DataTable Search(string fieldSearch, SearchBy searchBy) { ResultSearchXLSX.Clear(); if (Settings.listXLSX == null || Settings.listXLSX.Count == 0 || fieldSearch == string.Empty) { return(ResultSearchXLSX); } foreach (string file in Settings.listXLSX) { if (File.Exists(file)) { try { switch (searchBy) { case SearchBy.Code: SearchByCode(fieldSearch, file); break; case SearchBy.Name: SearchByName(fieldSearch, file); break; } } catch (Exception e) { MessageBox.Show(e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } return(ResultSearchXLSX); }
public static void TypeElement(SearchBy by, string locator, string textToType, string logMessage, bool hitEnterAfterType) { string postString = string.Empty; if (logMessage != "") { loggerInfo.Instance.Message(logMessage); } if (hitEnterAfterType) { postString = System.Environment.NewLine; } IWebElement element = FindElement(by, locator, string.Empty); try { ClickElement(element, false); loggerInfo.Instance.Message("Type '" + textToType + "' in locator: { " + locator + " }"); element.SendKeys(textToType + postString); } catch (Exception e) { e = new Exception(e.Message); loggerInfo.Instance.LogAppErro(e, "Unable to Type '" + textToType + "' in " + locator, NLog.LogLevel.Error); return; } }
public void SearchVisuallyByImageUrlWithCropShouldThrowWhenConstructed() { Assert.Throws <ClarifaiException>(() => { SearchBy.ImageVisually(CELEB1, new Crop(0.1M, 0.2M, 0.3M, 0.4M)); }); }
public static IWebElement FindElement(SearchBy by, string locator, int timeOut, IWebElement parentElement = null) { ReadOnlyCollection <IWebElement> SearchElements = FindElements(by, locator, timeOut, parentElement); if (SearchElements != null) { if (SearchElements.Count > 0) { loggerInfo.Instance.LogInfo("Found Element By [ " + by + " ]" + " Locator [ " + locator + " ]"); return(SearchElements.First <IWebElement>()); } else { PromptAlertMessage("Unable to find Element By [ " + by + " ]" + " Locator [ " + locator + " ]"); loggerInfo.Instance.LogAppErro(new Exception("Unable to find Element By [ " + by + " ]" + " Locator [ " + locator + " ]"), "", NLog.LogLevel.Error); TakeScreenShot(testEInfo); return(null); } } else { PromptAlertMessage("Unable to Error Message is Element By [ " + by + " ]" + " Locator [ " + locator + " ]"); loggerInfo.Instance.LogAppErro(new Exception("Unable to Error Message is Element By [ " + by + " ]" + " Locator [ " + locator + " ]"), "", NLog.LogLevel.Error); TakeScreenShot(testEInfo); return(null); } }
public IActionResult SearchResults(string Name, int Id) { if (!string.IsNullOrWhiteSpace(Name)) { try { string search = Name; SearchBy typeOfSearch = SearchBy.name; Pokemon p = DAL.ConvertToPokemonModels(search, typeOfSearch); return(View(p)); } catch { return(View("Search")); } } else if (Id != 0) { string search = Id.ToString(); SearchBy typeOfSearch = SearchBy.id; Pokemon p = DAL.ConvertToPokemonModels(search, typeOfSearch); return(View(p)); } return(View("")); }
private void cboNCT_TheLoai_SelectionChangeCommitted(object sender, EventArgs e) { _CurrentPage = "1"; _SearchBy = SearchBy.TheLoai; _IsSearchMenu = true; Search("http://v6.nhaccuatui.com", _SearchBy.ToString(), _IsSearchMenu); }
public async Task <IEnumerable <Job_DiscriptionView> > GetBy(SearchBy searchBy) { try { var vList = (from jd in adbContext.job_description.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join comp in adbContext.company on jd.Company_Id equals comp.Company_Id join dep in adbContext.department on jd.Dept_Id equals dep.Dept_Id join desig in adbContext.designation on jd.Desig_Id equals desig.Desig_Id where jd.isActive == 1 && comp.isActive == 1 select new Job_DiscriptionView { JD_Id = jd.JD_Id, Company_Id = jd.Company_Id, Company_Name = comp.Company_Name, Dept_Id = jd.Dept_Id, Dept_Name = dep.Dept_Name, Desig_Id = jd.Desig_Id, Desig_Name = desig.Desig_Name, JD_Code = jd.JD_Code, JD_Name = jd.JD_Name, JD_Description = jd.JD_Description, Notes = jd.Notes } ).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <ShiftView> > GetBy(SearchBy searchBy) { try { var vList = (from s in adbContext.shift.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join comp in adbContext.company on s.Company_Id equals comp.Company_Id where s.isActive == 1 && comp.isActive == 1 select new ShiftView { Shift_Id = s.Shift_Id, Company_Id = s.Company_Id, Company_Name = comp.Company_Name, Shift_Code = s.Shift_Code, Shift_Name = s.Shift_Name, Shift_Start = s.Shift_Start, Shift_End = s.Shift_End, NightShift = s.NightShift, Shift_Variable = s.Shift_Variable } ).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <Module_PermissionView> > GetBy(SearchBy searchBy) { try { var vList = (from mp in adbContext.module_permission.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join m in adbContext.module on mp.Module_Id equals m.Id select new Module_PermissionView { Id = mp.Id, Module_Id = mp.Module_Id, Module_Name = m.Name, Name = mp.Name, isActive = mp.isActive } ).Take(searchBy.RecordLimit).ToList(); if (vList == null || vList.Count() == 0) { throw new RecoredNotFoundException("Get Data Empty"); } return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <User_RoleView> > GetBy(SearchBy searchBy) { try { var vList = (from ur in adbContext.user_role.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join u in adbContext.users on ur.User_Id equals u.User_Id join r in adbContext.roles on ur.Role_Id equals r.Id where ur.isActive == 1 && u.isActive == 1 select new User_RoleView { Id = ur.Id, User_Id = ur.User_Id, Login_Id = u.Login_Id, Role_Id = ur.Role_Id, Name = r.Name } ).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public static Element InitializeElement(string locator, SearchBy locatorValue = SearchBy.Xpath) { Element element = new Element(); element.Search = new Search(locator); return(element); }
public static ElementsList InitializeElements(string locator, SearchBy locatorValue = SearchBy.Xpath) { ElementsList elements = new ElementsList(); elements.Search = new Search(locator); return(elements); }
public ActionResult ClassAdvanced(string searchString, int page, SearchBy searchBy, OrderBy orderBy, string universityId) { UserInformationModel<User> myUserInformation = GetUserInformatonModel(); searchString = MassageSearchString(searchString); SearchResultsModel mySearchResults = theSearchService.GetClassSearchResults(myUserInformation, searchString, page, searchBy, orderBy, universityId); return View("Results", mySearchResults); }
private void cboZing_CaSi_SelectionChangeCommitted(object sender, EventArgs e) { _CurrentPage = "1"; _SearchBy = SearchBy.CaSi; _IsSearchMenu = true; Search("http://mp3.zing.vn", _SearchBy.ToString(), _IsSearchMenu); }
public async Task <IEnumerable <ProbationView> > GetBy(SearchBy searchBy) { try { var vList = (from prob in adbContext.probation.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join comp in adbContext.company on prob.Company_Id equals comp.Company_Id where prob.isActive == 1 && comp.isActive == 1 select new ProbationView { Prob_Id = prob.Prob_Id, Company_Id = prob.Company_Id, Company_Name = comp.Company_Name, Prob_Code = prob.Prob_Code, Prob_Name = prob.Prob_Name, Prob_Description = prob.Prob_Description, Prob_DurationUnit = prob.Prob_DurationUnit, Prob_Duration = prob.Prob_Duration, Notes = prob.Notes, } ).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <SiteView> > GetBy(SearchBy searchBy) { try { var vList = (from s in adbContext.site.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join comp in adbContext.company on s.Company_Id equals comp.Company_Id where s.isActive == 1 && comp.isActive == 1 select new SiteView { Site_Id = s.Site_Id, Company_Id = s.Company_Id, Company_Name = comp.Company_Name, Site_Code = s.Site_Code, Site_Name = s.Site_Name, Address1 = s.Address1, Address2 = s.Address2, Address3 = s.Address3, Address4 = s.Address4, PostCode = s.PostCode, City = s.City, State = s.State, Country = s.Country } ).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Finds all books that contain the given value in their properties. /// </summary> /// <param name="tag">The searching criteria.</param> /// <param name="keyword">The keyword to be used in the search.</param> /// <returns>A collection of the found books.</returns> public IEnumerable <Book> FindBookByTag(SearchBy tag, string keyword) { if (string.IsNullOrWhiteSpace(keyword)) { throw new ArgumentException("No data to search with."); } string subset = keyword.ToUpperInvariant(); switch (tag) { case SearchBy.Isbn: return(this.bookSet.Where(b => string.Equals(b.Isbn, keyword, StringComparison.OrdinalIgnoreCase))); case SearchBy.Author: return(this.bookSet.Where(b => b.Author.ToUpperInvariant().Contains(subset))); case SearchBy.Title: return(this.bookSet.Where(b => b.Title.ToUpperInvariant().Contains(subset))); case SearchBy.Publisher: return(this.bookSet.Where(b => b.Publisher.ToUpperInvariant().Contains(subset))); default: throw new ArgumentException("Wrong searching tag."); } }
public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems) { Result result; try { Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application; UIDocument revitDoc = cmdData.Application.ActiveUIDocument; Document dbdoc = revitDoc.Document; Snoop.CollectorExts.CollectorExt.m_activeDoc = dbdoc; // TBD: see note in CollectorExt.cs SearchBy searchByWin = new SearchBy(dbdoc); ActiveDoc.UIApp = cmdData.Application; searchByWin.ShowDialog(); result = Result.Succeeded; } catch (System.Exception e) { msg = e.Message; result = Result.Failed; } return(result); }
public async Task <IActionResult> GetBy(SearchBy searchBy) { ResponseHelper objHelper = new ResponseHelper(); try { var vList = await commonQueryRepo.GetBy(searchBy); if (vList == null) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Get Empty Data"; } else { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Get Successfully"; objHelper.Data = vList; } return(Ok(objHelper)); } catch { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = "Get Unsuccessful"; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
public void Add(SearchScope scope, SearchBy searchBy, Operator op, string searchText) { var searchPredicate = HookExtensions.FormatSearchClause <T>(searchBy, op, searchText); switch (scope) { case SearchScope.ExecutingAssembly: _hook.AddRange(Assembly.GetExecutingAssembly().GetHooks <T>(searchPredicate)); break; case SearchScope.EntryAssembly: _hook.AddRange(Assembly.GetEntryAssembly().GetHooks <T>(searchPredicate)); break; case SearchScope.CallingAssembly: _hook.AddRange(Assembly.GetCallingAssembly().GetHooks <T>(searchPredicate)); break; case SearchScope.CurrentDirectory: List <Assembly> assemblies = DirectoryExtensions.GetAssemblies(Environment.CurrentDirectory, "*.dll"); assemblies.AddRange(DirectoryExtensions.GetAssemblies(Environment.CurrentDirectory, "*.exe")); foreach (var item in assemblies) { _hook.AddRange(item.GetHooks(searchPredicate)); } break; default: throw new InvalidOperationException("Invalid SearchScope: " + scope); } }
public static ReadOnlyCollection <IWebElement> FindElements(SearchBy by, string locator) { loggerInfo.Instance.LogInfo("Find Elements By [ " + by + " ]" + " Locator [ " + locator + " ]"); IWebElement parentElement = null; return(FindElements(by, locator, testTimeout, parentElement)); }
public async Task <IEnumerable <DesignationView> > GetBy(SearchBy searchBy) { try { var vList = (from desig in adbContext.designation.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join dept in adbContext.department on desig.Dept_Id equals dept.Dept_Id join comp in adbContext.company on desig.Company_Id equals comp.Company_Id join zone in adbContext.zone on desig.Zone_Id equals zone.Zone_Id select new DesignationView { Desig_Id = desig.Desig_Id, Desig_Code = desig.Desig_Code, Desig_Name = desig.Desig_Name, Report_To = desig.Report_To, AdditionalReport_To = desig.AdditionalReport_To, Company_Name = comp.Company_Name, Dept_Name = dept.Dept_Name, Zone_Name = zone.Zone_Name }).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public Pokemon ConvertToPokemonModels(string search, SearchBy typeOfSearch) { string pokemonData = GetPokemon(search, typeOfSearch); Pokemon p = JsonConvert.DeserializeObject <Pokemon>(pokemonData); return(p); }
public async Task SearchIssuesTest() { //Arrange var issues = new List <Issue>() { new Issue { Id = 1 }, new Issue { Id = 2 } }; int totalIssues = 2; var service = new SearchBy(issueRepository.Object); issueRepository.Setup(x => x.GetIssues(It.IsAny <Func <Issue, bool> >(), It.IsAny <int>(), It.IsAny <int>())) .Returns(Task.FromResult(issues)); issueRepository.Setup(x => x.CountIssues(It.IsAny <Func <Issue, bool> >())).Returns(Task.FromResult(totalIssues)); //Act var action = await service.SearchIssues(x => x.Id != 0, x => x.Status != Status.Close, searchSpecification); //Assert Assert.Equal(totalIssues, action.Issues.Count); Assert.Equal(totalIssues, action.Count.FilteredIssue); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (SearchBy.Equals("name", System.StringComparison.InvariantCultureIgnoreCase)) { if (string.IsNullOrEmpty(Name)) { yield return(new ValidationResult("Please specify a search Name.", new[] { nameof(Name) })); } } else if (SearchBy.Equals("coordinates", System.StringComparison.InvariantCultureIgnoreCase)) { string InvalidVertexMessage = "Please specify vertext coordinates."; if (!IsVertexValid(Vertex1)) { yield return(new ValidationResult(InvalidVertexMessage, new[] { nameof(Vertex1) })); } if (!IsVertexValid(Vertex2)) { yield return(new ValidationResult(InvalidVertexMessage, new[] { nameof(Vertex2) })); } if (!IsVertexValid(Vertex3)) { yield return(new ValidationResult(InvalidVertexMessage, new[] { nameof(Vertex3) })); } } else { yield return(new ValidationResult("Please specify a valid search type.", new[] { nameof(SearchBy) })); } }
public async Task <IEnumerable <Email_ConfigView> > GetBy(SearchBy searchBy) { try { var vList = (from con in adbContext.email_config.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join c in adbContext.company on con.Company_Id equals c.Company_Id select new Email_ConfigView { Email_Config_Id = con.Email_Config_Id, Company_Id = con.Company_Id, Company_Name = c.Company_Name, Email_Host = con.Email_Host, Email_Port = con.Email_Port, Email_UserName = con.Email_UserName, Email_Password = con.Email_Password, EnableSSL = con.EnableSSL, TLSEnable = con.TLSEnable } ).Take(searchBy.RecordLimit).ToList(); if (vList == null || vList.Count() == 0) { throw new RecoredNotFoundException("Get Data Empty"); } return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <ContractView> > GetBy(SearchBy searchBy) { try { var vList = (from con in adbContext.contract.Where(String.Format("{0}=={1}", searchBy.FieldName, searchBy.FieldValue)) join c in adbContext.company on con.Company_Id equals c.Company_Id where con.isActive == 1 && c.isActive == 1 select new ContractView { Contract_Id = con.Contract_Id, Company_Id = con.Company_Id, Company_Name = c.Company_Name, Contract_Code = con.Contract_Code, Contract_Name = con.Contract_Name, Contract_HoursDaily = con.Contract_HoursDaily, Contract_HoursWeekly = con.Contract_HoursWeekly, Contract_Days = con.Contract_Days, Contract_Type = con.Contract_Type, Notes = con.Notes } ).Take(searchBy.RecordLimit).ToList(); return(await Task.FromResult(vList)); } catch (Exception ex) { throw ex; } }
public SearchIndexViewModel(string query, SearchBy searchBy = SearchBy.FullText | SearchBy.Tag, SearchWhat searchWhat = SearchWhat.Groups | SearchWhat.Content) { if (!string.IsNullOrWhiteSpace(query)) { Query = query; if (searchBy.HasFlag(SearchBy.FullText)) { if (searchWhat.HasFlag(SearchWhat.Content)) { var comments = DataService.PerThread.GetCommentsByFullText(query, 100).Select(x => new SearchIndex_ResultViewModel(x)); var posts = DataService.PerThread.GetPostsByFullText(query, 100).Select(x => new SearchIndex_ResultViewModel(x)); var petitions = DataService.PerThread.GetPetitionsByFullText(query, 100).Select(x => new SearchIndex_ResultViewModel(x)); var polls = DataService.PerThread.GetPollsByFullText(query, 100).Select(x => new SearchIndex_ResultViewModel(x)); var surveys = DataService.PerThread.GetSurveysByFullText(query, 100).Select(x => new SearchIndex_ResultViewModel(x)); Content = comments.Union(posts.Union(petitions.Union(polls.Union(surveys)))).ToList(); } if (searchWhat.HasFlag(SearchWhat.Groups)) Groups = DataService.PerThread.GetGroupsByFullText(query, 100).Select(x => new SearchIndex_ResultViewModel(x)).ToList(); } if (searchBy.HasFlag(SearchBy.Tag)) { var tags = DataService.PerThread.TagSet.Where(x => x.Title.Contains(query) || query.Contains(x.Title)).ToList(); if (searchWhat.HasFlag(SearchWhat.Content)) { IEnumerable<SearchIndex_ResultViewModel> tagedContent = new List<SearchIndex_ResultViewModel>(); foreach (var c in tags.Where(x => x.Contents.Count != 0).Select(x => x.Contents)) tagedContent = tagedContent.Union(c.Select(x => new SearchIndex_ResultViewModel(x)).ToList()); Content = Content.Union(tagedContent).ToList(); } if (searchWhat.HasFlag(SearchWhat.Groups)) { var tagedGroups = tags.Where(x => x.GroupId.HasValue).Select(x => new SearchIndex_ResultViewModel(x.Group)).ToList(); Groups = Groups.Union(tagedGroups).ToList(); } } } }
/// <summary> /// Provide searching of a key and tells how many keys were found. You have to be on "Pages" page /// </summary> /// <param name="key"></param> /// <param name="howToSearch"></param> /// <returns>Number of keys found</returns> public int SearchKey(string key, SearchBy howToSearch) { if (howToSearch == SearchBy.Content) { ChooseElementInSelect("Content", _searchBySelect, SelectBy.Text); } _searchInput.SendKeys(key); _searchKeyButton.Click(); WaitAjax(); return Driver.FindElements(By.CssSelector("div > .table.table-hover.table-bordered:nth-child(2) > tbody > tr")).Count; }
public ActionResult DoAdvancedSearch(SearchFilter searchType, string searchString, int page, SearchBy searchBy, OrderBy orderBy, string universityId) { return JavaScript("window.top.location.href ='" + Url.Action(searchType.ToString() + "Advanced") + "?searchString=" + searchString + "&page=" + page + "&searchBy=" + searchBy.ToString() + "&orderBy=" + orderBy.ToString() + "&universityId=" + universityId + "';"); }
public DdeCustomTypeSchemaFactory(SearchBy searchBy, VisibleScopes scope) : base(searchBy, scope) { }
public Rollouts(Client client, DateTime date, SearchBy searchBy) { MySqlCommand cmd; Rollout roll; string dateField = (searchBy == SearchBy.RollDate) ? "rolledDate" : "scheduledDate"; date = date.Date; // Store date part, time part not needed. using(MySqlConnection conn = (MySqlConnection)this.Conn){ conn.Open(); cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM " + _table + " WHERE clientId = @clientId AND " + dateField + " = @" + dateField; cmd.Parameters.Add("@clientId", client.Id); cmd.Parameters.Add("@" + dateField, date); using(MySqlDataReader dr = cmd.ExecuteReader()){ if(!dr.HasRows && dateField == "scheduledDate"){ roll = new Rollout(); roll.Client = client; roll.ScheduledDate = date; roll.BusinessCollection = this; List.Add(roll); }else{ while (dr.Read()){ roll = new Rollout(dr); roll.BusinessCollection = this; List.Add(roll); } } } } }
private SearchResultsModel BuildSearchResultsModel(string aUniversityId, List<ISearchResult> aResults, Helpers.Search.SearchFilter aSearchType, int aPage, string aSearchString, int aTotalResults, IDictionary<string, string> aSearchByOptions, SearchBy aSearchBySelected, IDictionary<string, string> anOrderByOptions, OrderBy anOrderBySelected) { int myToGet = (aPage - 1) * SiteConfiguration.ResultsPerPage() + SiteConfiguration.ResultsPerPage() > aResults.Count ? aTotalResults % SiteConfiguration.ResultsPerPage() : SiteConfiguration.ResultsPerPage(); IEnumerable<ISearchResult> myFinalResultSet = aResults.GetRange((aPage - 1) * SiteConfiguration.ResultsPerPage(), myToGet); return new SearchResultsModel() { SearchType = aSearchType, SearchResults = myFinalResultSet, CurrentPage = aPage, TotalPages = (int)Math.Ceiling((double)aTotalResults / (double)SiteConfiguration.ResultsPerPage()), TotalResults = aTotalResults, SearchString = aSearchString, SearchByOptions = new SelectList(aSearchByOptions, "Value", "Key", aSearchBySelected), OrderByOptions = new SelectList(anOrderByOptions, "Value", "Key", anOrderBySelected), UniversityOptions = new SelectList(UniversityOptions(), "Value", "Key", aUniversityId) }; }
/// <summary> /// Search on Allmusic for the requested string /// </summary> /// <param name="searchBy"></param> /// <param name="searchStr"></param> /// <returns></returns> public bool FindInfo(SearchBy searchBy, string searchStr) { _searchby = searchBy; HTMLUtil util = new HTMLUtil(); string strPostData = ""; if (SearchBy.Albums == searchBy) { strPostData = string.Format(ALBUMSEARCH, HttpUtility.UrlEncode(searchStr)); } else { searchStr = SwitchArtist(searchStr); strPostData = string.Format(ARTISTSEARCH, HttpUtility.UrlEncode(searchStr)); } string strHTML = PostHTTP(MAINURL + URLPROGRAM, strPostData); if (strHTML.Length == 0) { return false; } _htmlCode = strHTML; // save the html content... Regex multiples = new Regex( @"\sSearch\sResults\sfor:", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled ); if (multiples.IsMatch(strHTML)) { string pattern = ""; if (searchBy.ToString().Equals("Artists")) { pattern = @"<tr.*?>\s*?.*?<td\s*?class=""relevance\stext-center"">\s*?.*\s*?.*</td>" + @"\s*?.*<td.*\s*?.*</td>\s*?.*<td>.*<a.*href=""(?<code>.*?)"">(?<name>.*)</a>.*</td>" + @"\s*?.*<td>(?<detail>.*)</td>\s*?.*<td>(?<detail2>.*)</td>"; } else if (searchBy.ToString().Equals("Albums")) { pattern = @"<tr.*?>\s*?.*?<td\s*?class=""relevance\stext-center"">\s*?.*\s*?.*</td>" + @"\s*?.*<td.*\s*?.*</td>\s*?.*<td>.*<a.*href=""(?<code>.*?)"">(?<name>.*)</a>.*</td>" + @"\s*?.*<td>(?<detail>.*)</td>\s*?.*<td>.*</td>\s*?.*<td>(?<detail2>.*)</td>"; } Match m; Regex itemsFoundFromSite = new Regex( pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled ); for (m = itemsFoundFromSite.Match(strHTML); m.Success; m = m.NextMatch()) { string code = m.Groups["code"].ToString(); string name = m.Groups["name"].ToString(); string detail = m.Groups["detail"].ToString(); string detail2 = m.Groups["detail2"].ToString(); util.RemoveTags(ref name); util.ConvertHTMLToAnsi(name, out name); util.RemoveTags(ref detail); util.ConvertHTMLToAnsi(detail, out detail); util.RemoveTags(ref detail2); util.ConvertHTMLToAnsi(detail2, out detail2); if (SearchBy.Artists == searchBy) { detail += " - " + detail2; if (detail.Length > 0) { _codes.Add(code); _values.Add(name + " - " + detail); } else { _codes.Add(code); _values.Add(name); } } else { MusicAlbumInfo albumInfo = new MusicAlbumInfo(); albumInfo.AlbumURL = code; albumInfo.Artist = detail; albumInfo.Title = name; albumInfo.DateOfRelease = detail2; _albumList.Add(albumInfo); } } _multiple = true; } else // found the right one {} return true; }
public SearchResultsModel MarketplaceSearchResults(UserInformationModel<User> aUserInformation, string aSearchString, int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string anItemType, string aUniversityId) { IEnumerable<MarketplaceItem> myItems = new List<MarketplaceItem>(); string myUniversityId = "All"; if (!aUniversityId.Equals("All")) { myUniversityId = aUniversityId; if (aSearchBy == SearchBy.Title) { myItems = theMarketplaceSerivce.GetLatestItemsSellingInUniversityByItemAndTitle(myUniversityId, anItemType, aSearchString); } } else { if (aSearchBy == SearchBy.Title) { myItems = theMarketplaceSerivce.GetLatestItemsSellingByTypeAndTitleForAnyUniversity(anItemType, aSearchString); } } if (anOrderBy == OrderBy.Title) { myItems = myItems.OrderBy(r => r.Title); } else if (anOrderBy == OrderBy.LowestPrice) { myItems = myItems.OrderBy(r => r.Price); } else if (anOrderBy == OrderBy.HighestPrice) { myItems = myItems.OrderByDescending(r => r.Price); } else if (anOrderBy == OrderBy.Newest) { myItems = myItems.OrderBy(r => r.DateTimeStamp); } List<ISearchResult> mySearchResult = new List<ISearchResult>(); mySearchResult.AddRange(myItems.Select(r => new ItemSearchResult(r) { UserInformationModel = aUserInformation })); int myTotalResults = myItems.Count(); SearchResultsModel myModel = BuildSearchResultsModel(myUniversityId, mySearchResult, (SearchFilter)Enum.Parse(typeof(SearchFilter), anItemType), aPage, aSearchString, myTotalResults, SearchByForItems(), aSearchBy, OrderByForItems(), anOrderBy); return myModel; }
public SearchResultsModel GetUserSearchResults(UserInformationModel<User> aUserInformation, string aSearchString, int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string aUniversityId) { IEnumerable<User> myUsers = new List<User>(); if (aSearchBy == SearchBy.Name) { if (aUserInformation == null) { myUsers = theSearchRepository.GetUserByName(aSearchString); } else { myUsers = theSearchRepository.GetUserByName(aUserInformation.UserId, aSearchString); } } if (anOrderBy == OrderBy.Name) { myUsers = myUsers.OrderBy(r => r.FirstName + " " + r.LastName); } List<ISearchResult> mySearchResult = new List<ISearchResult>(); mySearchResult.AddRange(myUsers.Select(r => new UserSearchResult(r) { UserInformationModel = aUserInformation })); int myTotalResults = myUsers.Count<User>(); SearchResultsModel myModel = BuildSearchResultsModel("All", mySearchResult, SearchFilter.USER, aPage, aSearchString, myTotalResults, SearchByForPeople(), aSearchBy, OrderByForPeople(), anOrderBy); return myModel; }
public SearchResultsModel GetTextBookSearchResults(UserInformationModel<User> aUserInformation, string aSearchString, int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string aUniversityId) { IEnumerable<TextBook> myTextBooks = new List<TextBook>(); string myUniversityId = "All"; if (!aUniversityId.Equals("All")) { myUniversityId = aUniversityId; if (aSearchBy == SearchBy.Title) { myTextBooks = theSearchRepository.GetTextBookByTitle(myUniversityId, aSearchString); } else if (aSearchBy == SearchBy.ClassCode) { myTextBooks = theSearchRepository.GetTextBookByClassCode(myUniversityId, aSearchString); } } else { if (aSearchBy == SearchBy.Title) { myTextBooks = theSearchRepository.GetTextBookByTitle(aSearchString); } else if (aSearchBy == SearchBy.ClassCode) { myTextBooks = theSearchRepository.GetTextBookByClassCode(aSearchString); } } if (anOrderBy == OrderBy.Title) { myTextBooks = myTextBooks.OrderBy(r => r.BookTitle); } else if (anOrderBy == OrderBy.ClassCode) { myTextBooks = myTextBooks.OrderBy(r => r.ClassSubject + r.ClassCourse); } else if (anOrderBy == OrderBy.LowestPrice) { myTextBooks = myTextBooks.OrderBy(r => r.Price); } else if (anOrderBy == OrderBy.HighestPrice) { myTextBooks = myTextBooks.OrderByDescending(r => r.Price); } List<ISearchResult> mySearchResult = new List<ISearchResult>(); mySearchResult.AddRange(myTextBooks.Select(r => new TextBookSearchResult(r) { UserInformationModel = aUserInformation })); int myTotalResults = myTextBooks.Count<TextBook>(); SearchResultsModel myModel = BuildSearchResultsModel(myUniversityId, mySearchResult, SearchFilter.TEXTBOOK, aPage, aSearchString, myTotalResults, SearchByForTextbook(), aSearchBy, OrderByForTextbook(), anOrderBy); return myModel; }
public SearchResultsModel GetClassSearchResults(UserInformationModel<User> aUserInformation, string aSearchString, int aPage, SearchBy aSearchBy, OrderBy anOrderBy, string aUniversityId) { IEnumerable<Class> myClasses = new List<Class>(); string myUniversityId = "All"; if (!aUniversityId.Equals("All")) { myUniversityId = aUniversityId; if (aSearchBy == SearchBy.Title) { myClasses = theSearchRepository.GetClassByTitle(myUniversityId, aSearchString); } else if (aSearchBy == SearchBy.ClassCode) { myClasses = theSearchRepository.GetClassByClassCode(myUniversityId, aSearchString); } } else { if (aSearchBy == SearchBy.Title) { myClasses = theSearchRepository.GetClassByTitle(aSearchString); } else if (aSearchBy == SearchBy.ClassCode) { myClasses = theSearchRepository.GetClassByClassCode(aSearchString); } } if (anOrderBy == OrderBy.Title) { myClasses = myClasses.OrderBy(r => r.Title); } else if (anOrderBy == OrderBy.ClassCode) { myClasses = myClasses.OrderBy(r => r.Subject + r.Course); } List<ISearchResult> mySearchResult = new List<ISearchResult>(); mySearchResult.AddRange(myClasses.Select(r => new ClassSearchResult(r))); int myTotalResults = myClasses.Count<Class>(); SearchResultsModel myModel = BuildSearchResultsModel(myUniversityId, mySearchResult, SearchFilter.CLASS, aPage, aSearchString, myTotalResults, SearchByForClass(), aSearchBy, OrderByForClass(), anOrderBy); return myModel; }
public IEnumerable<Group> GetGroups(UserInformationModel<User> aUser, string aSearchTerm, SearchBy aSearchBy, OrderBy orderBy, bool aMyGroups) { IEnumerable<Group> myGroups = new List<Group>(); if (aMyGroups) { if (aSearchBy == SearchBy.All) { myGroups = theGroupRepository.GetMyGroupsByAll(aUser.Details); } else if (aSearchBy == SearchBy.City) { myGroups = theGroupRepository.GetMyGroupsByCity(aUser.Details, aSearchTerm); } else if (aSearchBy == SearchBy.Name) { myGroups = theGroupRepository.GetMyGroupsByName(aUser.Details, aSearchTerm); } else if (aSearchBy == SearchBy.Tags) { myGroups = theGroupRepository.GetMyGroupsByKeywordTags(aUser.Details, aSearchTerm); } else if (aSearchBy == SearchBy.ZipCode) { if (!ZipCodeValidation.IsValid(aSearchTerm)) { throw new CustomException("The zip code must be 5 digits long."); } myGroups = theGroupRepository.GetMyGroupsByZipCode(aUser.Details, int.Parse(aSearchTerm)); } } else { User myUser = aUser != null ? aUser.Details : null; bool myIncludeAdmin = aUser != null; if (aSearchBy == SearchBy.All) { myGroups = theGroupRepository.GetGroupsByAll(myUser, myIncludeAdmin); } else if (aSearchBy == SearchBy.City) { myGroups = theGroupRepository.GetGroupsByCity(myUser, aSearchTerm, myIncludeAdmin); } else if (aSearchBy == SearchBy.Name) { myGroups = theGroupRepository.GetGroupsByName(myUser, aSearchTerm, myIncludeAdmin); } else if (aSearchBy == SearchBy.Tags) { myGroups = theGroupRepository.GetGroupsByKeywordTags(myUser, aSearchTerm, myIncludeAdmin); } else if (aSearchBy == SearchBy.ZipCode) { if (!ZipCodeValidation.IsValid(aSearchTerm)) { throw new CustomException("The zip code must be 5 digits long."); } myGroups = theGroupRepository.GetGroupsByZipCode(myUser, int.Parse(aSearchTerm), myIncludeAdmin); } } if (orderBy == OrderBy.City) { myGroups = myGroups.OrderBy(g => g.GroupCityStateTags.OrderBy(gc => gc.City)); } else if (orderBy == OrderBy.Name) { myGroups = myGroups.OrderBy(g => g.Name); } else if (orderBy == OrderBy.State) { myGroups = myGroups.OrderBy(g => g.GroupCityStateTags.OrderBy(gc => gc.State)); } else if (orderBy == OrderBy.ZipCode) { myGroups = myGroups.OrderBy(g => g.GroupZipCodeTags.Count > 0 ? g.GroupZipCodeTags.Min(gz => gz.ZipCode) : 0); } return myGroups; }
public HttpResponseMessage SearchForBook(string query, SearchBy searchBy=SearchBy.All) { try { var context = new LibrarySystemContext(); if (query == null || query == "") { throw new ArgumentException("Невалидно търсене!"); } IQueryable<Book> booksEntity; if (searchBy == SearchBy.Key) { booksEntity = context.Books.Where(b => b.Key.Contains(query)); } else if (searchBy == SearchBy.Author) { booksEntity = context.Books.Where(b => b.Author.Name.Contains(query)); } else if (searchBy == SearchBy.Title) { booksEntity = context.Books.Where(b => b.Title.Contains(query)); } else { booksEntity = context.Books.Where(b => b.Key.Contains(query) || b.Author.Name.Contains(query) || b.Title.Contains(query)); } var books = from book in booksEntity select new BookModel() { Title = book.Title, AuthorName = book.Author.Name, Description = book.Description, Key = book.Key, Year = book.Year }; var response = this.Request.CreateResponse(HttpStatusCode.OK, books); return response; } catch (Exception ex) { var response = this.Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return response; } }
public bool FindAlbumInfo(string strAlbum, string artistName, int releaseYear) { _searchby = SearchBy.Albums; _albumList.Clear(); if (FindInfo(SearchBy.Albums, strAlbum)) { // Sort the Album artistName = SwitchArtist(artistName); _albumList.Sort(new AlbumSort(strAlbum, artistName, releaseYear)); return true; } return false; }
public ActionResult Search(SearchBy searchBy, OrderBy orderBy, string searchTerm) { return SearchIssues(searchBy, orderBy, searchTerm); }
public IEnumerable<IssueWithDispositionModel> GetIssues(User aUser, SearchBy aSearchBy, OrderBy anOrderBy, string aSearchTerm) { IEnumerable<IssueWithDispositionModel> mySearchResults = new List<IssueWithDispositionModel>(); if (aSearchBy == SearchBy.All) { mySearchResults = theIssueRepository.GetIssues(aUser); } else if (aSearchBy == SearchBy.Title) { mySearchResults = theIssueRepository.GetIssuesByTitle(aUser, aSearchTerm); } else if (aSearchBy == SearchBy.Description) { mySearchResults = theIssueRepository.GetIssuesByDescription(aUser, aSearchTerm); } if (anOrderBy == OrderBy.LastReplyDate) { mySearchResults = mySearchResults.OrderByDescending( r => r.Issue.IssueReplys .Where(r2 => !r2.Deleted) .OrderByDescending(r2 => r2.DateTimeStamp) .FirstOrDefault<IssueReply>() != null ? r.Issue.IssueReplys .Where(r2 => !r2.Deleted) .OrderByDescending(r2 => r2.DateTimeStamp) .FirstOrDefault<IssueReply>().DateTimeStamp : OLD_DATE ); } else if (anOrderBy == OrderBy.LatestCreationDate) { mySearchResults = mySearchResults.OrderByDescending(i => i.Issue.DateTimeStamp); } else if (anOrderBy == OrderBy.Title) { mySearchResults = mySearchResults.OrderBy(i => i.Issue.Title); } return mySearchResults; }
private ActionResult SearchIssues(SearchBy aSearchBy, OrderBy anOrderBy, string aSearchTerm) { IEnumerable<IssueWithDispositionModel> myIssues = new List<IssueWithDispositionModel>(); ; try { myIssues = theIssueService.GetIssues(GetUserInformaton(), aSearchBy, anOrderBy, aSearchTerm); } catch (Exception e) { LogError(e, GET_LATEST_ISSUES_ERROR); return SendToErrorPage(GET_LATEST_ISSUES_ERROR); } if (myIssues.Count() == 0) { ViewData["Message"] = MessageHelper.NormalMessage(NO_ISSUES); } SearchModel<IssueWithDispositionModel> mySearchModel = new SearchModel<IssueWithDispositionModel>() { SearchResults = myIssues, SearchByOptions = new SelectList(theIssueService.SearchByOptions(), "Value", "Key", aSearchBy), OrderByOptions = new SelectList(theIssueService.OrderByOptions(), "Value", "Key", anOrderBy) }; return View("List", mySearchModel); }
public ActionResult Search(string searchTerm, SearchBy searchBy, OrderBy orderBy, bool showMyGroupsOnly) { if (!IsLoggedIn()) { return RedirectToLogin(); } IEnumerable<Group> myGroups = new List<Group>(); GroupSearchModel myGroupSearchModel = new GroupSearchModel() { SearchResults = myGroups, SearchByOptions = new SelectList(theGroupService.SearchByOptions(), "Value", "Key", searchBy.ToString()), OrderByOptions = new SelectList(theGroupService.OrderByOptions(), "Value", "Key", orderBy.ToString()) }; try { UserInformationModel<User> myUser = GetUserInformatonModel(); myGroups = theGroupService.GetGroups(myUser, searchTerm, searchBy, orderBy, showMyGroupsOnly); if (myGroups.Count<Group>() == 0) { ViewData["Message"] = MessageHelper.NormalMessage(NO_GROUPS); } myGroupSearchModel.SearchResults = myGroups; } catch(CustomException anException) { ViewData["Message"] = MessageHelper.ErrorMessage(anException.Message); } catch (Exception myException) { LogError(myException, GROUP_LIST_ERROR); ViewData["Message"] = GROUP_LIST_ERROR; } return View("List", myGroupSearchModel); }