Example #1
0
        private static BannedIpAddressCollection DBMapping(DBBannedIpAddressCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            var ipCollection = new BannedIpAddressCollection();

            foreach (var dbItem in dbCollection)
            {
                var item = DBMapping(dbItem);
                ipCollection.Add(item);
            }
            return(ipCollection);
        }
        /// <summary>
        /// Gets all IP addresses
        /// </summary>
        /// <returns>IP address collection</returns>
        public override DBBannedIpAddressCollection GetIpAddressAll()
        {
            DBBannedIpAddressCollection ipCollection = new DBBannedIpAddressCollection();
            Database  db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_BannedIpAddressLoadAll");

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBBannedIpAddress setting = GetIpAddressFromReader(dataReader);
                    ipCollection.Add(setting);
                }
            }
            return(ipCollection);
        }
Example #3
0
        /// <summary>
        /// Gets all IP addresses
        /// </summary>
        /// <returns>An IP address collection</returns>
        public static BannedIpAddressCollection GetBannedIpAddressAll()
        {
            string key  = BLACKLIST_ALLIP_KEY;
            object obj2 = NopCache.Get(key);

            if (CacheEnabled && (obj2 != null))
            {
                return((BannedIpAddressCollection)obj2);
            }

            DBBannedIpAddressCollection dbCollection = DBProviderManager <DBBlacklistProvider> .Provider.GetIpAddressAll();

            BannedIpAddressCollection collection = DBMapping(dbCollection);

            if (IpBlacklistManager.CacheEnabled)
            {
                NopCache.Max(key, collection);
            }
            return(collection);
        }