private void FillGaps(Dictionary <int, WurmLogMonthlyFileHeuristics> dayToHeuristicsMap, int lastDay, int dayNow, long filePositionInBytes)
 {
     for (int i = lastDay + 1; i < dayNow; i++)
     {
         dayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
         {
             DayOfMonth          = i,
             FilePositionInBytes = filePositionInBytes,
             LinesCount          = 0
         };
     }
 }
        private void FillDaysBeforeFirstFoundDay(Dictionary <int, WurmLogMonthlyFileHeuristics> dayToHeuristicsMap)
        {
            var firstDay = records.First().Day;

            for (int i = 1; i < firstDay; i++)
            {
                dayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
                {
                    DayOfMonth          = i,
                    FilePositionInBytes = 0,
                    LinesCount          = 0
                };
            }
        }
        private void AdvanceDays(string line, long lastReadLineStartPosition)
        {
            WurmLogMonthlyFileHeuristics lastDayInfo = DayToHeuristicsMap[DayToHeuristicsMap.Keys.Max()];
            lastDayInfo.LinesCount = LineCounter - 1;
            LineCounter = 1;

            // add file positions for new days
            for (int i = PreviousDay + 1; i <= CurrentDay; i++)
            {
                DayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
                {
                    DayOfMonth = i,
                    FilePositionInBytes = lastReadLineStartPosition,
                };
            }
            PreviousDay = CurrentDay;
        }
        private void FillDaysAfterLastFoundDay(Dictionary <int, WurmLogMonthlyFileHeuristics> dayToHeuristicsMap)
        {
            var lastRecordDay = records.Last().Day;
            int maxDay        = DayCountInThisLogMonth;

            if (ThisLogIsForCurrentMonth)
            {
                maxDay = today.Day;
            }

            for (int i = lastRecordDay + 1; i <= maxDay; i++)
            {
                dayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
                {
                    DayOfMonth          = i,
                    FilePositionInBytes = finalPositionInLogFile,
                    LinesCount          = 0
                };
            }
        }
        private void FinalizeCurrentDay(
            Dictionary <int, WurmLogMonthlyFileHeuristics> dayToHeuristicsMap,
            int day,
            int lineCounter,
            long dayBeginFilePosition,
            bool endOfFile = false)
        {
            if (endOfFile)
            {
                if (ThisLogIsForCurrentMonth && day == today.Day)
                {
                    lineCounter = int.MaxValue;
                }
            }

            dayToHeuristicsMap[day] = new WurmLogMonthlyFileHeuristics()
            {
                DayOfMonth          = day,
                FilePositionInBytes = dayBeginFilePosition,
                LinesCount          = lineCounter
            };
        }
        public void Complete(long finalPositionInLogFile)
        {
            AssertResultNotTaken();

            if (NoDataGathered)
            {
                return;
            }

            var lastDayProcessed = DayToHeuristicsMap.Keys.Max();
            WurmLogMonthlyFileHeuristics lastDayInfo = DayToHeuristicsMap[lastDayProcessed];

            if (ThisLogIsForCurrentMonth)
            {
                if (lastDayProcessed == today.Day)
                {
                    // we dont want limiting todays line counter
                    lastDayInfo.LinesCount = int.MaxValue;
                    LineCounter = 0;
                }
                else
                {
                    lastDayInfo.LinesCount = LineCounter;
                    LineCounter = 0;
                }

                for (int i = lastDayProcessed + 1; i <= today.Day; i++)
                {
                    if (i == today.Day)
                    {
                        //today has not yet ended, do not set a line limit
                        DayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
                        {
                            DayOfMonth = i,
                            FilePositionInBytes = finalPositionInLogFile,
                            LinesCount = int.MaxValue
                        };
                    }
                    else
                    {
                        //this day is past, it has no lines
                        DayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
                        {
                            DayOfMonth = i,
                            FilePositionInBytes = finalPositionInLogFile,
                            LinesCount = 0
                        };
                    }
                }
            }
            else
            {
                lastDayInfo.LinesCount = LineCounter;
                LineCounter = 0;
                for (int i = lastDayProcessed + 1; i <= DayCountInThisLogMonth; i++)
                {
                    //this day is past, it has no lines
                    DayToHeuristicsMap[i] = new WurmLogMonthlyFileHeuristics()
                    {
                        DayOfMonth = i,
                        FilePositionInBytes = finalPositionInLogFile,
                        LinesCount = 0
                    };
                }
            }
        }