async Task <SkillInfo> TryGetSkillFromDumps(string skillName, ServerGroup serverGroup) { SkillInfo skill = null; var dump = await skillDumps.GetSkillDumpAsync(serverGroup).ConfigureAwait(false); var skillinfo = dump?.TryGetSkillLevel(skillName); if (skillinfo != null) { skill = new SkillInfo(skillName, skillinfo.Value, dump.Stamp, null) { Server = await character.TryGetHistoricServerAtLogStampAsync(dump.Stamp) }; } return(skill); }
async Task FindLatestDumpForServerGroup(ServerGroup serverGroup) { var beginDate = Time.Get.LocalNowOffset; var maxBackDate = Time.Get.LocalNow - MaxDaysBack; SkillDumpInfo[] dumps = new SkillDumpInfo[0]; if (skillDumpsDirectory.Exists) { dumps = skillDumpsDirectory.GetFiles().Select(ConvertFileInfoToSkillDumpInfo) .Where(info => info != null && info.Stamp > maxBackDate) .OrderByDescending(info => info.Stamp) .ToArray(); } SkillDump foundDump = null; foreach (var dumpInfo in dumps) { var server = await character.TryGetHistoricServerAtLogStampAsync(dumpInfo.Stamp).ConfigureAwait(false); if (server != null) { if (server.ServerGroup == serverGroup) { foundDump = new RealSkillDump(serverGroup, dumpInfo, logger); break; } } else { logger.Log(LogLevel.Info, "Could not identify server for skill dump: " + dumpInfo.FileInfo.FullName, this, null); } } if (foundDump != null) { latestSkillDumps[serverGroup] = foundDump; } else { // if nothing found, place a stub to prevent another file search latestSkillDumps[serverGroup] = new StubSkillDump(serverGroup); } lastRebuild = beginDate; }
async Task <IWurmServer> TryGetServerAtStamp(DateTime dateTime) { var result = await character.TryGetHistoricServerAtLogStampAsync(dateTime).ConfigureAwait(false); if (result == null) { logger.Log(LogLevel.Info, string.Format("Server could not be identified for character {0} at stamp {1}", character.Name.Capitalized, dateTime), this, null); return(null); } return(result); }
public async Task GetHistoricServerAtLogStamp_Gets() { var server = await wurmCharacter.TryGetHistoricServerAtLogStampAsync(new DateTime(2014, 12, 15)); Expect(server.ServerName, EqualTo(new ServerName("Exodus"))); }