示例#1
0
        public void WriteLog(enumOperator action, string message, enumLog4net logLevel)
        {
            switch (logLevel)
            {
            case enumLog4net.INFO:
                _log.Info(Utils.GetIP(), CurrentUser.Name, Request.Url.ToString(), action.ToString(), message);
                return;

            case enumLog4net.WARN:
                _log.Warn(Utils.GetIP(), CurrentUser.Name, Request.Url.ToString(), action.ToString(), message);
                return;

            default:
                _log.Error(Utils.GetIP(), CurrentUser.Name, Request.Url.ToString(), action.ToString(), message);
                return;
            }
        }
示例#2
0
        /// <summary>
        /// 操作日志
        /// </summary>
        public void WriteLog(Common.Enums.enumOperator action, string message, Common.Enums.enumLog4net logLevel)
        {
            switch (logLevel)
            {
            case Common.Enums.enumLog4net.INFO:
                _log.Info(Utils.GetIP(), this.CurrentUser.Name, Request.Url.ToString(), action.ToString(), message);
                break;

            case Common.Enums.enumLog4net.WARN:
                _log.Warn(Utils.GetIP(), this.CurrentUser.Name, Request.Url.ToString(), action.ToString(), message);
                break;

            default:
                _log.Error(Utils.GetIP(), this.CurrentUser.Name, Request.Url.ToString(), action.ToString(), message);
                break;
            }
        }
示例#3
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="email"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        //[ValidateAntiForgeryToken]
        public ActionResult UserLogin(string email, string pwd)
        {
            var json = new JsonHelper()
            {
                Msg = "", Status = ""
            };

            try
            {
                var user = userManage.UserLogin(email, pwd);
                if (user != null)
                {
                    if (user.UserStatu == "1")
                    {
                        json.Msg = "用户状态已经被锁定,请联系管理员进行解锁";
                        log.Warn(Utils.GetIP(), user.UserEmail, Request.Url.ToString(), "Login", "用户登录,结果为:" + json.Msg);
                        return(Json(json));
                    }
                    json.Msg    = "登录成功";
                    json.Status = "Y";
                    log.Info(Utils.GetIP(), user.UserEmail, Request.Url.ToString(), "Login", "用户登录,结果为:" + json.Msg);
                    return(RedirectToAction("index", "Home"));
                }
                else
                {
                    json.Msg = "密码错误或者用户名错误";
                    log.Error(Utils.GetIP(), email, Request.Url.ToString(), "Login", "用户登录,结果为:" + json.Msg);
                    return(Json(json));
                }
            }
            catch (Exception e)
            {
                json.Msg = e.Message;
                log.Error(Utils.GetIP(), email, Request.Url.ToString(), "Login", "用户登录,结果为:" + json.Msg);
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public ActionResult Login(Domain.SYS_USER item)
        {
            var json = new JsonHelper()
            {
                Msg = "登录成功", Status = "n"
            };

            try
            {
                //获取表单验证码
                var code = Request.Form["code"];
                if (Session["gif"] != null)
                {
                    //判断用户输入的验证码是否正确
                    if (!string.IsNullOrEmpty(code) && code.ToLower() == Session["gif"].ToString().ToLower())
                    {
                        //调用登录验证接口 返回用户实体类
                        var users = UserManage.UserLogin(item.ACCOUNT.Trim(), item.PASSWORD.Trim());
                        if (users != null)
                        {
                            //是否锁定
                            if (users.ISCANLOGIN)
                            {
                                json.Msg = "用户已锁定,禁止登录,请联系管理员进行解锁";
                                log.Warn(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
                                return(Json(json));
                            }

                            var acconut = this.UserManage.GetAccountByUser(users);

                            //系统访问正常
                            if (acconut.System_Id.Count > 0)
                            {
                                //是否启用单用户登录
                                if (System.Configuration.ConfigurationManager.AppSettings["IsSingleLogin"] == "True")
                                {
                                    var UserOnline = UserOnlineManage.LoadListAll(p => p.FK_UserId == users.ID).FirstOrDefault();
                                    if (UserOnline != null && UserOnline.IsOnline)
                                    {
                                        json.Msg = "当前用户已登录,系统不允许重复登录!登录IP:" + UserOnline.UserIP;
                                        log.Error(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "重复登录:" + json.Msg);
                                    }
                                    else
                                    {
                                        //写入Session 当前登录用户
                                        SessionHelper.SetSession("CurrentUser", acconut);

                                        //记录用户信息到Cookies
                                        string cookievalue = "{\"id\":\"" + acconut.Id + "\",\"username\":\"" + acconut.LogName +
                                                             "\",\"password\":\"" + acconut.PassWord + "\",\"ToKen\":\"" +
                                                             Session.SessionID + "\"}";
                                        CookieHelper.SetCookie("cookie_rememberme", new Common.CryptHelper.AESCrypt().Encrypt(cookievalue),
                                                               null);

                                        json.Status = "y";
                                        json.ReUrl  = "/Sys/Home/Index";
                                        log.Info(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
                                    }
                                }
                                else
                                {
                                    //写入Session 当前登录用户
                                    SessionHelper.SetSession("CurrentUser", acconut);

                                    //记录用户信息到Cookies
                                    string cookievalue = "{\"id\":\"" + acconut.Id + "\",\"username\":\"" + acconut.LogName +
                                                         "\",\"password\":\"" + acconut.PassWord + "\",\"ToKen\":\"" +
                                                         Session.SessionID + "\"}";
                                    CookieHelper.SetCookie("cookie_rememberme", new Common.CryptHelper.AESCrypt().Encrypt(cookievalue),
                                                           null);

                                    json.Status = "y";
                                    json.ReUrl  = "/Sys/Home/Index";
                                    log.Info(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
                                }
                            }
                            else
                            {
                                json.Msg = "站点来源不可信,系统拒绝登录";
                                log.Warn(Utils.GetIP(), "其他系统访问者", "", "Login", "其他系统登录失败,原因:系统验证错误,系统拒绝登录");
                            }
                        }
                        else
                        {
                            json.Msg = "用户名或密码不正确";
                            log.Error(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
                        }
                    }
                    else
                    {
                        json.Msg = "验证码不正确";
                        log.Error(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
                    }
                }
                else
                {
                    json.Msg = "验证码已过期,请刷新验证码";
                    log.Error(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
                }
            }
            catch (Exception e)
            {
                json.Msg = e.Message;
                log.Error(Utils.GetIP(), item.ACCOUNT, Request.Url.ToString(), "Login", "系统登录,登录结果:" + json.Msg);
            }
            return(Json(json, JsonRequestBehavior.AllowGet));
        }