public TimeCountingRecords CalculateCountingRecords(Person person)
        {
            //get all snapshots
            var snapshots        = CalculateSnapshots(person);
            var trimmedSnapshots = TrimRecordsByDefinedTime(snapshots.Data);

            //calculate total time spent in different activities
            var countingRecords = new TimeCountingRecords();

            trimmedSnapshots.ToList().ForEach(
                record =>
                countingRecords.Add(record, person.CheckpointRate));

            return(countingRecords);
        }
        public IEnumerable <TimeCountingRecord> CalculateDailyCountingRecords(Person person)
        {
            var snapshots        = CalculateSnapshots(person); //get all snapshots
            var trimmedSnapshots = TrimRecordsByDefinedTime(snapshots.Data);

            //calculate daily time spent in different activities
            var dayCountingRecords = new List <TimeCountingRecord>();

            //calculate total time spent in different activities
            var countingRecords = new TimeCountingRecords();

            var  dayDate      = new DateTime();
            bool isDayDateSet = false;

            //get total daily time of activities
            trimmedSnapshots.ToList().ForEach(
                record =>
            {
                //get current record date
                DateTime recordDate = record.Date;

                //check if we set current day date
                if (!isDayDateSet)
                {
                    dayDate      = record.Date;
                    isDayDateSet = true;
                }

                //compare current day date and record date
                if (AreDatesEqual(recordDate, dayDate))
                {
                    countingRecords.Add(record, person.CheckpointRate);
                }
                else
                {
                    dayCountingRecords.Add(countingRecords.Records.Last());

                    isDayDateSet = false;

                    countingRecords = null;
                    countingRecords = new TimeCountingRecords();
                }
            });

            return(dayCountingRecords);
        }
Exemplo n.º 3
0
 public void SaveCountingRecords(TimeCountingRecords records, string toFilePath)
 {
     csvWriter.WriteData(records.Records, toFilePath);
 }