Beispiel #1
0
        /// <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);
            }
        }