List IEnumerable, listienumerable

Source: Internet
Author: User

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;
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.