Example #1
0
        /// <summary>
        /// 根据IP查找用户
        /// </summary>
        /// <param name="ip">ip地址</param>
        /// <returns>用户信息</returns>
        public static UserInfo GetShortUserInfoByIP(string ip)
        {
            IDataReader reader;
            UserInfo userInfo = null;

            if (appDBCache)
            {
                userInfo = IUserService.GetUserInfoByIP(ip);
                if (userInfo == null)
                {
                    reader = DatabaseProvider.GetInstance().GetUserInfoByIP(ip);
                    if (reader.Read())
                    {
                        userInfo = LoadSingleUserInfo(reader);
                        reader.Close();
                    }
                    //if (userInfo != null)
                    //    IUserService.CreateUser(userInfo);
                }
            }
            else
            {
                reader = DatabaseProvider.GetInstance().GetUserInfoByIP(ip);
                if (reader.Read())
                {
                    userInfo = LoadSingleUserInfo(reader);
                    reader.Close();
                }
            }
            return userInfo;
        }