public void processSearch(CustomSearch _search, UiSearch2.State _previous = UiSearch2.State.SearchResult) { m_PreviousState = _previous; m_LastSearch = _search; m_title.text = "Search : " + _search.SearchName; m_BtnDelete.isVisible = m_PreviousState == UiSearch2.State.Bookmarks; m_BtnSave.isVisible = m_PreviousState == UiSearch2.State.Create; m_loading.isVisible = true; displayMessage(string.Format("Process search: '{0}'", _search.SearchName), EDColors.YELLOW); if (_search.SearchSystem != null) { _search.SearchSystem.reference_system = EDDatas.Instance.getCurrentSystem().name; SearchEngine.Instance.SearchInSystems(_search.SearchSystem, _onSystemsReceived, _onSearchFailed); } else if (_search.SearchBodies != null) { _search.SearchBodies.reference_system = EDDatas.Instance.getCurrentSystem().name; SearchEngine.Instance.SearchInBodies(_search.SearchBodies, _onBodiesReceived, _onSearchFailed); } }
protected void btnCustomSearchGo_Click(object sender, EventArgs e) { CustomSearch search = new CustomSearch(); if (Config.Users.RequireProfileToShowInSearch) { search.HasAnswer = true; } else { search.hasAnswer_isSet = false; } search.Gender = (User.eGender) Convert.ToInt32(dropGender2.SelectedValue); if (Config.Users.InterestedInFieldEnabled && !Config.Users.DisableGenderInformation) search.InterestedIn = (User.eGender) Convert.ToInt32(dropInterestedIn2.SelectedValue); try { search.MinAge = Convert.ToInt32(txtAgeFrom2.Text); search.MaxAge = Convert.ToInt32(txtAgeTo2.Text); } catch { } if (Config.Users.LocationPanelVisible) { if (dropCountry2 != null) { search.Country = dropCountry2.SelectedValue; } if (dropRegion2 != null) { search.State = dropRegion2.SelectedValue; } if (dropCity2 != null) { search.City = dropCity2.SelectedValue; } if (txtZip2 != null) { search.Zip = txtZip2.Text; } } if (cbPhotoReq2.Checked) search.HasPhoto = true; List<ProfileAnswer[]> lSearchTerms = new List<ProfileAnswer[]>(); List<int> lSearchIDs = new List<int>(); ControlCollection currentSearchControls = null; switch ((User.eGender)Int32.Parse(dropGender2.SelectedValue)) { case Classes.User.eGender.Male: currentSearchControls = plhMaleSearchTerms.Controls; break; case Classes.User.eGender.Female: currentSearchControls = plhFemaleSearchTerms.Controls; break; case Classes.User.eGender.Couple: currentSearchControls = plhCoupleSearchTerms.Controls; break; } List<Control> parentControls = new List<Control>(); GetParentControls(currentSearchControls, parentControls); foreach (Control ctrl in currentSearchControls) { if (ctrl is IProfileSearchComponent) { IProfileSearchComponent searchTerm = (IProfileSearchComponent)ctrl; if (searchTerm.Answers != null && searchTerm.Answers.Length > 0) { ProfileQuestion question = ProfileQuestion.Fetch(searchTerm.Answers[0].Question.Id); if (question.ParentQuestionID.HasValue) { var parentControl = parentControls.Cast<IProfileSearchComponent>().FirstOrDefault( c => c != null && c.Answers.Length > 0 && c.Answers[0].Question.Id == question.ParentQuestionID); if (parentControl != null) { string[] parentAnswers = parentControl.Answers.Select(a => a.Value).ToArray(); if (!question.ParentQuestionChoices.Split(':').Any(parentChoice => parentAnswers.Contains(parentChoice))) { continue; } } } lSearchTerms.Add(searchTerm.Answers); lSearchIDs.AddRange(searchTerm.ChoiceIds); } } } if (CurrentUserSession != null) { SaveSavedSearch("_lastsearch_", lSearchIDs.ToArray()); if (cbSaveSearch.Checked) { if (txtSavedSearchName.Text == "") { return; } SaveSavedSearch(txtSavedSearchName.Text, lSearchIDs.ToArray()); LoadSavedSearches(); } } search.Answers = lSearchTerms.ToArray(); UserSearchResults results = search.GetResults(); SearchResults.ShowLastOnline = true; SearchResults.ShowViewedOn = false; SearchResults.ShowDistance = true; SearchResults.Results = results; pnlCustomSearch.Visible = false; pnlFilterOnline.Visible = false; pnlSearchResults.Visible = true; }
protected void fbBasicSearchGo_Click(object sender, EventArgs e) { if (txtUsername != null && txtUsername.Text != String.Empty) { UsernameSearch search = new UsernameSearch(); if (Config.Users.RequireProfileToShowInSearch) { search.HasAnswer = true; } search.Username = txtUsername.Text; Session["UsernameSearchRequest"] = search; } else { var search = new CustomSearch(); if (Config.Users.RequireProfileToShowInSearch) { search.HasAnswer = true; } else { search.hasAnswer_isSet = false; } search.Gender = (User.eGender) Convert.ToInt32(dropGender.SelectedValue); try { search.MinAge = Convert.ToInt32(txtAgeFrom.Text); search.MaxAge = Convert.ToInt32(txtAgeTo.Text); } catch (ArgumentException) { } catch (FormatException) { } search.Country = dropCountry.SelectedValue.Trim(); search.State = dropRegion.SelectedValue.Trim(); search.City = dropCity.SelectedValue.Trim(); var lSearchTerms = new List<ProfileAnswer[]>(); var controls = new List<IProfileSearchComponent>( Misc.Select<IProfileSearchComponent>(phProfileQuestions)); foreach (IProfileSearchComponent searchTerm in controls) { if (searchTerm.Answers != null && searchTerm.Answers.Length > 0) { ProfileQuestion question = ProfileQuestion.Fetch(searchTerm.Answers[0].Question.Id); if (!Config.Users.DisableGenderInformation && (!question.VisibleForMale && search.Gender == Classes.User.eGender.Male || !question.VisibleForFemale && search.Gender == Classes.User.eGender.Female || !question.VisibleForCouple && search.Gender == Classes.User.eGender.Couple)) continue; if (question.ParentQuestionID.HasValue) { var parentControl = controls.FirstOrDefault( c => c != null && c.Answers.Length > 0 && c.Answers[0].Question.Id == question.ParentQuestionID); if (parentControl != null) { string[] parentAnswers = parentControl.Answers.Select(a => a.Value).ToArray(); if (!question.ParentQuestionChoices.Split(':').Any(parentChoice => parentAnswers.Contains(parentChoice))) { continue; } } } lSearchTerms.Add(searchTerm.Answers); } } search.Answers = lSearchTerms.ToArray(); Session["CustomSearchRequest"] = search; } if (Config.BackwardCompatibility.UseClassicSearchPage) Response.Redirect("Search.aspx"); else Response.Redirect("Search2.aspx"); }
private static void AsyncProcessMailerQueue(object data) { if (mailerLock || DateTime.Now.DayOfWeek != DayOfWeek.Friday || !(DateTime.Now.Hour >= 8 && DateTime.Now.Hour <= 10)) { return; } try { mailerLock = true; CustomSearch search = new CustomSearch(); foreach (SavedSearch savedSearchToMail in SavedSearch.GetSavedSearchesToMail()) { User recipient = null; try { recipient = User.Load(savedSearchToMail.Username); if (!recipient.ReceiveEmails || recipient.Deleted) continue; if (recipient.Email.ToLower().Contains("@lovehitch.com")) continue; } catch (NotFoundException) { continue; } search.Gender = savedSearchToMail.Gender; if (Config.Users.InterestedInFieldEnabled) { search.InterestedIn = recipient.Gender; } search.MinAge = savedSearchToMail.AgeFrom; search.MaxAge = savedSearchToMail.AgeTo; search.Country = savedSearchToMail.Country; search.State = savedSearchToMail.State; search.City = savedSearchToMail.City; search.Zip = savedSearchToMail.Zip; if (savedSearchToMail.PhotoRequired) search.HasPhoto = true; search.SortAsc = false; search.SortColumn = "SignupDate"; #region Set Answers int lastQuestionId = -1; List<ProfileAnswer[]> groupedAnswers = new List<ProfileAnswer[]>(); List<ProfileAnswer> profileAnswers = new List<ProfileAnswer>(); foreach (int choiceId in savedSearchToMail.ChoiceIds) { ProfileChoice choice = null; try { choice = ProfileChoice.Fetch(choiceId); } catch (NotFoundException) { continue; } if (lastQuestionId != -1 && choice.Question.Id != lastQuestionId) { if (profileAnswers.Count > 0) groupedAnswers.Add(profileAnswers.ToArray()); profileAnswers.Clear(); } ProfileAnswer answer = new ProfileAnswer(recipient.Username, choice.Question.Id); answer.Value = choice.Value; profileAnswers.Add(answer); if (savedSearchToMail.ChoiceIds[savedSearchToMail.ChoiceIds.Length - 1] == choiceId) { if (profileAnswers.Count > 0) groupedAnswers.Add(profileAnswers.ToArray()); } lastQuestionId = choice.Question.Id; } search.Answers = groupedAnswers.ToArray(); #endregion UserSearchResults results = search.GetResults(); EmailTemplates.SavedSearchMatches matchesTemplate = new EmailTemplates.SavedSearchMatches(recipient.LanguageId); if (results != null && results.Usernames.Length >= matchesTemplate.NumberOfMatchesToMail) { string[] matches = new string[matchesTemplate.NumberOfMatchesToMail]; Array.Copy(results.Usernames, matches, matches.Length); Email.Send(Config.Misc.SiteTitle, Config.Misc.SiteEmail, recipient.Name, recipient.Email, matchesTemplate.GetFormattedSubject(recipient.Name), matchesTemplate.GetFormattedBody(matchesTemplate, recipient.Name, matches), true); savedSearchToMail.SetNextEmailDate(); } } } catch (Exception err) { Global.Logger.LogError("SavedSearchesEmailMatches", err); } finally { mailerLock = false; } }
protected void btnSearch_Click(object sender, EventArgs e) { UserSearchResults results; var username = txtUsername.Text.Trim(); if (username.Length > 0) { UsernameSearch usernameSearch = new UsernameSearch(); usernameSearch.Username = username; results = usernameSearch.GetResults(); SearchResults.ShowLastOnline = true; SearchResults.ShowViewedOn = false; SearchResults.ShowDistance = true; SearchResults.Results = results; return; } var search = new CustomSearch(); if (Config.Users.RequireProfileToShowInSearch) { search.HasAnswer = true; } else { search.hasAnswer_isSet = false; } if (!Config.Users.DisableGenderInformation) { search.Gender = (User.eGender) Convert.ToInt32(dropGender.SelectedValue); if (Config.Users.InterestedInFieldEnabled && !Config.Users.DisableGenderInformation) search.InterestedIn = (User.eGender) Convert.ToInt32(dropInterestedIn.SelectedValue); } if (!Config.Users.DisableAgeInformation) { try { search.MinAge = Convert.ToInt32(txtAgeFrom.Text); search.MaxAge = Convert.ToInt32(txtAgeTo.Text); } catch { } } if (Config.Users.LocationPanelVisible) { if (!IsPostBack && (CurrentUserSession == null || SavedSearch.Load(CurrentUserSession.Username, "_lastsearch_") == null)) { selectedCountry = String.IsNullOrEmpty(Config.Users.ForceCountry) ? Config.Users.DefaultCountry : Config.Users.ForceCountry; search.Country = selectedCountry; setDefault = true; } else { if (dropCountry != null) { search.Country = selectedCountry ?? dropCountry.SelectedValue(); } if (dropRegion != null) { search.State = selectedState ?? dropRegion.SelectedValue(); } if (dropCity != null) { search.City = selectedCity ?? dropCity.SelectedValue(); } } if (txtZip != null) { search.Zip = txtZip.Text; } if (dropDistance.SelectedValue != "-1") { search.FromLocation = Config.Users.GetLocation(search.Country, search.State, search.City); //if (CurrentUserSession != null && CurrentUserSession.Latitude.HasValue && CurrentUserSession.Longitude.HasValue) //{ // search.FromLocation = new Location { Longitude = CurrentUserSession.Longitude.Value, Latitude = CurrentUserSession.Latitude.Value }; // search.Distance = Int32.Parse(dropDistance.SelectedValue); //} var miles = Int32.Parse(dropDistance.SelectedValue); search.Distance = Config.Search.MeasureDistanceInKilometers ? miles * 0.621371192 : miles; } } if (cbPhotoReq.Checked) search.HasPhoto = true; search.OnlineOnly = cbOnlineOnly.Checked; var lSearchTerms = new List<ProfileAnswer[]>(); var lSearchIDs = new List<int>(); var controls = new List<IProfileSearchComponent>( Misc.Select<IProfileSearchComponent>(plhCustomSearch)); foreach (IProfileSearchComponent searchTerm in controls) { if (searchTerm.Answers != null && searchTerm.Answers.Length > 0) { ProfileQuestion question = ProfileQuestion.Fetch(searchTerm.Answers[0].Question.Id); if (!Config.Users.DisableGenderInformation && (!question.VisibleForMale && search.Gender == Classes.User.eGender.Male || !question.VisibleForFemale && search.Gender == Classes.User.eGender.Female || !question.VisibleForCouple && search.Gender == Classes.User.eGender.Couple)) continue; if (question.ParentQuestionID.HasValue) { var parentControl = controls.FirstOrDefault( c => c != null && c.Answers.Length > 0 && c.Answers[0].Question.Id == question.ParentQuestionID); if (parentControl != null) { string[] parentAnswers = parentControl.Answers.Select(a => a.Value).ToArray(); if (!question.ParentQuestionChoices.Split(':').Any(parentChoice => parentAnswers.Contains(parentChoice))) { continue; } } } lSearchTerms.Add(searchTerm.Answers); lSearchIDs.AddRange(searchTerm.ChoiceIds); } } if (Page.IsPostBack && CurrentUserSession != null) { SaveSavedSearch("_lastsearch_", lSearchIDs.ToArray()); if (cbSaveSearch.Checked) { if (txtSavedSearchName.Text == "") { return; } SaveSavedSearch(txtSavedSearchName.Text, lSearchIDs.ToArray()); LoadSavedSearches(); } } search.Answers = lSearchTerms.ToArray(); results = search.GetResults(); SearchResults.ShowLastOnline = true; SearchResults.ShowViewedOn = false; SearchResults.ShowDistance = true; SearchResults.Results = results; cbSaveSearch.Checked = false; }
public void setDatas(CustomSearch search) { Search = search; foreach (NxSimpleText text in m_content) { text.isVisible = false; } if (search == null) { m_type.text = "Empty"; m_type.Color = EDColors.GRAY; return; } m_type.Color = EDColors.YELLOW; if (search.SystemsNotes != null) { m_type.text = search.SearchName; string[] names = search.SystemsNotes.Keys.ToArray(); for (int i = 0; i < names.Length && i < m_content.Length; i++) { m_content[i].text = getSubstring(names[i]); m_content[i].isVisible = true; } } else if (search.SearchSystem != null) { m_type.text = "System search"; int i = 0; if (search.SearchSystem.filters.allegiance != null) { foreach (string v in search.SearchSystem.filters.allegiance?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } if (search.SearchSystem.filters.government != null) { foreach (string v in search.SearchSystem.filters.government?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } if (search.SearchSystem.filters.power != null) { foreach (string v in search.SearchSystem.filters.power?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } if (search.SearchSystem.filters.power_state != null) { foreach (string v in search.SearchSystem.filters.power_state?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } if (search.SearchSystem.filters.primary_economy != null) { foreach (string v in search.SearchSystem.filters.primary_economy?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } if (search.SearchSystem.filters.security != null) { foreach (string v in search.SearchSystem.filters.security?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } if (search.SearchSystem.filters.state != null) { foreach (string v in search.SearchSystem.filters.state?.value) { m_content[i].text = getSubstring(v); m_content[i].isVisible = true; i++; if (i >= m_content.Length) { break; } } } } else if (search.SearchBodies != null) { m_type.text = "Body search"; } setPositions(); }
/// <summary> /// Invokes a Custom Search event handler /// </summary> /// <param name="args">A CustomSearchEventArgs instance</param> protected virtual void OnCustomSearch(CustomSearchEventArgs args) { CustomSearch?.Invoke(this, args); }