Ejemplo n.º 1
0
        private void InitDateTime(PlanDutyDetail detail)
        {
            DateTime lastenddate =
                detail.PlanDutyClass.FirstStartToTime.AddHours(
                    (detail.PlanDutyClass.SecondStartTime - detail.PlanDutyClass.FirstEndTime).
                    TotalHours + (double)_OneDayMaxHour);

            if (RequestUtility.ConvertToTime(_From) >=
                RequestUtility.ConvertToTime(detail.PlanDutyClass.FirstStartFromTime) &&
                RequestUtility.ConvertToTime(_From) <=
                RequestUtility.ConvertToTime(detail.PlanDutyClass.FirstStartToTime))
            {
                _MorningStart = RequestUtility.ConvertToTime(_From);
            }
            else
            {
                _MorningStart = RequestUtility.ConvertToTime(detail.PlanDutyClass.FirstStartFromTime);
            }
            if (RequestUtility.ConvertToTime(_To) >=
                RequestUtility.ConvertToTime(detail.PlanDutyClass.SecondEndTime) &&
                RequestUtility.ConvertToTime(_To) <=
                RequestUtility.ConvertToTime(lastenddate))
            {
                _AfternoonEnd = RequestUtility.ConvertToTime(_To);
            }
            else
            {
                _AfternoonEnd =
                    RequestUtility.ConvertToTime(lastenddate);
            }
            _MorningEnd     = detail.PlanDutyClass.FirstEndTime;
            _AfternoonStart = detail.PlanDutyClass.SecondStartTime;
        }
        ///<summary>
        ///</summary>
        public void GetHourDesType(OutApplicationItem item, int accountid, out decimal putong, out decimal shuangxiu,
                                   out decimal jieri)
        {
            jieri     = 0m;
            putong    = 0m;
            shuangxiu = 0m;
            DateTime from = item.FromDate;
            DateTime to   = item.ToDate;

            _CalculateDays      = new CalculateDays(BllInstance.SpecialDateBllInstance.GetAllSpecialDate(null));
            _PlanDutyDetailList = _PlanDutyDal.GetPlanDutyDetailByAccount(accountid, from, to);

            CalculateOutCityHour calculateOutCityHour = new CalculateOutCityHour(from, to, accountid);

            calculateOutCityHour.Excute();
            foreach (DayAttendance attendance in calculateOutCityHour.DayAttendanceList)
            {
                PlanDutyDetail planDutyDetail =
                    PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, attendance.Date);
                if (_CalculateDays.IsNationalHoliday(attendance.Date))
                {
                    jieri += attendance.Hours;
                }

                else if (planDutyDetail.PlanDutyClass.IsWeek)
                {
                    shuangxiu += attendance.Hours;
                }
                else
                {
                    putong += attendance.Hours;
                }
            }
        }
Ejemplo n.º 3
0
        private static void InitDateTime(DateTime from, DateTime to, PlanDutyDetail detail,
                                         out DateTime dtMorningStart, out DateTime dtAfternoonEnd)
        {
            DateTime lastenddate =
                detail.PlanDutyClass.FirstStartToTime.AddHours(
                    (detail.PlanDutyClass.SecondStartTime - detail.PlanDutyClass.FirstEndTime).
                    TotalHours + (double)_OneDayMaxHour);

            if (RequestUtility.ConvertToTime(from) >=
                RequestUtility.ConvertToTime(detail.PlanDutyClass.FirstStartFromTime) &&
                RequestUtility.ConvertToTime(from) <=
                RequestUtility.ConvertToTime(detail.PlanDutyClass.FirstStartToTime))
            {
                dtMorningStart = RequestUtility.ConvertToTime(from);
            }
            else
            {
                dtMorningStart = RequestUtility.ConvertToTime(detail.PlanDutyClass.FirstStartFromTime);
            }
            if (RequestUtility.ConvertToTime(to) >=
                RequestUtility.ConvertToTime(detail.PlanDutyClass.SecondEndTime) &&
                RequestUtility.ConvertToTime(to) <=
                RequestUtility.ConvertToTime(lastenddate))
            {
                dtAfternoonEnd = RequestUtility.ConvertToTime(to);
            }
            else
            {
                dtAfternoonEnd =
                    RequestUtility.ConvertToTime(lastenddate);
            }
        }
Ejemplo n.º 4
0
        public List <PlanDutyDetail> GetCurrentPlanDutyDetailList(DateTime dt)
        {
            List <PlanDutyDetail> planDutyDetailList = new List <PlanDutyDetail>();
            DateTime monthFrom = dt.AddDays(1 - dt.Day);
            DateTime monthTo   = dt.AddDays(1 - dt.Day).AddMonths(1).AddDays(-1);
            DateTime temp      = monthFrom;

            while (DateTime.Compare(temp, monthTo) <= 0)
            {
                String[] sDateList = Request.Form.GetValues(temp.Year + "-" + temp.Month + "-" + temp.Day);

                PlanDutyDetail planDutyDetail = new PlanDutyDetail();
                planDutyDetail.Date          = temp;
                planDutyDetail.PlanDutyClass = new DutyClass();
                if (sDateList != null)
                {
                    planDutyDetail.PlanDutyClass.DutyClassID = Convert.ToInt32(sDateList[0]);
                }
                else
                {
                    return(null);
                }
                planDutyDetailList.Add(planDutyDetail);
                temp = temp.AddDays(1);
            }
            return(planDutyDetailList);
        }
        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);
        }
