Beispiel #1
0
        public void Initialise(ILogger logger)
        {
            GetLogger = logger;

            GeoIpStatistics geoIpStatistics = new GeoIpStatistics();

            GeoIpStatistics = geoIpStatistics as IGeoIpStatistics;
            GeoIpUpdate     = geoIpStatistics as IGeoIpStatisticsUpdate;
        }
Beispiel #2
0
        public GeoIpService(ISettingsProvider settingsProvider)
        {
            _geoIpStatistics = Initialisation.GeoIpUpdate ?? throw new InvalidOperationException();

            ThreadManager.Initialise();
            _geoIpSettings = settingsProvider.GetSettings <GeoIpPluginSettings>("SieraDeltaGeoIpPluginConfiguration");

            // if the connection string is a file, it contains the actual connection string, load it
            if (_geoIpSettings.DatabaseConnectionString.IndexOfAny(Path.GetInvalidPathChars()) == -1 &&
                File.Exists(_geoIpSettings.DatabaseConnectionString))
            {
                using (StreamReader rdr = new StreamReader(_geoIpSettings.DatabaseConnectionString))
                {
                    _geoIpSettings.DatabaseConnectionString = rdr.ReadToEnd();
                }
            }

            ThreadManager dataThread = null;

            switch (_geoIpSettings.GeoIpProvider)
            {
            case Enums.GeoIpProvider.Firebird:
                dataThread = new FirebirdDataProvider(_geoIpSettings, _tempIpCity);
                break;

            case Enums.GeoIpProvider.MySql:
                dataThread = new MySqlProvider(_geoIpSettings, _tempIpCity);
                break;

            case Enums.GeoIpProvider.MSSql:
                dataThread = new MSSQLProvider(_geoIpSettings, _tempIpCity);
                break;

            default:
                throw new InvalidOperationException();
            }

            _geoIpProvider = dataThread as IGeoIpProvider;

            if (_geoIpSettings.CacheAllData)
            {
                dataThread.ThreadFinishing += Thread_ThreadFinishing;
                ThreadManager.ThreadStart(dataThread, "Load GeoIp Data", System.Threading.ThreadPriority.Highest);
            }

            // create the cache
            _geoIpCache = new CacheManager("GeoIp Data Cache", new TimeSpan(24, 0, 0), true, false);
        }