예제 #1
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            RegisterBLL registerBLL = new RegisterBLL();

            registerBLL.firstName = this.tb_firstName.Text;
            registerBLL.lastName  = this.tb_lastName.Text;
            if (this.rb_female.Checked)
            {
                registerBLL.gender = "F";
            }
            else
            {
                registerBLL.gender = "M";
            }
            registerBLL.birthday   = Convert.ToDateTime(this.tb_birthday.Text);
            registerBLL.occupation = this.tb_occupation.Text;
            registerBLL.email      = this.tb_email.Text;
            registerBLL.role       = "P";

            registerBLL.updateProfile();

            this.tb_firstName.Enabled  = false;
            this.tb_lastName.Enabled   = false;
            this.tb_birthday.Enabled   = false;
            this.tb_occupation.Enabled = false;
            this.tb_email.Enabled      = false;
            this.rb_female.Enabled     = false;
            this.rb_male.Enabled       = false;
            this.btn_save.Visible      = false;
            this.btn_cancel.Visible    = false;
        }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterBLL registerbll = new RegisterBLL();
        string      str_mail    = Request.Form["email"].ToString();//传入用户输入的邮箱
        //string str_mail = "*****@*****.**";//测试用户输入的邮箱
        DataSet ds_user = registerbll.getUserByUserMail(str_mail);

        if (ds_user.Tables[0].Rows.Count > 0)  //注册过此邮箱
        {
            string strSmtpServer = "smtp.qq.com";
            string strFrom       = "*****@*****.**";
            string strFromPass   = "******";

            string strto      = str_mail;
            string strto_mi   = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strto, "md5");
            string strSubject = "TimeFlow重置密码";
            System.Text.StringBuilder strBody = new System.Text.StringBuilder();
            strBody.Append("你好,我们收到了一个重置你 TimeFlow 账户密码的请求,请点击下面的链接重置密码</br>");
            strBody.Append("<a href='http://localhost:10259/reset_2.html?userMail=" + strto_mi + "'>点击这里</a></br>");
            strBody.Append("如未能反应请点击下面链接:<a href='http://localhost:10259/reset_2.html?userMail=" + strto_mi + "'>http://localhost:10259/reset_2.html?userMail=" + strto_mi + "</a></br>");
            SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strto, strSubject, strBody.ToString());
            Response.Write("success");
        }
        else
        {
            Response.Write("not_exist");
        }
    }
예제 #3
0
        protected void btn_submit_Click(object sender, ImageClickEventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            RegisterBLL registerBLL = new RegisterBLL();

            registerBLL.firstName = this.tb_firstName.Text;
            registerBLL.lastName  = this.tb_lastName.Text;
            if (this.rb_female.Checked)
            {
                registerBLL.gender = "F";
            }
            else
            {
                registerBLL.gender = "M";
            }
            registerBLL.birthday   = Convert.ToDateTime(this.tb_birthday.Text);
            registerBLL.occupation = this.tb_occupation.Text;
            registerBLL.email      = this.tb_email.Text;
            registerBLL.password   = this.tb_password.Text;
            registerBLL.role       = "P";

            registerBLL.register();
            Response.Redirect("~/AppPage/registerSuccess.aspx");
        }
예제 #4
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            AccNum accNum = new AccNum();

            accNum.accNumber     = txtAccNum.Text.ToString();
            accNum.password      = txtPassword.Text.ToString();
            accNum.passwordAgain = txtPasswordAgain.Text.ToString();
            int r = RegisterBLL.UIPassword(accNum);

            if (r == 1)
            {
                int temp = RegisterBLL.GetAcc(accNum);
                if (temp == 1)
                {
                    MessageBox.Show("成功");
                }
                else
                {
                    MessageBox.Show("失败");
                }
            }
            else if (r == 0)
            {
                MessageBox.Show("对不起,两次密码输入的不一致");
            }
            else
            {
                MessageBox.Show("请呼叫专业人员,本系统不干活了");
            }
        }
