Beispiel #1
0
        public WurmServerHistory(
            [NotNull] string dataDirectoryFullPath,
            [NotNull] IWurmLogsHistory wurmLogsHistory,
            IWurmServerList wurmServerList,
            IWurmApiLogger logger,
            IWurmLogsMonitorInternal wurmLogsMonitor,
            IWurmLogFiles wurmLogFiles,
            IInternalEventAggregator internalEventAggregator,
            [NotNull] IWurmServerGroups wurmServerGroups,
            [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (dataDirectoryFullPath == null)
            {
                throw new ArgumentNullException(nameof(dataDirectoryFullPath));
            }
            if (wurmLogsHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsHistory));
            }
            if (wurmServerGroups == null)
            {
                throw new ArgumentNullException(nameof(wurmServerGroups));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }
            this.wurmLogsHistory  = wurmLogsHistory;
            this.wurmServerGroups = wurmServerGroups;
            this.wurmApiConfig    = wurmApiConfig;

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(dataDirectoryFullPath);

            var persistentLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var collection = persistentLibrary.GetCollection("serverhistory");

            var providerFactory = new ServerHistoryProviderFactory(
                collection,
                wurmLogsHistory,
                wurmServerList,
                logger,
                wurmLogsMonitor,
                wurmLogFiles,
                internalEventAggregator);


            jobExecutor = new JobExecutor(providerFactory, persistentLibrary);
            runner      = new QueuedJobsSyncRunner <object, ServerName>(jobExecutor, logger);
        }
        public WurmLogsHistory([NotNull] IWurmLogFiles wurmLogFiles, [NotNull] IWurmApiLogger logger,
                               [NotNull] string heuristicsDataDirectory, [NotNull] LogFileStreamReaderFactory logFileStreamReaderFactory,
                               [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (wurmLogFiles == null)
            {
                throw new ArgumentNullException(nameof(wurmLogFiles));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (heuristicsDataDirectory == null)
            {
                throw new ArgumentNullException(nameof(heuristicsDataDirectory));
            }
            if (logFileStreamReaderFactory == null)
            {
                throw new ArgumentNullException(nameof(logFileStreamReaderFactory));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(heuristicsDataDirectory);

            var persistentLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var heuristicsCollection = persistentLibrary.GetCollection("heuristics");

            var logsScannerFactory = new LogsScannerFactory(
                new LogFileParserFactory(logger),
                logFileStreamReaderFactory,
                new MonthlyLogFilesHeuristics(
                    heuristicsCollection,
                    wurmLogFiles,
                    new MonthlyHeuristicsExtractorFactory(logFileStreamReaderFactory, logger, wurmApiConfig)),
                wurmLogFiles,
                logger,
                wurmApiConfig);

            runner =
                new QueuedJobsSyncRunner <LogSearchParameters, ScanResult>(
                    new ScanJobExecutor(logsScannerFactory, persistentLibrary, logger),
                    logger);
        }