Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public List <DayAttendance> GetAllCalendarByEmployee(int AccountID, DateTime fromDate, DateTime toDate)
        {
            List <DayAttendance> dayAttendanceList = new List <DayAttendance>();
            List <OverWorkItem>  OverWorkItemList  =
                _OverWorkDal.GetAllOverWorkForCalendar(AccountID, fromDate, toDate);

            //由于加班的一项只能是一天,所以直接加就可以了
            foreach (OverWorkItem item in OverWorkItemList)
            {
                string typeName = "加班";
                // -1 全部;0 新增;1 提交;2 审核不通过;3 审核通过;4 取消请假;5 拒绝取消假期;6 批准取消假期;7 审核中;8 审核取消中
                if (item.Status == RequestStatus.New ||
                    item.Status == RequestStatus.Submit ||
                    item.Status == RequestStatus.Approving ||
                    item.Status == RequestStatus.CancelApproving ||
                    item.Status == RequestStatus.Cancelled)
                {
                    typeName = typeName + "(" + item.Status.Name + ")";
                }
                DayAttendance dayAttendance =
                    new DayAttendance(-1, typeName, item.CostTime, 0, item.FromDate, "", CalendarType.OverTime);
                dayAttendance.FromTime = fromDate;
                dayAttendance.ToTime   = toDate;
                dayAttendanceList.Add(dayAttendance);
            }
            return(dayAttendanceList);
        }
Ejemplo n.º 2
0
        public void TurnToDayAttendanceList(Employee employee)
        {
            List <DayAttendance> dayAttendances = new List <DayAttendance>();

            foreach (AttendanceBase attendanceBase in employee.EmployeeAttendance.AttendanceBaseList)
            {
                DayAttendance        dayAttendance = null;
                EarlyLeaveAttendance early;
                LaterAttendance      late;

                if (attendanceBase is AbsentAttendance)
                {
                    dayAttendance =
                        new DayAttendance(-1, attendanceBase.Name, attendanceBase.Days, 0, attendanceBase.TheDay,
                                          string.Empty, CalendarType.Absent);
                }
                else if ((early = attendanceBase as EarlyLeaveAttendance) != null)
                {
                    dayAttendance =
                        new DayAttendance(-1, early.Name, early.Days, early.EarlyLeaveMinutes, early.TheDay,
                                          string.Empty, CalendarType.LeaveEarly);
                }
                else if ((late = attendanceBase as LaterAttendance) != null)
                {
                    dayAttendance =
                        new DayAttendance(-1, late.Name, late.Days, late.LaterMinutes, late.TheDay, string.Empty,
                                          CalendarType.Late);
                }
                dayAttendances.Add(dayAttendance);
            }
            employee.EmployeeAttendance.DayAttendanceList.AddRange(dayAttendances);
        }
Ejemplo n.º 3
0
        ///<summary>
        /// 转换为日历显示
        ///</summary>
        ///<param name="employeeId"></param>
        ///<param name="theDayFrom"></param>
        ///<param name="theDayTo"></param>
        ///<param name="attendaceType"></param>
        ///<returns></returns>
        public List <DayAttendance> GetCalendarByEmployee(int employeeId, DateTime theDayFrom, DateTime theDayTo, AttendanceTypeEmnu attendaceType)
        {
            //获取员工缺勤信息
            List <AttendanceBase> baseList = _AttendanceDal.GetCalendarByEmployee(employeeId, theDayFrom, theDayTo,
                                                                                  attendaceType);
            List <DayAttendance> dayAttendances = new List <DayAttendance>();

            //转换为日历
            foreach (AttendanceBase attendanceBase in baseList)
            {
                DayAttendance        dayAttendance = null;
                EarlyLeaveAttendance early;
                LaterAttendance      late;

                if (attendanceBase is AbsentAttendance)
                {
                    dayAttendance =
                        new DayAttendance(-1, attendanceBase.Name, attendanceBase.Days * 8, 0, attendanceBase.TheDay,
                                          string.Empty, CalendarType.Absent);
                }
                else if ((early = attendanceBase as EarlyLeaveAttendance) != null)
                {
                    dayAttendance = new DayAttendance(-1, early.Name, early.Days, early.EarlyLeaveMinutes, early.TheDay,
                                                      string.Empty, CalendarType.LeaveEarly);
                }
                else if ((late = attendanceBase as LaterAttendance) != null)
                {
                    dayAttendance =
                        new DayAttendance(-1, late.Name, late.Days, late.LaterMinutes, late.TheDay, string.Empty,
                                          CalendarType.Late);
                }
                dayAttendances.Add(dayAttendance);
            }
            return(dayAttendances);
        }
