protected void BtnRegister_Click(object sender, EventArgs e)
        {
            IEncourageStrategy <int> strategy2;

            if (!this.userSiteConfig.EnableUserReg)
            {
                return;
            }
            if (!this.Page.IsValid)
            {
                return;
            }
            this.CheckUserName();
            this.CheckEmail();
            UserInfo usersInfo = new UserInfo();

            usersInfo.Email          = this.TxtEmail.Text;
            usersInfo.FaceWidth      = 0;
            usersInfo.FaceHeight     = 0;
            usersInfo.PrivacySetting = 0;
            ContacterInfo contacterInfo = new ContacterInfo();

            contacterInfo.Sex            = (UserSexType)Enum.Parse(typeof(UserSexType), "0");
            contacterInfo.Marriage       = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), "0");
            contacterInfo.Income         = -1;
            contacterInfo.Education      = -1;
            contacterInfo.ClientId       = 0;
            contacterInfo.ParentId       = 0;
            contacterInfo.CreateTime     = DateTime.Now;
            contacterInfo.Owner          = "";
            contacterInfo.UserType       = ContacterType.EnterpriceMainContacter;
            contacterInfo.UpdateTime     = DateTime.Now;
            contacterInfo.UserName       = Users.UserNamefilter(this.TxtRegUserName.Text);
            contacterInfo.Birthday       = null;
            usersInfo.UserName           = Users.UserNamefilter(this.TxtRegUserName.Text);
            usersInfo.UserPassword       = StringHelper.MD5(this.TxtRegPassword.Text);
            usersInfo.GroupId            = this.userSiteConfig.GroupId;
            usersInfo.JoinTime           = DateTime.Now;
            usersInfo.RegTime            = DateTime.Now;
            usersInfo.UserExp            = (int)this.userSiteConfig.PresentExp;
            usersInfo.UserPoint          = 0;
            usersInfo.IsInheritGroupRole = true;
            usersInfo.Status             = UserStatus.None;
            string str = DataSecurity.MakeRandomString(10);

            usersInfo.LastPassword = str;
            if (this.userSiteConfig.EmailCheckReg)
            {
                usersInfo.Status   = UserStatus.WaitValidateByEmail;
                usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10);
            }
            if (this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin;
            }
            if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail;
            }
            usersInfo.EndTime = new DateTime?(DateTime.Now);
            usersInfo.Balance = 0M;
            string str2 = "";

            if (ApiData.IsAPiEnable())
            {
                str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtRegPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage);
                if (str2 != "true")
                {
                    DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>");
                }
                str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtRegPassword.Text, "1");
            }
            if (!Users.Add(usersInfo, contacterInfo))
            {
                DynamicPage.WriteErrMsg("<li>注册失败!</li>");
                return;
            }
            if (this.userSiteConfig.PresentMoney != 0.0)
            {
                IEncourageStrategy <decimal> strategy = new UserMoney();
                strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱");
            }
            if (this.userSiteConfig.PresentValidNum == 0)
            {
                goto Label_03EF;
            }
            int howMany = 0;

            if (this.userSiteConfig.PresentValidNum == -1)
            {
                howMany = 0x270f;
            }
            else
            {
                switch (this.userSiteConfig.PresentValidUnit)
                {
                case 1:
                    howMany = this.userSiteConfig.PresentValidNum;
                    goto Label_03C4;

                case 2:
                    howMany = this.userSiteConfig.PresentValidNum * 30;
                    goto Label_03C4;

                case 3:
                    howMany = this.userSiteConfig.PresentValidNum * 0x16d;
                    goto Label_03C4;
                }
                howMany = this.userSiteConfig.PresentValidNum;
            }
            Label_03C4:
            strategy2 = new UserDate();
            strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期");
