Пример #1
0
 public async Task <IList <LogEntry> > ScanLogsAsync(DateTime minDate, DateTime maxDate, LogType logType,
                                                     ScanResultOrdering scanResultOrdering)
 {
     return(await logsHistory.ScanAsync(new LogSearchParameters()
     {
         CharacterName = character.Name.Normalized,
         LogType = logType,
         MinDate = minDate,
         MaxDate = maxDate,
         ScanResultOrdering = scanResultOrdering
     }).ConfigureAwait(false));
 }
Пример #2
0
        private async Task ScanLogsHistory(TimeSpan maxTimeToLookBackInLogs)
        {
            DateTime maxDate = await currentServerLookupFinished.Task.ConfigureAwait(false);

            DateTime minDate = maxDate.SubtractConstrain(maxTimeToLookBackInLogs);

            // if already scanned, optimize
            if (scannedMinDate != null)
            {
                if (minDate >= scannedMinDate)
                {
                    // do not scan, if this period has already been scanned
                    return;
                }
                maxDate = scannedMinDate.Value;
            }

            var entries = await logsHistory.ScanAsync(new LogSearchParameters()
            {
                CharacterName = character.Name.Normalized,
                LogType       = LogType.Skills,
                MinDate       = minDate,
                MaxDate       = maxDate
            }).ConfigureAwait(false);

            SkillEntryParser parser = new SkillEntryParser(logger);

            foreach (var wurmLogEntry in entries)
            {
                SkillInfo skillInfo = parser.TryParseSkillInfoFromLogLine(wurmLogEntry);
                if (skillInfo != null)
                {
                    var entryServer =
                        await
                        character.TryGetHistoricServerAtLogStampAsync(wurmLogEntry.Timestamp).ConfigureAwait(false);

                    if (entryServer != null)
                    {
                        skillInfo.Server = entryServer;
                        skillsMap.UpdateSkill(skillInfo, entryServer);
                    }
                    else
                    {
                        logger.Log(LogLevel.Info,
                                   "Skill info rejected, server could not be identified for this entry: " + wurmLogEntry,
                                   this,
                                   null);
                    }
                }
            }

            scannedMinDate = minDate;
        }