Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.user_code model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            //利用反射获得属性的所有公共属性
            PropertyInfo[]        pros  = model.GetType().GetProperties();
            List <MySqlParameter> paras = new List <MySqlParameter>();

            strSql.Append("update  " + databaseprefix + "user_code set ");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + "=@" + pi.Name + ",");                            //声明参数
                        paras.Add(new MySqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(" where id=@id ");
            paras.Add(new MySqlParameter("@id", model.id));
            return(DbHelperMySql.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0);
        }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.user_code GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.user_code model = new Model.user_code();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(','));
            strSql.Append(" from " + databaseprefix + "user_code");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32, 4)
            };
            parameters[0].Value = id;
            DataTable dt = DbHelperMySql.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 private string verify_invite_reg(string user_name, string invite_code)
 {
     if (string.IsNullOrEmpty(invite_code))
     {
         return("{\"status\":0, \"msg\":\"邀请码不能为空!\"}");
     }
     BLL.user_code   codeBll   = new BLL.user_code();
     Model.user_code codeModel = codeBll.GetModel(invite_code);
     if (codeModel == null)
     {
         return("{\"status\":0, \"msg\":\"邀请码不正确或已过期!\"}");
     }
     if (userConfig.invitecodecount > 0)
     {
         if (codeModel.count >= userConfig.invitecodecount)
         {
             codeModel.status = 1;
             return("{\"status\":0, \"msg\":\"该邀请码已经被使用!\"}");
         }
     }
     //检查是否给邀请人增加积分
     if (userConfig.pointinvitenum > 0)
     {
         new BLL.user_point_log().Add(codeModel.user_id, codeModel.user_name, userConfig.pointinvitenum, "邀请用户【" + user_name + "】注册获得积分", true);
     }
     //更改邀请码状态
     codeModel.count += 1;
     codeBll.Update(codeModel);
     return("success");
 }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.user_code GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_id,user_name,type,str_code,count,status,eff_time,add_time from dt_user_code ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.user_code model = new Model.user_code();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["type"] != null && ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = ds.Tables[0].Rows[0]["type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["str_code"] != null && ds.Tables[0].Rows[0]["str_code"].ToString() != "")
                {
                    model.str_code = ds.Tables[0].Rows[0]["str_code"].ToString();
                }
                if (ds.Tables[0].Rows[0]["count"] != null && ds.Tables[0].Rows[0]["count"].ToString() != "")
                {
                    model.count = int.Parse(ds.Tables[0].Rows[0]["count"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["eff_time"] != null && ds.Tables[0].Rows[0]["eff_time"].ToString() != "")
                {
                    model.eff_time = DateTime.Parse(ds.Tables[0].Rows[0]["eff_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 重写虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     action   = PLRequest.GetQueryString("action");
     username = PLRequest.GetQueryString("username");
     username = Utils.DropHTML(username);
     //检查是否关闭会员注册服务
     if (action == "" && uconfig.regstatus == 0)
     {
         HttpContext.Current.Response.Redirect(linkurl("register", "?action=close"));
         return;
     }
     //Email验证
     if (action == "checkmail")
     {
         string          code  = PLRequest.GetQueryString("code");
         BLL.user_code   bll   = new BLL.user_code();
         Model.user_code model = bll.GetModel(code);
         if (model == null) //返回出错
         {
             HttpContext.Current.Response.Redirect(linkurl("register", "?action=checkerror"));
             return;
         }
         //修改申请码状态
         model.status = 1;
         bll.Update(model);
         //修改用户状态
         new BLL.users().UpdateField(model.user_id, "status=0");
     }
 }
Beispiel #6
0
        /// <summary>
        /// 根据用户名得到一个对象实体
        /// </summary>
        public Model.user_code GetModel(string user_name, string code_type, string datepart)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.user_code model = new Model.user_code();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(',') + " from " + databaseprefix + "user_code");
            strSql.Append(" where status=0 and datediff(" + datepart + ",eff_time,getdate())<=0 and user_name=@user_name and type=@type");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@user_name", MySqlDbType.VarChar, 100),
                new MySqlParameter("@type",      MySqlDbType.VarChar, 20)
            };
            parameters[0].Value = user_name;
            parameters[1].Value = code_type;

            DataSet ds = DbHelperMySql.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 根据生成码得到一个对象实体
        /// </summary>
        public Model.user_code GetModel(string str_code)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.user_code model = new Model.user_code();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(',') + " from " + databaseprefix + "user_code");
            strSql.Append(" where status=0 and datediff(d,eff_time,getdate())<=0 and str_code=@str_code");
            SqlParameter[] parameters =
            {
                new SqlParameter("@str_code", SqlDbType.NVarChar, 255)
            };
            parameters[0].Value = str_code;

            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        private string verify_email(Model.users userModel)
        {
            BLL.user_code   codeBll = new BLL.user_code();
            Model.user_code codeModel;
            //检查是否重复提交
            codeModel = codeBll.GetModel(userModel.user_name, Vincent._DTcms.DTEnums.CodeEnum.RegVerify.ToString(), "d");
            if (codeModel == null)
            {
                codeModel           = new Model.user_code();
                codeModel.user_id   = userModel.id;
                codeModel.user_name = userModel.user_name;
                codeModel.type      = Vincent._DTcms.DTEnums.CodeEnum.RegVerify.ToString();
                codeModel.str_code  = userModel.strcode;
                codeModel.eff_time  = DateTime.Now.AddDays(userConfig.regemailexpired);
                codeModel.add_time  = DateTime.Now;
                new BLL.user_code().Add(codeModel);
            }
            //获得邮件内容
            Model.mail_template mailModel = new BLL.mail_template().GetModel("regverify");
            if (mailModel == null)
            {
                return("{\"status\":0, \"msg\":\"邮件发送失败,邮件模板内容不存在!\"}");
            }
            //替换模板内容
            string titletxt = mailModel.maill_title;
            string bodytxt  = mailModel.content;

            titletxt = titletxt.Replace("{webname}", siteConfig.webname);
            titletxt = titletxt.Replace("{username}", userModel.user_name);
            bodytxt  = bodytxt.Replace("{webname}", siteConfig.webname);
            bodytxt  = bodytxt.Replace("{webtel}", siteConfig.webtel);
            bodytxt  = bodytxt.Replace("{weburl}", siteConfig.weburl);
            bodytxt  = bodytxt.Replace("{username}", userModel.user_name);
            bodytxt  = bodytxt.Replace("{valid}", userConfig.regemailexpired.ToString());
            bodytxt  = bodytxt.Replace("{linkurl}", "http://" + HttpContext.Current.Request.Url.Authority.ToLower()
                                       + "/checkemail.aspx?action=checkmail&userid=" + userModel.id + "&strcode=" + userModel.strcode);
            //发送邮件
            try
            {
                _Email.SendMail(siteConfig.emailsmtp,
                                siteConfig.emailusername,
                                _DESEncrypt.Decrypt(siteConfig.emailpassword),
                                siteConfig.emailnickname,
                                siteConfig.emailfrom,
                                userModel.email,
                                titletxt, bodytxt);
            }
            catch (Exception)
            {
                //return "{\"status\":0, \"msg\":\""+ex.Message+"\"}";
                return("{\"status\":0, \"msg\":\"邮件发送失败,请联系本站管理员!\"}");
            }
            return("success");
        }
Beispiel #9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.user_code model)
        {
            int newId;

            using (OleDbConnection conn = new OleDbConnection(DbHelperOleDb.connectionString))
            {
                conn.Open();
                using (OleDbTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "user_code(");
                        strSql.Append("user_id,user_name,[type],str_code,[count],status,user_ip,eff_time,add_time)");
                        strSql.Append(" values (");
                        strSql.Append("@user_id,@user_name,@type,@str_code,@count,@status,@user_ip,@eff_time,@add_time)");
                        OleDbParameter[] parameters =
                        {
                            new OleDbParameter("@user_id",   OleDbType.Integer,   4),
                            new OleDbParameter("@user_name", OleDbType.VarChar, 100),
                            new OleDbParameter("@type",      OleDbType.VarChar,  20),
                            new OleDbParameter("@str_code",  OleDbType.VarChar, 255),
                            new OleDbParameter("@count",     OleDbType.Integer,   4),
                            new OleDbParameter("@status",    OleDbType.Integer,   4),
                            new OleDbParameter("@user_ip",   OleDbType.VarChar,  20),
                            new OleDbParameter("@eff_time",  OleDbType.Date),
                            new OleDbParameter("@add_time",  OleDbType.Date)
                        };
                        parameters[0].Value = model.user_id;
                        parameters[1].Value = model.user_name;
                        parameters[2].Value = model.type;
                        parameters[3].Value = model.str_code;
                        parameters[4].Value = model.count;
                        parameters[5].Value = model.status;
                        parameters[6].Value = model.user_ip;
                        parameters[7].Value = model.eff_time;
                        parameters[8].Value = model.add_time;
                        DbHelperOleDb.ExecuteSql(conn, trans, strSql.ToString(), parameters);
                        //取得新插入的ID
                        newId = GetMaxId(conn, trans);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(-1);
                    }
                }
            }
            return(newId);
        }
