示例#1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(EmailCheckInfo model)
        {
            try
            {
                int            rowsAffected;
                SqlParameter[] parameters =
                {
                    new SqlParameter("@typeid",    SqlDbType.TinyInt,    1),
                    new SqlParameter("@userid",    SqlDbType.Int,        4),
                    new SqlParameter("@email",     SqlDbType.NVarChar,  50),
                    new SqlParameter("@addtime",   SqlDbType.DateTime),
                    new SqlParameter("@status",    SqlDbType.TinyInt,    1),
                    new SqlParameter("@checktime", SqlDbType.DateTime),
                    new SqlParameter("@Expired",   SqlDbType.DateTime),
                    new SqlParameter("@id",        SqlDbType.Int, 4)
                };
                parameters[0].Value     = (int)model.typeid;
                parameters[1].Value     = model.userid;
                parameters[2].Value     = model.email;
                parameters[3].Value     = model.addtime;
                parameters[4].Value     = (int)model.status;
                parameters[5].Value     = model.checktime;
                parameters[6].Value     = model.Expired;
                parameters[7].Direction = ParameterDirection.Output;

                rowsAffected = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_useremailcheck_add", parameters);
                return((int)parameters[7].Value);
                //return model.id;
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                return(0);
            }
        }
示例#2
0
        public static string requestChangePwd(string username)
        {
            var url       = ServerAddrs.lylApiServerAddr + "api/user/requestChangePwd";
            var checkInfo = new EmailCheckInfo
            {
                username = username
            };
            var checkid = HTTPRuqest.LYLPost <string>(url, checkInfo);

            return(checkid);
        }
示例#3
0
        public static bool?checkRegisterUser(string checkId, string checkCode)
        {
            var url       = ServerAddrs.lylApiServerAddr + "api/user/checkRegisterInfo";
            var checkInfo = new EmailCheckInfo
            {
                checkId      = checkId,
                checkingCode = checkCode
            };

            return(HTTPRuqest.LYLPost <bool?>(url, checkInfo));
        }
示例#4
0
        public static bool?checkChangePwd(string checkId, string checkCode, string newPwd)
        {
            var url       = ServerAddrs.lylApiServerAddr + "api/user/checkChangePwdInfo";
            var checkInfo = new EmailCheckInfo
            {
                checkId      = checkId,
                checkingCode = checkCode,
                pwd          = newPwd
            };

            return(HTTPRuqest.LYLPost <bool?>(url, checkInfo));
        }