Ejemplo n.º 6
0
        public static List <CalendarADay> Turn(List <OutApplication> originalDataList,
                                               List <PlanDutyDetail> planDutyDetailList, List <SpecialDate> specialList, List <CalendarADay> retList)
        {
            foreach (OutApplication outApplication in originalDataList)
            {
                foreach (OutApplicationItem originalDataItem in outApplication.Item)
                {
                    DateTime from     = originalDataItem.FromDate;
                    DateTime to       = originalDataItem.ToDate;
                    decimal  costHour = 0m;
                    if (from >= to)
                    {
                        CreateOutApplicationInfoInADay(retList, from, 0, outApplication, originalDataItem, from, to);
                    }
                    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)
                        {
                            TimeSpan ts = detail.PlanDutyClass.FirstStartToTime -
                                          detail.PlanDutyClass.FirstStartFromTime;
                            DateTime fromtemp =
                                new DateTime(date.Year, date.Month, date.Day, detail.PlanDutyClass.FirstStartFromTime.Hour,
                                             detail.PlanDutyClass.FirstStartFromTime.Minute,
                                             detail.PlanDutyClass.FirstStartFromTime.Second);
                            DateTime totemp =
                                new DateTime(date.Year, date.Month, date.Day, detail.PlanDutyClass.SecondEndTime.Add(ts).Hour,
                                             detail.PlanDutyClass.SecondEndTime.Add(ts).Minute,
                                             detail.PlanDutyClass.SecondEndTime.Add(ts).Second);
                            if (i == 0)
                            {
                                fromtemp = from;
                            }
                            if (i == days)
                            {
                                totemp = to;
                            }
                            //排除双休日,节假日
                            if (!detail.PlanDutyClass.IsWeek)
                            {
                                decimal hour = Utility.CalculateOneDay(fromtemp, totemp, 0, detail);
                                costHour += hour;
                                CreateOutApplicationInfoInADay(retList, date, hour, outApplication, originalDataItem,
                                                               fromtemp, totemp);
                            }
                        }
                        date = date.AddDays(1);
                    }
                }
            }
            return(retList);
        }
