public void PopulateControls(User user) { if (!Config.Users.LocationPanelVisible) return; if (dropCountry != null && user.Country.IsNotNullOrEmpty()) { CascadingDropDownCountry.SelectedValue = user.Country; CascadingDropDownCountry.LoadingText = user.Country; CascadingDropDownCountry.PromptText = PageBase.PleaseChooseTranslated; } if (dropRegion != null && user.State.IsNotNullOrEmpty()) { CascadingDropDownState.SelectedValue = user.State; CascadingDropDownState.LoadingText = user.State; CascadingDropDownState.PromptText = PageBase.PleaseChooseTranslated; } if (dropCity != null && user.City.IsNotNullOrEmpty()) { CascadingDropDownCity.SelectedValue = user.City; CascadingDropDownCity.LoadingText = user.City; CascadingDropDownCity.PromptText = PageBase.PleaseChooseTranslated; } if (txtZipCode != null) { txtZipCode.Text = user.ZipCode; } }
//public static double FetchBayesianAverage(string username, TimeSpan period) //{ // double average; // var fromDate = DateTime.Now.Subtract(period); // var averageRating = FetchAverageRating(period, gender, minAge, maxAge); // var averageNumberOfVotes = FetchAverageNumberOfVotes(period, gender, minAge, maxAge); // using (var db = new AspNetDatingDataContext()) // { // var userNumberOfVotes = db.Votes.Count(v => v.v_tousername == username // && v.v_timestamp >= fromDate); // var userAverageRating = db.Votes.Where(v => v.v_tousername == username // && v.v_timestamp >= fromDate) // .Average(v => (double?) v.v_score) ?? 0; // average = ((averageNumberOfVotes*averageRating) + (userNumberOfVotes*userAverageRating)) // /(averageNumberOfVotes + userNumberOfVotes); // } // return average; //} public static double FetchAverageRating(TimeSpan period, User.eGender gender, int minAge, int maxAge) { string cacheKey = String.Format("Votes_FetchAverageRating_{0}_{1}_{2}_{3}", period, gender, minAge, maxAge); if (HttpContext.Current != null && HttpContext.Current.Cache[cacheKey] != null) { return (double) HttpContext.Current.Cache[cacheKey]; } double average; var fromDate = DateTime.Now.Subtract(period); DateTime fromBirthdate = DateTime.Now.Subtract(TimeSpan.FromDays((maxAge + 1) * 365.25)); DateTime toBirthdate = DateTime.Now.Subtract(TimeSpan.FromDays(minAge * 365.25)); using (var db = new AspNetDatingDataContext()) { average = (from v in db.Votes join u in db.Users on v.v_tousername equals u.u_username where v.v_timestamp >= fromDate && u.u_gender == (int)gender && u.u_birthdate >= fromBirthdate && u.u_birthdate <= toBirthdate select (double?)v.v_score).Average() ?? 0; } if (HttpContext.Current != null) { HttpContext.Current.Cache.Insert(cacheKey, average, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); } return average; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { WideBoxStart1.Title = Lang.Trans("Status"); MiscTemplates.SubscriptionCompleted subscriptionCompletedTemplate = new MiscTemplates.SubscriptionCompleted(LanguageId); lblMessage.Text = subscriptionCompletedTemplate.Text; if (CurrentUserSession != null) { Classes.User user = new User(CurrentUserSession.Username); user.Load(); CurrentUserSession.Paid = user.Paid; CurrentUserSession.BillingPlanOptions = null; CurrentUserSession.Credits = user.Credits; } //if (!Config.Credits.Required) //{ // if (CurrentUserSession != null && !Classes.User.IsNonPaidMember(CurrentUserSession.Username)) // { // CurrentUserSession.Paid = true; // CurrentUserSession.BillingPlanOptions = null; // } //} //else //{ // if (CurrentUserSession != null) // CurrentUserSession.Credits = Classes.User.Load(CurrentUserSession.Username).Credits; //} }
protected void Page_Load(object sender, EventArgs e) { // This page checks your database to see if your users have any WM windows that need to be launched // Also, it updates your database telling your site that the user is currently on the site // This will need to be set to the userID of the currently logged in member String strUserID = CurrentUserSession == null ? null : CurrentUserSession.Username; int iRefreshInterval = Request.QueryString["iRefreshInterval"] != null ? Int32.Parse(Request.QueryString["iRefreshInterval"]) : 5; if (iRefreshInterval > 0) { metaRefresh.Attributes["HTTP-EQUIV"] = "refresh"; metaRefresh.Attributes["content"] = String.Format("{0};URL={1}?iRefreshInterval={2}", iRefreshInterval, Request.FilePath, iRefreshInterval); } else metaRefresh.Visible = false; // clear out any old values (that were requested over 15 minutes ago) InstantMessenger.DeleteOldOpenWindowRequests(); if (strUserID != null) { // update your database so that everyone knows this user is online right now CurrentUserSession.UpdateLastOnline(false); // execute strQuery against your database // select a list of users who want to talk with the current user and we haven't opened a window for 5 mins // join it with your existing users table so you can get their display name string[] users = InstantMessenger.FetchPendingUsers(strUserID); StringBuilder sb = new StringBuilder(); sb.Append("<script language=\"javascript\">\n"); sb.Append("<!--\n"); foreach (string user in users) { User targetUser = new User(user); targetUser.Load(); InstantMessenger.SetWindowOpened(user, strUserID); //Modified by Miroslav Parvanov //real names are changed back to usernames sb.AppendFormat("window.parent.up_launchWM('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}');\n", strUserID, user, CurrentUserSession.Username, targetUser.Username, targetUser.Gender.ToString(), targetUser.Age, targetUser.City); //sb.AppendFormat("window.parent.up_launchWM('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}');\n", // strUserID, user, CurrentUserSession.Name, targetUser.Name, // targetUser.Gender.ToString(), targetUser.Age, targetUser.City); } sb.Append("//-->\n"); sb.Append("</script>\n"); ClientScript.RegisterClientScriptBlock(typeof(wmLauncher_), "launchWM", sb.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.Params["username"] != null) { user = Classes.User.Load(Request.Params["username"]); EditProfileCtrl1.User = user; } } }
public void PopulateCombos(User user) { comboAgeFrom.Items.Clear(); comboAgeTo.Items.Clear(); for (int i = Config.Users.MinAge; i <= Config.Users.MaxAge; i++) { comboAgeTo.Items.Add(i.ToString()); comboAgeFrom.Items.Add(i.ToString()); } comboAgeFrom.SelectedValue = user != null && user.Age - 10 > MinAge ? (user.Age - 10).ToString() : MinAge.ToString(); comboAgeTo.SelectedValue = user != null && user.Age + 10 < MaxAge ? (user.Age + 10).ToString() : MaxAge.ToString(); }
public static Dictionary<string, double> FetchTopUsers(User.eGender gender, int minAge, int maxAge, TimeSpan period, int count) { DateTime fromBirthdate = DateTime.Now.Subtract(TimeSpan.FromDays((maxAge + 1) * 365.25)); DateTime toBirthdate = DateTime.Now.Subtract(TimeSpan.FromDays(minAge * 365.25)); string cacheKey = String.Format("Votes_FetchTopUsers_{0}_{1}_{2}_{3}_{4}", gender, minAge, maxAge, period, count); if (HttpContext.Current != null && HttpContext.Current.Cache[cacheKey] != null) { return (Dictionary<string, double>) HttpContext.Current.Cache[cacheKey]; } var userRatings = new Dictionary<string, double>(); var fromDate = DateTime.Now.Subtract(period); var averageRating = FetchAverageRating(period, gender, minAge, maxAge); var averageNumberOfVotes = FetchAverageNumberOfVotes(period, gender, minAge, maxAge); using (var db = new AspNetDatingDataContext()) { foreach (var rating in (from v in db.Votes join u in db.Users on v.v_tousername equals u.u_username where v.v_timestamp >= fromDate && u.u_gender == (int) gender && u.u_birthdate >= fromBirthdate && u.u_birthdate <= toBirthdate group v by v.v_tousername into uv select new { Username = uv.Key, Rating = ((averageNumberOfVotes*averageRating) + (uv.Count()*uv.Average(v => v.v_score))) /(averageNumberOfVotes + uv.Count()) }).OrderByDescending( uv => uv.Rating).Take(count)) { userRatings.Add(rating.Username, rating.Rating); } } if (HttpContext.Current != null) { HttpContext.Current.Cache.Insert(cacheKey, userRatings, null, DateTime.Now.AddMinutes(30), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); } return userRatings; }
public void PopulateControls(User user) { if (!Config.Users.LocationPanelVisible) return; if (dropCountry != null && user.Country.IsNotNullOrEmpty()) { CascadingDropDownCountry.SelectedValue = user.Country; } if (dropRegion != null && user.State.IsNotNullOrEmpty()) { CascadingDropDownState.SelectedValue = user.State; } if (dropCity != null && user.City.IsNotNullOrEmpty()) { CascadingDropDownCity.SelectedValue = user.City; } }
public void PopulateCombos(User user) { dropGender.Items.Clear(); dropGender.Items.Add( new ListItem(Lang.Trans("Men"), ((int)User.eGender.Male).ToString())); dropGender.Items.Add( new ListItem(Lang.Trans("Women"), ((int)User.eGender.Female).ToString())); if (Config.Users.CouplesSupport) { dropGender.Items.Add( new ListItem(Lang.Trans("Couples"), ((int)User.eGender.Couple).ToString())); } dropInterestedIn.Items.Clear(); dropInterestedIn.Items.Add( new ListItem(Lang.Trans("Men"), ((int)User.eGender.Male).ToString())); dropInterestedIn.Items.Add( new ListItem(Lang.Trans("Women"), ((int)User.eGender.Female).ToString())); if (Config.Users.CouplesSupport) { dropInterestedIn.Items.Add( new ListItem(Lang.Trans("Couples"), ((int)User.eGender.Couple).ToString())); } if (user != null) { InterestedInGender = ((int)user.Gender); LookingForGender = ((int)user.InterestedIn); bool toEnable = !(Page is Search2) || MatchmakerHelper.IsMatchmakerState || Convert.ToBoolean(ConfigurationManager.AppSettings["ENABLE_CHANGE_MY_GENDER_IN_SEARCH"]); dropGender.Enabled = toEnable; dropInterestedIn.Enabled = toEnable; } else { if (!_interestedInGenderIsSet) InterestedInGender = ((int)User.eGender.Female); if (!_lookingForGenderIsSet) LookingForGender = ((int)User.eGender.Male); } }
protected void LoadMySingleFriends(User.eGenderSearch gender) { var user = PageBase.GetCurrentUserSession(); var genderFriendsSearch = new QuickSingleFriendsSearch { UsersCount = RepeatColumns * LimitRows, PageNumber = 0, MaxAge = Math.Min(user.IncomingMessagesRestrictions.AgeTo, Config.Users.MaxAge), MinAge = Math.Max(user.IncomingMessagesRestrictions.AgeFrom, Config.Users.MinAge), MatchmakerUsername = user.Username, FriendGender = gender }; Results = genderFriendsSearch.GetResults(); }
/// <summary> /// Updates user account data /// </summary> /// <param name="user">User object</param> /// <param name="updatePaidStatus">if set to <c>true</c> [update paid status].</param> public static void Update(User user, bool updatePaidStatus) { if ((!user.latitude.HasValue || !user.longitude.HasValue) && Config.ThirdPartyServices.GetMissingCoordinatesFromGoogleMaps && Config.ThirdPartyServices.GoogleMapsAPIKey.Length > 0) { try { double[] coordinates = GoogleMaps.GetCoordinates(user.city + "," + user.country); if (coordinates != null && coordinates.Length >= 2) { user.latitude = coordinates[0]; user.longitude = coordinates[1]; } } catch (Exception err) { Global.Logger.LogError("User.Update", err); } } using (SqlConnection conn = Config.DB.Open()) { SqlHelper.ExecuteNonQuery(conn, "UpdateUser", user.username, user.password, user.email, user.name, user.gender, user.interestedIn, user.birthdate, user.birthdate2 == DateTime.MinValue ? null : (object) user.birthdate2, user.active, user.smsConfirmed, user.receiveEmails, user.profileVisible, user.country, user.state, user.zipCode, user.city, user.paid, user.messageVerificationsLeft, user.languageId, user.billingDetails, user.invitedBy, user.incomingMessagesRestrictions, user.deleted, user.affiliateID, user.options, user.longitude, user.latitude, updatePaidStatus, user.tokenUniqueId, user.personalizationInfo, user.credits, user.moderationScores, user.SpamSuspected, user.faceControlApproved, user.ProfileSkin, user.statusText, user.isFeaturedMember, user.mySpaceID, user.facebookID, user.eventsSettings); } string cachekey = String.Format("User_Load_{0}", user.username); if (HttpContext.Current != null && HttpContext.Current.Cache[cachekey] != null) { HttpContext.Current.Cache.Remove(cachekey); } }
public static Location GetLocation(User user) { if (user != null && user.Longitude.HasValue && user.Latitude.HasValue) { var loc = new Location { Longitude = user.Longitude.Value, Latitude = user.Latitude.Value }; return loc; } return null; }
private static ScheduledAnnouncement[] Fetch(int? id, User.eGender? gender, bool? paidMember, bool? hasPhotos, bool? hasProfile, int? languageID, string country, string region, eType? type) { using (SqlConnection conn = Config.DB.Open()) { SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchScheduledAnnouncement", id, gender, paidMember, hasPhotos, hasProfile, languageID, country, region, type); List<ScheduledAnnouncement> lScheduledAnnouncements = new List<ScheduledAnnouncement>(); while (reader.Read()) { ScheduledAnnouncement scheduledAnnouncement = new ScheduledAnnouncement(); scheduledAnnouncement.id = (int)reader["ID"]; scheduledAnnouncement.name = (string) reader["Name"]; scheduledAnnouncement.subject = (string)reader["Subject"]; scheduledAnnouncement.body = (string)reader["Body"]; scheduledAnnouncement.gender = reader["Gender"] != DBNull.Value ? (User.eGender?) ((int) reader["Gender"]) : null; scheduledAnnouncement.paidMember = reader["PaidMember"] != DBNull.Value ? (bool?) reader["PaidMember"] : null; scheduledAnnouncement.hasPhotos = reader["HasPhotos"] != DBNull.Value ? (bool?)reader["HasPhotos"] : null; scheduledAnnouncement.hasProfile = reader["HasProfile"] != DBNull.Value ? (bool?)reader["HasProfile"] : null; scheduledAnnouncement.languageID = reader["LanguageID"] != DBNull.Value ? (int?)reader["LanguageID"] : null; scheduledAnnouncement.country = reader["Country"] != DBNull.Value ? (string)reader["Country"] : null; scheduledAnnouncement.region = reader["Region"] != DBNull.Value ? (string)reader["Region"] : null; scheduledAnnouncement.type = (eType) reader["Type"]; scheduledAnnouncement.date = reader["Date"] != DBNull.Value ? (DateTime?)reader["Date"] : null; scheduledAnnouncement.days = reader["Days"] != DBNull.Value ? (int?)reader["Days"] : null; lScheduledAnnouncements.Add(scheduledAnnouncement); } return lScheduledAnnouncements.ToArray(); } }
public double? GetDistanceFromUser(User user, bool inKilometers) { Location from = Config.Users.GetLocation(this); Location to = Config.Users.GetLocation(user); if (from != null && to != null) { return Distance.GetDistance(from, to, inKilometers ? 'k' : 'm'); } return null; }
public static string[] GetUsersWithinRadius(Location inLocation, bool? hasAnswer, User.eGender gender, int maxAge, int minAge, bool photoReq, double inRadius, int maxResults) { if (null == inLocation) throw new ArgumentNullException("inLocation", "Null location passed in."); if (inRadius <= 0.0) throw new ArgumentOutOfRangeException("inRadius", inRadius, "Invalid value for radius passed in."); if (Double.MinValue == inLocation.Latitude) throw new ArgumentException("inLocation.Latitude", string.Format( "The database does not contain latitude information for {0}, {1}.", inLocation.City, inLocation.State)); if (Double.MinValue == inLocation.Longitude) throw new ArgumentException("inLocation.Longitude", string.Format( "The database does not contain longitude information for {0}, {1}.", inLocation.City, inLocation.State)); RadiusBox radBox = RadiusBox.Create(inLocation, inRadius); using (SqlConnection conn = DB.Open()) { SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchUsersInRadius", hasAnswer, (int)gender, DateTime.Now.Subtract(TimeSpan.FromDays(maxAge * 365.25)), DateTime.Now.Subtract(TimeSpan.FromDays(minAge * 365.25)), photoReq, radBox.BottomLine, radBox.TopLine, radBox.LeftLine, radBox.RightLine, inLocation.Longitude, inLocation.Latitude, radBox.Radius, maxResults); var lResults = new List<string>(); while (reader.Read()) { var username = (string)reader["Username"]; //if (reader["Longitude"] is double && reader["Latitude"] is double) //{ // Location loc = new Location(); // double distance = Distance.GetDistance(inLocation, loc); // if (distance <= radBox.Radius) lResults.Add(username); //} } return lResults.ToArray(); } }
private void MySingleFriends(User.eGenderSearch gender) { if (HttpContext.Current == null) HttpContext.Current = itsContext; ProcessMenuButtonClick(lnkQuickFriendsSearch, "Quick Friends Search", "Friends Search Results", false); if (CurrentUserSession == null) return; var search = new QuickSingleFriendsSearch { MatchMaker = CurrentUserSession, MatchmakerUsername = CurrentUserSession.Username, FriendGender = gender }; //if (CurrentUserSession != null) search.ExcludeUsername.Add(CurrentUserSession.Username); //if (MatchmakerHelper.IsMatchToFriendAlredySelected) search.ExcludeUsername.Add(MatchmakerHelper.MatchToUsername); SearchResults.Results = new FacebookAndUsersMergeResults { Usernames = search.GetResults().Usernames, FacebookIds = null }; }
protected void btnRegister_Click(object sender, EventArgs e) { #region Validate username try { if (txtUsername.Text.Length == 0) { lblError.Text = Lang.Trans("Please specify username!"); return; } if (Classes.User.IsUsernameTaken(txtUsername.Text)) { lblError.Text = Lang.Trans("Username is already taken!"); return; } foreach (string reservedUsername in Config.Users.ReservedUsernames) { if (reservedUsername == txtUsername.Text.ToLower()) { lblError.Text = Lang.Trans("Username is reserved!"); return; } } } catch (ArgumentException err) // Invalid username { lblError.Text = err.Message; return; } #endregion #region Validate e-mail address try { if (txtEmail.Text.Length == 0) { lblError.Text = Lang.Trans("Please specify e-mail address!"); return; } if (txtEmail.Text.ToLower().EndsWith("@mail.bg")) { lblError.Text = Lang.Trans("E-mails from mail.bg are not accepted!"); return; } if (Config.Users.CheckForDuplicateEmails && Classes.User.IsEmailUsed(txtEmail.Text)) { lblError.Text = Lang.Trans("E-mail address is already used!"); return; } } catch (ArgumentException err) // Invalid e-mail address { lblError.Text = err.Message; return; } #endregion #region Validate passwords if (txtPassword.Text.Length == 0) { lblError.Text = Lang.Trans("Please specify password!"); return; } if (txtPassword2.Text.Length == 0) { lblError.Text = Lang.Trans("Please verify password!"); return; } if (txtPassword.Text != txtPassword2.Text) { lblError.Text = Lang.Trans("Passwords do not match!"); return; } #endregion #region Validate name if (txtName.Text.Length == 0) { lblError.Text = Lang.Trans("Please enter your name!"); return; } #endregion #region Validate gender if (dropGender.SelectedIndex == 0) { lblError.Text = Lang.Trans("Please select your gender!"); return; } #endregion #region Validate InterestedIn if (Config.Users.InterestedInFieldEnabled) { if (dropInterestedIn.SelectedIndex == 0) { lblError.Text = Lang.Trans("Please select who are you interested in!"); return; } } #endregion #region Validate birthdate1 if (!datePicker1.ValidDateEntered) { lblError.Text = Lang.Trans("Please select your birthdate!"); return; } #endregion #region Validate birthdate2 if ((User.eGender)Convert.ToInt32(dropGender.SelectedValue) == Classes.User.eGender.Couple && !datePicker2.ValidDateEntered) { lblError.Text = Lang.Trans("Please select your birthdate!"); return; } #endregion #region Validate agreement if (!cbAgreement.Checked) { lblError.Text = Lang.Trans("You must accept the agreement to proceed!"); return; } #endregion #region Validate location if (Config.Users.LocationPanelVisible) { if (dropCountry != null && dropCountry.SelectedValue == String.Empty) { lblError.Text = Lang.Trans("Please select your country!"); return; } if (dropRegion.Items.Count > 1 && dropRegion.SelectedValue == "") { lblError.Text = Lang.Trans("Please select your state!"); return; } if (txtZipCode != null && txtZipCode.Text == String.Empty) { lblError.Text = Lang.Trans("Please enter your Zip/Postal Code"); return; } if (dropCity != null && dropCity.SelectedValue == "") { lblError.Text = Lang.Trans("Please select your city!"); return; } } #endregion #region Validate Invitation Code if (Config.Users.InvitationCode != String.Empty) { if (Config.Users.InvitationCode != txtInvitationCode.Text) { lblError.Text = Lang.Trans("Invalid Invitation Code!"); return; } } #endregion #region Validate IP address if (Properties.Settings.Default.BannedCountries.Count > 0) { foreach (string countryCode in Properties.Settings.Default.BannedCountries) { if (IPToCountry.GetCountry(Request.UserHostAddress) == countryCode.Trim()) { lblError.Text = Lang.Trans("Registration is not allowed for your country!"); return; } } } #endregion try { User newUser = new User(txtUsername.Text); #region Save location if (Config.Users.LocationPanelVisible) { if (dropCountry != null) { newUser.Country = dropCountry.SelectedValue; } if (dropRegion != null) { newUser.State = dropRegion.SelectedValue; } if (txtZipCode != null) { newUser.ZipCode = txtZipCode.Text; } if (dropCity != null) { newUser.City = dropCity.SelectedValue; } Location loc = Config.Users.GetLocation(newUser.Country, newUser.State, newUser.City); if (loc != null) { newUser.Longitude = loc.Longitude; newUser.Latitude = loc.Latitude; } } #endregion newUser.Password = txtPassword.Text; newUser.Email = txtEmail.Text; newUser.Name = txtName.Text; newUser.Gender = (User.eGender)Convert.ToInt32(dropGender.SelectedValue); newUser.Birthdate = datePicker1.SelectedDate; newUser.LanguageId = LanguageId; if (newUser.Gender == Classes.User.eGender.Couple) { newUser.Birthdate2 = datePicker2.SelectedDate; } if (Config.Users.InterestedInFieldEnabled) { newUser.InterestedIn = (User.eGender)Convert.ToInt32(dropInterestedIn.SelectedValue); } else { if (Config.Users.DisableGenderInformation) newUser.InterestedIn = Classes.User.eGender.Male; else newUser.InterestedIn = newUser.Gender == Classes.User.eGender.Male ? Classes.User.eGender.Female : Classes.User.eGender.Male; } newUser.ReceiveEmails = Config.Users.EmailNotificationsDefault; #region Set and Delete invitedBy cookie if (Request.Cookies["invitedBy"] != null) { newUser.InvitedBy = Server.HtmlEncode(Request.Cookies["invitedBy"].Value); HttpCookie cookie = new HttpCookie("invitedBy"); cookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie); } #endregion #region Set and Delete affiliateID cookie if (Request.Cookies["affiliateID"] != null) { newUser.AffiliateID = Convert.ToInt32(Server.HtmlEncode(Request.Cookies["affiliateID"].Value)); HttpCookie cookie = new HttpCookie("affiliateID"); cookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie); } #endregion newUser.Create(Request.UserHostAddress); if (Config.Users.SmsConfirmationRequired) { Response.Redirect("~/SmsConfirm.aspx?username="******"Home.aspx"); Response.Redirect("ManageProfile.aspx"); } else StatusPageMessage = Lang.Trans ("<b>Your account has been created successfully!</b><br><br>" + "You will receive a confirmation e-mail shortly. In order " + "to finish your registration you'll have to click the " + "activation link in the e-mail."); } catch (System.Threading.ThreadAbortException) { } catch (ArgumentException err) { lblError.Text = err.Message; return; } catch (Exception err) { lblError.Text = Lang.Trans ("Unknown error has occured while trying to create " + "your account! Please try again later."); Log(err); return; } Response.Redirect("Default.aspx"); }
public User[] FetchFriends() { string[] usernames = FetchFriends(username); User[] users = new User[usernames.Length]; for (int i = 0; i < usernames.Length; i++) { users[i] = Load(usernames[i]); } return users; }
private void AddFriends(User user) { List<string> usernames = new List<string>(); if (FacebookFriendIDs != null && FacebookFriendIDs.Length > 0) { usernames.AddRange(Classes.User.FetchUsernamesByFacebookID(FacebookFriendIDs)); } foreach (var username in usernames) { try { User friend = Classes.User.Load(username); user.AddToFriends(username); friend.AddToFriends(user.Username); } catch (NotFoundException) { } } }
/// <summary> /// Creates Saved Search object with id = -1. /// </summary> /// <param name="username">The username.</param> /// <param name="name">The name.</param> /// <param name="gender">The gender.</param> /// <param name="country">The country.</param> /// <param name="state">The state.</param> /// <param name="zip">The zip.</param> /// <param name="city">The city.</param> /// <param name="ageFrom">The age from.</param> /// <param name="ageTo">The age to.</param> /// <param name="photoRequired">if set to <c>true</c> [photo required].</param> /// <param name="choiceIds">The choice ids.</param> /// <returns>SavedSearch object</returns> public static SavedSearch Create(string username, string name, User.eGender gender, string country, string state, string zip, string city, int ageFrom, int ageTo, bool photoRequired, int[] choiceIds, bool emailMatches, int emailFrequency, DateTime? nextEmailDate) { SavedSearch ss = new SavedSearch(); ss.username = username; ss.name = name; ss.gender = gender; ss.country = country; ss.state = state; ss.zip = zip; ss.city = city; ss.ageFrom = ageFrom; ss.ageTo = ageTo; ss.photoRequired = photoRequired; ss.choiceIds = choiceIds; ss.emailMatches = emailMatches; ss.emailFrequency = emailFrequency; ss.nextEmailDate = nextEmailDate; return ss; }
private void GetAnswers(Control control, List<Control> parentControls, List<ProfileAnswer> toSave, List<ProfileAnswer> toDelete, List<int> modifiedQuestionIDs) { string[] usernames = User.FetchMutuallyFriends(CurrentUserSession.Username); foreach (Control ctl in control.Controls) { if (ctl is IProfileQuestionComponent) { try { ProfileAnswer answer = ((IProfileQuestionComponent)ctl).Answer; ProfileQuestion question = ((IProfileQuestionComponent)ctl).Answer.Question; if (question.ParentQuestionID.HasValue) { var currentQuestionParentControl = parentControls.Cast<IProfileQuestionComponent>().FirstOrDefault( c => c.Answer.Question.Id == question.ParentQuestionID); if (currentQuestionParentControl != null) { string[] parentAnswers = (currentQuestionParentControl).Answer.Value.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries); if (!question.ParentQuestionChoices.Split(':').Any(parentChoice => parentAnswers.Contains(parentChoice))) { answer.Value = String.Empty; // the control is not visible and his answers should be deleted } } } if (answer.Value != String.Empty) { if (Config.Misc.EnableBadWordsFilterProfile && (answer.Question.EditStyle == ProfileQuestion.eEditStyle.SingleLine || answer.Question.EditStyle == ProfileQuestion.eEditStyle.MultiLine)) { answer.Value = Parsers.ProcessBadWords(answer.Value); } if (answer.Question.RequiresApproval && (DateTime.Now - User.UserSince).Days < Config.Users.AutoApproveAnswers) { if (CurrentUserSession.Level != null) { if (!CurrentUserSession.Level.Restrictions.AutoApproveAnswers && !CurrentUserSession.BillingPlanOptions.AutoApproveAnswers.Value) { rejectAnswer(answer); } } else if (!CurrentUserSession.BillingPlanOptions.AutoApproveAnswers.Value) { rejectAnswer(answer); } } toSave.Add(answer); if (answer.Approved) { ProfileAnswer oldAnswer = null; try { oldAnswer = ProfileAnswer.Fetch(answer.User.Username, answer.Question.Id); } catch (NotFoundException) { continue; } if (oldAnswer.Value != answer.Value) { if (!modifiedQuestionIDs.Contains(answer.Question.Id)) modifiedQuestionIDs.Add(answer.Question.Id); foreach (string friendUsername in usernames) { if (Config.Users.NewEventNotification) { string text = String.Format("Your friend {0} has updated the \"{1}\" section in their profile".Translate(), "<b>" + CurrentUserSession.Username + "</b>", answer.Question.Name); int imageID = 0; try { imageID = Photo.GetPrimary(CurrentUserSession.Username).Id; } catch (NotFoundException) { User user = null; try { user = Classes.User.Load(CurrentUserSession.Username); imageID = ImageHandler.GetPhotoIdByGender(user.Gender); } catch (NotFoundException) { continue; } } string thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true); User.SendOnlineEventNotification(CurrentUserSession.Username, friendUsername, text, thumbnailUrl, UrlRewrite.CreateShowUserUrl( CurrentUserSession.Username)); } } } } } else { toDelete.Add(answer); } } catch (AnswerRequiredException err) { lblError.CssClass = "error"; lblError.Text = err.Message; litAlert.Text = "<script>var alert_string = '" + err.Message.Replace("'", "\\'") + "';</script>"; //Response.Write("<script>alert('" + err.Message.Replace("'", "\\'") + "');</script>"); throw err; } } else { GetAnswers(ctl, parentControls, toSave, toDelete, modifiedQuestionIDs); } } }
public static int GetPhotoIdByGender(User.eGender gender) { int photoId; switch (gender) { case User.eGender.Male: photoId = -1; break; case User.eGender.Female: photoId = -2; break; case User.eGender.Couple: photoId = -3; break; default: photoId = 0; break; } return photoId; }
public static string RenderImageTag(User.eGender gender, int width, int height, string cssClass, bool useCache, bool diskCache) { int photoId = GetPhotoIdByGender(gender); return RenderImageTag(photoId, width, height, cssClass, useCache, diskCache); }
private static void ShowAvatarImage(HttpContext context, User.eGender gender, int MaxWidth, int MaxHeight) { switch (gender) { case User.eGender.Male: ShowUserImage( //Image.FromFile(context.Server.MapPath("~/Images") + "\\nophoto-m.png"), Image.FromFile(context.Server.MapPath("~/Images") + "\\default_male.png"), context, MaxWidth, MaxHeight, -1); break; case User.eGender.Female: ShowUserImage( //Image.FromFile(context.Server.MapPath("~/Images") + "\\nophoto-f.png"), Image.FromFile(context.Server.MapPath("~/Images") + "\\default_female.png"), context, MaxWidth, MaxHeight, -2); break; case User.eGender.Couple: ShowUserImage( //Image.FromFile(context.Server.MapPath("~/Images") + "\\nophoto-c.png"), Image.FromFile(context.Server.MapPath("~/Images") + "\\nophoto-c.png"), context, MaxWidth, MaxHeight, -3); break; } }
private void StorePrimaryPhoto(User user) { if (PrimaryPhotoURL != null) { var request = (HttpWebRequest)WebRequest.Create(PrimaryPhotoURL); request.Method = "GET"; using (var stream = request.GetResponse().GetResponseStream()) { Photo photo = new Photo(); System.Drawing.Image image; try { image = System.Drawing.Image.FromStream(stream); photo.Image = image; photo.Primary = true; photo.Name = String.Empty; photo.Description = String.Empty; photo.User = user; photo.Approved = Config.Photos.AutoApprovePhotos; photo.Save(true); photo.Image.Dispose(); } catch (Exception ex) { Log(ex); } } } }
protected void btnGenerateMembers_Click(object sender, EventArgs e) { int fromAge, toAge; if (!int.TryParse(this.txtAgeFrom.Text,out fromAge)) fromAge = Config.Users.MinAge; if (!int.TryParse(this.txtAgeTo.Text,out toAge)) toAge = Config.Users.MaxAge; int month = 0; int day = 0; int repeatMax = int.Parse(txtRepeatingTimes.Text); for (int age = fromAge; age <= toAge; age++) { DateTime birthday = new DateTime(DateTime.Now.Year-age,month+1,day+1); for (int i = 0; i < repeatMax; i++) { User user = new User { Active = true, Country = txtCountry.Text, State = txtRegion.Text, City = txtRegion.Text, Credits = 1000, Birthdate = birthday, Paid = (age % 2) == 0, LanguageId = 6, ProfileVisible=true }; string ext = (user.Paid ? "p" : "np")+i; createUser(user, "Male" + age + ext, "Single", Classes.User.eGender.Male, Classes.User.eGender.Female, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Man" + age + ext, "Single", Classes.User.eGender.Male, Classes.User.eGender.Female, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Divorced" + age + ext, "Divorce", Classes.User.eGender.Male, Classes.User.eGender.Female, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Female" + age + ext, "Single", Classes.User.eGender.Female, Classes.User.eGender.Male, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Woman" + age + ext, "Single", Classes.User.eGender.Female, Classes.User.eGender.Male, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Divorcee" + age + ext, "Divorce", Classes.User.eGender.Female, Classes.User.eGender.Male, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Gay" + age + ext, "Single", Classes.User.eGender.Male, Classes.User.eGender.Male, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "Lesbi" + age + ext, "Single", Classes.User.eGender.Female, Classes.User.eGender.Female, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "MarriedM" + age + ext, "Married", Classes.User.eGender.Male, Classes.User.eGender.Matchmaker, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "MarriedF" + age + ext, "Married", Classes.User.eGender.Female, Classes.User.eGender.Matchmaker, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "MarriedG" + age + ext, "Married", Classes.User.eGender.Male, Classes.User.eGender.Matchmaker, (int)(DateTime.Now.Ticks % (255 * 255))); createUser(user, "MarriedL" + age + ext, "Married", Classes.User.eGender.Female, Classes.User.eGender.Matchmaker, (int)(DateTime.Now.Ticks % (255 * 255))); } month = (month+1) % 12; day = (day+1) % 28; } }
public bool IsVisible(User.eGender gender) { if ((gender == User.eGender.Male && visibleForMale) || (gender == User.eGender.Female && visibleForFemale) || (gender == User.eGender.Couple && visibleForCouple)) { return true; } return false; }
private void createUser(User user, string username, string status, User.eGender gender, User.eGender interestedIn, int ipIdx) { if (!Classes.User.IsUsernameTaken(username)) { user.Username = username; user.Password = username; user.Name = String.Format("{0} {1}{2}", status, gender, user.Age); user.Gender = gender; user.InterestedIn = interestedIn; user.StatusText = status; user.Email = String.Format("{0}@lovehitch.com", username); Classes.User.Create(user, String.Format("192.168.{0}.{1}", ipIdx/255, ipIdx%255)); } var random = new Random((int)(DateTime.Now.Ticks%int.MaxValue)); ProfileTopic[] topics = ProfileTopic.Fetch(); foreach (ProfileTopic profileTopic in topics) { ProfileQuestion[] questions = profileTopic.FetchQuestions(); foreach (ProfileQuestion profileQuestion in questions) { try { var existAnswer = ProfileAnswer.Fetch(username, profileQuestion.Id); if (existAnswer != null) continue; } catch { ProfileChoice[] choices = profileQuestion.FetchChoices(); if (choices!=null&&choices.Length > 0) { var answer = new ProfileAnswer(username, profileQuestion.Id) { Value = choices[random.Next(choices.Length - 1)].Value }; answer.Save(); } } } } }
private void AddRemovedFriendRelationshipEvent(string fromUsername, string toUsername, Relationship.eRelationshipStatus type) { Event newEvent = new Event(fromUsername); newEvent.Type = Event.eType.RemovedFriendRelationship; RemovedFriendRelationship removedFriendRelationship = new RemovedFriendRelationship(); removedFriendRelationship.Username = toUsername; removedFriendRelationship.Type = type; newEvent.DetailsXML = Misc.ToXml(removedFriendRelationship); newEvent.Save(); if (Config.Users.NewEventNotification) { string[] usernames = User.FetchMutuallyFriends(fromUsername); string text = String.Format("{0} {1} are no longer in relationship ({2})".Translate(), "<b>" + fromUsername + "</b>", toUsername, Relationship.GetRelationshipStatusString(type)); int imageID = 0; try { imageID = Photo.GetPrimary(fromUsername).Id; } catch (NotFoundException) { User user = null; try { user = User.Load(fromUsername); imageID = ImageHandler.GetPhotoIdByGender(user.Gender); } catch (NotFoundException) { return; } } string thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true); foreach (string friendUsername in usernames) { if (toUsername == friendUsername) continue; User.SendOnlineEventNotification(fromUsername, friendUsername, text, thumbnailUrl, UrlRewrite.CreateShowUserUrl(toUsername)); } } }
//protected void btnGetCSV_Click(object sender, EventArgs e) //{ // if (Results != null) // { // Response.Clear(); // Response.ContentType = "application/text"; // Response.ContentEncoding = Encoding.UTF8; // Response.Charset = Encoding.UTF8.EncodingName; // Response.AppendHeader("content-disposition", "attachment; filename=results.csv"); // Response.Write(Parsers.ParseCSV(FetchResultsDataTable(Results.Get(), true))); // Response.End(); // } //} protected void btnGenerateMembersCsvClick(object sender, EventArgs e) { var path = Server.MapPath("~/images/fakeprofiles/fakeprofiles.csv"); if (!File.Exists(path)) return; string[] lines = File.ReadAllLines(path,Encoding.UTF8); int month = 0; int day = 0; foreach (var line in lines) { string[] fields = line.Split(','); var age = int.Parse(fields[4]); DateTime birthday = new DateTime( DateTime.Now.Year - age, 12-(++month%12), 29-(++day%29)); User user = new User { Active = true, Country = fields[1], State = fields[2], City = fields[3], Credits = 1000, Birthdate = birthday, Paid = true, LanguageId = 6, ProfileVisible = true }; createUser(user, fields[0].Replace(" ", ""), fields[9] == "רווק" ? "Single" : "Married", fields[5] == "גבר" ? Classes.User.eGender.Male : Classes.User.eGender.Female, fields[6] == "גבר" ? Classes.User.eGender.Male : Classes.User.eGender.Female, (int)(DateTime.Now.Ticks % (255 * 255))); } }