Beispiel #10
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.user_code model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "user_code set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("user_name=@user_name,");
            strSql.Append("[type]=@type,");
            strSql.Append("str_code=@str_code,");
            strSql.Append("[count]=@count,");
            strSql.Append("status=@status,");
            strSql.Append("user_ip=@user_ip,");
            strSql.Append("eff_time=@eff_time,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@user_id",   OleDbType.Integer,   4),
                new OleDbParameter("@user_name", OleDbType.VarChar, 100),
                new OleDbParameter("@type",      OleDbType.VarChar,  20),
                new OleDbParameter("@str_code",  OleDbType.VarChar, 255),
                new OleDbParameter("@count",     OleDbType.Integer,   4),
                new OleDbParameter("@status",    OleDbType.Integer,   4),
                new OleDbParameter("@user_ip",   OleDbType.VarChar,  20),
                new OleDbParameter("@eff_time",  OleDbType.Date),
                new OleDbParameter("@add_time",  OleDbType.Date),
                new OleDbParameter("@id",        OleDbType.Integer, 4)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.str_code;
            parameters[4].Value = model.count;
            parameters[5].Value = model.status;
            parameters[6].Value = model.user_ip;
            parameters[7].Value = model.eff_time;
            parameters[8].Value = model.add_time;
            parameters[9].Value = model.id;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #11
