private MonthlyFileHeuristics CreateMonthlyFileHeuristics(WurmLogMonthlyFile wurmLogMonthlyFile)
        {
            var dayMap = new Dictionary<int, DayInfo>();
            var days = wurmLogMonthlyFile.DayToHeuristicsMap.OrderBy(pair => pair.Key).ToArray();
            int totalLines = 0;
            foreach (var pair in days)
            {
                dayMap.Add(pair.Key,
                    new DayInfo(
                        pair.Value.FilePositionInBytes,
                        pair.Value.LinesCount,
                        totalLines
                        ));
                totalLines += pair.Value.LinesCount;
            }

            return new MonthlyFileHeuristics(
                wurmLogMonthlyFile.LogDate,
                dayMap,
                wurmLogMonthlyFile.HasValidBytePositions);
        }
        private WurmLogMonthlyFile GetEntityForFile(LogFileInfo logFileInfo)
        {
            WurmLogMonthlyFile fileData;
            bool isNewFile = false;
            bool needsSaving = false;
            if (!persistentData.Entity.WurmLogFiles.TryGetValue(logFileInfo.FileNameNormalized, out fileData))
            {
                fileData = new WurmLogMonthlyFile { FileName = logFileInfo.FileNameNormalized };
                isNewFile = true;
                needsSaving = true;
            }

            FileInfo fileInfo = new FileInfo(logFileInfo.FullPath);
            var fileLength = fileInfo.Length;
            if (fileData.LastKnownSizeInBytes < fileLength)
            {
                var extractor = monthlyHeuristicsExtractorFactory.Create(logFileInfo);
                var results = extractor.ExtractDayToPositionMap();
                fileData.LogDate = results.LogDate;
                fileData.DayToHeuristicsMap = results.Heuristics;
                fileData.HasValidBytePositions = results.HasValidBytePositions;
                fileData.LastKnownSizeInBytes = fileLength;
                needsSaving = true;
            }
            fileData.LastUpdated = Time.Get.LocalNowOffset;

            if (isNewFile) persistentData.Entity.WurmLogFiles.Add(fileData.FileName, fileData);
            if (needsSaving) persistentData.FlagAsChanged();
            return fileData;
        }