コード例 #1
0
ファイル: ThankYou.aspx.cs プロジェクト: haimon74/Easy-Fixup
        /// <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;
            //}
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
 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;
         }
     }
 }
コード例 #5
0
 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();    
 }
コード例 #6
0
ファイル: Voting.cs プロジェクト: haimon74/Easy-Fixup
        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 ezFixUpDataContext())
            {
                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;
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
 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 Search3) || 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);
     }
 }
コード例 #9
0
        //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)));
                    
            }
        }
コード例 #10
0
ファイル: Config.cs プロジェクト: haimon74/Easy-Fixup
 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;
 }
コード例 #11
0
        protected void BtnGenerateMembersCsvClick(object sender, EventArgs e)
        {
            //var path = Server.MapPath("~/images/profiles/List.xlsx");
            var path = Config.Directories.Home + @"\images\profiles\List.csv";

            if (!File.Exists(path))
            {
                MessageBox.Show("List.cvs file doesn't exist.", Misc.MessageType.Error);
                return;
            }
            try
            {
                string[] lines = File.ReadAllLines(path, Encoding.UTF8);
                int month = 0;
                int day = 0;
                //foreach (var line in lines)
                for (int i = 1; i < lines.Length; i++)
                {
                    var line = lines[i];
                    string[] fields = line.Split(',');

                    if (fields.Length < 7) continue;

                    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 = 100000,
                                        Birthdate = birthday,
                                        Paid = true,
                                        LanguageId = 6,
                                        ProfileVisible = true
                                    };
                    createUser(
                        user,
                        fields[0],
                        "Single",
                        fields[5].ToLower() == "man" ? Classes.User.eGender.Male : Classes.User.eGender.Female,
                        fields[6].ToLower() == "man" ? Classes.User.eGender.Male : Classes.User.eGender.Female,
                        (int)(DateTime.Now.Ticks % (255 * 255)),
                        age,
                        fields.Length > 7 ? fields[7] : null,
                        fields.Length > 8 ? fields[8] : null
                        );
                }
                MessageBox.Show("Operation Succeeded.", Misc.MessageType.Success);
            }
            catch (Exception ex)
            {
                var msg = String.Format("Operation didn't complete. <br/>Had exception: {0} <br/>Inner exception: {1} <br/>Stack Trace: {2}"
                                        , ex.Message
                                        , ex.InnerException != null ? ex.InnerException.Message : ""
                                        , ex.StackTrace);
                MessageBox.Show(msg, Misc.MessageType.Error);
            }
        }
コード例 #12
0
 private void StoreUserPhoto(User user, string photoPath, bool isPrimary)
 {
     if (photoPath.IsNotNullOrEmpty() && File.Exists(photoPath))
     {
         try
         {
             using (var image = System.Drawing.Image.FromFile(photoPath))
             {
                 var photo = new Photo();
                 photo.Image = image;
                 photo.Primary = isPrimary;
                 photo.Approved = true;
                 photo.Name = String.Empty;
                 photo.Description = String.Empty;
                 photo.User = user;
                 photo.Save(true);
                 if (isPrimary)
                     Photo.SetPrimary(user.Username, photo);
                 photo.ApprovePhoto(CurrentAdminSession.Username);
             }
             
             var destination = photoPath.Replace(".jpg", "v.jpg");
             File.Copy(photoPath, destination);
             File.Delete(photoPath);
         }
         catch (Exception ex)
         {
             Log(ex);
         }
     }
 }
コード例 #13
0
ファイル: Friends3.aspx.cs プロジェクト: haimon74/Easy-Fixup
        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
                                        };
        }
コード例 #14
0
ファイル: Profiles.cs プロジェクト: haimon74/Easy-Fixup
 public bool IsVisible(User.eGender gender)
 {
     if ((gender == Classes.User.eGender.Male && visibleForMale)
         || (gender == Classes.User.eGender.Female && visibleForFemale)
         || (gender == Classes.User.eGender.Couple && visibleForCouple))
     {
         return true;
     }
     return false;
 }
コード例 #15
0
ファイル: Settings.ascx.cs プロジェクト: haimon74/Easy-Fixup
        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));
                }
            }
        }
コード例 #16
0
ファイル: SavedSearches.cs プロジェクト: haimon74/Easy-Fixup
        /// <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;
        }