0
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.user_code DataRowToModel(DataRow row)
 {
     Model.user_code model = new Model.user_code();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["user_name"] != null)
         {
             model.user_name = row["user_name"].ToString();
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
         if (row["str_code"] != null)
         {
             model.str_code = row["str_code"].ToString();
         }
         if (row["count"] != null && row["count"].ToString() != "")
         {
             model.count = int.Parse(row["count"].ToString());
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["user_ip"] != null)
         {
             model.user_ip = row["user_ip"].ToString();
         }
         if (row["eff_time"] != null && row["eff_time"].ToString() != "")
         {
             model.eff_time = DateTime.Parse(row["eff_time"].ToString());
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return model;
 }
Beispiel #12
0
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.user_code DataRowToModel(DataRow row)
 {
     Model.user_code model = new Model.user_code();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["user_name"] != null)
         {
             model.user_name = row["user_name"].ToString();
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
         if (row["str_code"] != null)
         {
             model.str_code = row["str_code"].ToString();
         }
         if (row["count"] != null && row["count"].ToString() != "")
         {
             model.count = int.Parse(row["count"].ToString());
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["user_ip"] != null)
         {
             model.user_ip = row["user_ip"].ToString();
         }
         if (row["eff_time"] != null && row["eff_time"].ToString() != "")
         {
             model.eff_time = DateTime.Parse(row["eff_time"].ToString());
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return(model);
 }
Beispiel #13
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.user_code model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_user_code set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("user_name=@user_name,");
            strSql.Append("type=@type,");
            strSql.Append("str_code=@str_code,");
            strSql.Append("count=@count,");
            strSql.Append("status=@status,");
            strSql.Append("eff_time=@eff_time,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",   SqlDbType.Int,         4),
                new SqlParameter("@user_name", SqlDbType.NVarChar,  100),
                new SqlParameter("@type",      SqlDbType.NVarChar,   20),
                new SqlParameter("@str_code",  SqlDbType.NVarChar,  255),
                new SqlParameter("@count",     SqlDbType.Int,         4),
                new SqlParameter("@status",    SqlDbType.TinyInt,     1),
                new SqlParameter("@eff_time",  SqlDbType.DateTime),
                new SqlParameter("@add_time",  SqlDbType.DateTime),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.str_code;
            parameters[4].Value = model.count;
            parameters[5].Value = model.status;
            parameters[6].Value = model.eff_time;
            parameters[7].Value = model.add_time;
            parameters[8].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #14
0
 /// <summary>
 /// 重写父类的虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     action = MXRequest.GetQueryString("action");
     if (action == "reset")
     {
         string strcode = MXRequest.GetQueryString("code");
         if (strcode != null)
         {
             model = new BLL.user_code().GetModel(strcode);
             if (model == null)
             {
                 HttpContext.Current.Response.Redirect(linkurl("repassword", "error"));
                 return;
             }
         }
     }
 }
Beispiel #15
0
 /// <summary>
 /// 重写父类的虚方法,此方法将在Init事件前执行
 /// </summary>
 protected override void ShowPage()
 {
     action = MXRequest.GetQueryString("action");
     if (action == "reset")
     {
         string strcode = MXRequest.GetQueryString("code");
         if (strcode != null)
         {
             model = new BLL.user_code().GetModel(strcode);
             if (model == null)
             {
                 HttpContext.Current.Response.Redirect(linkurl("repassword", "error"));
                 return;
             }
         }
     }
 }
        private string verify_mobile(Model.users userModel)
        {
            //生成随机码
            string strcode = Vincent._DTcms.Utils.Number(4);

            BLL.user_code   codeBll = new BLL.user_code();
            Model.user_code codeModel;
            //检查是否重复提交
            codeModel = codeBll.GetModel(userModel.user_name, Vincent._DTcms.DTEnums.CodeEnum.RegVerify.ToString(), "n");
            if (codeModel == null)
            {
                codeModel           = new Model.user_code();
                codeModel.user_id   = userModel.id;
                codeModel.user_name = userModel.user_name;
                codeModel.type      = Vincent._DTcms.DTEnums.CodeEnum.RegVerify.ToString();
                codeModel.str_code  = strcode;
                codeModel.eff_time  = DateTime.Now.AddMinutes(userConfig.regsmsexpired);
                codeModel.add_time  = DateTime.Now;
                new BLL.user_code().Add(codeModel);
            }
            //获得短信模板内容
            Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode");
            if (smsModel == null)
            {
                return("{\"status\":0, \"msg\":\"发送失败,短信模板内容不存在!\"}");
            }
            //替换模板内容
            string msgContent = smsModel.content;

            msgContent = msgContent.Replace("{webname}", siteConfig.webname);
            msgContent = msgContent.Replace("{webtel}", siteConfig.webtel);
            msgContent = msgContent.Replace("{weburl}", siteConfig.weburl);
            msgContent = msgContent.Replace("{username}", userModel.user_name);
            msgContent = msgContent.Replace("{code}", codeModel.str_code);
            msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString());
            //发送短信
            string tipMsg     = string.Empty;
            bool   sendStatus = new BLL.sms_message().Send(userModel.mobile, msgContent, 2, out tipMsg);

            if (!sendStatus)
            {
                return("{\"status\": 0, \"msg\": \"短信发送失败," + tipMsg + "\"}");
            }
            return("success");
        }
        private void user_invite_code(HttpContext context)
        {
            //检查用户是否登录
            Model.users model = new BasePage().GetUserInfo();
            if (model == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}");
                return;
            }
            //检查是否开启邀请注册
            if (userConfig.regstatus != 2)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,系统不允许通过邀请注册!\"}");
                return;
            }
            BLL.user_code codeBll = new BLL.user_code();
            //检查申请是否超过限制
            if (userConfig.invitecodenum > 0)
            {
                int result = codeBll.GetCount("user_name='" + model.user_name + "' and type='" + Vincent._DTcms.DTEnums.CodeEnum.Register.ToString() + "' and datediff(d,add_time,getdate())=0");
                if (result >= userConfig.invitecodenum)
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,您申请邀请码的数量已超过每天限制!\"}");
                    return;
                }
            }
            //删除过期的邀请码
            codeBll.Delete("type='" + Vincent._DTcms.DTEnums.CodeEnum.Register.ToString() + "' and status=1 or datediff(d,eff_time,getdate())>0");
            //随机取得邀请码
            string str_code = Vincent._DTcms.Utils.GetCheckCode(8);

            Model.user_code codeModel = new Model.user_code();
            codeModel.user_id   = model.id;
            codeModel.user_name = model.user_name;
            codeModel.type      = Vincent._DTcms.DTEnums.CodeEnum.Register.ToString();
            codeModel.str_code  = str_code;
            if (userConfig.invitecodeexpired > 0)
            {
                codeModel.eff_time = DateTime.Now.AddDays(userConfig.invitecodeexpired);
            }
            codeBll.Add(codeModel);
            context.Response.Write("{\"status\":1, \"msg\":\"恭喜您,申请邀请码已成功!\"}");
            return;
        }
