Пример #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);
        }
Пример #2
0
 public JobExecutor([NotNull] ServerHistoryProviderFactory serverHistoryProviderFactory,
                    [NotNull] PersistentCollectionsLibrary persistentLibrary)
 {
     if (serverHistoryProviderFactory == null)
     {
         throw new ArgumentNullException(nameof(serverHistoryProviderFactory));
     }
     if (persistentLibrary == null)
     {
         throw new ArgumentNullException(nameof(persistentLibrary));
     }
     this.serverHistoryProviderFactory = serverHistoryProviderFactory;
     this.persistentLibrary            = persistentLibrary;
 }
Пример #3
0
        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);
        }
Пример #4
0
 public ScanJobExecutor([NotNull] LogsScannerFactory logsScannerFactory,
                        [NotNull] PersistentCollectionsLibrary persistentLibrary, [NotNull] IWurmApiLogger logger)
 {
     if (logsScannerFactory == null)
     {
         throw new ArgumentNullException(nameof(logsScannerFactory));
     }
     if (persistentLibrary == null)
     {
         throw new ArgumentNullException(nameof(persistentLibrary));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     this.logsScannerFactory = logsScannerFactory;
     this.persistentLibrary  = persistentLibrary;
     this.logger             = logger;
 }
Пример #5
0
 public JobRunner([NotNull] LiveLogs liveLogs, [NotNull] LogHistory logHistory, [NotNull] WebFeeds webFeeds,
                  [NotNull] PersistentCollectionsLibrary persistentCollectionsLibrary)
 {
     if (liveLogs == null)
     {
         throw new ArgumentNullException(nameof(liveLogs));
     }
     if (logHistory == null)
     {
         throw new ArgumentNullException(nameof(logHistory));
     }
     if (webFeeds == null)
     {
         throw new ArgumentNullException(nameof(webFeeds));
     }
     if (persistentCollectionsLibrary == null)
     {
         throw new ArgumentNullException(nameof(persistentCollectionsLibrary));
     }
     this.liveLogs   = liveLogs;
     this.logHistory = logHistory;
     this.webFeeds   = webFeeds;
     this.persistentCollectionsLibrary = persistentCollectionsLibrary;
 }
 public void Setup()
 {
     DataDir = TempDirectoriesFactory.CreateEmpty();
     var lib = new PersistentCollectionsLibrary(new FlatFilesPersistenceStrategy(DataDir.AbsolutePath));
     System = new SortedServerHistory(lib.DefaultCollection.GetObject<WurmApi.Modules.Wurm.ServerHistory.PersistentModel.ServerHistory>("default"));
 }
Пример #7
0
        public void Bootstrap()
        {
            var marshaller = new WinFormsMainThreadEventMarshaller(mainForm);

            try
            {
                dataDirectory = new SharedDataDirectory();
            }
            catch (LockFailedException)
            {
                // must have exclusive lock on data directory, else most likely another app instance is using it
                //mainForm.Close();
                Application.Exit();
                return;
            }

            persistentLibrary = new PersistentCollectionsLibrary(new FlatFilesPersistenceStrategy(
                Path.Combine(dataDirectory.FullName, "WurmAssistantLiteSettings")));

            var globalSettings =
                new WurmAssistantLiteSettings(
                    persistentLibrary.DefaultCollection.GetObject<GlobalSettingsEntity>("GlobalSettings"))
                {
                    DataDirectoryFullPath = dataDirectory.FullName
                };

            var configurator = new Configurator(globalSettings);

            var valid = configurator.ExecConfig();
            if (!valid)
            {
                // stopping construction and exiting
                //mainForm.Close();
                Application.Exit();
                return;
            }

            var wurmAssistantConfig = configurator.BuildWurmAssistantConfig();

            // bind app specific dependencies
            kernel.Bind<WurmAssistantLiteSettings>().ToConstant(globalSettings);
            kernel.Bind<IWurmAssistantConfig, WurmAssistantConfig>().ToConstant(wurmAssistantConfig);
            kernel.Bind<IEventMarshaller, WinFormsMainThreadEventMarshaller>().ToConstant(marshaller);
            kernel.Bind<IEnvironment, Environment>().ToConstant(environment);
            kernel.Bind<ILogSearcherModuleGui>().To<LogSearcherForm>();

            // bootstrap core
            coreBootstrapper = new CoreBootstrapper(kernel);

            var appStartViewModel = coreBootstrapper.GetAppStartViewModel();
            var appStartView = new AppStartView(appStartViewModel);
            mainForm.SetAppCoreView(appStartView);

            var logOutputViewModel = appStartViewModel.LogOutputViewModel;
            var logOutputTempView = new LogOutputView(logOutputViewModel);
            mainForm.SetLogOutputView(logOutputTempView);

            coreBootstrapper.BootstrapRuntime();
            globalLogger = kernel.Get<LoggerFactory>().Create("WA-Lite");
            globalLogger.Info("Core bootstrapping completed");

            globalLogger.Info("Resolving application runtime");
            var appRunningViewModel = coreBootstrapper.GetAppRunningViewModel();
            var appRunningView = new AppRunningView(appRunningViewModel, globalSettings);
            mainForm.SetAppCoreView(appRunningView);
            globalLogger.Info("Application runtime resolved");

            Bootstrapped = true;
            // save last, so if configuration causes bootstrap crash, it does not get saved
            SaveSettings();
            globalLogger.Info("Settings saved");
        }
Пример #8
0
        public WurmServers(
            [NotNull] IWurmLogsHistory wurmLogsHistory,
            [NotNull] IWurmLogsMonitorInternal wurmLogsMonitor,
            [NotNull] IWurmServerList wurmServerList,
            [NotNull] IHttpWebRequests httpWebRequests,
            [NotNull] string dataDirectory,
            [NotNull] IWurmCharacterDirectories wurmCharacterDirectories,
            [NotNull] IWurmServerHistory wurmServerHistory,
            [NotNull] IWurmApiLogger logger,
            [NotNull] IWurmServerGroups wurmServerGroups,
            [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (wurmLogsHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsHistory));
            }
            if (wurmLogsMonitor == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsMonitor));
            }
            if (wurmServerList == null)
            {
                throw new ArgumentNullException(nameof(wurmServerList));
            }
            if (httpWebRequests == null)
            {
                throw new ArgumentNullException(nameof(httpWebRequests));
            }
            if (dataDirectory == null)
            {
                throw new ArgumentNullException(nameof(dataDirectory));
            }
            if (wurmCharacterDirectories == null)
            {
                throw new ArgumentNullException(nameof(wurmCharacterDirectories));
            }
            if (wurmServerHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmServerHistory));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmServerGroups == null)
            {
                throw new ArgumentNullException(nameof(wurmServerGroups));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }

            this.wurmServerGroups = wurmServerGroups;
            this.wurmApiConfig    = wurmApiConfig;

            liveLogsDataQueue = new LiveLogsDataQueue(wurmLogsMonitor);
            LiveLogs liveLogs = new LiveLogs(liveLogsDataQueue, wurmServerHistory);

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(dataDirectory);

            persistentCollectionsLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var             persistent      = persistentCollectionsLibrary.DefaultCollection.GetObject <ServersData>("WurmServers");
            LogHistorySaved logHistorySaved = new LogHistorySaved(persistent);
            LogHistory      logHistory      = new LogHistory(wurmLogsHistory,
                                                             wurmCharacterDirectories,
                                                             wurmServerHistory,
                                                             logHistorySaved,
                                                             new LogEntriesParser(),
                                                             logger);

            WebFeeds webFeeds = new WebFeeds(httpWebRequests, wurmServerList, logger);

            runner = new QueuedJobsSyncRunner <Job, JobResult>(new JobRunner(liveLogs, logHistory, webFeeds, persistentCollectionsLibrary), logger);

            wurmServerFactory = new WurmServerFactory(runner);

            var descriptions = wurmServerList.All;

            foreach (var serverDescription in descriptions)
            {
                RegisterServer(serverDescription);
            }
        }