/// <summary> /// Extracts all entries spanning given scan parameters. /// Extraction is performed on a separate thread. /// Returned entries are in descending timestamp order. /// </summary> /// <returns></returns> public ScanResult Scan() { logSearchParameters.AssertAreValid(); var filesManager = wurmLogFiles.GetForCharacter(new CharacterName(logSearchParameters.CharacterName)); LogFileInfo[] logFileInfos = filesManager.GetLogFiles(logSearchParameters.MinDate, logSearchParameters.MaxDate) .Where(info => info.LogType == logSearchParameters.LogType).ToArray(); cancellationManager.ThrowIfCancelled(); CharacterMonthlyLogHeuristics characterHeuristics = monthlyHeuristics.GetForCharacter(new CharacterName(logSearchParameters.CharacterName)); cancellationManager.ThrowIfCancelled(); var result = GetEntries(logFileInfos, characterHeuristics); switch (logSearchParameters.ScanResultOrdering) { case ScanResultOrdering.Ascending: return(new ScanResult(result.OrderBy(entry => entry.Timestamp).ToList())); case ScanResultOrdering.Descending: return(new ScanResult(result.OrderByDescending(entry => entry.Timestamp).ToList())); default: throw new Exception("Unsupported ScanResultOrdering value: " + logSearchParameters.ScanResultOrdering); } }
public void Setup() { ClientMock.PopulateFromZip(Path.Combine(TestPaksZippedDirFullPath, "logs-samples-emptyfiles.7z")); TestGuyDirectoryInfo = new DirectoryInfo(ClientMock.InstallDirectory.FullPath) .GetDirectories("players") .Single() .GetDirectories("Testguy") .Single(); TotalFileCount = TestGuyDirectoryInfo.GetDirectories("logs").Single().GetFiles().Length; System = Fixture.WurmApiManager.WurmLogFiles; TestGuyLogFiles = System.GetForCharacter(TestGuyCharacterName); }
public ServerHistoryProvider Create(CharacterName characterName) { if (characterName == null) { throw new ArgumentNullException(nameof(characterName)); } var persistent = persistentCollection.GetObject <PersistentModel.ServerHistory>(characterName.Normalized); var wurmCharacterLogFiles = wurmLogFiles.GetForCharacter(characterName); return(new ServerHistoryProvider( characterName, persistent, wurmLogsMonitor, wurmLogsHistory, wurmServerList, logger, wurmCharacterLogFiles, internalEventAggregator)); }
private void Rebuild() { List <Exception> exceptions = new List <Exception>(); lock (locker) { var characters = wurmCharacterDirectories.GetAllCharacters().ToHashSet(); var newMap = characterNameToEngineManagers.ToDictionary(pair => pair.Key, pair => pair.Value); foreach (var characterName in characters) { try { LogsMonitorEngineManager man; if (!newMap.TryGetValue(characterName, out man)) { var manager = new LogsMonitorEngineManager( characterName, new CharacterLogsMonitorEngineFactory( logger, new SingleFileMonitorFactory( logFileStreamReaderFactory, new LogFileParser(logger)), wurmLogFiles.GetForCharacter(characterName), internalEventAggregator), publicEventInvoker, logger, internalEventInvoker); newMap.Add(characterName, manager); } } catch (Exception exception) { exceptions.Add(exception); } } characterNameToEngineManagers = newMap; } if (exceptions.Any()) { throw new AggregateException(exceptions); } }
public virtual CharacterMonthlyLogHeuristics GetForCharacter(CharacterName characterName) { if (characterName == null) { throw new ArgumentNullException(nameof(characterName)); } CharacterMonthlyLogHeuristics heuristics; if (!cache.TryGetValue(characterName, out heuristics)) { IPersistent <WurmCharacterLogsEntity> persistentData = heuristicsPersistentCollection.GetObject <WurmCharacterLogsEntity>(characterName.Normalized); heuristics = new CharacterMonthlyLogHeuristics( persistentData, monthlyHeuristicsExtractorFactory, wurmLogFiles.GetForCharacter(characterName)); cache.Add(characterName, heuristics); } return(heuristics); }