Example #1
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());
                    }
                }
            }
        }
Example #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string oldPwd   = this.OldPwd.Value.Trim();
            string newPwd   = this.NewPwd.Value.Trim();
            string checkPwd = this.CheckPwd.Value.Trim();

            AccountsPrincipal user;

            SM.YuQing.Model.Person currentUser;
            SM.YuQing.BLL.Person   userBLL = new SM.YuQing.BLL.Person();
            user = new AccountsPrincipal(Context.User.Identity.Name);
            if (Session["UserInfo"] == null)
            {
                return;
            }
            currentUser = (SM.YuQing.Model.Person)Session["UserInfo"];
            SM.YuQing.Accounts.AccountsPrincipal newUser = SM.YuQing.Accounts.AccountsPrincipal.ValidateLogin(currentUser.Code, oldPwd);
            if (newUser == null)
            {
                lblMsg.Text = "旧密码输入有误!";
                return;
            }
            if (userBLL.ResetPwd(currentUser.ID, AccountsPrincipal.EncryptPassword(newPwd)))
            {
                lblMsg.Text = "密码修改成功!";
                string clientip = Request.UserHostAddress;
                SM.YuQing.BLL.Log.Add("操作", currentUser.Code + " 修改密码", 0, 0, clientip);
            }
        }
        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));
        }
Example #4
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));
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            SM.YuQing.BLL.Person bll = new SM.YuQing.BLL.Person();
            //DataTable dt = bll.GetAllList().Tables[0];
            List <SM.YuQing.Model.Person> lst = bll.GetModelList("");

            context.Response.Write(JsonConvert.SerializeObject(lst));
        }
Example #6
0
 public void AddRegions(SM.YuQing.Model.Person person, string[] ids)
 {
     SM.YuQing.BLL.Person bll = new SM.YuQing.BLL.Person();
     foreach (string item in ids)
     {
         if (item != "" && item != "undefined")
         {
             bll.AddRegions(person.ID, Convert.ToInt32(item));
         }
     }
 }
Example #7
0
        public string GetFields()
        {
            SM.YuQing.BLL.Person person = new SM.YuQing.BLL.Person();
            bool permission             = person.HavePermission(HttpContext.Current.User.Identity.Name, "监测数据管理", "修改");

            string fields = "";

            if (permission)
            {
                fields = "{field: \'Property\',title: \'性质\',width: 80,editor: {type: \'combobox\',options: {valueField: \'val\',textField: \'txt\',data: types,panelHeight: \'auto\',editable: false}}},{field: \'opt\', title: \'操作\', align: \'center\',formatter: function (value, rowData, rowIndex) {return rowData.ID == \"\" ? \"\" : \"<a href=\'#\'onclick=\'saveProperty(\" + rowData.ID + \", \" + rowIndex + \");\'><span style=\'color:blue\'>保存</span></a>\";}}";
            }
            else
            {
                fields = "{field: \'Property\',title: \'性质\',width: 80}";
            }
            return(fields);
        }
Example #8
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));
        }
Example #9
0
        public string GetRegions()
        {
            string id = Request.QueryString["id"];

            SM.YuQing.BLL.Person           bll        = new SM.YuQing.BLL.Person();
            List <SM.YuQing.Model.Regions> regions    = bll.GetRegions(Convert.ToInt32(id));
            List <SM.YuQing.Model.Regions> allRegions = (new SM.YuQing.BLL.Regions()).GetModelList("");
            string content = "";

            foreach (SM.YuQing.Model.Regions item in allRegions)
            {
                if (regions.Contains(item))
                {
                    content += "<input id='" + item.ID + "' type='checkbox' checked='true'>" + item.Region;
                }
                else
                {
                    content += "<input id='" + item.ID + "' type='checkbox'>" + item.Region;
                }
            }
            return(content);
        }
Example #10
0
 public string GetUserDisplayName()
 {
     SM.YuQing.BLL.Person   bll    = new SM.YuQing.BLL.Person();
     SM.YuQing.Model.Person person = bll.GetModelFromCode(Context.User.Identity.Name);
     return(person.Name);
 }
Example #11
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));
        }