Ejemplo n.º 4
0
        public async Task <ApiResult <HistoryAttendanceVm> > GetHistoryAttendanceVm(historyAttendanceRequest request)
        {
            var queryStudentSchedule = from s in _context.Schedules
                                       join c in _context.Courses on s.Id_Course equals c.Id_Course
                                       join rc in _context.RegisterCourses on c.Id_Course equals rc.Id_Course
                                       join st in _context.Students on rc.Id_Student equals st.Id
                                       join cl in _context.Classes on s.Id_Class equals cl.Id_Class
                                       where s.Id_Course == request.Id_Cource && st.Id == request.Id_User
                                       select new { s, st, c, cl };
            var dataStudentSchedule = await queryStudentSchedule.Select(x => new DayAttendance()
            {
                Date        = x.s.Date,
                id_Schedule = x.s.Id_Schedule,
                Status      = false
            }).ToListAsync();

            var queryStudentAttdendace = from s in _context.Schedules
                                         join ha in _context.HistoryAttendances on s.Id_Schedule equals ha.Id_Schedule
                                         join d in _context.DetailHAs on ha.Id_HistoryAttendace equals d.Id_HistoryAttendance
                                         join st in _context.Students on d.Id_Student equals st.Id
                                         where s.Id_Course == request.Id_Cource && st.Id == request.Id_User
                                         select new { ha };
            var dataStudentAttdendace = await queryStudentAttdendace.Select(x => x.ha.Id_Schedule).ToListAsync();

            var data = new List <DayAttendance>();

            foreach (var item in dataStudentSchedule)
            {
                int check = dataStudentAttdendace.IndexOf(item.id_Schedule);
                if (check == -1)
                {
                    data.Add(item);
                }
                else
                {
                    var user = new DayAttendance()
                    {
                        Date        = item.Date,
                        id_Schedule = item.id_Schedule,
                        Status      = true
                    };
                    data.Add(user);
                }
            }

            var users = await _context.Students.FindAsync(request.Id_User);

            var course = await _context.Courses.FindAsync(request.Id_Cource);


            var result = new HistoryAttendanceVm()
            {
                NameUser       = users.FullName,
                NameCourse     = course.Name,
                DayAttendances = data
            };

            return(new ApiSuccessResult <HistoryAttendanceVm>(result));
        }
Ejemplo n.º 5
0
        private decimal Calculate(DateTime from, DateTime to)
        {
            decimal costHour = 0m;

            if (from >= to)
            {
                DayAttendance dayAttendance = new DayAttendance(-1, _TypeName, 0, 0, from, "", CalendarType.Out);
                dayAttendance.FromTime = from;
                dayAttendance.ToTime   = to;
                _DayAttendanceList.Add(dayAttendance);
                return(0);
            }
            int      days = (to.Date - from.Date).Days;
            DateTime date = from;

            for (int i = 0; i <= days; i++)
            {
                PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, date);
                if (detail != null && detail.PlanDutyClass != null)
                {
                    _MorningStart   = detail.PlanDutyClass.FirstStartFromTime;
                    _MorningEnd     = detail.PlanDutyClass.FirstEndTime;
                    _AfternoonStart = detail.PlanDutyClass.SecondStartTime;
                    _AfternoonEnd   = detail.PlanDutyClass.FirstStartToTime.AddHours((_AfternoonStart - _MorningEnd).TotalHours + (double)_OneDayMaxHour);
                    DateTime fromtemp = _MorningStart;
                    DateTime totemp   = _AfternoonEnd;
                    if (i == 0)
                    {
                        fromtemp = from;
                    }
                    if (i == days)
                    {
                        totemp = to;
                    }
                    //ÅųýË«ÐÝÈÕ,½Ú¼ÙÈÕ
                    if (!detail.PlanDutyClass.IsWeek)
                    {
                        decimal hour = CalculateOneDay(fromtemp, totemp);
                        costHour += hour;
                        DayAttendance dayAttendance = new DayAttendance(-1, _TypeName, hour, 0, date, "", CalendarType.Out);
                        dayAttendance.FromTime = from;
                        dayAttendance.ToTime   = to;
                        _DayAttendanceList.Add(dayAttendance);
                    }
                    date = date.AddDays(1);
                }
            }
            return(costHour);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        public List <DayAttendance> GetCalendarByEmployee(int AccountID, DateTime fromDate, DateTime toDate)
        {
            List <DayAttendance> dayAttendanceList   = new List <DayAttendance>();
            List <OverWorkItem>  OverWorkItemList    = new List <OverWorkItem>();
            List <OverWorkItem>  OverWorkItemFromDal =
                _OverWorkDal.GetOverWorkForCalendar(AccountID, fromDate, toDate);

            foreach (OverWorkItem item in OverWorkItemFromDal)
            {
                if (item.Status == RequestStatus.Cancelled || item.Status == RequestStatus.CancelApproving)
                {
                    OverWorkItem OverWorkItem =
                        _OverWorkDal.GetOverWorkItemByItemID(item.ItemID);
                    if (OverWorkUtility.IsAgreed(OverWorkItem))
                    {
                        OverWorkItemList.Add(item);
                    }
                }
                else
                {
                    OverWorkItemList.Add(item);
                }
            }
            //由于加班的一项只能是一天,所以直接加就可以了
            foreach (OverWorkItem item in OverWorkItemList)
            {
                DayAttendance dayAttendance;
                if (!item.Adjust)
                {
                    dayAttendance =
                        new DayAttendance(-1, OverWorkUtility.GetOverWorkTypeNotAdjustName(item.OverWorkType),
                                          item.CostTime, 0, item.FromDate, "", CalendarType.OverTime);
                    dayAttendance.FromTime = fromDate;
                    dayAttendance.ToTime   = toDate;
                    dayAttendanceList.Add(dayAttendance);
                }
                dayAttendance =
                    new DayAttendance(-1, OverWorkUtility.GetOverWorkTypeName(item.OverWorkType), item.CostTime, 0,
                                      item.FromDate, "", CalendarType.OverTime);
                dayAttendance.FromTime = fromDate;
                dayAttendance.ToTime   = toDate;
                dayAttendanceList.Add(dayAttendance);
            }
            return(dayAttendanceList);
        }