Label_03EF:
            if (this.userSiteConfig.PresentPoint != 0)
            {
                IEncourageStrategy <int> strategy3 = new UserPoint();
                strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券");
            }
            if (this.userSiteConfig.EmailCheckReg)
            {
                MailInfo mailInfo = new MailInfo();
                mailInfo.IsBodyHtml = true;
                mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
                List <MailAddress> list = new List <MailAddress>();
                list.Add(new MailAddress(usersInfo.Email));
                mailInfo.MailToAddressList = list;
                mailInfo.MailBody          = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum);
                mailInfo.Subject           = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码";
                if (SendMail.Send(mailInfo) == MailState.Ok)
                {
                    DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx");
                }
                else
                {
                    DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx");
                }
            }
            string str3 = "";

            if (this.userSiteConfig.EnableRegCompany)
            {
                str3 = "<li><a href='/Company/RegCompany.aspx'>继续注册企业?</a></li>";
            }
            if (usersInfo.Status == UserStatus.None)
            {
                bool     isPersistent = false;
                DateTime now          = DateTime.Now;
                DateTime expiration   = DateTime.Now;
                isPersistent = false;
                expiration   = now.AddDays(1.0);
                UserPrincipal principal = new UserPrincipal();
                principal.UserName     = usersInfo.UserName;
                principal.LastPassword = usersInfo.LastPassword;
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, now, expiration, isPersistent, principal.SerializeToString());
                string     str4   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4);
                if (isPersistent)
                {
                    cookie.Expires = expiration;
                }
                cookie.HttpOnly = true;
                cookie.Path     = FormsAuthentication.FormsCookiePath;
                cookie.Secure   = FormsAuthentication.RequireSSL;
                base.Response.Cookies.Add(cookie);
                this.Session["UserName"] = usersInfo.UserName;
            }
            if (SiteConfig.ShopConfig.IsPayPassword)
            {
                BasePage.ResponseRedirect("../User/RegisterPayPassword.aspx?Url=FastRegister");
            }
            else
            {
                DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "../Shop/Payment.aspx");
            }
        }
示例#2
0
        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            UserInfo info;
            bool     flag = false;
            int      num  = DataConverter.CLng(this.DropGroupId.SelectedValue);

            if (this.ViewState["UserInfo"] != null)
            {
                info = this.ViewState["UserInfo"] as UserInfo;
            }
            else
            {
                info = new UserInfo();
            }
            if (!string.IsNullOrEmpty(this.TxtQuestion.Text))
            {
                info.Question = this.TxtQuestion.Text;
            }
            if (!string.IsNullOrEmpty(this.TxtAnswer.Text))
            {
                info.Answer = StringHelper.MD5(this.TxtAnswer.Text);
            }
            info.GroupId        = num;
            info.Email          = this.TxtEmail.Text;
            info.UserFace       = this.TxtUserFace.Text;
            info.FaceWidth      = DataConverter.CLng(this.TxtFaceWidth.Text);
            info.FaceHeight     = DataConverter.CLng(this.TxtFaceHeight.Text);
            info.Sign           = this.TxtSign.Text;
            info.PrivacySetting = DataConverter.CLng(this.RadlPrivacySetting.SelectedValue);
            info.UserTrueName   = this.TxtTrueName.Text.Trim();
            ContacterInfo contacterInfo = new ContacterInfo();

            contacterInfo.ContacterId = DataConverter.CLng(this.HdnContacterID.Value);
            contacterInfo.UserName    = info.UserName;
            contacterInfo.TrueName    = this.TxtTrueName.Text;
            contacterInfo.Title       = this.TxtTitle.Text;
            this.PersonalInformation1.GetContacter(contacterInfo);
            this.LiaisonInformation1.GetContacter(contacterInfo);
            info.Sex = this.PersonalInformation1.UserSex;
            contacterInfo.Company        = this.TxtCompany.Text;
            contacterInfo.Department     = this.TxtDepartment.Text;
            contacterInfo.Position       = this.TxtPosition.Text;
            contacterInfo.Operation      = this.TxtOperation.Text;
            contacterInfo.CompanyAddress = this.TxtCompanyAddress.Text;
            contacterInfo.ClientId       = 0;
            contacterInfo.ParentId       = 0;
            contacterInfo.CreateTime     = DateTime.Now;
            contacterInfo.Owner          = "";
            contacterInfo.UserType       = ContacterType.EnterpriceMainContacter;
            contacterInfo.UpdateTime     = DateTime.Now;
            if (string.Compare(this.ViewState["action"].ToString(), "Add", StringComparison.OrdinalIgnoreCase) == 0)
            {
                info.UserName           = Users.UserNamefilter(this.TxtUserName.Text);
                info.UserPassword       = StringHelper.MD5(this.TxtUserPassword.Text.ToLower());
                info.JoinTime           = DateTime.Now;
                info.RegTime            = DateTime.Now;
                info.Status             = UserStatus.None;
                info.IsInheritGroupRole = true;
                contacterInfo.UserName  = info.UserName;
                if (Users.Exists(info.UserName))
                {
                    AdminPage.WriteSuccessMsg("<li>该用户名已被他人占用,请输入不同的用户名!</li>");
                }
                else
                {
                    if (ApiData.IsAPiEnable())
                    {
                        string str = ApiFunction.RegUser(info.UserName, this.TxtUserPassword.Text.ToLower(), info.Question, info.Answer, info.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage);
                        if (str != "true")
                        {
                            AdminPage.WriteErrMsg(str + "<br><li>增加失败!</li>");
                        }
                    }
                    flag = Users.Add(info, contacterInfo);
                }
            }
            else
            {
                if (this.TxtUserPassword.Text != info.UserPassword)
                {
                    info.UserPassword = StringHelper.MD5(this.TxtUserPassword.Text.ToLower());
                }
                if (ApiData.IsAPiEnable())
                {
                    string str2 = ApiFunction.UpdateUser(info.UserName, this.TxtUserPassword.Text.ToLower(), info.Email, info.Question, this.TxtAnswer.Text, info.UserTrueName, info.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage);
                    if (str2 != "true")
                    {
                        AdminPage.WriteErrMsg("<li>" + str2 + "</li>");
                    }
                }
                flag = Users.Update(info, contacterInfo);
                if (info.UserType == UserType.Creator)
                {
                    this.Company1.Action    = this.ViewState["action"].ToString();
                    this.Company1.CompanyId = info.CompanyId;
                    Company.Update(this.Company1.CompanyInfo);
                }
            }
            string returnurl = "UserShow.aspx?UserID=" + info.UserId.ToString();

            if (DataConverter.CBoolean(BasePage.RequestString("Administrator")))
            {
                returnurl = "Administrator.aspx?UserName="******"<li>保存会员信息成功!</li>", returnurl);
            }
            else
            {
                AdminPage.WriteErrMsg("<li>保存会员信息失败!</li>");
            }
        }