예제 #5
0
    public void operateLink(string userMail, string validateCode)
    {
        RegisterBLL regbll = new RegisterBLL();

        Client myUser = new Client();

        myUser.Mail = userMail;

        DataSet ds_user = regbll.getUserByUserMail(userMail);

        if (ds_user.Tables[0].Rows.Count == 0)
        {
            Response.Write("该注册信息已不存在,验证失败");
        }
        else
        {
            //验证过期
            DateTime ZCTime  = Convert.ToDateTime(ds_user.Tables[0].Rows[0]["addData"]);
            DateTime NowTime = DateTime.Now;

            TimeSpan time1 = new TimeSpan(ZCTime.Ticks);
            TimeSpan time2 = new TimeSpan(NowTime.Ticks);

            string diff = time2.Subtract(time1).TotalHours.ToString();
            double time = Convert.ToDouble(diff);

            //验证是否过期
            if (time > 12)
            {
                Response.Write("验证码已经过期,验证失败");
                return;
            }
            //验证链接是否用过
            if (ds_user.Tables[0].Rows[0]["validateCode"].ToString() == "")
            {
                Response.Write("已经验证过了,请返回到登录页面,登录体验吧");
                return;
            }
            //验证激活账号,修改账号状态
            if (validateCode == ds_user.Tables[0].Rows[0]["validateCode"].ToString())
            {
                int update = regbll.updateValidateCode(myUser);
                if (update == 1)                          //验证成功并且修改数据库用户状态
                {
                    Response.Write("验证成功,请返回到登录页面,登录体验吧");
                }
                else
                {
                    Response.Write("状态未改变,未激活");
                }
            }
        }
    }
예제 #6
0
        public static void RegisterComponents(IServiceCollection services)
        {
            services.AddHttpClient();
            services.AddSingleton <RequestToHttpHelper>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            RegisterBLL.RegisterComponents(services);
            RegisterDAL.RegisterComponents(services);
            RegisterMediatR.RegisterComponents(services);

            //自动注入IAutoInject
            services.Scan(x =>
            {
                var entryAssembly        = Assembly.GetEntryAssembly();
                var referencedAssemblies = entryAssembly.GetReferencedAssemblies().Select(Assembly.Load);
                var assemblies           = new List <Assembly> {
                    entryAssembly
                }.Concat(referencedAssemblies);

                x.FromAssemblies(assemblies)
                .AddClasses(classes => classes.AssignableTo(typeof(IAutoInject)))
                .AsImplementedInterfaces()
                .WithScopedLifetime()
                //接口注册Scoped
                .AddClasses(classes => classes.AssignableTo(typeof(IScopedAutoInject)))
                .AsImplementedInterfaces()
                .WithScopedLifetime()
                //接口注册Singleton
                .AddClasses(classes => classes.AssignableTo(typeof(ISingletonAutoInject)))
                .AsImplementedInterfaces()
                .WithSingletonLifetime()
                //接口注册Transient
                .AddClasses(classes => classes.AssignableTo(typeof(ITransientAutoInject)))
                .AsImplementedInterfaces()
                .WithTransientLifetime()
                //具体类注册Scoped
                .AddClasses(classes => classes.AssignableTo(typeof(ISelfScopedAutoInject)))
                .AsSelf()
                .WithScopedLifetime()
                //具体类注册Singleton
                .AddClasses(classes => classes.AssignableTo(typeof(ISelfSingletonAutoInject)))
                .AsSelf()
                .WithSingletonLifetime()
                //具体类注册Transient
                .AddClasses(classes => classes.AssignableTo(typeof(ISelfTransientAutoInject)))
                .AsSelf()
                .WithTransientLifetime();
            });
        }
예제 #7
0
        public void signup_registration_Testing()
        {
            RegisterBLL checkRegiseterbll = new RegisterBLL();

            int ExpectedCount = checkRegiseterbll.countUser() + 1;

            checkRegiseterbll._fname           = "test";
            checkRegiseterbll._lname           = "test1";
            checkRegiseterbll._username        = "******";
            checkRegiseterbll._password        = "******";
            checkRegiseterbll._email           = "*****@*****.**";
            checkRegiseterbll._dob             = "2018/07/19";
            checkRegiseterbll._confirmpassword = "******";
            checkRegiseterbll._gender          = "Male";
            checkRegiseterbll.insertUserInfo();

            int actualCount = checkRegiseterbll.countUser();

            Assert.AreEqual(ExpectedCount, actualCount);
        }