示例#5
0
        public static string requestRegisterUser(string username, string pwd, string email)
        {
            var url       = ServerAddrs.lylApiServerAddr + "api/user/requestRegisterUser";
            var checkInfo = new EmailCheckInfo
            {
                username = username,
                pwd      = pwd,
                email    = email
            };
            var checkid = HTTPRuqest.LYLPost <string>(url, checkInfo);

            return(checkid);
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public static EmailCheckInfo GetModelFromDs(DataSet ds)
        {
            EmailCheckInfo model = new EmailCheckInfo();

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["typeid"].ToString() != "")
                {
                    model.typeid = (EmailCheckType)int.Parse(ds.Tables[0].Rows[0]["typeid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["userid"].ToString() != "")
                {
                    model.userid = int.Parse(ds.Tables[0].Rows[0]["userid"].ToString());
                }
                model.email = ds.Tables[0].Rows[0]["email"].ToString();
                if (ds.Tables[0].Rows[0]["addtime"].ToString() != "")
                {
                    model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = (EmailCheckStatus)int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["checktime"].ToString() != "")
                {
                    model.checktime = DateTime.Parse(ds.Tables[0].Rows[0]["checktime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Expired"].ToString() != "")
                {
                    model.Expired = DateTime.Parse(ds.Tables[0].Rows[0]["Expired"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#7
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public bool Update(EmailCheckInfo model)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",        SqlDbType.Int,        4),
                    new SqlParameter("@typeid",    SqlDbType.TinyInt,    1),
                    new SqlParameter("@userid",    SqlDbType.Int,        4),
                    new SqlParameter("@email",     SqlDbType.NVarChar,  50),
                    new SqlParameter("@status",    SqlDbType.TinyInt,    1),
                    new SqlParameter("@checktime", SqlDbType.DateTime),
                    new SqlParameter("@result",    SqlDbType.TinyInt, 1)
                };
                parameters[0].Value     = model.id;
                parameters[1].Value     = (int)model.typeid;
                parameters[2].Value     = model.userid;
                parameters[3].Value     = model.email;
                parameters[4].Value     = (int)model.status;
                parameters[5].Value     = model.checktime;
                parameters[6].Direction = ParameterDirection.Output;

                DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_useremailcheck_update", parameters);

                bool success = Convert.ToByte(parameters[6].Value) == 1;

                //bool success = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_useremailcheck_update", parameters) > 0;
                //if (success && model.status == EmailCheckStatus.已审核)
                //{
                //    Factory.ClearCache(model.userid);
                //}
                return(success);
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);
                return(false);
            }
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="username"></param>
        /// <param name="userId"></param>
        /// <param name="email"></param>
        string SendMail(string username, int userId, string email)
        {
            string message = "";

            try
            {
                string tempcontent = viviapi.WebComponents.Template.Helper.GetEmailRegisterTemp();
                if (!string.IsNullOrEmpty(tempcontent))
                {
                    var itemInfo = new EmailCheckInfo
                    {
                        userid    = userId,
                        status    = EmailCheckStatus.提交中,
                        addtime   = DateTime.Now,
                        checktime = DateTime.Now,
                        email     = email,
                        typeid    = EmailCheckType.注册,
                        Expired   = DateTime.Now.AddDays(7)
                    };

                    int result = EmailCheckBll.Add(itemInfo);
                    if (result > 0)
                    {
                        string parms       = string.Format("id={0}&", result);
                        string securityKey = HttpUtility.UrlEncode(Cryptography.RijndaelEncrypt(parms));
                        string verifyurl   = GetVerifyUrl(securityKey);

                        tempcontent = tempcontent.Replace("{#useremail#}", email);
                        tempcontent = tempcontent.Replace("{#username#}", username);
                        tempcontent = tempcontent.Replace("{#sitename#}", webInfo.Name);
                        tempcontent = tempcontent.Replace("{#sitedomain#}", webInfo.Domain);
                        tempcontent = tempcontent.Replace("{#verify_email#}", verifyurl);

                        var emailcom = new EmailHelper(email
                                                       , email + "账号激活"
                                                       , tempcontent
                                                       , true
                                                       , System.Text.Encoding.GetEncoding("gbk"));

                        if (emailcom.Send2())
                        {
                            message = "注册成功,请到注册邮箱完成账号激活!";
                        }
                        else
                        {
                            message = "注册成功,激活邮件发送失败!";
                        }
                    }
                }
                else
                {
                    message = "未找到模板,请联系商务";
                }
            }
            catch (Exception ex)
            {
                message = "系统错误,请联系商务!";
            }

            return(message);
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newemail"></param>
        /// <returns></returns>
        public string SendChange_email(string newemail)
        {
            string message;

            try
            {
                string tempcontent = Helper.GetEmailChangeTemp();
                if (!string.IsNullOrEmpty(tempcontent))
                {
                    var itemInfo = new EmailCheckInfo
                    {
                        userid    = CurrentUser.ID,
                        status    = EmailCheckStatus.提交中,
                        addtime   = DateTime.Now,
                        checktime = DateTime.Now,
                        email     = newemail,
                        typeid    = EmailCheckType.修改,
                        Expired   = DateTime.Now.AddDays(7)
                    };

                    var bll    = new EmailCheck();
                    int result = bll.Add(itemInfo);
                    if (result > 0)
                    {
                        string parms       = string.Format("id={0}&", result);
                        string securityKey = HttpUtility.UrlEncode(Cryptography.RijndaelEncrypt(parms));
                        string verifyurl   = GetVerifyUrl(securityKey);

                        tempcontent = tempcontent.Replace("{#personName#}", CurrentUser.full_name);
                        tempcontent = tempcontent.Replace("{#useremail#}", newemail);
                        string sitename   = "";
                        string sitedomain = "";
                        if (webInfo != null)
                        {
                            sitename   = webInfo.Name;
                            sitedomain = webInfo.Domain;
                        }
                        tempcontent = tempcontent.Replace("{#sitename#}", sitename);
                        tempcontent = tempcontent.Replace("{#sitedomain#}", sitedomain);
                        tempcontent = tempcontent.Replace("{#verify_email#}", verifyurl);

                        var emailcom = new EmailHelper(CurrentUser.Email
                                                       , CurrentUser.Email + "修改邮箱"
                                                       , tempcontent
                                                       , true
                                                       , System.Text.Encoding.Default);

                        emailcom.Send2();

                        message = "操作成功";
                    }
                    else
                    {
                        message = "系统出错,请联系管理员";
                    }
                }
                else
                {
                    message = "系统出错,未找到邮件模版!";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(message);
        }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string msg = "";

            try
            {
                string   decodeparams = Cryptography.RijndaelDecrypt(Parms);
                string[] arr          = decodeparams.Split('&');
                if (arr.Length == 2)
                {
                    int itemId = 0;

                    if (int.TryParse(arr[0].Split('=')[1], out itemId))
                    {
                        var            bll      = new EmailCheck();
                        EmailCheckInfo itemInfo = bll.GetModel(itemId);
                        if (
                            itemInfo == null ||
                            itemInfo.status != EmailCheckStatus.提交中 ||
                            itemInfo.Expired < DateTime.Now
                            )
                        {
                            msg = "无效的信息或此链接已使用";
                        }
                        else
                        {
                            itemInfo.checktime = DateTime.Now;
                            itemInfo.status    = EmailCheckStatus.已审核;

                            msg = "操作";
                            if (itemInfo.typeid == EmailCheckType.认证)
                            {
                                msg = "绑定邮箱";
                            }
                            else if (itemInfo.typeid == EmailCheckType.修改)
                            {
                                msg = "修改邮箱";
                            }
                            else if (itemInfo.typeid == EmailCheckType.注册)
                            {
                                msg = "激活邮箱";
                            }

                            if (bll.Update(itemInfo))
                            {
                                msg += "成功";
                            }
                            else
                            {
                                msg += "失败";
                            }
                        }
                    }
                    else
                    {
                        msg = "无效参数";
                    }
                }
            }
            catch
            {
                msg = "提交无效的参数";
            }
            string script = string.Format(@"
<SCRIPT LANGUAGE='javascript'><!--
alert({0});
location.href='/index.aspx';
//--></SCRIPT>
", AntiXss.JavaScriptEncode(msg));

            HttpContext.Current.Response.Write(script);
        }
示例#11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email"></param>
        string SendMail(string email)
        {
            string msg = string.Empty;

            try
            {
                string tempcontent = viviapi.WebComponents.Template.Helper.GetEmailAuthenticateTemp();
                if (!string.IsNullOrEmpty(tempcontent))
                {
                    var itemInfo = new EmailCheckInfo
                    {
                        userid    = UserId,
                        status    = EmailCheckStatus.提交中,
                        addtime   = DateTime.Now,
                        checktime = DateTime.Now,
                        email     = email,
                        typeid    = EmailCheckType.认证,
                        Expired   = DateTime.Now.AddDays(7)
                    };


                    int result = _emailCheck.Add(itemInfo);
                    if (result > 0)
                    {
                        string parms       = string.Format("id={0}&", result);
                        string securityKey = HttpUtility.UrlEncode(viviLib.Security.Cryptography.RijndaelEncrypt(parms));
                        string verifyurl   = GetVerifyUrl(securityKey);

                        //Session["ReverifyEmail"] = email;
                        //Session["ReverifyParms"] = securityKey;

                        tempcontent = tempcontent.Replace("{#personName#}", CurrentUser.full_name);
                        tempcontent = tempcontent.Replace("{#useremail#}", email);
                        tempcontent = tempcontent.Replace("{#sitename#}", SiteName);
                        tempcontent = tempcontent.Replace("{#sitedomain#}", webInfo.Domain);
                        tempcontent = tempcontent.Replace("{#verify_email#}", verifyurl);

                        var emailcom = new EmailHelper(email
                                                       , email + "绑定邮箱"
                                                       , tempcontent
                                                       , true
                                                       , System.Text.Encoding.Default);

                        emailcom.Send2();

                        msg = "操作已提交,请查收邮件。";
                    }
                }
                else
                {
                    msg = "未找到模板,请联系客服。";
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }

            //AlertAndRedirect(msg);
            return(msg);
        }