コード例 #1
0
        public object SendYzmSms(string mobile)
        {
            if (!ValidatorClass.Validator(mobile, CheckType.Mobile, null, false))
            {
                return(new { Rcode = -1, Rmsg = "参数错误" });
            }
            Random            rand   = new Random();
            string            errmsg = null;
            base_identifycode info   = new base_identifycode
            {
                code     = rand.Next(100000, 999999).ToString(),
                sendtime = DateTime.Now,
                endtime  = DateTime.Now.AddMinutes(3),
                phone    = mobile
            };
            bool success = BaseBLL.PutIdentifyCode(info, out errmsg);

            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "写入验证码出错" + errmsg }
            }
            ;
            if (!SmsServiceBLL.SmsSingleSendByYunpian(mobile, info.code, null, null, true, out errmsg))
            {
                return(new { Rcode = -1, Rmsg = "发送短信出错:" + errmsg });
            }
            return(new { Rcode = 1, Rmsg = "短信已下发,请注意查收" });
        }
コード例 #2
0
        public object UserReg(base_user_extend userinfo)
        {
            string errmsg = null;

            if (userinfo.yzmcode == null || userinfo.yzmcode.Length != 6)
            {
                return(new { Rcode = -1, Rmsg = "注册失败:请填写验证码" });
            }
            base_identifycode identifycode = BLL.BaseBLL.GetIdentifyCodeInfo(userinfo.phone, userinfo.email, userinfo.yzmcode, out errmsg);

            if (identifycode == null)
            {
                return new { Rcode = 0, Rmsg = "验证码错误" }
            }
            ;
            else if (DateTime.Now > identifycode.endtime)
            {
                return new { Rcode = 0, Rmsg = "验证码超时,请重新获取验证码" }
            }
            ;

            userinfo.passwd     = StrFormatClass.MD5ToDepth(userinfo.passwd);
            userinfo.usertype   = 1;
            userinfo.userlevel  = 1;
            userinfo.sourcetype = 1;
            userinfo.customerid = 0;
            userinfo.status     = 1;
            userinfo.grade      = 0;
            userinfo.period     = 0;
            userinfo.classname  = ".";
            userinfo.school     = ".";
            int userid = userLoginManager.UserReg(userinfo, out errmsg);

            if (userid > 0)
            {
                base_userlogs log = new base_userlogs()
                {
                    logtype     = 21, // 21 注册; 22 登录;
                    restype     = "0",
                    rescode     = userid.ToString(),
                    logcontent  = string.Format("注册用户{0}", userinfo.username),
                    creator     = 0,
                    createdtime = DateTime.Now
                };

                BLL.BaseBLL.WriteUserLog(log, out errmsg);//记录注册日志

                return(new { Rcode = 1, Rdata = userid });
            }
            else if (!string.IsNullOrEmpty(errmsg))
            {
                return(new { Rcode = -1, Rmsg = "注册失败:" + errmsg });
            }
            else
            {
                return(new { Rcode = 0, Rmsg = "注册失败" });
            }
        }
コード例 #3
0
        public static bool PutIdentifyCode(base_identifycode info, out string errmsg)
        {
            List <DataParameter> pars = new List <DataParameter>();

            pars.Add(new DataParameter("phone", info.phone));
            pars.Add(new DataParameter("email", info.email));
            pars.Add(new DataParameter("code", info.code));
            pars.Add(new DataParameter("sendtime", info.sendtime));
            pars.Add(new DataParameter("endtime", info.endtime));
            string sqlstr = "insert into base_identifycode (phone,email,code,sendtime,endtime) values (@phone,@email,@code,@sendtime,@endtime)";

            return(MySqlHelper.ExecuteCommand(sqlstr, out errmsg, pars.ToArray()) > 0);
        }
コード例 #4
0
        public object UserFindPasswd(base_users userinfo)
        {
            string errmsg = null;

            if (userinfo.yzmcode == null || userinfo.yzmcode.Length != 6)
            {
                return(new { Rcode = -1, Rmsg = "找回密码失败:请填写验证码" });
            }
            base_identifycode identifycode = BLL.BaseBLL.GetIdentifyCodeInfo(userinfo.phone, userinfo.email, userinfo.yzmcode, out errmsg);

            if (identifycode == null)
            {
                return new { Rcode = 0, Rmsg = "验证码错误" }
            }
            ;
            else if (DateTime.Now > identifycode.endtime)
            {
                return new { Rcode = 0, Rmsg = "验证码超时,请重新获取验证码" }
            }
            ;

            userinfo.passwd = StrFormatClass.MD5ToDepth(userinfo.passwd);

            bool issuc = userLoginManager.UserFindPasswd(userinfo, out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(new { Rcode = -1, Rmsg = "找回密码失败:" + errmsg });
            }
            if (issuc)
            {
                return(new { Rcode = 1, Rmsg = "ok" });
            }
            else
            {
                return(new { Rcode = 0, Rmsg = "找回密码失败" });
            }
        }
コード例 #5
0
        public object SendYzmEmail(string email)
        {
            if (!ValidatorClass.Validator(email, CheckType.Email, null, false))
            {
                return(new { Rcode = -1, Rmsg = "参数错误" });
            }
            Random            rand   = new Random();
            string            errmsg = null;
            base_identifycode info   = new base_identifycode
            {
                code     = rand.Next(100000, 999999).ToString(),
                sendtime = DateTime.Now,
                endtime  = DateTime.Now.AddMinutes(5),
                email    = email
            };
            bool success = BaseBLL.PutIdentifyCode(info, out errmsg);

            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "写入验证码出错" + errmsg }
            }
            ;
            string subject = Models.GlobalParameters.SmtpSignTitle + "验证邮件";
            string content = string.Format("您的验证码为 {0} ,请勿轻易告诉他人!", info.code);

            NetClass.SmtpServer = Models.GlobalParameters.SmtpServer;
            NetClass.Account    = Models.GlobalParameters.SmtpUser;
            NetClass.Passwd     = Models.GlobalParameters.SmtpPass;
            NetClass.MailFrom   = Models.GlobalParameters.SmtpMail;
            if (!NetClass.SendMail(email, subject, content, Models.GlobalParameters.SmtpMail, ref errmsg))
            {
                return(new { Rcode = -1, Rmsg = "发送邮件出错:" + errmsg });
            }
            return(new { Rcode = 1, Rmsg = "邮件已发送,请注意查收" });
        }
    }
コード例 #6
0
ファイル: BaseBLL.cs プロジェクト: xiaosachuchen/-version2
 internal static bool PutIdentifyCode(base_identifycode info, out string errmsg)
 {
     return(DAL.BaseDAL.PutIdentifyCode(info, out errmsg));
 }