コード例 #17
0
ファイル: Templates.cs プロジェクト: haimon74/Easy-Fixup
        public static string GetFormattedString(this string templateStr, User user)
        {
            return templateStr.GetKeyValueFormattedString("%%RECIPIENT%%", user.Name)
                              .GetKeyValueFormattedString("%%CONFIRM_URL%%", String.Format(""))
                              .GetKeyValueFormattedString("%%SENDER%%",user.Name)
                              //.GetKeyValueFormattedString("%%MESSAGE%%","")
                              .GetKeyValueFormattedString("%%USERNAME%%",user.Username)
                              .GetKeyValueFormattedString("%%RECIPIENTNAME%%",user.Name)
                              .GetKeyValueFormattedString("%%PHOTOURL%%",ImageHandler.CreateImageUrl(user.GetPrimaryPhoto().Id,200,200,false,false,true)
                              .GetKeyValueFormattedString("%%AGE%%",user.Age.ToString())
                              .GetKeyValueFormattedString("%%PROFILEURL%%",Config.Urls.Home+"ShowUser_"+user.Username+".aspx")
                              .GetKeyValueFormattedString("%%PHOTOID%%",user.GetPrimaryPhoto().Id.ToString())
                              //.GetKeyValueFormattedString("%%USERSPROFILES%%","")
                              .GetKeyValueFormattedString("%%USER%%",user.Username)
                              .GetKeyValueFormattedString("%%SITETITLE%%","ezFixUp")
                              //.GetKeyValueFormattedString("%%REASON%%","")
                              //.GetKeyValueFormattedString("%%SUBJECT%%","")
                              //.GetKeyValueFormattedString("%%GROUP%%","")
                              //.GetKeyValueFormattedString("%%RECIPIENTUSERNAME%%","")
                              //.GetKeyValueFormattedString("%%AFFILIATE%%","")
                              .GetKeyValueFormattedString("%%DAYSLEFTFORMEMBERSHIP%%",(Subscription.FetchActiveSubscription(user.Username).RenewDate - DateTime.Now).ToString())
                              .GetKeyValueFormattedString("%%NUMBEROFFRIENDS%%",user.FetchFriends().Length.ToString())
                              .GetKeyValueFormattedString("%%MAILBAOXLINK%%",Config.Urls.Home+"/Mailbox.aspx")
                              .GetKeyValueFormattedString("%%FRIENDSLINK%%",Config.Urls.Home+"/FriendsList.aspx")
                              .GetKeyValueFormattedString("%%MATCHMAKERLINK%%",Config.Urls.Home+"/Home_mm.aspx")
                              .GetKeyValueFormattedString("%%FACEBOOKAPPLINK%%",Config.Urls.FacebookHome)
                              .GetKeyValueFormattedString("%%INVITEFRIENDSLINK%%",Config.Urls.Home+"/InviteFriends.aspx")
                              .GetKeyValueFormattedString("%%CREDITBALANCE%%",Config.Urls.Home+"/ManageProfile.aspx?sel=payment")
                              .GetKeyValueFormattedString("%%MATCHMAKINGCOUNT%%",MatchMaking.FetchMatchMakings(user.Username).Length.ToString())
                              .GetKeyValueFormattedString("%%NEWMESSAGESCOUNT%%",Message.FetchNewMessages(user.Username).Length.ToString())
                              .GetKeyValueFormattedString("%%TOTALINBOXCOUNT%%",Message.FetchInbox(user.Username).Length.ToString())
                              .GetKeyValueFormattedString("%%TOTALRECIEVEDGIFTSCOUNT%%", "")
                              .GetKeyValueFormattedString("%%TOTALSENTGIFTSCOUNT%%",""));
                                          
	
        }
コード例 #18
0
ファイル: Register.aspx.cs プロジェクト: haimon74/Easy-Fixup
        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");
        }
コード例 #19
0
ファイル: Voting.cs プロジェクト: haimon74/Easy-Fixup
        public static double FetchAverageNumberOfVotes(TimeSpan period, User.eGender gender, 
            int minAge, int maxAge)
        {
            string cacheKey = String.Format("Votes_FetchAverageNumberOfVotes_{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 ezFixUpDataContext())
            {
                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
                           group v by v.v_tousername
                           into uv
                               select (double?) uv.Count()).Average() ?? 0;
                           
            }

            if (HttpContext.Current != null)
            {
                HttpContext.Current.Cache.Insert(cacheKey, average, null, DateTime.Now.AddHours(1),
                                                 Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable,
                                                 null);
            }

            return average;
        }
コード例 #20
0
ファイル: Image.ashx.cs プロジェクト: haimon74/Easy-Fixup
        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);
        }