예제 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterBLL resetbll   = new RegisterBLL();
        string      user_email = Request.Form["userMail"].ToString();

        if (user_email != null)                                                                                           //从前端链接字符中得到需要重置密码的用户的邮箱
        {
            string re_psw = Request.Form["newpwd"].ToString();                                                            //得到用户重置的密码
            //  string re_psw = ("666666");//测试用户输入的重置密码
            string new_repsw = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(re_psw, "MD5"); //加密

            int reset = resetbll.resetPsw(new_repsw, user_email);
            if (reset == 1)                              //重置成功
            {
                Response.Write("success");
            }
            else
            {
                Response.Write("fail");
            }
        }
    }
예제 #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //注册
        RegisterBLL registerbll = new RegisterBLL();
        LoginBLL    mybll       = new LoginBLL();
        Client      myUser      = new Client();
        ClientInfo  user_info   = new ClientInfo();
        string      strFuncName = Request.Form["type"].Trim();
        string      strPsw      = Request.Form["password"].ToString();
        string      newPsw      = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strPsw, "MD5");//加密

        myUser.Password = newPsw;

        switch (strFuncName)
        {
        case "email":
            myUser.Mail = Request.Form["username"].ToString();

            //邮箱验证:验证码,用户状态,注册时间
            Random random    = new Random();
            string checkCode = "";
            for (int i = 0; i <= 4; i++)
            {
                int num = random.Next(1, 10);
                checkCode += num.ToString();
            }
            string validataCode = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(checkCode, "md5");
            myUser.validateCode = validataCode;        //生成验证码
            myUser.UserState    = 0;                   //用户状态默认为未激活
            myUser.LockState    = 1;                   //用户注册时默认为未封锁状态
            myUser.addData      = System.DateTime.Now; //获得当前用户注册的时间

            //用户注册时赋值默认信息
            user_info.FollowerNum = 0;
            user_info.FolloweeNum = 0;
            user_info.NickName    = myUser.Mail;
            user_info.Pic         = "Portrait/default.jpg";



            int add_mail = registerbll.addMail(myUser);
            if (add_mail == 1)                                  //注册成功就发送邮件
            {
                DataSet ds_user = mybll.getUserMail(myUser);
                user_info.ID = Convert.ToInt32(ds_user.Tables[0].Rows[0]["ID"]);
                int add_info = registerbll.addInfo(user_info);
                Response.Write("success");

                //发邮箱参数配置
                string strSmtpServer = "smtp.qq.com";
                string strFrom       = "*****@*****.**";
                string strFromPass   = "******";

                string strto      = myUser.Mail;
                string strSubject = "账号激活";
                System.Text.StringBuilder strBody = new System.Text.StringBuilder();
                strBody.Append("点击下面链接激活账号,12小时有效,否则重新注册账号,链接只能使用一次,请尽快激活!</br>");
                strBody.Append("<a href='http://localhost:10259/active.aspx?userMail=" + myUser.Mail + "&validateCode=" + myUser.validateCode + "'>点击这里</a></br>");
                strBody.Append("如未能激活请点击下面链接:<a href='http://localhost:10259/active.aspx?userMail=" + myUser.Mail + "&validateCode=" + myUser.validateCode + "'>http://localhost:10259/active.aspx?userMail=" + myUser.Mail + "&validateCode=" + myUser.validateCode + "</a></br>");
                SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strto, strSubject, strBody.ToString());
            }
            else
            {
                if (add_mail == 2)
                {
                    Response.Write("takeup");
                }
                else
                {
                    Response.Write("fail");
                }
            }
            break;

            //case "phone":
            //     myUser.Phone = Request.Form["username"].ToString();
            //     int add_phone = registerbll.addPhone(myUser);
            //     if (add_phone == 1)
            //        {
            //            Response.Write("success");
            //        }
            //        else
            //        {
            //            if (add_phone == 2)
            //            {
            //                Response.Write("takeup");
            //            }
            //            else
            //            {
            //               Response.Write("fail");
            //            }
            //        }
            //        break;
        }
    }