示例#3
0
        protected void BtnRegStep2_Click(object sender, EventArgs e)
        {
            IEncourageStrategy <int> strategy2;

            if (!this.userSiteConfig.EnableUserReg)
            {
                return;
            }
            if (!this.Page.IsValid)
            {
                return;
            }
            this.CheckUserName();
            this.CheckEmail();
            this.CheckCode();
            this.CheckQAofReg();
            UserInfo usersInfo = new UserInfo();

            usersInfo.Question       = this.TxtQuestion.Text;
            usersInfo.Answer         = StringHelper.MD5(this.TxtAnswer.Text);
            usersInfo.Email          = this.TxtEmail.Text;
            usersInfo.UserFace       = this.TxtUserFace.Text;
            usersInfo.FaceWidth      = DataConverter.CLng(this.TxtFaceWidth.Text);
            usersInfo.FaceHeight     = DataConverter.CLng(this.TxtFaceHeight.Text);
            usersInfo.Sign           = this.TxtSign.Text;
            usersInfo.PrivacySetting = DataConverter.CLng(this.DropPrivacy.SelectedValue);
            string str = DataSecurity.MakeRandomString(10);

            usersInfo.LastPassword = str;
            ContacterInfo contacterInfo = new ContacterInfo();

            contacterInfo.TrueName    = this.TxtTrueName.Text;
            contacterInfo.Country     = this.Region.Country;
            contacterInfo.Province    = this.Region.Province;
            contacterInfo.City        = this.Region.City;
            contacterInfo.Address     = this.TxtAddress.Text;
            contacterInfo.ZipCode     = this.TxtZipCode.Text;
            contacterInfo.OfficePhone = this.TxtOfficePhone.Text;
            contacterInfo.HomePhone   = this.TxtHomePhone.Text;
            contacterInfo.Mobile      = this.TxtMobile.Text;
            contacterInfo.Fax         = this.TxtFax.Text;
            contacterInfo.Homepage    = this.TxtHomepage.Text;
            contacterInfo.Email       = this.TxtEmail.Text;
            contacterInfo.QQ          = this.TxtQQ.Text;
            contacterInfo.Msn         = this.TxtMSN.Text;
            contacterInfo.Icq         = this.TxtICQ.Text;
            contacterInfo.Yahoo       = this.TxtYahoo.Text;
            contacterInfo.UC          = this.TxtUC.Text;
            contacterInfo.Aim         = this.TxtAim.Text;
            contacterInfo.IdCard      = this.TxtIDCard.Text;
            contacterInfo.Sex         = (UserSexType)Enum.Parse(typeof(UserSexType), this.DropSex.SelectedValue);
            contacterInfo.Marriage    = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), DataConverter.CLng(this.DropMarriage.SelectedValue).ToString());
            if (this.GetDisplayStyle("Income") != "none")
            {
                contacterInfo.Income = DataConverter.CLng(this.DropIncome.SelectedValue);
            }
            else
            {
                contacterInfo.Income = -1;
            }
            contacterInfo.Education      = -1;
            contacterInfo.Company        = this.TxtCompany.Text;
            contacterInfo.Department     = this.TxtDepartment.Text;
            contacterInfo.ClientId       = 0;
            contacterInfo.ParentId       = 0;
            contacterInfo.CreateTime     = DateTime.Now;
            contacterInfo.Owner          = "";
            contacterInfo.UserType       = ContacterType.EnterpriceMainContacter;
            contacterInfo.UpdateTime     = DateTime.Now;
            contacterInfo.UserName       = Users.UserNamefilter(this.TxtUserName.Text);
            contacterInfo.Phs            = this.TxtPHS.Text;
            contacterInfo.Birthday       = string.IsNullOrEmpty(this.TxtBirthday.Text) ? null : new DateTime?(this.TxtBirthday.Date);
            contacterInfo.Position       = this.TxtPosTitle.Text;
            usersInfo.UserName           = Users.UserNamefilter(this.TxtUserName.Text);
            usersInfo.UserPassword       = StringHelper.MD5(this.TxtPassword.Text);
            usersInfo.GroupId            = this.userSiteConfig.GroupId;
            usersInfo.JoinTime           = DateTime.Now;
            usersInfo.RegTime            = DateTime.Now;
            usersInfo.UserExp            = (int)this.userSiteConfig.PresentExp;
            usersInfo.UserPoint          = 0;
            usersInfo.IsInheritGroupRole = true;
            usersInfo.Status             = UserStatus.None;
            if (this.userSiteConfig.EmailCheckReg)
            {
                usersInfo.Status   = UserStatus.WaitValidateByEmail;
                usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10);
            }
            if (this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin;
            }
            if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail;
            }
            usersInfo.EndTime = new DateTime?(DateTime.Now);
            usersInfo.Balance = 0M;
            string str2 = "";

            if (ApiData.IsAPiEnable())
            {
                str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage);
                if (str2 != "true")
                {
                    DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>");
                }
                str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtPassword.Text, "1");
            }
            if (!Users.Add(usersInfo, contacterInfo))
            {
                DynamicPage.WriteErrMsg("<li>注册失败!</li>");
                return;
            }
            if (this.userSiteConfig.PresentMoney != 0.0)
            {
                IEncourageStrategy <decimal> strategy = new UserMoney();
                strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱");
            }
            if (this.userSiteConfig.PresentValidNum == 0)
            {
                goto Label_0665;
            }
            int howMany = 0;

            if (this.userSiteConfig.PresentValidNum == -1)
            {
                howMany = 0x270f;
            }
            else
            {
                switch (this.userSiteConfig.PresentValidUnit)
                {
                case 1:
                    howMany = this.userSiteConfig.PresentValidNum;
                    goto Label_063A;

                case 2:
                    howMany = this.userSiteConfig.PresentValidNum * 30;
                    goto Label_063A;

                case 3:
                    howMany = this.userSiteConfig.PresentValidNum * 0x16d;
                    goto Label_063A;
                }
                howMany = this.userSiteConfig.PresentValidNum;
            }
            Label_063A:
            strategy2 = new UserDate();
            strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期");
            Label_0665:
            if (this.userSiteConfig.PresentPoint != 0)
            {
                IEncourageStrategy <int> strategy3 = new UserPoint();
                strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券");
            }
            if (this.userSiteConfig.EmailCheckReg)
            {
                MailInfo mailInfo = new MailInfo();
                mailInfo.IsBodyHtml = true;
                mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
                List <MailAddress> list = new List <MailAddress>();
                list.Add(new MailAddress(usersInfo.Email));
                mailInfo.MailToAddressList = list;
                mailInfo.MailBody          = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum);
                mailInfo.Subject           = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码";
                if (SendMail.Send(mailInfo) == MailState.Ok)
                {
                    DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx");
                }
                else
                {
                    DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx");
                }
            }
            string str3 = "";

            if (this.userSiteConfig.EnableRegCompany)
            {
                str3 = "<li><a href='Company/RegCompany.aspx'>继续注册企业?</a></li>";
            }
            if (usersInfo.Status == UserStatus.None)
            {
                UserPrincipal principal = new UserPrincipal();
                principal.UserName     = usersInfo.UserName;
                principal.LastPassword = usersInfo.LastPassword;
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, DateTime.Now, DateTime.Now.AddMinutes(60.0), false, principal.SerializeToString());
                string     str4   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4);
                cookie.HttpOnly = true;
                cookie.Path     = FormsAuthentication.FormsCookiePath;
                cookie.Secure   = FormsAuthentication.RequireSSL;
                base.Response.Cookies.Add(cookie);
            }
            if (SiteConfig.ShopConfig.IsPayPassword)
            {
                BasePage.ResponseRedirect("RegisterPayPassword.aspx?Url=Register");
            }
            else
            {
                DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "Default.aspx");
            }
        }