Beispiel #18
0
 /// <summary>
 /// 将对象转换实体
 /// </summary>
 public Model.user_code DataRowToModel(DataRow row)
 {
     Model.user_code model = new Model.user_code();
     if (row != null)
     {
         //利用反射获得属性的所有公共属性
         Type modelType = model.GetType();
         for (int i = 0; i < row.Table.Columns.Count; i++)
         {
             //查找实体是否存在列表相同的公共属性
             PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
             if (proInfo != null && row[i] != DBNull.Value)
             {
                 proInfo.SetValue(model, row[i], null);//用索引值设置属性值
             }
         }
     }
     return(model);
 }
Beispiel #19
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.user_code model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "user_code(");
            strSql.Append("user_id,user_name,type,str_code,count,status,user_ip,eff_time,add_time)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@user_name,@type,@str_code,@count,@status,@user_ip,@eff_time,@add_time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",   SqlDbType.Int,         4),
                new SqlParameter("@user_name", SqlDbType.NVarChar,  100),
                new SqlParameter("@type",      SqlDbType.NVarChar,   20),
                new SqlParameter("@str_code",  SqlDbType.NVarChar,  255),
                new SqlParameter("@count",     SqlDbType.Int,         4),
                new SqlParameter("@status",    SqlDbType.TinyInt,     1),
                new SqlParameter("@user_ip",   SqlDbType.NVarChar,   20),
                new SqlParameter("@eff_time",  SqlDbType.DateTime),
                new SqlParameter("@add_time",  SqlDbType.DateTime)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.str_code;
            parameters[4].Value = model.count;
            parameters[5].Value = model.status;
            parameters[6].Value = model.user_ip;
            parameters[7].Value = model.eff_time;
            parameters[8].Value = model.add_time;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #20
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.user_code model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder(); //数据字段
            StringBuilder str2   = new StringBuilder(); //数据参数

            //利用反射获得属性的所有公共属性
            PropertyInfo[]        pros  = model.GetType().GetProperties();
            List <MySqlParameter> paras = new List <MySqlParameter>();

            strSql.Append("insert into " + databaseprefix + "user_code(");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + ",");                                             //拼接字段
                        str2.Append("@" + pi.Name + ",");                                       //声明参数
                        paras.Add(new MySqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(") values (");
            strSql.Append(str2.ToString().Trim(','));
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY;");
            object obj = DbHelperMySql.GetSingle(strSql.ToString(), paras.ToArray());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #21
0
        public static string GetInviteCode(Agp2pDataContext context = null)
        {
            if (context == null)
            {
                context = new Agp2pDataContext();
            }
            var userInfo = GetUserInfoByLinq(context);

            HttpContext.Current.Response.TrySkipIisCustomErrors = true;
            if (userInfo == null)
            {
                HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return("请先登录");
            }

            var userCode = context.dt_user_code.FirstOrDefault(u => u.user_id == userInfo.id && u.type == DTEnums.CodeEnum.Register.ToString());

            //新增一个邀请码
            if (userCode == null)
            {
                var codeBll   = new BLL.user_code();
                var strCode   = Utils.GetCheckCode(8);
                var codeModel = new Model.user_code
                {
                    user_id   = userInfo.id,
                    user_name = userInfo.user_name,
                    type      = DTEnums.CodeEnum.Register.ToString(),
                    str_code  = strCode,
                    eff_time  = DateTime.Now.AddDays(1)
                };

                codeBll.Add(codeModel);
                return(strCode);
            }
            return(userCode.str_code);
        }
Beispiel #22
0
 private string verify_mobile(Model.users userModel)
 {
     //生成随机码
     string strcode = Utils.Number(4);
     BLL.user_code codeBll = new BLL.user_code();
     Model.user_code codeModel;
     //检查是否重复提交
     codeModel = codeBll.GetModel(userModel.user_name, DTEnums.CodeEnum.RegVerify.ToString(), "n");
     if (codeModel == null)
     {
         codeModel = new Model.user_code();
         codeModel.user_id = userModel.id;
         codeModel.user_name = userModel.user_name;
         codeModel.type = DTEnums.CodeEnum.RegVerify.ToString();
         codeModel.str_code = strcode;
         codeModel.eff_time = DateTime.Now.AddMinutes(userConfig.regsmsexpired);
         codeModel.add_time = DateTime.Now;
         new BLL.user_code().Add(codeModel);
     }
     //获得短信模板内容
     Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode");
     if (smsModel == null)
     {
         return "{\"status\":0, \"msg\":\"发送失败,短信模板内容不存在!\"}";
     }
     //替换模板内容
     string msgContent = smsModel.content;
     msgContent = msgContent.Replace("{webname}", siteConfig.webname);
     msgContent = msgContent.Replace("{webtel}", siteConfig.webtel);
     msgContent = msgContent.Replace("{weburl}", siteConfig.weburl);
     msgContent = msgContent.Replace("{username}", userModel.user_name);
     msgContent = msgContent.Replace("{code}", codeModel.str_code);
     msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString());
     //发送短信
     string tipMsg = string.Empty;
     bool sendStatus = new BLL.sms_message().Send(userModel.mobile, msgContent, 2, out tipMsg);
     if (!sendStatus)
     {
         return "{\"status\": 0, \"msg\": \"短信发送失败," + tipMsg + "\"}";
     }
     return "success";
 }
