private static List <Employee> CleanAttendanceInAndOutList(IList <AttendanceInAndOutRecord> attendances) { List <Employee> employeeList = new List <Employee>(); for (int i = 0; i < attendances.Count; i++) { List <AttendanceInAndOutRecord> records = new List <AttendanceInAndOutRecord>(); records.Add(attendances[i]); string employeename = attendances[i].EmployeeName; DateTime time = attendances[i].IOTime; for (int j = i + 1; j < attendances.Count; j++) { if (attendances[j].EmployeeName == employeename && attendances[j].IOTime.Date == time.Date) { records.Add(attendances[j]); attendances.RemoveAt(j); j--; } } Employee emp = new Employee(); emp.Account = new Account(0, "", employeename); emp.EmployeeAttendance = new EmployeeAttendance(); DateTime intime = AttendanceInAndOutRecord.FindEarlistTime(records); DateTime outtime = AttendanceInAndOutRecord.FindLatestTime(records); emp.EmployeeAttendance.AttendanceInAndOutStatistics = new AttendanceInAndOutStatistics(intime, outtime, ""); employeeList.Add(emp); } return(employeeList); }
public static List <CalendarADay> Turn(List <AttendanceInAndOutRecord> originalDataList, List <CalendarADay> retList , List <PlanDutyDetail> planDutyDetailList , DateTime from, DateTime to) { for (int i = 0; from.AddDays(i).Date <= to.Date; i++) { PlanDutyDetail planDutyDetail = PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, from.AddDays(i).Date); if (planDutyDetail == null || planDutyDetail.PlanDutyClass.IsWeek) { continue; } CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, from.AddDays(i).Date); List <AttendanceInAndOutRecord> dtOriginalDataList = AttendanceInAndOutRecord.GetAttendanceInAndOutRecordByDate(originalDataList, from.AddDays(i).Date); if (dtOriginalDataList.Count == 0) { MonthItem monthNoRecord = new MonthItem(); monthNoRecord.CType = CalendarShowType.Attendance; monthNoRecord.Title = "无打卡记录"; monthNoRecord.Date = from.AddDays(i).Date; monthNoRecord.Detail = "无打卡记录"; calendarADay.MonthItems.Add(monthNoRecord); Utility.Clean(calendarADay); continue; } DateTime dtStart = AttendanceInAndOutRecord.FindEarlistTime(dtOriginalDataList); DateTime dtEnd = AttendanceInAndOutRecord.FindLatestTime(dtOriginalDataList); if (!IsInitTime(dtStart)) { DayItem day = new DayItem(); day.CType = CalendarShowType.Attendance; day.Start = day.End = dtStart; day.DayDetail = "打卡 " + dtStart.ToShortTimeString(); calendarADay.DayItems.Add(day); } if (!IsInitTime(dtEnd)) { DayItem day = new DayItem(); day.CType = CalendarShowType.Attendance; day.Start = day.End = dtEnd; day.DayDetail = "打卡 " + dtEnd.ToShortTimeString(); calendarADay.DayItems.Add(day); } MonthItem month = new MonthItem(); month.CType = CalendarShowType.Attendance; month.Title = "打卡 " + (!IsInitTime(dtStart) ? dtStart.ToShortTimeString() : "") + "--" + (!IsInitTime(dtEnd) ? dtEnd.ToShortTimeString() : ""); month.Date = from.AddDays(i).Date; month.Detail = "最早打卡时间:" + (!IsInitTime(dtStart) ? dtStart.ToString() : "--") + "<br>" + "最晚打卡时间:" + (!IsInitTime(dtEnd) ? dtEnd.ToString() : "--"); calendarADay.MonthItems.Add(month); Utility.Clean(calendarADay); } return(retList); }
public void SendEmailForEmployees() { try { string[] temp = _IShowCalendarDetail.EmployeeInfo.Split(';'); string employeeName = temp[1]; string status = ""; if (temp.Length > 2) { status = temp[3]; } int.TryParse(temp[0], out _EmployeeID); List <string> cc = new List <string>(); IBll.Accounts.IAccountBll _IGetEmployee = BllInstance.AccountBllInstance; Account account = _IGetEmployee.GetAccountById(_EmployeeID); if (account == null) { return; } List <string> to = new List <string>(); to.Add(account.Email1); if (!string.IsNullOrEmpty(account.Email2)) { to.Add(account.Email2); } if (!DateTime.TryParse(_IShowCalendarDetail.Date, out _Date)) { _IShowCalendarDetail.ResultMessage = "请选择一个日期!"; return; } List <AttendanceInAndOutRecord> _AttendanceInAndOutRecordList = _IAttendanceInOutRecordFacade.GetSelfAttendanceInAndOutRecordByCondition(_EmployeeID, _Date, _Date.AddDays(1).AddMinutes(-1)); DateTime e = AttendanceInAndOutRecord.FindEarlistTime(_AttendanceInAndOutRecordList); DateTime l = AttendanceInAndOutRecord.FindLatestTime(_AttendanceInAndOutRecordList); string inTime = e == Convert.ToDateTime("2999-12-31") ? "无" : e.ToString(); string outTime = l == Convert.ToDateTime("1900-1-1") ? "无" : l.ToString(); IAttendanceReadDataFacade _IAttendanceReadDataFacade = new AttendanceReadDataFacade(); _IAttendanceReadDataFacade.AttendanceSendEmailToEmployee(employeeName, inTime, outTime, status, new DateTime(_Date.Year, _Date.Month, _Date.Day, 0, 0, 0).ToString(), new DateTime(_Date.Year, _Date.Month, _Date.Day, 23, 59, 59).ToString(), to, cc, _LoginUser); _IShowCalendarDetail.ResultMessage = "邮件已发送"; } catch (Exception ex) { _IShowCalendarDetail.ResultMessage = ex.Message; } }
private static List <UnKownTimeSpan> CaculateAbsentTimes(DateTime theday, PlanDutyDetail thedayPlanDutyDetail, List <OutApplication> outApplicationList, List <LeaveRequest> leaveRequestList, List <AttendanceInAndOutRecord> attendanceInAndOutRecordList) { List <UnKownTimeSpan> uktsList = new List <UnKownTimeSpan>(); uktsList.Add( new UnKownTimeSpan( new DateTime(theday.Year, theday.Month, theday.Day, thedayPlanDutyDetail.PlanDutyClass.FirstStartFromTime.Hour, thedayPlanDutyDetail.PlanDutyClass.FirstStartFromTime.Minute, thedayPlanDutyDetail.PlanDutyClass.FirstStartFromTime.Second), new DateTime(theday.Year, theday.Month, theday.Day, thedayPlanDutyDetail.PlanDutyClass.FirstEndTime.Hour, thedayPlanDutyDetail.PlanDutyClass.FirstEndTime.Minute, thedayPlanDutyDetail.PlanDutyClass.FirstEndTime.Second))); uktsList.Add( new UnKownTimeSpan( new DateTime(theday.Year, theday.Month, theday.Day, thedayPlanDutyDetail.PlanDutyClass.SecondStartTime.Hour, thedayPlanDutyDetail.PlanDutyClass.SecondStartTime.Minute, thedayPlanDutyDetail.PlanDutyClass.SecondStartTime.Second), new DateTime(theday.Year, theday.Month, theday.Day, thedayPlanDutyDetail.PlanDutyClass.SecondEndTime.Hour, thedayPlanDutyDetail.PlanDutyClass.SecondEndTime.Minute, thedayPlanDutyDetail.PlanDutyClass.SecondEndTime.Second))); foreach (LeaveRequest leaveRequest in leaveRequestList) { foreach (LeaveRequestItem leaveRequestItem in leaveRequest.LeaveRequestItems) { UpdateAbsentTimesForKownTimeSpan(uktsList, leaveRequestItem.FromDate, leaveRequestItem.ToDate); } } foreach (OutApplication outApplication in outApplicationList) { foreach (OutApplicationItem outApplicationItem in outApplication.Item) { UpdateAbsentTimesForKownTimeSpan(uktsList, outApplicationItem.FromDate, outApplicationItem.ToDate); } } UpdateAbsentTimesForKownTimeSpan(uktsList, AttendanceInAndOutRecord.FindEarlistTime(attendanceInAndOutRecordList), AttendanceInAndOutRecord.FindLatestTime(attendanceInAndOutRecordList)); return(uktsList); }