Exemple #1
0
        public JsonResult CheckLogin()
        {
            string Account = Request.Form["Account"];          //账户
            string Pwd = Request.Form["Password"];                    //密码
            BASE_USERBLL BASE_USERibll = new BASE_USERBLL();
            BASE_USER BASE_USER = new BASE_USER();
            BASE_COMPANYBLL BASE_COMPANYibll = new BASE_COMPANYBLL();
            BASE_COMPANY BASE_COMPANY = new BASE_COMPANY();
            AMS_SysLogBLL ams_syslogibll = new AMS_SysLogBLL();
            AMS_IPBlacklistBLL ams_ipblacklistibll = new AMS_IPBlacklistBLL();
            IPScanerHelper objScan = new IPScanerHelper();
            string Msg = "";
            #region 登录
            try
            {
                string IPAddress = RequestHelper.GetIPAddress();
                objScan.IP = IPAddress;
                objScan.DataPath = Server.MapPath("../Themes/IPScaner/QQWry.Dat");
                string IPAddressName = objScan.IPLocation();
                //系统管理
                if (Account == ConfigHelper.GetValue("CurrentUserName") && Md5Helper.MD5(Pwd, 32) == ConfigHelper.GetValue("CurrentPassword"))
                {
                    SessionUser user = new SessionUser();
                    user.UserId = "System";
                    user.Account = "System";
                    user.UserName = "******";
                    user.Gender = 1;
                    user.Password = ams_user.Password;
                    user.DepartmentId = "超级管理员";
                    user.DepartmentName = "超级管理员";
                    RequestSession.AddSessionUser(user);
                    Msg = "3";//验证成功
                    ams_syslogibll.AddSysLoginLog(ams_user.Account, "登录成功", IPAddress, IPAddressName);
                }
                else
                {
                    #region 验证
                    ams_ipblacklistibll.TheIpIsRange(IPAddress);
                    string outmsg;
                    ams_user = ams_useribll.UserLogin(Account.Trim(), Pwd.Trim(), out outmsg);
                    if (outmsg != "-1")
                    {
                        if (outmsg == "succeed")
                        {
                            if (ams_user.Enabled == 1)
                            {
                                string DepartmentName = "";
                                ams_organization = ams_organizationibll.GetEntity(ams_user.DepartmentId);
                                if (ams_organization != null)
                                {
                                    DepartmentName = ams_organization.FullName;
                                }
                                SessionUser user = new SessionUser();
                                user.UserId = ams_user.UserId;
                                user.Account = ams_user.Account;
                                user.UserName = ams_user.RealName;
                                user.Gender = ams_user.Gender;
                                user.Password = ams_user.Password;
                                user.Secretkey = ams_user.Secretkey;
                                user.DepartmentId = ams_user.DepartmentId;
                                user.DepartmentName = DepartmentName;
                                RequestSession.AddSessionUser(user);
                                Msg = "3";//验证成功
                                ams_syslogibll.AddSysLoginLog(ams_user.Account, "登录成功", IPAddress, IPAddressName);
                            }
                            else
                            {
                                Msg = "2";//账户锁定
                                ams_syslogibll.AddSysLoginLog(ams_user.Account, "账户锁定", IPAddress, IPAddressName);
                            }
                        }
                        else
                        {
                            Msg = "4";//账户或者密码有错误
                            ams_syslogibll.AddSysLoginLog(ams_user.Account, "登录失败", IPAddress, IPAddressName);
                        }
                    }
                    else if (outmsg == "-1")
                    {
                        Msg = "-1";
                    }
                    else
                    {
                        Msg = DbErrorMsg.ReturnMsg;//服务连接不上
                    }
                    #endregion
                }
            }

            catch (Exception ex)
            {
                Msg = ex.Message;
            }
            #endregion
            return Json(Msg);
        }
Exemple #2
0
        public static void AddSessionUser(SessionUser user)
        {
            HttpContext rq = HttpContext.Current;

            rq.Session[SESSION_USER] = user;
        }