Ejemplo n.º 1
0
        /// <summary>
        /// 保存大师信息
        /// </summary>
        public string SaveMasterInfo()
        {
            string ReturnJson =string.Empty;
            try
            {
                //表单读取
                string UserName = Request["UserName"];
                string Pwd = Request["Pwd"];
                string Birthday = Request["Birthday"];
                string Name = Request["Name"];
                string Sex = Request["Sex"];
                string MobilePhone = Request["MobilePhone"];
                string TelePhone = Request["TelePhone"];
                string QQ = Request["QQ"];
                string Introduce = Request["Introduce"];
                string Email = Request["Email"];
                //string CheckCode = Request["CheckCode"];
                string PicturePath = Request["Picturepath"];

                //验证码校验
                //if (Tools.IsNullOrEmpty(Session["checkcode"]) || !CheckCode.Equals(Session["checkcode"].ToString()))
                //{
                //    ReturnJson =Tools.WriteJsonForReturn(false, "验证码错误!");
                //}
                //字符串sql注入检测
                if (Tools.IsValidInput(ref UserName, true) && Tools.IsValidInput(ref Pwd, true) && Tools.IsValidInput(ref Email, true))
                {
                    //元素赋值
                    Master info = new Master();
                    info.Username = UserName;
                    info.Email = Email;
                    info.Name = Name;
                    info.Password = Tools.GetMD5(Pwd);
                    info.BirthDay = Convert.ToDateTime(Birthday);
                    info.Introduction = Introduce;
                    info.mobilephone = MobilePhone;
                    info.Picturepath = PicturePath;
                    info.QQ = QQ;
                    info.Nation = "";
                    info.Reward = "";
                    info.appreciation = "";
                    info.Zipcode = "";
                    info.Address = "";
                    info.Sex = Sex;
                    info.rank = 0;
                    info.hit = 0;
                    info.Isrecommend = "0";
                    info.Isshow = "0";
                    info.state = "0";
                    info.state1 = "0";
                    info.Telephone = TelePhone;
                    info.website = ""; //context.Request.Url.Scheme + "://" + context.Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/Master/MasterInfo.aspx?MasterId="+info.Id);
                    //加随机验证码
                    info.VCode = Guid.NewGuid().ToString("N");
                    //验证失效(1小时以内激活有效)
                    info.VTime = DateTime.Now.AddHours(1);

                    //验证用户名
                    if (!masterBLL.CheckExistUserName(info.Username))
                    {
                        ReturnJson = Tools.WriteJsonForReturn(false, "用户名重复");
                    }
                    if (masterBLL.AddNew(info) > 0)
                    {
                         //激活网址生成
                        string webpath = Request.Url.Scheme + "://" + Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/Master/EmailChecking") + "?UserName="******"&YZM=" + info.VCode;
                        string body = "尊敬的" + info.Username + "用户:请点击些链接激活:";
                        body += "<a href=" + webpath + ">" + webpath + "</a>";

                        RogerSMTP roger = new RogerSMTP(info.Email, "大师用户激活", body);
                        if (roger.Send())

                        //SMTP smtp = new SMTP(info.Email);
                        ////激活网址生成
                        //string webpath = Request.Url.Scheme + "://" + Request.Url.Authority + System.Web.VirtualPathUtility.ToAbsolute("~/MasterZone/EmailChecking.aspx") + "?UserName="******"&YZM=" + info.VCode;
                        ////发送激活邮件
                        //if (smtp.Activation(webpath, info.Username))
                        {

                            ReturnJson = Tools.WriteJsonForReturn(true, Tools.GetEmail(info.Email));

                        }
                        else
                        {
                            ReturnJson = Tools.WriteJsonForReturn(false, "发送激活邮件失败!");
                        }
                    }
                    else
                    {
                        ReturnJson = Tools.WriteJsonForReturn(false, "注册失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                //logger.Error("错误!", ex);
                ReturnJson = Tools.WriteJsonForReturn(false, "系统出错!");
            }
            return ReturnJson;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 增加master
 /// </summary>
 /// <param name="model">tableName实体</param>
 /// <returns>执行状态</returns>
 public int AddNew(Master model)
 {
     return masterDAL.AddNew(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 大师登录
        /// </summary>
        public string MasterAjaxLogin()
        {
            string ReturnJson = BLLUtil.WriteJsonForReturn(false, "");
            try
            {
                //获取数据
                string Name = Request["Name"];
                string Pwd = Request["Pwd"];
                string IsSaveName = Request["cbName"];
                string IsSavePwd = Request["cbPwd"];
                //用户登录状态
                bool Status = false;
                //返回给客户端的json数据
                //sql注入检测
                if (Tools.IsValidInput(ref Name, true) && (Tools.IsValidInput(ref Pwd, true)) && (Tools.IsValidInput(ref IsSaveName, true)) && (Tools.IsValidInput(ref IsSavePwd, true)))
                {
                    Master info = new Master();
                    info.Username = Name;
                    info.Password = Pwd;
                    ReturnJson = masterBLL.ReturnJson(info, out Status);
                    if (Status) //如果成功登陆
                    {
                        //记住帐号和密码
                        masterBLL.RememberUserInfo(info, masterBLL.GetRememberType(IsSaveName, IsSavePwd));

                        //保存登录状态
                        Session["MasterName"] = info.Username;
                        //如果登录成功,则把用户ID放在Session中
                        if (Tools.IsNullOrEmpty(Session["MasterId"]))
                        {
                            Session["MasterId"] = masterBLL.GetMasterId(info.Username);
                        }
                    }
                }
                return ReturnJson;
            }
            catch (Exception ex)
            {
                //logger.Error("大师登录出错!", ex);
                return string.Empty;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 返回给客户端的json格式数据(用于根据用户登录状态决定)
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public string ReturnJson(Master info, out bool Status)
 {
     //登录状态
     Status = MasterLogin(info);
     //生成json格式数据
     return BLLUtil.WriteJsonForReturn(Status, info.Username);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 记住用户信息
        /// </summary>
        /// <param name="Type">记住用户信息类别</param>
        /// <returns></returns>
        public bool RememberUserInfo(Master info, RememberType type)
        {
            if (type == RememberType.RememberName)
            {
                //记住帐号7天
                CookieHelper.SetCookie("MasterName", info.Username, DateTime.Now.AddDays(7));
            }
            else if (type == RememberType.RememberNameAndPwd)
            {

                //md5哈希加密
                string sercret = Tools.GetMD5(info.Password);
                //同时记住帐号和密码7天
                CookieHelper.SetCookie("MasterName", info.Username, DateTime.Now.AddDays(7));
                CookieHelper.SetCookie("MasterPwd", sercret, DateTime.Now.AddDays(7));
            }
            else
            {
                return false;
            }
            return true;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <param name="info">model</param>
 /// <returns></returns>
 public bool MasterLogin(Master info)
 {
     info.Password = Tools.GetMD5(info.Password);
     return masterDAL.MasterLogin(info);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 增加master
 /// </summary>
 /// <param name="model">tableName实体</param>
 /// <returns>执行状态</returns>
 public int AddNew(Master model)
 {
     db.Masters.Add(model);
     return db.SaveChanges();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <param name="info">会员model</param>
 /// <returns></returns>
 public bool MasterLogin(Master info)
 {
     return db.Masters.Count(s => s.Username == info.Username && s.Password == info.Password && s.state == "1") > 0;
 }