Ejemplo n.º 7
0
 public bool FindOnePlanDutyDetail(PlanDutyDetail planDutyDetail)
 {
     if (planDutyDetail.Date.ToShortDateString() == _Date.ToShortDateString())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 查找在时间范围内PlanDutyDetail
 /// </summary>
 /// <param name="planDutyDetail"></param>
 /// <returns></returns>
 public bool FindPlanDutyDetail(PlanDutyDetail planDutyDetail)
 {
     if (DateTime.Compare(planDutyDetail.Date.Date, _Date) >= 0 &&
         DateTime.Compare(toTime, planDutyDetail.Date.Date) >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 插入班别详情
        /// </summary>
        /// <param name="planDutyDetail"></param>
        /// <param name="PlanDutyTableID"></param>
        /// <param name="conn"></param>
        /// <param name="trans"></param>
        /// <returns></returns>
        private static void InsertPlanDutyDetail(PlanDutyDetail planDutyDetail, int PlanDutyTableID, SqlConnection conn, SqlTransaction trans)
        {
            int        pkid;
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Parameters.Add(_ParmPKID, SqlDbType.Int).Direction    = ParameterDirection.Output;
            sqlCommand.Parameters.Add(_PlanDutyTableID, SqlDbType.Int).Value = PlanDutyTableID;
            sqlCommand.Parameters.Add(_Date, SqlDbType.DateTime).Value       = planDutyDetail.Date;
            sqlCommand.Parameters.Add(_DutyClassID, SqlDbType.Int).Value     = planDutyDetail.PlanDutyClass.DutyClassID;
            SqlHelper.TransExecuteNonQueryReturnPKID("InsertPlanDutyDetail", sqlCommand, conn, trans, out pkid);
            //return pkid;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 查找某一个月的PlanDutyDetail
 /// </summary>
 /// <param name="planDutyDetail"></param>
 /// <returns></returns>
 private bool FindPlanDutyDetail(PlanDutyDetail planDutyDetail)
 {
     if (planDutyDetail.Date.Year == _Date.Year &&
         planDutyDetail.Date.Month == _Date.Month)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 11
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.º 12
0
        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);
        }
Ejemplo n.º 13
0
        private PlanDutyDetail InitDate()
        {
            PlanDutyDetail planDutyDetail = PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, _From);

            _MorningStart = planDutyDetail.PlanDutyClass.FirstStartToTime == DateTime.MinValue
                                ? CalculateHourUtility.FixMorningStartTo
                                : planDutyDetail.PlanDutyClass.FirstStartToTime;
            _MorningEnd = planDutyDetail.PlanDutyClass.FirstEndTime == DateTime.MinValue
                              ? CalculateHourUtility.FixMorningEnd
                              : planDutyDetail.PlanDutyClass.FirstEndTime;
            _AfternoonStart = planDutyDetail.PlanDutyClass.SecondStartTime == DateTime.MinValue
                                  ? CalculateHourUtility.FixAfternoonStart
                                  : planDutyDetail.PlanDutyClass.SecondStartTime;
            _AfternoonEnd = planDutyDetail.PlanDutyClass.SecondEndTime == DateTime.MinValue
                                ? CalculateHourUtility.FixAfternoonEndFrom
                                : planDutyDetail.PlanDutyClass.SecondEndTime;

            return(planDutyDetail);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 获取班别详情
        /// </summary>
        /// <param name="PlanDutyTableID"></param>
        /// <returns></returns>
        private static List <PlanDutyDetail> GetPlanDutyDetailByPlanDutyTableID(int PlanDutyTableID)
        {
            List <PlanDutyDetail> planDutyDetails = new List <PlanDutyDetail>();
            SqlCommand            sqlCommand      = new SqlCommand();

            sqlCommand.Parameters.Add(_DbPlanDutyTableID, SqlDbType.Int).Value = PlanDutyTableID;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetPlanDutyDetailByPlanDutyTableID", sqlCommand))
            {
                while (sdr.Read())
                {
                    PlanDutyDetail planDutyDetail = new PlanDutyDetail();
                    planDutyDetail.PlanDutyDetailID          = Convert.ToInt32(sdr[_DbPKID]);
                    planDutyDetail.Date                      = Convert.ToDateTime(sdr[_DbDate]);
                    planDutyDetail.PlanDutyClass             = new DutyClass();
                    planDutyDetail.PlanDutyClass.DutyClassID = Convert.ToInt32(sdr[_DbDutyClassID]);
                    planDutyDetails.Add(planDutyDetail);
                }
                return(planDutyDetails);
            }
        }
Ejemplo n.º 15
0
        private DateTime?GetSequenceDayOfWork(int sequence, DateTime monthDate)
        {
            if (_PlanDutyDetailList == null)
            {
                _PlanDutyDetailList = (new PlanDutyFacade()).GetPlanDutyDetailByAccount(_AccountID, _PlanDutyFrom,
                                                                                        _PlanDutyTo);
            }
            DateTime dt = new DateTime(monthDate.Year, monthDate.Month, 1);

            if (sequence > 0)
            {
                int find = 0;
                for (int i = 0; i < (_PlanDutyTo.Date - _PlanDutyFrom.Date).Days; i++)
                {
                    PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, dt);
                    if (!detail.PlanDutyClass.IsWeek)
                    {
                        find++;
                        if (find == sequence)
                        {
                            return(dt);
                        }
                    }
                    dt = dt.AddDays(1);
                }
            }
            else if (sequence == 0)
            {
                dt = GetLastDate(monthDate);
                for (int i = 0; i < (_PlanDutyTo.Date - _PlanDutyFrom.Date).Days; i++)
                {
                    PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, dt);
                    if (!detail.PlanDutyClass.IsWeek)
                    {
                        return(dt);
                    }
                    dt = dt.AddDays(-1);
                }
            }
            return(null);
        }
Ejemplo n.º 16
0
        public List <PlanDutyDetail> GetPlanDutyDetailByAccount(int AccountID, DateTime dateStart, DateTime dateEnd)
        {
            List <PlanDutyDetail> planDutyDetails = new List <PlanDutyDetail>();
            SqlCommand            sqlCommand      = new SqlCommand();

            sqlCommand.Parameters.Add(_DbAccountID, SqlDbType.Int).Value     = AccountID;
            sqlCommand.Parameters.Add(_DbFromTime, SqlDbType.DateTime).Value = dateStart;
            sqlCommand.Parameters.Add(_DbToTime, SqlDbType.DateTime).Value   = dateEnd;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetPlanDutyDetailByAccount", sqlCommand))
            {
                while (sdr.Read())
                {
                    PlanDutyDetail planDutyDetail = new PlanDutyDetail();
                    planDutyDetail.PlanDutyClass             = new DutyClass();
                    planDutyDetail.PlanDutyClass.DutyClassID = Convert.ToInt32(sdr[_DbPKID]);
                    if (planDutyDetail.PlanDutyClass.DutyClassID != -1)
                    {
                        planDutyDetail.PlanDutyClass.DutyClassName        = (sdr[_DbDutyClassName]).ToString();
                        planDutyDetail.PlanDutyClass.FirstStartFromTime   = Convert.ToDateTime(sdr[_DbFirstStartFromTime]);
                        planDutyDetail.PlanDutyClass.FirstStartToTime     = Convert.ToDateTime(sdr[_DbFirstStartToTime]);
                        planDutyDetail.PlanDutyClass.FirstEndTime         = Convert.ToDateTime(sdr[_DbFirstEndTime]);
                        planDutyDetail.PlanDutyClass.SecondStartTime      = Convert.ToDateTime(sdr[_DbSecondStartTime]);
                        planDutyDetail.PlanDutyClass.SecondEndTime        = Convert.ToDateTime(sdr[_DbSecondEndTime]);
                        planDutyDetail.PlanDutyClass.AllLimitTime         = Convert.ToDecimal(sdr[_DbAllLimitTime]);
                        planDutyDetail.PlanDutyClass.LateTime             = Convert.ToInt32(sdr[_DbLateTime]);
                        planDutyDetail.PlanDutyClass.EarlyLeaveTime       = Convert.ToInt32(sdr[_DbEarlyLeaveTime]);
                        planDutyDetail.PlanDutyClass.AbsentEarlyLeaveTime = Convert.ToInt32(sdr[_DbAbsentEarlyLeaveTime]);
                        planDutyDetail.PlanDutyClass.AbsentLateTime       = Convert.ToInt32(sdr[_DbAbsentLateTime]);
                        planDutyDetail.Date = Convert.ToDateTime(sdr[_DbDate]);
                    }
                    else
                    {
                        planDutyDetail.PlanDutyClass.DutyClassName = "休息";
                        planDutyDetail.Date = Convert.ToDateTime(sdr[_DbDate]);
                    }
                    planDutyDetails.Add(planDutyDetail);
                }
                return(planDutyDetails);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 初始化调休,将出差信息变成一条条调休记录
        /// </summary>
        /// <returns></returns>
        private List <AdjustRest> InitAdjustRestList()
        {
            List <AdjustRest>     adjustRestList      = new List <AdjustRest>();
            DateTime              from                = _OutApplicationItem.FromDate;
            DateTime              to                  = _OutApplicationItem.ToDate;
            CalculateDays         _CalculateDays      = new CalculateDays(BllInstance.SpecialDateBllInstance.GetAllSpecialDate(null));
            List <PlanDutyDetail> _PlanDutyDetailList =
                new PlanDutyDal().GetPlanDutyDetailByAccount(_AccountID, from, to);

            CalculateOutCityHour calculateOutCityHour = new CalculateOutCityHour(from, to, _AccountID);

            calculateOutCityHour.Excute();
            foreach (DayAttendance attendance in calculateOutCityHour.DayAttendanceList)
            {
                PlanDutyDetail planDutyDetail =
                    PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, attendance.Date);
                AdjustRest ar = new AdjustRest();
                ar.AdjustYear = attendance.Date;
                if (_CalculateDays.IsNationalHoliday(attendance.Date))
                {
                    //节日
                    ar.SurplusHours = attendance.Hours * _AdjustRule.OutCityJieRiRate;
                }

                else if (planDutyDetail.PlanDutyClass.IsWeek)
                {
                    //双休
                    ar.SurplusHours = attendance.Hours * _AdjustRule.OutCityShuangXiuRate;
                }
                else
                {
                    //普通
                    ar.SurplusHours = 0; //attendance.Hours*_AdjustRule.OutCityPuTongRate;
                }
                adjustRestList.Add(ar);
            }
            return(adjustRestList);
        }
Ejemplo n.º 18
0
        private void JudgeOverWorkType()
        {
            if (_PlanDutyDetailList == null)
            {
                HrmisUtility.ThrowException(HrmisUtility._OverWorkType_Not_OneDay);
            }
            else
            {
                PlanDutyDetail planDutyDetail = InitDate();
                if (_CalculateDays.IsNationalHoliday(_From))
                {
                    OverWorkType = OverWorkType.JieRi;
                }

                else if (planDutyDetail.PlanDutyClass.IsWeek)
                {
                    OverWorkType = OverWorkType.ShuangXiu;
                }
                else
                {
                    OverWorkType = OverWorkType.PuTong;
                }
            }
        }
Ejemplo n.º 19
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                List <PlanDutyDetail> planDutyDetailList =
                    new PlanDutyFacade().GetPlanDutyDetailByAccount(source[0].Owner.Id, start, end);

                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is DayRepeat)
                    {
                        DayRepeat type = (DayRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date = tempstart;
                        int      days = (tempend.Date - tempstart.Date).Days;
                        for (int i = 0; i <= days; i++)
                        {
                            bool isadd = false;
                            if (type.EveryWork || type.EveryWeek)
                            {
                                PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, date);
                                if ((type.EveryWork && !detail.PlanDutyClass.IsWeek) ||
                                    (type.EveryWeek && detail.PlanDutyClass.IsWeek))
                                {
                                    isadd = true;
                                }
                            }
                            else
                            {
                                if ((date.Date - type.RangeStart.Date).Days % type.NDayOnce == 0)
                                {
                                    isadd = true;
                                }
                            }
                            if (isadd)
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, notes.Start, notes.End), date, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 系统自动发信
        /// </summary>
        private void SystemSendEmailByCondition(OutInTimeConditionEnum outInTimeCondition)
        {
            sendMail = new AttendanceSendEmail();
            StringBuilder emailContentBuilder = new StringBuilder();

            for (int i = 0; i < AllEmployeeList.Count; i++)
            {
                //找前一天数据
                DateTime tempDate = _SearchTo.AddDays(-1);
                while (DateTime.Compare(Convert.ToDateTime(_SearchFrom.ToShortDateString()),
                                        Convert.ToDateTime(tempDate.ToShortDateString())) <= 0)
                {
                    AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutRecordList = _DalRecord.
                                                                                         GetAttendanceInAndOutRecordByCondition
                                                                                             (AllEmployeeList[i].Account.Id, "", tempDate, tempDate.AddDays(1), InOutStatusEnum.All,
                                                                                             OutInRecordOperateStatusEnum.All, Convert.ToDateTime("1900-1-1"),
                                                                                             Convert.ToDateTime("2900-12-31"));

                    AllEmployeeList[i].EmployeeAttendance.InAndOutStatistics(tempDate);

                    bool           isOnDuty          = true;
                    PlanDutyDetail dayPlanDutyDetail =
                        PlanDutyDetail.GetPlanDutyDetailByDate(
                            AllEmployeeList[i].EmployeeAttendance.PlanDutyDetailList, tempDate);
                    if (dayPlanDutyDetail == null)
                    {
                        if (tempDate.DayOfWeek == DayOfWeek.Saturday ||
                            tempDate.DayOfWeek == DayOfWeek.Sunday)
                        {
                            isOnDuty = false;
                        }
                    }
                    else if (dayPlanDutyDetail.PlanDutyClass.DutyClassID == -1)
                    {
                        isOnDuty = false;
                    }

                    string absentString = "";

                    //如果这一天是休息日且进出单打卡 或者 非休息日且满足发信条件 或者 不正常数据
                    if ((!isOnDuty && AllEmployeeList[i].EmployeeAttendance.IsOutInTimeCondition(OutInTimeConditionEnum.InOrOutTimeOnlyOneIsNull)) ||
                        (isOnDuty && AllEmployeeList[i].EmployeeAttendance.IsOutInTimeCondition(outInTimeCondition)) ||
                        !AllEmployeeList[i].EmployeeAttendance.StatisticIsNormal(tempDate, out absentString))
                    {
                        string inTime  = AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutStatistics.InTime.ToString();
                        string outTime = AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutStatistics.OutTime.ToString();
                        string status  = AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutStatistics.LeaveRequestAndOut;

                        SendEmailForEmployees(AllEmployeeList[i], inTime, outTime, status, tempDate);
                        SendMessageForEmployees(AllEmployeeList[i], tempDate);

                        emailContentBuilder.Append(AllEmployeeList[i].Account.Name);
                        emailContentBuilder.Append(tempDate.ToShortDateString());
                        emailContentBuilder.Append(" 进入时间:");
                        emailContentBuilder.Append(inTime == "2999-12-31 0:00:00" ? "无打卡记录" : inTime);
                        emailContentBuilder.Append(" 离开时间:");
                        emailContentBuilder.Append(outTime == "1900-1-1 0:00:00" ? "无打卡记录" : outTime);
                        emailContentBuilder.Append(" 请假或外出情况:");
                        emailContentBuilder.Append(string.IsNullOrEmpty(status) ? "无" : status);
                        if (absentString != "")
                        {
                            emailContentBuilder.Append(absentString);
                        }
                        emailContentBuilder.Append(Environment.NewLine);
                    }
                    tempDate = tempDate.AddDays(-1);
                }
            }
            if (emailContentBuilder.Length > 0)
            {
                emailContentBuilder.Append("请核对打卡信息和外出请假情况,如果信息有误,请登录系统查看!");
                string subject = _SearchFrom + "--" + _SearchTo + "期间的考勤信息";
                sendMail.AttendanceSendEmailToHR(subject, emailContentBuilder);
            }
        }
Ejemplo n.º 21
0
        public List <PlanDutyDetail> InitNewPlanDutyDetailList(DateTime date)
        {
            List <PlanDutyDetail> planDutyDetailList = new List <PlanDutyDetail>();
            DateTime monthFrom = date.AddDays(1 - date.Day);
            DateTime monthTo   = date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1);
            DateTime temp      = monthFrom;

            #region 如果有周期则找出周期值

            bool  isCaculatePeriod = false;
            int[] periodValue      = new int[0];
            //如果周期已经设定,且设定为大于0的整数
            if (!string.IsNullOrEmpty(_ItsView.SetPlanDutyView.Period.Trim()) &&
                Int32.TryParse(_ItsView.SetPlanDutyView.Period, out period) &&
                period > 0)
            {
                List <PlanDutyDetail> lastPlanDutyDetailList =
                    _ItsView.SetPlanDutyView.GetViewState(date.AddMonths(-1).Year + ";" + date.AddMonths(-1).Month);
                //并且可以找到上个月的ViewState,则可以计算周期
                isCaculatePeriod = lastPlanDutyDetailList != null;
                if (isCaculatePeriod)
                {
                    //找出周期值
                    periodValue = new int[period];
                    _Date       = monthFrom.AddDays(-period - 1);
                    for (int i = 0; i < period; i++)
                    {
                        _Date = _Date.AddDays(1);
                        PlanDutyDetail planDutyDetail = lastPlanDutyDetailList.Find(FindOnePlanDutyDetail);
                        if (planDutyDetail != null)
                        {
                            periodValue[i] = planDutyDetail.PlanDutyClass.DutyClassID;
                        }
                        else//如果有找不到周期则不计算
                        {
                            isCaculatePeriod = false;
                            break;
                        }
                    }
                }
            }
            #endregion
            while (DateTime.Compare(temp, monthTo) <= 0)
            {
                _Date = temp;
                SpecialDate    specialDate    = specialDateList.Find(FindSpecialDate);
                PlanDutyDetail planDutyDetail = new PlanDutyDetail();
                planDutyDetail.Date          = temp;
                planDutyDetail.PlanDutyClass = new DutyClass();
                if (isCaculatePeriod && periodValue.Length > 0)//如果计算周期
                {
                    planDutyDetail.PlanDutyClass.DutyClassID = periodValue[(temp.Day - monthFrom.Day) % period];
                }
                else//否则绑定公司特殊日期
                {
                    if (specialDate != null && dutyClassList.Count > 0)
                    {
                        planDutyDetail.PlanDutyClass.DutyClassID = specialDate.IsWork == 1 ? 1 : -1;
                    }
                    else
                    {
                        //如果不是周末,且有班别类表
                        if (temp.DayOfWeek != DayOfWeek.Saturday &&
                            temp.DayOfWeek != DayOfWeek.Sunday &&
                            dutyClassList.Count > 0)
                        {
                            planDutyDetail.PlanDutyClass.DutyClassID = 1;
                        }
                        else
                        {
                            planDutyDetail.PlanDutyClass.DutyClassID = -1;
                        }
                    }
                }
                planDutyDetailList.Add(planDutyDetail);
                temp = temp.AddDays(1);
            }
            return(planDutyDetailList);
        }
Ejemplo n.º 22
0
        public static List <CalendarADay> Turn(List <AttendanceBase> originalDataList,
                                               List <CalendarADay> retList, List <PlanDutyDetail> planDutyDetailList,
                                               List <OutApplication> outApplicationList, List <LeaveRequest> leaveRequestList, List <AttendanceInAndOutRecord> attendanceInAndOutRecordList)
        {
            foreach (AttendanceBase originalData in originalDataList)
            {
                PlanDutyDetail theDayPlanDuty =
                    PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, originalData.TheDay);
                if (theDayPlanDuty == null)
                {
                    continue;
                }
                CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, originalData.TheDay);

                DayItem   day   = new DayItem();
                MonthItem month = new MonthItem();
                day.ObjectID = month.ObjectID = originalData.AttendanceId;
                day.CType    = month.CType = CalendarShowType.Absent;
                day.ObjectID = month.ObjectID = originalData.AttendanceId;
                month.Date   = calendarADay.Date;
                LaterAttendance      late;
                EarlyLeaveAttendance early;
                if (originalData is AbsentAttendance)
                {
                    day.Start = theDayPlanDuty.PlanDutyClass.FirstStartFromTime;
                    day.End   = originalData.Days == 1
                                  ? theDayPlanDuty.PlanDutyClass.SecondEndTime
                                  : theDayPlanDuty.PlanDutyClass.FirstEndTime;
                    if (originalData.Days != 1)
                    {
                        List <UnKownTimeSpan> uktsList =
                            CaculateAbsentTimes(originalData.TheDay, theDayPlanDuty, outApplicationList,
                                                leaveRequestList,
                                                attendanceInAndOutRecordList);
                        foreach (UnKownTimeSpan span in uktsList)
                        {
                            if ((span.To - span.From).TotalMinutes >= theDayPlanDuty.PlanDutyClass.AbsentLateTime
                                ||
                                (span.To - span.From).TotalMinutes >= theDayPlanDuty.PlanDutyClass.AbsentEarlyLeaveTime)
                            {
                                day.Start = span.From;
                                day.End   = span.To;
                            }
                        }
                    }
                    day.DayDetail = originalData.Name + " " + Utility.FormatNumData(originalData.Days * 8) + "小时";
                    month.Title   = month.Detail = originalData.Name + " " + Utility.FormatNumData(originalData.Days * 8) + "小时";
                }
                else if ((early = originalData as EarlyLeaveAttendance) != null)
                {
                    day.Start        = theDayPlanDuty.PlanDutyClass.SecondEndTime.AddMinutes(-early.EarlyLeaveMinutes);
                    day.End          = theDayPlanDuty.PlanDutyClass.SecondEndTime;
                    day.DayDetail    = early.Name + " " + Utility.FormatNumData(early.EarlyLeaveMinutes) + "分钟";
                    month.Title      =
                        month.Detail = early.Name + " " + Utility.FormatNumData(early.EarlyLeaveMinutes) + "分钟";
                }
                else if ((late = originalData as LaterAttendance) != null)
                {
                    day.Start     = theDayPlanDuty.PlanDutyClass.FirstStartFromTime;
                    day.End       = theDayPlanDuty.PlanDutyClass.FirstStartFromTime.AddMinutes(late.LaterMinutes);
                    day.DayDetail = late.Name + " " + Utility.FormatNumData(late.LaterMinutes) + "分钟";
                    month.Title   = month.Detail = late.Name + " " + Utility.FormatNumData(late.LaterMinutes) + "分钟";
                }

                calendarADay.DayItems.Add(day);
                calendarADay.MonthItems.Add(month);
                Utility.Clean(calendarADay);
            }
            return(retList);
        }