Beispiel #23
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.user_code GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,user_id,user_name,type,str_code,count,status,eff_time,add_time from dt_user_code ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) };
            parameters[0].Value = id;

            Model.user_code model = new Model.user_code();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["type"] != null && ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = ds.Tables[0].Rows[0]["type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["str_code"] != null && ds.Tables[0].Rows[0]["str_code"].ToString() != "")
                {
                    model.str_code = ds.Tables[0].Rows[0]["str_code"].ToString();
                }
                if (ds.Tables[0].Rows[0]["count"] != null && ds.Tables[0].Rows[0]["count"].ToString() != "")
                {
                    model.count = int.Parse(ds.Tables[0].Rows[0]["count"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["eff_time"] != null && ds.Tables[0].Rows[0]["eff_time"].ToString() != "")
                {
                    model.eff_time = DateTime.Parse(ds.Tables[0].Rows[0]["eff_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Beispiel #24
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.user_code model)
 {
     return(dal.Update(model));
 }
Beispiel #25
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.user_code model)
 {
     return(dal.Add(model));
 }
Beispiel #26
0
 private void user_getpassword(HttpContext context)
 {
     string code = DTRequest.GetFormString("txtCode");
     string username = DTRequest.GetFormString("txtUserName").Trim();
     //检查用户名是否正确
     if (string.IsNullOrEmpty(username))
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,用户名不可为空!\"}");
         return;
     }
     //校检验证码
     string result = verify_code(context, code);
     if (result != "success")
     {
         context.Response.Write(result);
         return;
     }
     //检查用户信息
     BLL.users bll = new BLL.users();
     Model.users model = bll.GetModel(username);
     if (model == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,您输入的用户名不存在!\"}");
         return;
     }
     if (string.IsNullOrEmpty(model.email))
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"您尚未设置邮箱地址,无法使用取回密码功能!\"}");
         return;
     }
     //生成随机码
     string strcode = Utils.GetCheckCode(20);
     //获得邮件内容
     Model.mail_template mailModel = new BLL.mail_template().GetModel("getpassword");
     if (mailModel == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"邮件发送失败,邮件模板内容不存在!\"}");
         return;
     }
     //检查是否重复提交
     BLL.user_code codeBll = new BLL.user_code();
     Model.user_code codeModel;
     codeModel = codeBll.GetModel(username, DTEnums.CodeEnum.RegVerify.ToString());
     if (codeModel == null)
     {
         codeModel = new Model.user_code();
         //写入数据库
         codeModel.user_id = model.id;
         codeModel.user_name = model.user_name;
         codeModel.type = DTEnums.CodeEnum.Password.ToString();
         codeModel.str_code = strcode;
         codeModel.eff_time = DateTime.Now.AddDays(1);
         codeModel.add_time = DateTime.Now;
         codeBll.Add(codeModel);
     }
     //替换模板内容
     string titletxt = mailModel.maill_title;
     string bodytxt = mailModel.content;
     titletxt = titletxt.Replace("{webname}", siteConfig.webname);
     titletxt = titletxt.Replace("{username}", model.user_name);
     bodytxt = bodytxt.Replace("{webname}", siteConfig.webname);
     bodytxt = bodytxt.Replace("{username}", model.user_name);
     bodytxt = bodytxt.Replace("{linkurl}", Utils.DelLastChar(siteConfig.weburl, "/") + new BasePage().linkurl("repassword1", "reset", strcode)); //此处需要修改
     //发送邮件
     try
     {
         DTMail.sendMail(siteConfig.emailstmp,
             siteConfig.emailusername,
             DESEncrypt.Decrypt(siteConfig.emailpassword),
             siteConfig.emailnickname,
             siteConfig.emailfrom,
             model.email,
             titletxt, bodytxt);
     }
     catch
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"邮件发送失败,请联系本站管理员!\"}");
         return;
     }
     context.Response.Write("{\"msg\":1, \"msgbox\":\"邮件发送成功,请登录您的邮箱找回登录密码!\"}");
     return;
 }
