Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request["action"];

            if (action == "code")
            {
                string validatecode = context.Request["validatecode"];

                if (Common.WebCommon.CheckValidateCode(validatecode))
                {
                    HttpContext.Current.Session["vcode"] = validatecode;
                    context.Response.Write("验证码正确!");
                }
                else
                {
                    context.Response.Write("验证码错误!");
                }
            }
            else if (action == "name")
            {
                string       name     = context.Request["id"];
                Dal.UsersDAL usersDAL = new Dal.UsersDAL();
                if (usersDAL.GetModel(name) != null)
                {
                    context.Response.Write("账号可以使用");
                }
                else
                {
                    context.Response.Write("账号不存在!");
                }
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string name = context.Request["txtName"];
            string mail = context.Request["txtMail"];

            Dal.UsersDAL usersDAL = new Dal.UsersDAL();
            Model.Users  users    = usersDAL.GetModel(name);
            if (users != null)
            {
                if (users.Mail == mail)
                {
                    Dal.SettingsDAL settingsDAL = new Dal.SettingsDAL();
                    //系统随机产生一个新密码,同时更新数据库,将新的秘密发到用户的邮箱中
                    string newPwd = Guid.NewGuid().ToString().Substring(0, 8); //产生新的密码
                    users.UserPwd = newPwd;
                    usersDAL.Update(users);                                    //更新数据库(一定要将产生的密码加密后存入数据库,但是发送给用户邮箱的一定要是明文)

                    MailMessage mailMessage = new MailMessage();
                    //源邮件地址
                    mailMessage.From = new MailAddress(settingsDAL.GetValue("系统邮件地址"));
                    //目的邮件地址,可以有多个收件人
                    mailMessage.To.Add(new MailAddress(users.Mail));
                    mailMessage.Subject = "工夹具智能管理系统账号更新";//发送邮件的标题

                    StringBuilder sb = new StringBuilder();
                    sb.Append("用户名是" + users.UserName + "的用户 ");
                    sb.Append("您的新密码是:" + newPwd);

                    mailMessage.Body = sb.ToString();//发送邮件的内容
                    SmtpClient client = new SmtpClient(settingsDAL.GetValue("系统邮件SMTP"));
                    client.Credentials = new NetworkCredential(settingsDAL.GetValue("系统邮件用户名"), settingsDAL.GetValue("系统邮件密码"));

                    try
                    {
                        client.Send(mailMessage);//发送大量邮件时会阻塞,可以将要发送的邮箱放入队列中
                        context.Response.Write("邮件发送成功!");
                    }
                    catch
                    {
                    }
                }
                else
                {
                    context.Response.Write("邮箱错误!");
                }
            }
            else
            {
                context.Response.Write("未查询到此用户!");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = int.Parse(context.Request.Form["id"]);

            Dal.UsersDAL usersDAL = new Dal.UsersDAL();
            Users        userInfo = usersDAL.GetModel(id);

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string str = js.Serialize(userInfo);

            context.Response.Write(str);
        }
Beispiel #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            Dal.UsersDAL       usersDAL = new Dal.UsersDAL();
            List <Model.Users> users    = usersDAL.GetListArray("ID>0");

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string str = js.Serialize(users);


            context.Response.Write(str);
        }
Beispiel #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = int.Parse(context.Request.Form["id"]);

            Dal.UsersDAL usersDAL = new Dal.UsersDAL();
            if (usersDAL.Delete(id))
            {
                context.Response.Write("ok");
            }
            else
            {
                context.Response.Write("no");
            }
        }
Beispiel #6
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     Model.Users users = new Model.Users();
     users.UserName   = context.Request["name"];
     users.UserPwd    = context.Request["pwd"];
     users.Phone      = context.Request["phone"];
     users.Mail       = context.Request["email"];
     users.Permission = context.Request["permission"];
     Dal.UsersDAL usersDAL = new Dal.UsersDAL();
     if (usersDAL.Add(users) > 0)
     {
         context.Response.Write("ok");
     }
     else
     {
         context.Response.Write("no");
     }
 }
Beispiel #7
0
        ///// <summary>
        ///// 校验cookie中是否有值
        ///// </summary>
        //private void CheckCookieInfo()
        //{
        //    if (Request.Cookies["cp1"] != null && Request.Cookies["cp2"] != null)
        //    {
        //        string username = Request.Cookies["cp1"].Value;
        //        string pwd = Request.Cookies["cp2"].Value;
        //        Model.Users users = UsersDAL.GetModel(username); /*usersDal.GetModel(username);*/
        //        if (users != null)
        //        {
        //            if (pwd == Common.WebCommon.GetMd5String(Common.WebCommon.GetMd5String(users.Loginpwd)))
        //            {
        //                Session["userinfor"] = users;
        //                if (string.IsNullOrWhiteSpace(Request["hiddenUrl"]))
        //                {
        //                    Context.Response.Redirect("/工夹具/index.html");
        //                }
        //                else
        //                {
        //                    Context.Response.Redirect(Request["hiddenUrl"]);
        //                }
        //            }
        //        }
        //        Response.Cookies["cp1"].Expires = DateTime.Now.AddDays(-1);
        //        Response.Cookies["cp2"].Expires = DateTime.Now.AddDays(-1);
        //    }
        //}
        private void checkPwd()
        {
            //接受用户输入的信息
            string userName = Context.Request["username"];
            string userPwd  = Context.Request["pwd"];

            Dal.UsersDAL usersDAL = new Dal.UsersDAL();
            Model.Users  users    = usersDAL.GetModel(userName);
            if (users != null)
            {
                if (users.UserPwd.Trim() == userPwd.Trim())
                {
                    Session["UserInfo"] = users;
                    if (users.Permission.Trim() == "1")
                    {
                        Context.Response.Redirect("/UI/p1.aspx");
                    }
                    else if (users.Permission.Trim() == "2")
                    {
                        Context.Response.Redirect("/UI/p2.aspx");
                    }
                    else if (users.Permission.Trim() == "3")
                    {
                        Context.Response.Redirect("/UI/p3.aspx");
                    }
                    else if (users.Permission.Trim() == "4")
                    {
                        Context.Response.Redirect("/UI/p4.aspx");
                    }
                }
                else
                {
                    Context.Response.Write("密码错误,请检查!!!");
                }
            }
            else
            {
                Context.Response.Write("该用户不存在!!!");
            }
        }