Exemplo n.º 1
0
        public bool IsLogin()
        {
            string CookieValue = ReadCookie();

            if (!string.IsNullOrEmpty(CookieValue))
            {
                string CookieDEVal = DES.Decrypt(CookieValue);
                try
                {
                    CookieModel cm     = Newtonsoft.Json.JsonConvert.DeserializeObject <CookieModel>(CookieDEVal);
                    var         entity = Trans.Db.Data.NUser_Info.Get("UserName=@UserName AND UserId=@UserId AND Status=1 AND IsDel=0", "", new object[] { cm.USERNAME, cm.USERID });
                    if (entity != null && entity.UserId > 0)
                    {
                        this.OpUser = entity;
                        int CookieExpireMinutes = 0;
                        if (!int.TryParse(CookieMinutes, out CookieExpireMinutes))
                        {
                            CookieExpireMinutes = 30;
                        }
                        System.Web.HttpContext.Current.Response.Cookies[CookieName].Domain  = CookieDomain;
                        System.Web.HttpContext.Current.Response.Cookies[CookieName].Expires = DateTime.Now.AddMinutes(CookieExpireMinutes);
                        System.Web.HttpContext.Current.Response.Cookies[CookieName].Value   = CookieValue;
                        return(true);
                    }
                }
                catch (Exception ex) { Console.WriteLine(ex.Message); }
            }
            return(false);
        }
Exemplo n.º 2
0
 private void SetParameters()
 {
     if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
     {
         Trans.Db.Model.NUser_Info user = Trans.Db.Data.NUser_Info.Get("UserName=@UserName AND Password=@Password AND Status=1 AND IsDel=0", "", new object[] { UserName, Password }, true);
         if (user != null && user.UserId > 0)
         {
             int CookieExpireMinutes = 0;
             if (!int.TryParse(CookieMinutes, out CookieExpireMinutes))
             {
                 CookieExpireMinutes = 30;
             }
             HttpCookie UserCookie = new HttpCookie(CookieName);
             UserCookie.Domain  = CookieDomain;
             UserCookie.Expires = DateTime.Now.AddMinutes(CookieExpireMinutes);
             UserCookie.Value   = HttpUtility.UrlEncode(DES.Encrypt("{\"USERID\":" + user.UserId.ToString() + ",\"USERNAME\":\"" + user.UserName + "\"}"), Encoding.UTF8);
             Response.Cookies.Add(UserCookie);
             Response.Write("<script>alert('登录成功');location.href='Default.aspx';</script>");
         }
         else
         {
             Response.Write("<script>alert('登录失败');</script>");
         }
     }
 }
Exemplo n.º 3
0
        private void SetParameters()
        {
            if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
            {
                Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Trim(), "MD5");
                Trans.Db.Model.NUser_Info user = Trans.Db.Data.NUser_Info.Get("UserName=@UserName AND Password=@Password AND Status=1 AND IsDel=0", "", new object[] { UserName.Trim(), Password }, true);
                if (user != null && user.UserId > 0)
                {
                    int CookieExpireMinutes = 0;
                    if (!int.TryParse(CookieMinutes, out CookieExpireMinutes))
                    {
                        CookieExpireMinutes = 30;
                    }
                    HttpCookie UserCookie = new HttpCookie(CookieName);
                    UserCookie.Domain  = CookieDomain;
                    UserCookie.Expires = DateTime.Now.AddMinutes(CookieExpireMinutes);
                    UserCookie.Value   = HttpUtility.UrlEncode(DES.Encrypt("{\"USERID\":" + user.UserId.ToString() + ",\"USERNAME\":\"" + user.UserName + "\"}"), Encoding.UTF8);
                    Response.Cookies.Add(UserCookie);

                    Common.LogUtility.DBLog Userlog = new Common.LogUtility.DBLog();

                    Userlog.UserOperLog("登陆访问", UserName + "登陆", user.UserId);


                    Response.Write("<script>alert('登录成功');location.href='Default.aspx';</script>");
                }
                else
                {
                    Response.Write("<script>alert('登录失败');</script>");
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BasePage base1 = new BasePage();

            UserName = base1.OpUser.UserName;
            OpUser   = base1.OpUser;
            GetMenuList();
        }
Exemplo n.º 5
0
 private void UpdateStatus()
 {
     Trans.Db.Model.NUser_Info userinfo = Trans.Db.Data.NUser_Info.Get("Userid=@Userid  ", "", new object[] { UserId });
     userinfo.Status = Convert.ToInt32(!Convert.ToBoolean(userinfo.Status));
     if (Trans.Db.Data.NUser_Info.Update(userinfo) > 0)
     {
         Response.Write("<script>alert('操作成功');window.location.href='Users.aspx'</script>");
     }
     else
     {
         Response.Write("<script>alert('操作失败');window.location.href='Users.aspx'</script>");
     }
 }
Exemplo n.º 6
0
 private void SetParameters()
 {
     if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password) && !string.IsNullOrEmpty(SruePwd))
     {
         Trans.Db.Model.NUser_Info user = Trans.Db.Data.NUser_Info.Get(" UserName=@UserName and isdel=0 ", "", new object[] { UserName });
         if (user.UserId > 0)
         {
             Response.Write("<script>alert('此用户已存在');href='Users.aspx';</script>");
         }
         else
         {
             if (SruePwd != Password)
             {
                 Response.Write("<script>alert('两次密码不同');</script>");
             }
             else
             {
                 user.UserName   = UserName;
                 user.Password   = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5");
                 user.CreateTime = DateTime.Now;
                 user.Status     = 1;
                 if (Trans.Db.Data.NUser_Info.insert(user))
                 {
                     Response.Write("<script>alert('添加成功');href='Users.aspx'</script>");
                 }
                 else
                 {
                     Response.Write("<script>alert('添加失败');</script>");
                 }
             }
         }
     }
     else
     {
         Response.Write("<script>alert('请完善信息');;</script>");
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 获得用户列表
        /// </summary>
        private void GetUserList()
        {
            string UserId = Request["UserId"];

            NUser_Info = Trans.Db.Data.NUser_Info.Get("UserId=@UserId", "", new object[] { UserId }, true);
        }