コード例 #21
0
ファイル: Image.ashx.cs プロジェクト: haimon74/Easy-Fixup
        public static int GetPhotoIdByGender(User.eGender gender)
        {
            int photoId;

            switch (gender)
            {
                case Classes.User.eGender.Male:
                    photoId = -1;
                    break;
                case Classes.User.eGender.Female:
                    photoId = -2;
                    break;
                case Classes.User.eGender.Couple:
                    photoId = -3;
                    break;
                default:
                    photoId = 0;
                    break;
            }

            return photoId;
        }
コード例 #22
0
        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 = (SqlDataReader) SqlHelper.GetDB().ExecuteReader( "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();
            }
        }
コード例 #23
0
ファイル: Events.cs プロジェクト: haimon74/Easy-Fixup
 public static bool IsEventsSettingEnabled(eType type, User user)
 {
     return (user.EventsSettings & (ulong)type) == (ulong)type;
 }
コード例 #24
0
        private static DataTable FetchResultsDataTable(User[] users, bool isCSV)
        {
            DataTable dtResults = new DataTable("SearchResults");

            dtResults.Columns.Add("Username");
            dtResults.Columns.Add("Name");
            dtResults.Columns.Add("Gender");
            dtResults.Columns.Add("Birthdate");
            dtResults.Columns.Add("SignupDate");
            dtResults.Columns.Add("SignupIP");
            dtResults.Columns.Add("Email");
            dtResults.Columns.Add("CountryCode");
            dtResults.Columns.Add("CountryName");

            if (users != null && users.Length > 0)
                foreach (User user in users)
                {
                    string countryCode = null;
                    string countryName = null;
                    if (!isCSV)
                    {
                        if (user.SignupIp != "127.0.0.1" && user.SignupIp != "0.0.0.0"
                            && !user.SignupIp.StartsWith("192.168."))
                        {
                            countryCode = IPToCountry.GetCountry(user.SignupIp);
                        }

                        if (countryCode != null)
                        {
                            countryName = Config.Users.GetCountryByCode(countryCode);
                        }    
                    }
                    else
                    {
                        countryName = user.Country;
                    }
                    
                    dtResults.Rows.Add(new object[]
                                               {
                                                   user.Username,
                                                   user.Name,
                                                   Lang.TransA(user.Gender.ToString()),
                                                   user.Birthdate.ToShortDateString(),
                                                   user.UserSince.ToShortDateString(),
                                                   user.SignupIp,
                                                   user.Email,
                                                   countryCode,
                                                   countryName
                                               });
                }

            return dtResults;
        }
コード例 #25
0
        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);
                }
            }
        }
コード例 #26
0
        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;
            }
        }
コード例 #27
0
        private void createUser(User user, string name, string status,
                                User.eGender gender, User.eGender interestedIn,
                                int ipIdx, int age, string img1, string img2)
        {
            var username = name.Replace(" ", "").Substring(0, 4) + age;
            var random = new Random((int)(DateTime.Now.Ticks % int.MaxValue));
            int day = random.Next(1, 28);
            int month = random.Next(1, 12);
            int year = DateTime.Now.Year - age;

            if (!Classes.User.IsUsernameTaken(username))
            {
                user.Username = username;
                user.Password = username;
                user.Name = name;
                user.Gender = gender;
                user.InterestedIn = interestedIn;
                user.StatusText = status;
                user.Email = String.Format("{0}@ezFixUp.com", username);
                user.Birthdate = new DateTime(year, month, day);
                Classes.User.Create(user, String.Format("192.168.{0}.{1}", ipIdx / 255, ipIdx % 255));

                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
                                };
                                try
                                {
                                    answer.Save();
                                }
                                catch (Exception ex) { }
                            }
                        }
                    }
                }
            }
            else
            {
                user = Classes.User.Load(username);
            }

            if (user != null && user.SignupIp.IsNotNullOrEmpty() && user.SignupIp.StartsWith("192.168."))
            {
                user.updateLastLogin(DateTime.Now.Ticks.ToString());

                var pathTemplate = Config.Directories.Home + @"\images\profiles\{0}.jpg";
                if (img1.Trim().IsNotNullOrEmpty())
                    StoreUserPhoto(user, String.Format(pathTemplate, img1), true);
                if (img2.IsNotNullOrEmpty())
                    StoreUserPhoto(user, String.Format(pathTemplate, img2), false);
            }
        }
コード例 #28
0
 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}@ezFixUp.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();
                 }
             }
         }
     }
 }
コード例 #29
0
 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();
 }
コード例 #30
0
ファイル: Config.cs プロジェクト: haimon74/Easy-Fixup
            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 = (SqlDataReader)
                        SqlHelper.GetDB().ExecuteReader(
                                                "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();
                }
            }