Ejemplo n.º 7
0
        private decimal Calculate(DateTime from, DateTime to)
        {
            // -1 全部;0 新增;1 提交;2 审核不通过;3 审核通过;4 取消请假;5 拒绝取消假期;6 批准取消假期;7 审核中;8 审核取消中
            if (_RequestStatus == RequestStatus.New ||
                _RequestStatus == RequestStatus.Submit ||
                _RequestStatus == RequestStatus.Approving ||
                _RequestStatus == RequestStatus.CancelApproving ||
                _RequestStatus == RequestStatus.Cancelled)
            {
                _LeaveRequestTypeName = _LeaveRequestTypeName + "(" + _RequestStatus.Name + ")";
            }
            decimal costHour = 0m;

            if (from >= to)
            {
                DayAttendance dayAttendance =
                    new DayAttendance(_LeaveRequestTypeID, _LeaveRequestTypeName, 0, 0, from, "", CalendarType.Leave);
                dayAttendance.FromTime = from;
                dayAttendance.ToTime   = to;
                _DayAttendanceList.Add(dayAttendance);
                return(0);
            }
            int      days = (to.Date - from.Date).Days;
            DateTime date = from;

            for (int i = 0; i <= days; i++)
            {
                PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, date);

                if (detail != null && detail.PlanDutyClass != null)
                {
                    InitDateTime(detail);
                    DateTime fromtemp = _MorningStart;
                    DateTime totemp   = _AfternoonEnd;
                    if (i == 0)
                    {
                        fromtemp = from;
                    }
                    if (i == days)
                    {
                        totemp = to;
                    }
                    decimal hour;
                    //排除双休日,节假日
                    if (_IncludeLegalHoliday && _CalculateDays.IsNationalHoliday(date))
                    {
                        if (detail.PlanDutyClass.IsWeek)
                        {
                            hour      = _OneDayMaxHour;
                            costHour += hour;
                        }
                        else
                        {
                            hour      = CalculateOneDay(fromtemp, totemp);
                            costHour += hour;
                        }
                        DayAttendance dayAttendance =
                            new DayAttendance(_LeaveRequestTypeID, _LeaveRequestTypeName, hour, 0, date, "",
                                              CalendarType.Leave);
                        dayAttendance.FromTime = from;
                        dayAttendance.ToTime   = to;
                        _DayAttendanceList.Add(dayAttendance);
                    }
                    else if (_IncludeRestDay && detail.PlanDutyClass.IsWeek && !_CalculateDays.IsNationalHoliday(date))
                    {
                        hour      = _OneDayMaxHour;
                        costHour += hour;
                        DayAttendance dayAttendance =
                            new DayAttendance(_LeaveRequestTypeID, _LeaveRequestTypeName, hour, 0, date, "",
                                              CalendarType.Leave);
                        dayAttendance.FromTime = from;
                        dayAttendance.ToTime   = to;
                        _DayAttendanceList.Add(dayAttendance);
                    }
                    else if (!detail.PlanDutyClass.IsWeek)
                    {
                        hour      = CalculateOneDay(fromtemp, totemp);
                        costHour += hour;
                        DayAttendance dayAttendance =
                            new DayAttendance(_LeaveRequestTypeID, _LeaveRequestTypeName, hour, 0, date, "",
                                              CalendarType.Leave);
                        dayAttendance.FromTime = from;
                        dayAttendance.ToTime   = to;
                        _DayAttendanceList.Add(dayAttendance);
                    }
                    date = date.AddDays(1);
                }
            }
            return(costHour);
        }