Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.Form["id"];

            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            SM.YuQing.BLL.Person   bll    = new SM.YuQing.BLL.Person();
            SM.YuQing.Model.Person person = bll.GetModel(Convert.ToInt32(id));

            //删除区域关联
            bll.ClearAllRegions(Convert.ToInt32(id));
            //删除角色关联
            bll.ClearAllRoles(Convert.ToInt32(id));
            //删除用户
            bool      success = bll.Delete(Convert.ToInt32(id));
            Hashtable ht      = new Hashtable();

            if (success)
            {
                ht.Add("success", true);
                string clientip = context.Request.UserHostAddress;
                SM.YuQing.BLL.Log.Add("操作", context.User.Identity.Name + " 删除用户[" + person.Code + "]", 0, 0, clientip);
            }
            else
            {
                ht.Add("errorMsg", "Some errors occured.");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
Пример #2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = SM.YuQing.Library.PageValidate.InputText(Request.Form["Code"].Trim(), 30);
            string password = SM.YuQing.Library.PageValidate.InputText(Request.Form["Pwd"].Trim(), 30);

            SM.YuQing.BLL.Log.Add("登录", userName + " 尝试登录", 0, 0, Request.UserHostAddress);

            //验证登录信息,如果验证通过则返回当前用户对象的安全上下文信息
            SM.YuQing.Accounts.AccountsPrincipal newUser = SM.YuQing.Accounts.AccountsPrincipal.ValidateLogin(userName, password);
            if (newUser == null)//记录登录次数
            {
                if ((Session["PassErrorCountAdmin"] != null) && (Session["PassErrorCountAdmin"].ToString() != ""))
                {
                    int PassErroeCount = Convert.ToInt32(Session["PassErrorCountAdmin"]);
                    Session["PassErrorCountAdmin"] = PassErroeCount + 1;
                }
                else
                {
                    Session["PassErrorCountAdmin"] = 1;
                }
                lblMsg.Text = "用户名或密码错误!";
                return;
            }
            else
            {
                SM.YuQing.BLL.Person userBLL = new SM.YuQing.BLL.Person();

                SM.YuQing.Model.Person currentUser = userBLL.GetModel(((SM.YuQing.Accounts.SiteIdentity)newUser.Identity).FID);
                Context.User = newUser;

                if (currentUser.IsLock == 1)
                {
                    lblMsg.Text = "您的用户名已被管理锁定!";
                    return;
                }
                FormsAuthentication.SetAuthCookie(userName, false);
                //登录成功日志
                string clientip = Request.UserHostAddress;
                SM.YuQing.BLL.Log.Add("登录", currentUser.Code + " 登录成功", 0, 0, clientip);
                userBLL.UpdateLoginInfo(currentUser.ID, DateTime.Now);
                Session["UserInfo"] = currentUser;
                if (Session["returnPage"] != null)
                {
                    string returnpage = Session["returnPage"].ToString();
                    Session["returnPage"] = null;
                    Response.Redirect(returnpage);
                }
                else
                {
                    if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
                    {
                        Response.Redirect("Admin/Index.aspx");
                    }
                    else
                    {
                        Response.Redirect(Request.QueryString["ReturnUrl"].ToString());
                    }
                }
            }
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.Form["id"];

            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            SM.YuQing.BLL.Person   bll    = new SM.YuQing.BLL.Person();
            SM.YuQing.Model.Person person = bll.GetModel(Convert.ToInt32(id));
            if (person.IsLock == 0)
            {
                person.IsLock = 1;
            }
            else
            {
                person.IsLock = 0;
            }
            bool success = bll.Update(person);

            Hashtable ht = new Hashtable();

            if (success)
            {
                ht.Add("success", true);
                string clientip = context.Request.UserHostAddress;
                SM.YuQing.BLL.Log.Add("操作", context.User.Identity.Name + " " + (person.IsLock == 1 ? "锁定" : "解锁") + "用户[" + person.Code + "]", 0, 0, clientip);
            }
            else
            {
                ht.Add("errorMsg", "Some errors occured.");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
Пример #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            int id = Convert.ToInt32(context.Request.QueryString["id"]);

            SM.YuQing.BLL.Person   bll    = new SM.YuQing.BLL.Person();
            SM.YuQing.Model.Person person = bll.GetModel(id);
            person.Pwd = "";
            if (person.IsLock == 1)
            {
                person.Status = "on";
            }
            else
            {
                person.Status = "off";
            }
            context.Response.Write(JsonConvert.SerializeObject(person));
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            string id     = context.Request.QueryString["id"];
            string Name   = context.Request.Form["Name"];
            string Code   = context.Request.Form["Code"];
            string Pwd    = context.Request.Form["Pwd"];
            string RoleID = context.Request.Form["RoleID"];

            bool   success;
            string errorMsg = "";

            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string clientip = context.Request.UserHostAddress;

            if (id == null)
            {
                SM.YuQing.BLL.Person   bll = new SM.YuQing.BLL.Person();
                SM.YuQing.Model.Person p   = bll.GetModelFromCode(Code);
                if (p == null)
                {
                    SM.YuQing.Model.Person person = new SM.YuQing.Model.Person();
                    person.Name          = Name;
                    person.Code          = Code;
                    person.Pwd           = AccountsPrincipal.EncryptPassword(Pwd);
                    person.CreatePerson  = context.User.Identity.Name;
                    person.CreateTime    = DateTime.Now;
                    person.UpdatePerson  = context.User.Identity.Name;
                    person.UpdateTime    = DateTime.Now;
                    person.IsLock        = 0;
                    person.LastLoginTime = DateTime.Now;
                    person.LoginTimes    = 0;

                    success = bll.Add(person);

                    SM.YuQing.BLL.Log.Add("操作", context.User.Identity.Name + " 创建用户[" + person.Code + "]", 0, 0, clientip);
                }
                else
                {
                    success  = false;
                    errorMsg = "此用户名已存在!";
                }
            }
            else
            {
                string[] ids = context.Request.Form["ids"].Split(',');

                SM.YuQing.BLL.Person   bll    = new SM.YuQing.BLL.Person();
                SM.YuQing.Model.Person person = bll.GetModel(Convert.ToInt32(id));
                person.Name = Name;
                if (Pwd != "")
                {
                    person.Pwd = AccountsPrincipal.EncryptPassword(Pwd);
                }
                person.UpdatePerson = context.User.Identity.Name;
                person.UpdateTime   = DateTime.Now;

                success = bll.Update(person);
                bll.ClearAllRegions(person.ID);
                AddRegions(person, ids);
                bll.ClearAllRoles(person.ID);
                if (!string.IsNullOrEmpty(RoleID))
                {
                    bll.AddRoles(person.ID, Convert.ToInt32(RoleID));
                }
                SM.YuQing.BLL.Log.Add("操作", context.User.Identity.Name + " 修改用户[" + person.Code + "]", 0, 0, clientip);
            }
            Hashtable ht = new Hashtable();

            if (success)
            {
                ht.Add("success", true);
            }
            else
            {
                if (errorMsg == "")
                {
                    ht.Add("errorMsg", "Some errors occured.");
                }
                else
                {
                    ht.Add("errorMsg", errorMsg);
                }
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }