コード例 #1
0
 public FilterIPController(FilterIPApp filterIPApp)
 {
     this.filterIPApp = filterIPApp;
 }
コード例 #2
0
ファイル: UserApp.cs プロジェクト: zhaopeifa/NFine.Framework
        //登录
        public UserEntity CheckLogin(string username, string password)
        {
            bool   DL = true;
            string ip = Net.Ip;
            //获取访问通过的ip
            List <FilterIPEntity> list = new FilterIPApp().GetList();

            if (list != null && list.Count != 0)
            {
                foreach (FilterIPEntity fi in list)
                {
                    bool b = Net.isinip(ip, fi.F_StartIP, fi.F_EndIP);
                    if (b)
                    {
                        DL = false;
                        break;
                    }
                }

                if (DL)
                {
                    UserEntity userEntity = service.FindEntity(t => t.F_Account == username);
                    if (userEntity != null)
                    {
                        if (userEntity.F_EnabledMark == true)
                        {
                            UserLogOnEntity userLogOnEntity = userLogOnApp.GetForm(userEntity.F_Id);
                            string          dbPassword      = Md5.md5(DESEncrypt.Encrypt(password.ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower();
                            if (dbPassword == userLogOnEntity.F_UserPassword)
                            {
                                DateTime lastVisitTime = DateTime.Now;
                                int      LogOnCount    = (userLogOnEntity.F_LogOnCount).ToInt() + 1;
                                if (userLogOnEntity.F_LastVisitTime != null)
                                {
                                    userLogOnEntity.F_PreviousVisitTime = userLogOnEntity.F_LastVisitTime.ToDate();
                                }
                                userLogOnEntity.F_LastVisitTime = lastVisitTime;
                                userLogOnEntity.F_LogOnCount    = LogOnCount;
                                userLogOnApp.UpdateForm(userLogOnEntity);
                                return(userEntity);
                            }
                            else
                            {
                                throw new Exception("密码不正确,请重新输入");
                            }
                        }
                        else
                        {
                            throw new Exception("账户被系统锁定,请联系管理员");
                        }
                    }
                    else
                    {
                        throw new Exception("账户不存在,请重新输入");
                    }
                }
                else
                {
                    throw new Exception("您的ip被禁用了!");
                }
            }
            else
            {
                UserEntity userEntity = service.FindEntity(t => t.F_Account == username);
                if (userEntity != null)
                {
                    if (userEntity.F_EnabledMark == true)
                    {
                        UserLogOnEntity userLogOnEntity = userLogOnApp.GetForm(userEntity.F_Id);
                        string          dbPassword      = Md5.md5(DESEncrypt.Encrypt(password.ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower();
                        if (dbPassword == userLogOnEntity.F_UserPassword)
                        {
                            DateTime lastVisitTime = DateTime.Now;
                            int      LogOnCount    = (userLogOnEntity.F_LogOnCount).ToInt() + 1;
                            if (userLogOnEntity.F_LastVisitTime != null)
                            {
                                userLogOnEntity.F_PreviousVisitTime = userLogOnEntity.F_LastVisitTime.ToDate();
                            }
                            userLogOnEntity.F_LastVisitTime = lastVisitTime;
                            userLogOnEntity.F_LogOnCount    = LogOnCount;
                            userLogOnApp.UpdateForm(userLogOnEntity);
                            return(userEntity);
                        }
                        else
                        {
                            throw new Exception("密码不正确,请重新输入");
                        }
                    }
                    else
                    {
                        throw new Exception("账户被系统锁定,请联系管理员");
                    }
                }
                else
                {
                    throw new Exception("账户不存在,请重新输入");
                }
            }
        }