Ejemplo n.º 23
0
        public static decimal CalculateOneDay(DateTime from, DateTime to, decimal leastHour, PlanDutyDetail detail)
        {
            TimeSpan ts = detail.PlanDutyClass.FirstStartToTime -
                          detail.PlanDutyClass.FirstStartFromTime;
            DateTime fromtemp = from;
            DateTime totemp   = to;

            if (DateTimeCompareShortTime(from, detail.PlanDutyClass.FirstStartFromTime) <= 0)
            {
                fromtemp = detail.PlanDutyClass.FirstStartFromTime;
            }
            else if (DateTimeCompareShortTime(from, detail.PlanDutyClass.FirstEndTime) >= 0 &&
                     DateTimeCompareShortTime(from, detail.PlanDutyClass.SecondStartTime) <= 0)
            {
                fromtemp = detail.PlanDutyClass.SecondStartTime;
            }
            if (DateTimeCompareShortTime(to, detail.PlanDutyClass.SecondEndTime.Add(ts)) >= 0)
            {
                totemp = detail.PlanDutyClass.SecondEndTime.Add(ts);
            }
            else if (DateTimeCompareShortTime(to, detail.PlanDutyClass.FirstEndTime) >= 0 &&
                     DateTimeCompareShortTime(to, detail.PlanDutyClass.SecondStartTime) <= 0)
            {
                totemp = detail.PlanDutyClass.FirstEndTime;
            }
            double  tsTotalMinutes = DateTimeCompareShortTime(totemp, fromtemp);
            decimal costMinutes    = tsTotalMinutes < 0 ? 0m : Convert.ToDecimal(tsTotalMinutes);

            if (DateTimeCompareShortTime(fromtemp, detail.PlanDutyClass.FirstEndTime) <= 0 &&
                DateTimeCompareShortTime(fromtemp, detail.PlanDutyClass.FirstStartFromTime) >= 0 &&
                DateTimeCompareShortTime(totemp, detail.PlanDutyClass.SecondEndTime.Add(ts)) <= 0 &&
                DateTimeCompareShortTime(totemp, detail.PlanDutyClass.SecondStartTime) >= 0)
            {
                costMinutes -=
                    Convert.ToDecimal(
                        (detail.PlanDutyClass.SecondStartTime - detail.PlanDutyClass.FirstEndTime).TotalMinutes);
            }
            decimal answer = leastHour == 0 ? ConvertToHour(costMinutes / 60) : ConvertToHour(costMinutes / 60, leastHour);

            return(answer > _OneDayMaxHour ? _OneDayMaxHour : answer);
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
0
        public static List <CalendarADay> Turn(List <WorkTask> originalDataList, List <CalendarADay> retList,
                                               List <PlanDutyDetail> planDutyDetailList, int accountID, DateTime startDate, DateTime endDate)
        {
            foreach (WorkTask originalData in originalDataList)
            {
                for (int i = 0; originalData.StartDate.AddDays(i).Date <= originalData.EndDate.Date; i++)
                {
                    if (originalData.StartDate.AddDays(i).Date < startDate.Date ||
                        originalData.StartDate.AddDays(i).Date > endDate.Date)
                    {
                        continue;
                    }
                    PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, originalData.StartDate.AddDays(i).Date);
                    if (detail != null && detail.PlanDutyClass != null && detail.PlanDutyClass.IsWeek)
                    {
                        continue;
                    }
                    CalendarADay calendarADay =
                        CalendarADay.CreateOrGetCalendarADayByDate(retList, originalData.StartDate.AddDays(i).Date);

                    MonthItem month = new MonthItem();
                    month.CType  = CalendarShowType.WorkTask;
                    month.Title  = originalData.Title;
                    month.Date   = originalData.StartDate.AddDays(i).Date;
                    month.Detail = month.Title +
                                   (originalData.Account.Id == accountID ? "" : "<br>创建人:" + originalData.Account.Name)
                                   + "<br>时段:" + originalData.StartDate.ToShortDateString() + "--" +
                                   originalData.EndDate.ToShortDateString() + " 状态:<span class=\"" +
                                   originalData.Status.Style + "\">" + originalData.Status.Name +
                                   "</span><br>" + originalData.Description;
                    calendarADay.MonthItems.Add(month);

                    DayItem day = new DayItem();
                    day.CType = CalendarShowType.WorkTask;
                    day.Start = day.End = originalData.StartDate.AddDays(i).Date;

                    if (detail != null)
                    {
                        day.Start =
                            new DateTime(day.Start.Year, day.Start.Month, day.Start.Day,
                                         detail.PlanDutyClass.FirstStartFromTime.Hour,
                                         detail.PlanDutyClass.FirstStartFromTime.Minute,
                                         detail.PlanDutyClass.FirstStartFromTime.Second); //todo by wsl
                        day.End =
                            new DateTime(day.End.Year, day.End.Month, day.End.Day,
                                         detail.PlanDutyClass.SecondEndTime.Hour,
                                         detail.PlanDutyClass.SecondEndTime.Minute,
                                         detail.PlanDutyClass.SecondEndTime.Second);
                    }
                    else
                    {
                        day.Start = new DateTime(day.Start.Year, day.Start.Month, day.Start.Day, 9, 0, 0);
                        day.End   = new DateTime(day.End.Year, day.End.Month, day.End.Day, 17, 0, 0);
                    }

                    day.DayDetail = month.Title +
                                    (originalData.Account.Id == accountID ? "" : "<br>创建人:" + originalData.Account.Name)
                                    + "<br>时段:" +
                                    originalData.StartDate.ToShortDateString() + "--" +
                                    originalData.EndDate.ToShortDateString() + "<br>状态:" + originalData.Status.Name +
                                    "<br>" + originalData.Description;
                    calendarADay.DayItems.Add(day);
                    Utility.Clean(calendarADay);
                }
            }
            return(retList);
        }
