/// <summary> /// 注册 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LBSubmint_Click(object sender, EventArgs e) { try { if (TxtEmail.Text.Length == 0) { return; } log.Info("注册开始"); if (Session["CaptchaImageText"] == null) { ShowAlert("注册失败", "服务器忙,请稍后再试!"); return; } string validateCode = Session["CaptchaImageText"].ToString(); if (TxtValidCode.Text != validateCode) { ShowAlert("注册失败", "验证码错误!"); return; } if (string.IsNullOrEmpty(TxtSudentCode.Text)) { ShowAlert("注册失败", "学号不能为空"); return; } if (string.IsNullOrEmpty(TxtUserName.Text)) { ShowAlert("注册失败", "姓名不能为空"); return; } if (TxtUserPassword.Text.Length < 6 || TxtUserPassword.Text.Length > 20) { ShowAlert("注册失败", "密码长度必须在6至20之间"); return; } String ZipRegex = @"/^\w{0,19}$/"; if (System.Text.RegularExpressions.Regex.IsMatch(TxtUserPassword.Text, ZipRegex)) { ShowAlert("注册失败", "密码含有非法字符,只能输入数字、字母和\"_\"的组合。"); return; } if (String.Compare(TxtUserPassword.Text.Trim(), TxtUserPasswordAgain.Text.Trim()) != 0) { ShowAlert("注册失败", "两次密码输入不一致,请重新输入。"); return; } if (!RBGenderFemale.Checked && !RBGenderMale.Checked) { ShowAlert("注册失败", "性别不能为空"); return; } if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0") { ; } else if ( YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0") { ShowAlert("提示", "请完善您的生日信息!"); return; } Guid id = new Guid(Request.QueryString["id"]); CY.UME.Core.Business.AccountInviteInfo aii = CY.UME.Core.Business.AccountInviteInfo.Load(id); if (aii == null) { ShowAlert("注册失败", "邀请已失效!"); return; } CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper(); CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account(); account.Code = TxtSudentCode.Text; account.DateCreated = DateTime.Now; account.HasAvatar = false; account.IsTeacher = false; account.Name = TxtUserName.Text; account.NickName = string.Empty; account.ViewNumber = 0; account.Save(); // extend info CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(account.Id); if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0") { ae.Birthday = UME.Core.Global.MinDateTime; } else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0") { ShowAlert("提示", "请完善您的生日信息!"); return; } else { int day = 0, month = 0, year = 0; if (int.TryParse(DayHF.Value, out day)) ae.BirthDate = day; if (int.TryParse(MonthHF.Value, out month)) ae.BirthMonth = month; if (int.TryParse(YearHF.Value, out year)) ae.BirthYear = year; ae.Birthday = new DateTime(year, month, day);//生日 } ae.Email = TxtEmail.Text; ae.Gender = RBGenderMale.Checked ? 1 : 0; ae.IsEmailChecked = true; //ae.LibUserId = 0; ae.Password = sh.ComputeMD5Hash(TxtUserPassword.Text); ae.UniversityId = CY.Utility.Common.ConvertUtility.ConvertToInt(selUniversity.Value, -1);// 学校 ae.CollegeId = CY.Utility.Common.ConvertUtility.ConvertToInt(selCollege.Value, -1);// 学院 ae.GradeId = int.Parse(DDLGrades.SelectedValue); ae.Save(); // add friendship CY.UME.Core.Business.Friendship fs = new CY.UME.Core.Business.Friendship(); fs.AccountId = aii.InviterId; fs.DateCreated = DateTime.Now; fs.CommunicateNum = 0; fs.FriendId = account.Id; fs.IsChecked = true; fs.Remark = string.Empty; fs.Save(); fs = new CY.UME.Core.Business.Friendship(); fs.AccountId = account.Id; fs.CommunicateNum = 0; fs.DateCreated = DateTime.Now; fs.FriendId = aii.InviterId; fs.IsChecked = true; fs.Remark = string.Empty; fs.Save(); aii.IsAccepted = true; aii.Save(); #region 更新邀请人的积分 int inviteFriendCredit; if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount", out inviteFriendCredit) && (inviteFriendCredit != 0)) { CY.UME.Core.Business.Account invitor = CY.UME.Core.Business.Account.Load(aii.InviterId); if (invitor != null) { int orgCredit = invitor.Credit; int modifiedCredit = orgCredit + inviteFriendCredit; invitor.Credit = modifiedCredit; invitor.Save(); CreditHistory ch = new CreditHistory(); ch.AccountId = invitor.Id; ch.DateCreated = DateTime.Now; ch.Id = Guid.NewGuid(); ch.InstanceId = aii.Id.ToString(); ch.Original = orgCredit; ch.Modified = modifiedCredit; ch.Variation = inviteFriendCredit; ch.Type = "invitefriend"; ch.Description = "成功邀请用户 " + account.Name; ch.Save(); // 邀请层级效应 CY.UME.Core.Business.Account invitor2 = invitor.GetInviter(); if (invitor2 != null) { int inviteFriendCredit2; if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount2", out inviteFriendCredit2) && (inviteFriendCredit2 != 0)) { orgCredit = invitor2.Credit; modifiedCredit = orgCredit + inviteFriendCredit2; invitor2.Credit = modifiedCredit; invitor2.Save(); ch = new CreditHistory(); ch.AccountId = invitor2.Id; ch.DateCreated = DateTime.Now; ch.Id = Guid.NewGuid(); ch.InstanceId = aii.Id.ToString(); ch.Original = orgCredit; ch.Modified = modifiedCredit; ch.Variation = inviteFriendCredit2; ch.Type = "invitefriend"; ch.Description = "所邀请用户 " + invitor.Name + " 成功邀请了 " + account.Name; ch.Save(); } } } } #endregion log.Info("注册结束"); if (Session["user"] != null) { Session["user"] = account.Id.ToString(); } else { Session.Add("user", account.Id.ToString()); } ShowAlert("注册成功", "恭喜您已经成功注册UME账号,现在系统将引导您至完善个人信息页面"); ExecuteClientScript("setTimeout(function(){window.location.href='UploadAvatar.aspx?type=firstNum'}, 2000)"); } catch (Exception ex) { log.Error("用户注册失败:" + ex.Message); } }
/// <summary> /// 注册 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LB_Next_Click(object sender, EventArgs e) { if (TxtEmail.Text.Length == 0) { return; } CY.UME.Core.Business.SystemLog.SaveLog("Info", "注册开始"); if (Session["CaptchaImageText"] == null)// 验证码 { ShowAlert("注册失败", "服务器忙,请稍后再试!"); return; } string validateCode = Session["CaptchaImageText"].ToString(); if (TxtValidCode.Text != validateCode) { ShowAlert("注册失败", "验证码错误!"); return; } if (string.IsNullOrEmpty(TxtSudentCode.Text)) { ShowAlert("注册失败", "学号不能为空"); return; } if (string.IsNullOrEmpty(TxtUserName.Text)) { ShowAlert("注册失败", "姓名不能为空"); return; } if (TxtUserPassword.Text.Length < 6 || TxtUserPassword.Text.Length > 20) { ShowAlert("注册失败", "密码长度必须在6至20之间"); return; } String ZipRegex = @"/^\w{0,19}$/"; if (System.Text.RegularExpressions.Regex.IsMatch(TxtUserPassword.Text, ZipRegex)) { ShowAlert("注册失败", "密码含有非法字符,只能输入数字、字母和\"_\"的组合。"); return; } if (String.Compare(TxtUserPassword.Text.Trim(), TxtUserPasswordAgain.Text.Trim()) != 0) { ShowAlert("注册失败", "两次密码输入不一致,请重新输入。"); return; } if (!RBGenderFemale.Checked && !RBGenderMale.Checked) { ShowAlert("注册失败", "性别不能为空"); return; } if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0") { ; } else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0") { ShowAlert("提示", "请完善您的生日信息!"); return; } CY.UME.Core.Business.AccountExtend aeTemp = CY.UME.Core.Business.AccountExtend.Load(TxtEmail.Text.Trim()); if (aeTemp != null) { ShowAlert("提示", "该邮箱已被使用!"); return; } CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper(); CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account(); account.Code = TxtSudentCode.Text; account.DateCreated = DateTime.Now; account.HasAvatar = false; account.IsTeacher = false; account.Name = TxtUserName.Text; account.NickName = string.Empty; account.ViewNumber = 0; account.Save(); // extend info CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(account.Id); if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0") { ae.Birthday = UME.Core.Global.MinDateTime; } else { int day = 0, month = 0, year = 0; if (int.TryParse(DayHF.Value, out day)) ae.BirthDate = day; if (int.TryParse(MonthHF.Value, out month)) ae.BirthMonth = month; if (int.TryParse(YearHF.Value, out year)) ae.BirthYear = year; ae.Birthday = new DateTime(year, month, day);//生日 } ae.Email = TxtEmail.Text.Trim(); ae.Gender = RBGenderMale.Checked ? 1 : 0; ae.IsEmailChecked = true; //ae.LibUserId = 0; ae.Password = sh.ComputeMD5Hash(TxtUserPassword.Text); ae.UniversityId = CY.Utility.Common.ConvertUtility.ConvertToInt(HFUniversity.Value, -1);// 学校 ae.CollegeId = CY.Utility.Common.ConvertUtility.ConvertToInt(HFCollege.Value, -1);// 学院 ae.GradeId = int.Parse(DDLGrades.SelectedValue); ae.IsShow = 0; ae.Save(); try { /**************************************************废除的代码/*************************************************/ /************************MySQL数据库同步开始************************* CY.UME.Core.Business.Ask_members members = new CY.UME.Core.Business.Ask_members(); members.Id = account.Id; members.Username = ae.Email; members.Password = ae.Password; //members.Secques = ""; members.Save(); CY.UME.Core.Business.Ask_memberfields memberfields = new CY.UME.Core.Business.Ask_memberfields(); memberfields.Id = account.Id; memberfields.Username = ae.Email; memberfields.Email = ae.Email; memberfields.Nickname = account.NickName; memberfields.Realname = account.Name;//HFURLEncodeName.Value; memberfields.Gender = ae.Gender; memberfields.Birthday = 0; memberfields.Score = 200;//后面去改 memberfields.Save(); /************************MySQL数据库同步结束*************************/ } catch (Exception ex) { CY.UME.Core.Business.SystemLog.SaveLog("Error", "用户同步失败:" + ex.Message); } CY.UME.Core.Business.SystemLog.SaveLog("Info", account.Name + "注册成功"); if (Session["user"] != null) { Session["user"] = account.Id.ToString(); } else { Session.Add("user", account.Id.ToString()); } try { if (!string.IsNullOrEmpty(Request.QueryString["inviterId"])) { long inviterId = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["inviterId"], -1); if (inviterId != -1) { Core.Business.Account InviteFriendAccount = Core.Business.Account.Load(inviterId); if (InviteFriendAccount != null) {//邀请用户须存在 AccountInviteInfo ai = new AccountInviteInfo(); ai.Id = Guid.NewGuid(); ai.InviterId = inviterId; ai.InviteeEmail = ae.Email; ai.DateCreated = account.DateCreated; ai.IsAccepted = true; ai.Remark = "从活动过来的"; ai.Save(); CY.UME.Core.Business.Friendship fs = new Friendship(); fs.AccountId = account.Id; fs.DateCreated = DateTime.Now; fs.FriendId = InviteFriendAccount.Id; fs.IsChecked = true; fs.Remark = "活动邀请"; fs.Save(); CY.UME.Core.Business.Friendship fs2 = new Friendship(); fs2.AccountId = InviteFriendAccount.Id; fs2.FriendId = account.Id; fs2.DateCreated = DateTime.Now; fs2.IsChecked = true; fs2.Remark = "活动邀请"; fs2.Save(); } } } if (!string.IsNullOrEmpty(Request.QueryString["invId"])) { long invId = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["invId"], -1); if (invId != -1) { Core.Business.AccountInviteInfo InviteAccount = new AccountInviteInfo(); InviteAccount.Id = Guid.NewGuid(); InviteAccount.InviterId = invId; InviteAccount.DateCreated = DateTime.Now; InviteAccount.InviteeEmail = ae.Email; InviteAccount.IsAccepted = true; InviteAccount.Save(); #region 更新邀请人的积分 int inviteFriendCredit; if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount", out inviteFriendCredit) && (inviteFriendCredit != 0)) { CY.UME.Core.Business.Account invitor = CY.UME.Core.Business.Account.Load(invId); if (invitor != null) { CY.UME.Core.Business.Friendship fs = new Friendship(); fs.AccountId = account.Id; fs.DateCreated = DateTime.Now; fs.FriendId = invitor.Id; fs.IsChecked = true; fs.Remark = "被链接邀请"; fs.Save(); CY.UME.Core.Business.Friendship fs2 = new Friendship(); fs2.AccountId = invitor.Id; fs2.FriendId = account.Id; fs2.DateCreated = DateTime.Now; fs2.IsChecked = true; fs2.Remark = "链接邀请"; fs2.Save(); int orgCredit = invitor.Credit; int modifiedCredit = orgCredit + inviteFriendCredit; invitor.Credit = modifiedCredit; invitor.Save(); CreditHistory ch = new CreditHistory(); ch.AccountId = invitor.Id; ch.DateCreated = DateTime.Now; ch.Id = Guid.NewGuid(); ch.InstanceId = invId.ToString(); ch.Original = orgCredit; ch.Modified = modifiedCredit; ch.Variation = inviteFriendCredit; ch.Type = "invitefriend"; ch.Description = "成功邀请用户 " + account.Name; ch.AssistAccountId = account.Id; ch.Save(); // 邀请层级效应 CY.UME.Core.Business.Account invitor2 = invitor.GetInviter(); if (invitor2 != null) { int inviteFriendCredit2; if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount2", out inviteFriendCredit2) && (inviteFriendCredit2 != 0)) { orgCredit = invitor2.Credit; modifiedCredit = orgCredit + inviteFriendCredit2; invitor2.Credit = modifiedCredit; invitor2.Save(); ch = new CreditHistory(); ch.AccountId = invitor2.Id; ch.DateCreated = DateTime.Now; ch.Id = Guid.NewGuid(); ch.InstanceId = invId.ToString(); ch.Original = orgCredit; ch.Modified = modifiedCredit; ch.Variation = inviteFriendCredit2; ch.Type = "invitefriend"; ch.Description = "所邀请用户 " + invitor.Name + " 成功邀请了 " + account.Name; ch.Save(); } } } } #endregion } } } catch (Exception) { } //ShowAlert("注册成功", "恭喜您已经成功注册UME账号,现在系统将引导您至完善个人信息页面"); //ExecuteClientScript("setTimeout(function(){window.location.href='UploadAvatar.aspx?type=firstNum'}, 1000)") SaveAccountCookie(TxtEmail.Text.Trim(), sh.ComputeMD5Hash(TxtUserPassword.Text));//保存Cookie用于问问吧登录 Server.Transfer("UploadAvatar.aspx?type=firstNum"); }