Beispiel #27
0
 private string verify_email(Model.users userModel)
 {
     //生成随机码
     string strcode = Utils.GetCheckCode(20);
     BLL.user_code codeBll = new BLL.user_code();
     Model.user_code codeModel;
     //检查是否重复提交
     codeModel = codeBll.GetModel(userModel.user_name, DTEnums.CodeEnum.RegVerify.ToString());
     if (codeModel == null)
     {
         codeModel = new Model.user_code();
         codeModel.user_id = userModel.id;
         codeModel.user_name = userModel.user_name;
         codeModel.type = DTEnums.CodeEnum.RegVerify.ToString();
         codeModel.str_code = strcode;
         codeModel.eff_time = DateTime.Now.AddDays(userConfig.regemailexpired);
         codeModel.add_time = DateTime.Now;
         new BLL.user_code().Add(codeModel);
     }
     //获得邮件内容
     Model.mail_template mailModel = new BLL.mail_template().GetModel("regverify");
     if (mailModel == null)
     {
         return "{\"msg\":0, \"msgbox\":\"邮件发送失败,邮件模板内容不存在!\"}";
     }
     //替换模板内容
     string titletxt = mailModel.maill_title;
     string bodytxt = mailModel.content;
     titletxt = titletxt.Replace("{webname}", siteConfig.webname);
     titletxt = titletxt.Replace("{username}", userModel.user_name);
     bodytxt = bodytxt.Replace("{webname}", siteConfig.webname);
     bodytxt = bodytxt.Replace("{username}", userModel.user_name);
     bodytxt = bodytxt.Replace("{linkurl}", Utils.DelLastChar(siteConfig.weburl, "/") + new Web.UI.BasePage().linkurl("register")+"?action=checkmail&strcode=" + codeModel.str_code);
     //发送邮件
     try
     {
         DTMail.sendMail(siteConfig.emailstmp,
             siteConfig.emailusername,
             DESEncrypt.Decrypt(siteConfig.emailpassword),
             siteConfig.emailnickname,
             siteConfig.emailfrom,
             userModel.email,
             titletxt, bodytxt);
     }
     catch
     {
         return "{\"msg\":0, \"msgbox\":\"邮件发送失败,请联系本站管理员!\"}";
     }
     return "success";
 }
 private void user_getpassword(HttpContext context)
 {
     string site = DTRequest.GetQueryString("site");
     string code = DTRequest.GetFormString("txtCode");
     string type = DTRequest.GetFormString("txtType");
     string username = DTRequest.GetFormString("txtUserName").Trim();
     //检查站点目录
     if (string.IsNullOrEmpty(site))
     {
         context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}");
         return;
     }
     //检查用户名
     if (string.IsNullOrEmpty(username))
     {
         context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户名不可为空!\"}");
         return;
     }
     //检查取回密码类型
     if (string.IsNullOrEmpty(type))
     {
         context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择取回密码类型!\"}");
         return;
     }
     //校检验证码
     string result = verify_code(context, code);
     if (result != "success")
     {
         context.Response.Write(result);
         return;
     }
     //检查用户信息
     BLL.users bll = new BLL.users();
     Model.users model = bll.GetModel(username);
     if (model == null)
     {
         context.Response.Write("{\"status\":0, \"msg\":\"对不起,您输入的用户名不存在!\"}");
         return;
     }
     //发送取回密码的短信或邮件
     if (type.ToLower() == "mobile") //使用手机取回密码
     {
         #region 发送短信==================
         if (string.IsNullOrEmpty(model.mobile))
         {
             context.Response.Write("{\"status\":0, \"msg\":\"您尚未绑定手机号码,无法取回密码!\"}");
             return;
         }
         Model.sms_template smsModel = new BLL.sms_template().GetModel("usercode"); //取得短信内容
         if (smsModel == null)
         {
             context.Response.Write("{\"status\":0, \"msg\":\"发送失败,短信模板不存在,请联系管理员!\"}");
         }
         string strcode = Utils.Number(4); //随机验证码
         //检查是否重复提交
         BLL.user_code codeBll = new BLL.user_code();
         Model.user_code codeModel;
         codeModel = codeBll.GetModel(username, DTEnums.CodeEnum.RegVerify.ToString(), "d");
         if (codeModel == null)
         {
             codeModel = new Model.user_code();
             //写入数据库
             codeModel.user_id = model.id;
             codeModel.user_name = model.user_name;
             codeModel.type = DTEnums.CodeEnum.Password.ToString();
             codeModel.str_code = strcode;
             codeModel.eff_time = DateTime.Now.AddMinutes(userConfig.regsmsexpired);
             codeModel.add_time = DateTime.Now;
             codeBll.Add(codeModel);
         }
         //替换标签
         string msgContent = smsModel.content;
         msgContent = msgContent.Replace("{webname}", siteConfig.webname);
         msgContent = msgContent.Replace("{weburl}", siteConfig.weburl);
         msgContent = msgContent.Replace("{webtel}", siteConfig.webtel);
         msgContent = msgContent.Replace("{code}", codeModel.str_code);
         msgContent = msgContent.Replace("{valid}", userConfig.regsmsexpired.ToString());
         //发送短信
         string tipMsg = string.Empty;
         bool result1 = new BLL.sms_message().Send(model.mobile, msgContent, 1, out tipMsg);
         if (!result1)
         {
             context.Response.Write("{\"status\":0, \"msg\":\"发送失败," + tipMsg + "\"}");
             return;
         }
         context.Response.Write("{\"status\":1, \"msg\":\"手机验证码发送成功!\", \"url\":\""
             + new BasePage().getlink(site, new BasePage().linkurl("repassword", "?action=mobile&username="******"\"}");
         return;
         #endregion
     }
     else if (type.ToLower() == "email") //使用邮箱取回密码
     {
         #region 发送邮件==================
         if (string.IsNullOrEmpty(model.email))
         {
             context.Response.Write("{\"status\":0, \"msg\":\"您尚未绑定邮箱,无法取回密码!\"}");
             return;
         }
         //生成随机码
         string strcode = Utils.GetCheckCode(20);
         //获得邮件内容
         Model.mail_template mailModel = new BLL.mail_template().GetModel("getpassword");
         if (mailModel == null)
         {
             context.Response.Write("{\"status\":0, \"msg\":\"邮件发送失败,邮件模板内容不存在!\"}");
             return;
         }
         //检查是否重复提交
         BLL.user_code codeBll = new BLL.user_code();
         Model.user_code codeModel;
         codeModel = codeBll.GetModel(username, DTEnums.CodeEnum.RegVerify.ToString(), "d");
         if (codeModel == null)
         {
             codeModel = new Model.user_code();
             //写入数据库
             codeModel.user_id = model.id;
             codeModel.user_name = model.user_name;
             codeModel.type = DTEnums.CodeEnum.Password.ToString();
             codeModel.str_code = strcode;
             codeModel.eff_time = DateTime.Now.AddDays(userConfig.regemailexpired);
             codeModel.add_time = DateTime.Now;
             codeBll.Add(codeModel);
         }
         //替换模板内容
         string titletxt = mailModel.maill_title;
         string bodytxt = mailModel.content;
         titletxt = titletxt.Replace("{webname}", siteConfig.webname);
         titletxt = titletxt.Replace("{username}", model.user_name);
         bodytxt = bodytxt.Replace("{webname}", siteConfig.webname);
         bodytxt = bodytxt.Replace("{weburl}", siteConfig.weburl);
         bodytxt = bodytxt.Replace("{webtel}", siteConfig.webtel);
         bodytxt = bodytxt.Replace("{valid}", userConfig.regemailexpired.ToString());
         bodytxt = bodytxt.Replace("{username}", model.user_name);
         bodytxt = bodytxt.Replace("{linkurl}", "http://" + HttpContext.Current.Request.Url.Authority.ToLower()
             + new BasePage().getlink(site, new BasePage().linkurl("repassword", "?action=email&code=" + codeModel.str_code)));
         //发送邮件
         try
         {
             DTMail.sendMail(siteConfig.emailsmtp,
                 siteConfig.emailssl,
                 siteConfig.emailusername,
                 DESEncrypt.Decrypt(siteConfig.emailpassword),
                 siteConfig.emailnickname,
                 siteConfig.emailfrom,
                 model.email,
                 titletxt, bodytxt);
         }
         catch
         {
             context.Response.Write("{\"status\":0, \"msg\":\"邮件发送失败,请联系本站管理员!\"}");
             return;
         }
         context.Response.Write("{\"status\":1, \"msg\":\"邮件发送成功,请登录邮箱查看邮件!\"}");
         return;
         #endregion
     }
     context.Response.Write("{\"status\":0, \"msg\":\"发生未知错误,请检查参数是否正确!\"}");
     return;
 }
Beispiel #29
0
 private void user_invite_code(HttpContext context)
 {
     //检查用户是否登录
     Model.users model = new BasePage().GetUserInfo();
     if (model == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,用户没有登录或登录超时啦!\"}");
         return;
     }
     //检查是否开启邀请注册
     if (userConfig.regstatus != 2)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,系统不允许通过邀请注册!\"}");
         return;
     }
     BLL.user_code codeBll = new BLL.user_code();
     //检查申请是否超过限制
     if (userConfig.invitecodenum > 0)
     {
         int result = codeBll.GetCount("user_name='" + model.user_name + "' and type='" + DTEnums.CodeEnum.Register.ToString() + "' and datediff(d,add_time,getdate())=0");
         if (result >= userConfig.invitecodenum)
         {
             context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,您申请的邀请码数量已超过每天的限制!\"}");
             return;
         }
     }
     //删除过期的邀请码
     codeBll.Delete("type='" + DTEnums.CodeEnum.Register.ToString() + "' and status=1 or datediff(d,eff_time,getdate())>0");
     //随机取得邀请码
     string str_code = Utils.GetCheckCode(8);
     Model.user_code codeModel = new Model.user_code();
     codeModel.user_id = model.id;
     codeModel.user_name = model.user_name;
     codeModel.type = DTEnums.CodeEnum.Register.ToString();
     codeModel.str_code = str_code;
     if (userConfig.invitecodeexpired > 0)
     {
         codeModel.eff_time = DateTime.Now.AddDays(userConfig.invitecodeexpired);
     }
     codeBll.Add(codeModel);
     context.Response.Write("{\"msg\":1, \"msgbox\":\"恭喜您,申请邀请码已成功!\"}");
     return;
 }
 private string send_verify_email(string site, Model.users userModel)
 {
     //生成随机码
     string strcode = Utils.GetCheckCode(20);
     BLL.user_code codeBll = new BLL.user_code();
     Model.user_code codeModel;
     //检查是否重复提交
     codeModel = codeBll.GetModel(userModel.user_name, DTEnums.CodeEnum.RegVerify.ToString(), "d");
     if (codeModel == null)
     {
         codeModel = new Model.user_code();
         codeModel.user_id = userModel.id;
         codeModel.user_name = userModel.user_name;
         codeModel.type = DTEnums.CodeEnum.RegVerify.ToString();
         codeModel.str_code = strcode;
         codeModel.eff_time = DateTime.Now.AddDays(userConfig.regemailexpired);
         codeModel.add_time = DateTime.Now;
         new BLL.user_code().Add(codeModel);
     }
     //获得邮件内容
     Model.mail_template mailModel = new BLL.mail_template().GetModel("regverify");
     if (mailModel == null)
     {
         return "{\"status\":0, \"msg\":\"邮件发送失败,邮件模板内容不存在!\"}";
     }
     //替换模板内容
     string titletxt = mailModel.maill_title;
     string bodytxt = mailModel.content;
     titletxt = titletxt.Replace("{webname}", siteConfig.webname);
     titletxt = titletxt.Replace("{username}", userModel.user_name);
     bodytxt = bodytxt.Replace("{webname}", siteConfig.webname);
     bodytxt = bodytxt.Replace("{webtel}", siteConfig.webtel);
     bodytxt = bodytxt.Replace("{weburl}", siteConfig.weburl);
     bodytxt = bodytxt.Replace("{username}", userModel.user_name);
     bodytxt = bodytxt.Replace("{valid}", userConfig.regemailexpired.ToString());
     bodytxt = bodytxt.Replace("{linkurl}", "http://" + HttpContext.Current.Request.Url.Authority.ToLower()
         + new Web.UI.BasePage().getlink(site, new Web.UI.BasePage().linkurl("register", "?action=checkmail&code=" + codeModel.str_code)));
     //发送邮件
     try
     {
         DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl,
             siteConfig.emailusername,
             DESEncrypt.Decrypt(siteConfig.emailpassword),
             siteConfig.emailnickname,
             siteConfig.emailfrom,
             userModel.email,
             titletxt, bodytxt);
     }
     catch
     {
         return "{\"status\":0, \"msg\":\"邮件发送失败,请联系本站管理员!\"}";
     }
     return "success";
 }