Beispiel #1
0
        /// <summary>
        /// 登录成功后,记录日志
        /// </summary>
        public void Log(string OptContent, string OptRemark)
        {
            var      currentAdminEx = new CurrentAdminEx();
            AdminLog entity         = new AdminLog()
            {
                OptContent = OptContent, OptRemark = OptRemark
            };

            entity.IP           = currentAdminEx.LoginedIP;
            entity.UserID       = currentAdminEx.SAID;
            entity.UserName     = currentAdminEx.SAName;
            entity.UserNickName = currentAdminEx.SANickName;
            base.Add(entity);
        }
Beispiel #2
0
        public void DeleteSysAdmin(int said)
        {
            var sysAdmin = new CurrentAdminEx();

            if (sysAdmin.SAID == said)
            {
                throw new InvalidOperationException("无法删除当前已登录管理员");
            }
            SystemAdmin admin = base.GetByCondition(new DirectSpecification <SystemAdmin>(sa => sa.SAID == said));

            using (TransactionScope scope = new TransactionScope())
            {
                Remove(admin);
                _adminLogService.Log("删除系统管理员", "管理员姓名:" + admin.SANickName + " || 帐号:" + admin.SAName + " || 性别:" + (admin.SASex ? "男" : "女") + " || 注册时间:" + admin.RegTime);
                scope.Complete();
            }
        }
Beispiel #3
0
        public ActionResult Logout()
        {
            bool logged = User.Identity.IsAuthenticated;

            if (!logged)
            {
                return(Content("未登录,不需要注销!"));
            }
            CurrentAdminEx curUser = new CurrentAdminEx();

            FormsAuthentication.SignOut();
            if (Request.Cookies["WquanAdminAuth"] != null)
            {
                Request.Cookies["WquanAdminAuth"].Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(Request.Cookies["WquanAdminAuth"]);
            }
            Request.Cookies.Clear();
            Session.Clear();
            _adminCacheService.Remove(AdminCacheService.SysAdmin_Current_prefix + curUser.SAName);
            string js = "window.top.location='/';";

            return(JavaScript(js));
        }