public static List <EmpMonthlyProductivityEntity> ProcessAttendence(List <ViewAttData> finalOutput, string _dateFrom, string _dateTo) { TAS2013Entities db = new TAS2013Entities(); List <EmpMonthlyProductivityEntity> listOfEmps = new List <EmpMonthlyProductivityEntity>(); var result = finalOutput.OrderBy(m => m.EmpName).Select(m => m.EmpID).Distinct(); foreach (var emp in result) { EmpMonthlyProductivityEntity mp = new EmpMonthlyProductivityEntity(); Emp employee = db.Emps.Where(aa => aa.EmpID == emp).FirstOrDefault(); mp.EmpName = employee.EmpName; mp.Designation = employee.Designation.DesignationName; mp.EmpNo = employee.EmpNo; mp.Company = employee.Company.CompName; mp.SectionName = employee.Section.SectionName; mp.TotalActualWork = 0; mp.TotalExpectedWork = 0; List <ActualExpected> Mins = new List <ActualExpected>(); Boolean found = false; DateTime from = Convert.ToDateTime(_dateFrom); DateTime to = Convert.ToDateTime(_dateTo); while (from <= to) { foreach (ViewAttData att in finalOutput) { if (att.EmpID == emp && att.AttDate == from) { found = true; from = from.AddDays(1); ActualExpected ae = new ActualExpected(); if (att.WorkMin != null) { ae.actual = (double)att.WorkMin; mp.TotalActualWork = mp.TotalActualWork + ae.actual; } else { ae.actual = 0.0; } if (att.ShifMin != null || att.StatusDO == false || att.StatusGZ == false) { ae.expected = (double)att.ShifMin; mp.TotalExpectedWork = mp.TotalExpectedWork + ae.expected; } else { ae.expected = 0.0; } Mins.Add(ae); break; } } if (!found) { from = from.AddDays(1); } else { found = false; } } mp = DecompressActualAndExpectedMinForRDLC(mp, Mins); listOfEmps.Add(mp); } return(listOfEmps); }
public static List<EmpMonthlyProductivityEntity> ProcessAttendence(List<ViewAttData> finalOutput, string _dateFrom, string _dateTo) { TAS2013Entities db = new TAS2013Entities(); List<EmpMonthlyProductivityEntity> listOfEmps = new List<EmpMonthlyProductivityEntity>(); var result = finalOutput.OrderBy(m => m.EmpName ).Select(m => m.EmpID).Distinct(); foreach (var emp in result) { EmpMonthlyProductivityEntity mp = new EmpMonthlyProductivityEntity(); Emp employee = db.Emps.Where(aa => aa.EmpID == emp).FirstOrDefault(); mp.EmpName = employee.EmpName; mp.Designation =employee.Designation.DesignationName; mp.EmpNo = employee.EmpNo; mp.Company = employee.Company.CompName; mp.SectionName =employee.Section.SectionName; mp.TotalActualWork = 0; mp.TotalExpectedWork = 0; List<ActualExpected> Mins = new List<ActualExpected>(); Boolean found = false; DateTime from = Convert.ToDateTime(_dateFrom); DateTime to = Convert.ToDateTime(_dateTo); while (from <= to) { foreach (ViewAttData att in finalOutput) { if (att.EmpID == emp && att.AttDate == from) { found = true; from = from.AddDays(1); ActualExpected ae = new ActualExpected(); if (att.WorkMin != null) { ae.actual = (double)att.WorkMin; mp.TotalActualWork = mp.TotalActualWork + ae.actual; } else ae.actual = 0.0; if (att.ShifMin != null || att.StatusDO == false || att.StatusGZ == false) { ae.expected = (double)att.ShifMin; mp.TotalExpectedWork = mp.TotalExpectedWork + ae.expected; } else ae.expected = 0.0; Mins.Add(ae); break; } } if (!found) { from = from.AddDays(1); } else { found = false; } } mp = DecompressActualAndExpectedMinForRDLC(mp, Mins); listOfEmps.Add(mp); } return listOfEmps; }