Example #1
0
 static MonthShiftReportViewModel()
 {
     criterias = new SetOfCriteriaForSelectingJournalRecords();
     criterias.AddCriteria(new ExcludeСoncomitant()
     {
         IsEnabled = true
     });
     criterias.AddCriteria(new ExcludeRepair()
     {
         IsEnabled = true
     });
 }
Example #2
0
        public ICollection <MonthShiftReportRecord> GetMonthShiftsReport(DateTime date, DateTime dateEnd, SetOfCriteriaForSelectingJournalRecords criterias)
        {
            var journalRecords = new JournalRepository(_ctx).GetRecordsForPeriod(date, dateEnd);

            journalRecords = criterias.ApplyAllCriterias(journalRecords);
            return(journalRecords
                   .GroupBy(jr => new { jr.Shift, jr.WorkArea, jr.Operation.Work.OperationGroup })
                   .Select(g => new MonthShiftReportRecord
            {
                RecordHeader = g.Key.OperationGroup,
                Month = g.First().Date.ToString("MMMM"),
                Year = g.First().Date.ToString("yyyy"),
                Shift = g.Key.Shift.Value,
                WorkArea = g.Key.WorkArea,
                Quantity = g.Count(),
                Duration = g.Sum(jr => Math.Round(jr.Duration.TotalHours, 2)),
                Normative = g.Sum(jr => Math.Round(jr.Normative.TotalHours, 2)),
                Deviation = Math.Round(g.Sum(jr => Math.Round(jr.Duration.TotalHours, 2)) - g.Sum(jr => Math.Round(jr.Normative.TotalHours, 2)), 2),
            }).ToList());
        }