Ejemplo n.º 26
0
        public static List <CalendarADay> Turn(List <LeaveRequest> originalDataList,
                                               List <PlanDutyDetail> planDutyDetailList, List <SpecialDate> specialList, List <CalendarADay> retList)
        {
            CalculateDays _CalculateDays = new CalculateDays(specialList);

            foreach (LeaveRequest originalData in originalDataList)
            {
                foreach (LeaveRequestItem originalDataItem in originalData.LeaveRequestItems)
                {
                    DateTime from     = originalDataItem.FromDate;
                    DateTime to       = originalDataItem.ToDate;
                    decimal  costHour = 0m;
                    if (from >= to)
                    {
                        CreateLeaveRequestInfoInADay(retList, from, 0, originalData, originalDataItem, from, to);
                    }
                    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)
                        {
                            DateTime dtMorningStart, dtAfternoonEnd;
                            InitDateTime(from, to, detail, out dtMorningStart, out dtAfternoonEnd);
                            DateTime fromtemp =
                                new DateTime(date.Year, date.Month, date.Day, dtMorningStart.Hour,
                                             dtMorningStart.Minute, dtMorningStart.Second);
                            DateTime totemp =
                                new DateTime(date.Year, date.Month, date.Day, dtAfternoonEnd.Hour,
                                             dtAfternoonEnd.Minute, dtAfternoonEnd.Second);
                            if (i == 0)
                            {
                                fromtemp = from;
                            }
                            if (i == days)
                            {
                                totemp = to;
                            }
                            decimal hour;
                            //排除双休日,节假日
                            if (originalData.LeaveRequestType.IncludeLegalHoliday == LegalHoliday.Include &&
                                _CalculateDays.IsNationalHoliday(date))
                            {
                                if (detail.PlanDutyClass.IsWeek)
                                {
                                    hour      = Utility._OneDayMaxHour;
                                    costHour += hour;
                                }
                                else
                                {
                                    hour      = Utility.CalculateOneDay(fromtemp, totemp, originalData.LeaveRequestType.LeastHour, detail);
                                    costHour += hour;
                                }
                                CreateLeaveRequestInfoInADay(retList, date, hour, originalData, originalDataItem, fromtemp,
                                                             totemp);
                            }
                            else if (originalData.LeaveRequestType.IncludeLegalHoliday == LegalHoliday.Include &&
                                     detail.PlanDutyClass.IsWeek && !_CalculateDays.IsNationalHoliday(date))
                            {
                                hour      = Utility._OneDayMaxHour;
                                costHour += hour;
                                CreateLeaveRequestInfoInADay(retList, date, hour, originalData, originalDataItem, fromtemp,
                                                             totemp);
                            }

                            else if (!detail.PlanDutyClass.IsWeek)
                            {
                                hour      = Utility.CalculateOneDay(fromtemp, totemp, originalData.LeaveRequestType.LeastHour, detail);
                                costHour += hour;
                                CreateLeaveRequestInfoInADay(retList, date, hour, originalData, originalDataItem, fromtemp,
                                                             totemp);
                            }
                        }
                        date = date.AddDays(1);
                    }
                }
            }

            return(retList);
        }