List IEnumerable, listienumerable
// Summary by department
IEnumerable <WeekReportWithDepartmentInfo> report = summary
. GroupBy (x => new
{
X. DeptID,
X. DeptName
}). Select (g => new WeekReportWithDepartmentInfo
{
DeptID = g. Key. DeptID,
DeptName = g. Key. DeptName,
TotalNumber = g. Count (),
WorkOvertime = g. Sum (a => a. WorkOverHours ),
WorkLeave = g. Where (a => a. IsNeedAttendance = true). Sum (a => a. WorkHours ),
PersonalLeave = g. Where (a => a. IsNeedAttendance = true). Sum (a => a. PersonalLeave ),
PaidLeave = g. Where (a => a. IsNeedAttendance = true). Sum (a => a. PaidLeave ),
LateAndLeavingEarly = g. Where (a => a. IsNeedAttendance = true). Sum (a => a. LateAndLeavingEarly)
}). Skip (PageSize * (CurrentPage-1). Take (PageSize );
// Total number of rows
Int rows = summary
. GroupBy (x => new
{
X. DeptID,
X. DeptName
}). Count ();
List <WeekReportWithDepartmentInfo> reportlist = new List <WeekReportWithDepartmentInfo> ();
IEnumerable <string> tempEmail;
Foreach (WeekReportWithDepartmentInfo item in report)
{
// Find the owner of the current Department
TempEmail = employees. Where (e => e. DeptID = item. DeptID). Select (s => s. Email );
Item. TotalNumber = summary. Where (e => e. DeptID = item. DeptID). GroupBy (x => new {x. EmpID}). Count ();
//// Summarize the false information of all persons
// Item. PersonalLeave = personalLeave. Where (p => tempEmail. Contains (p. Key). Sum (s => s. Value );
//// Summarize the total working hours of paid leave for all persons
// Item. PaidLeave = paidLeave. Where (p => tempEmail. Contains (p. Key). Sum (s => s. Value );
// Double jialeave = JiaLeave. Where (p => tempEmail. Contains (p. Key). Sum (s => s. Value );
//// Late, early departure, working hours
// Item. LateAndLeavingEarly = item. LateAndLeavingEarly-jialeave;
// Item. LateAndLeavingEarly = item. LateAndLeavingEarly <0? 0: item. LateAndLeavingEarly;
// Summarize the total overtime hours of All Persons
// Item. WorkOvertime = workOvertime. Where (p => tempEmail. Contains (p. Key). Sum (s => s. Value );
// Full attendance
Item. QqingNumber = item. TotalNumber-summary. Where (s => s. IsNeedAttendance & s. DeptID = item. DeptID & s. AttendanceState! = 9). Select (s => s. EmpID). Distinct (). Count (); // deduplication
// Item. WorkLeave during normal attendance
// Error Rate
Item. BsenteeismRatio = (item. LateAndLeavingEarly + item. PersonalLeave + item. PaidLeave)/item. WorkLeave * 100;
// Overtime rate
Item. OvertimeRatio = item. WorkOvertime/item. WorkLeave * 100;
Reportlist. Add (item );
}
// IEnumerable <KeyValue <string, double> JiaLeave = leaveWithWeek. Where (l => l. TypeName! = LeaveType. Overtime
// & Amp; l. TypeName! = LeaveType. Punch-in)
//. GroupBy (x => new {x. Email })
//. Select (g => new KeyValue <string, double>
//{
// Key = g. Key. Email,
// Value = g. Sum (a => (a. AskLeaveHour ))
//});
// Sign in)
TempAtdRec = attendances. where (a =>. empID = emp. empID &. recDateTime> workDay. getInTime (). addHours (-4) &. recDateTime <workDay. getOutTime ()). orderBy (a =>. recDateTime );
If (tempAtdRec. Count ()> 0)
{
Info. SigninTime = tempAtdRec. First (). RecTime;
Info. SigninDateTime = tempAtdRec. First (). RecDateTime;
}
// Sign off)
TempAtdRec = attendances. where (a =>. empID = emp. empID &. recDateTime> workDay. getInTime () &. recDateTime <workDay. getInTime (). addDays (1 ). addHours (-4 )). orderByDescending (a =>. recDateTime );
If (tempAtdRec. Count ()> 0)
{
Info. SignoutTime = tempAtdRec. First (). RecTime;
Info. SignoutDateTime = tempAtdRec. First (). RecDateTime;
}