コード例 #1
0
        protected void ProcessWeek(EmployeePlanningDayList planning_days, SrvEmployeeRecordingDayList actual_days, IWorkingModelData week)
        {
            CountSaturday = 0;
            CountSunday = 0;
            WorkingDaysBefore = 0;
            WorkingDaysAfter = 0;

            _days_diction.Clear();

            DateTime endDateSunday = CurrentMonday.AddDays(13);

            if (planning_days != null && planning_days.List != null && planning_days.List.Count > 0)
            {
                for (int i = 0; i < planning_days.List.Count; i++)
                {
                    if (planning_days.List[i].Date <= endDateSunday)
                    {
                        _days_diction[planning_days.List[i].Date] = (IEmployeeDay)planning_days.List[i];
                    }
                }
            }

            if (actual_days!= null && actual_days.List != null && actual_days.List.Count > 0)
            {
                for (int i = 0; i < actual_days.List.Count; i++)
                {
                    if (actual_days.List[i].Date <= endDateSunday)
                        _days_diction[actual_days.List[i].Date] = (IEmployeeDay)actual_days.List[i];
                }
            }

            int SumOfPlannedHoursByMonth = 0;
            foreach (IEmployeeDay day in _days_diction.Values)
            {
                if (day.Date < CurrentMonday && day.Date.Month == CurrentMonday.Month)
                {
                    SumOfPlannedHoursByMonth += day.AllreadyPlannedHours;

                    if (day.Date.DayOfWeek == DayOfWeek.Saturday && day.WorkingHours > 0)
                    {
                            CountSaturday++;
                    }
                    if (day.Date.DayOfWeek == DayOfWeek.Sunday && day.WorkingHours > 0)
                    {
                            CountSunday++;
                    }
                }
            }
            DateTime begin;
            IEmployeeDay day_item = null;
            for (int i = 1; i <= 7; i++)
            {
                begin = CurrentMonday.AddDays(-i);
                if (_days_diction.TryGetValue(begin, out day_item) && day_item.WorkingHours > 0)
                {
                    WorkingDaysBefore++;
                }
                else
                    break;

            }
            DateTime sunday = DateTimeHelper.GetSunday(CurrentMonday);
            for (int i = 1; i <= 7; i++)
            {
                begin = sunday.AddDays(i);
                if (_days_diction.TryGetValue(begin, out day_item) && day_item.WorkingHours > 0)
                {
                    WorkingDaysAfter++;
                }
                else
                    break;

            }

            //Debug.Assert(week.WorkingTimeByMonth == SumOfPlannedHoursByMonth);
            //Debug.Assert(week.CountSaturday == (byte)CountSaturday);
            //Debug.Assert(week.CountSunday == (byte)CountSunday);
            //Debug.Assert(week.WorkingDaysBefore == (byte)WorkingDaysBefore);
            //Debug.Assert(week.WorkingDaysAfter == (byte)WorkingDaysAfter);

            week.WorkingTimeByMonth = SumOfPlannedHoursByMonth;
            week.CountSaturday = (byte)CountSaturday;
            week.CountSunday = (byte)CountSunday;

            week.WorkingDaysBefore = (byte)WorkingDaysBefore;
            week.WorkingDaysAfter = (byte)WorkingDaysAfter;
        }
コード例 #2
0
        protected void ProcessWeek(EmployeePlanningDayList planning_days, SrvEmployeeRecordingDayList actual_days, IWorkingModelData week)
        {
            CountSaturday     = 0;
            CountSunday       = 0;
            WorkingDaysBefore = 0;
            WorkingDaysAfter  = 0;

            _days_diction.Clear();

            DateTime endDateSunday = CurrentMonday.AddDays(13);

            if (planning_days != null && planning_days.List != null && planning_days.List.Count > 0)
            {
                for (int i = 0; i < planning_days.List.Count; i++)
                {
                    if (planning_days.List[i].Date <= endDateSunday)
                    {
                        _days_diction[planning_days.List[i].Date] = (IEmployeeDay)planning_days.List[i];
                    }
                }
            }


            if (actual_days != null && actual_days.List != null && actual_days.List.Count > 0)
            {
                for (int i = 0; i < actual_days.List.Count; i++)
                {
                    if (actual_days.List[i].Date <= endDateSunday)
                    {
                        _days_diction[actual_days.List[i].Date] = (IEmployeeDay)actual_days.List[i];
                    }
                }
            }


            int SumOfPlannedHoursByMonth = 0;

            foreach (IEmployeeDay day in _days_diction.Values)
            {
                if (day.Date < CurrentMonday && day.Date.Month == CurrentMonday.Month)
                {
                    SumOfPlannedHoursByMonth += day.AllreadyPlannedHours;

                    if (day.Date.DayOfWeek == DayOfWeek.Saturday && day.WorkingHours > 0)
                    {
                        CountSaturday++;
                    }
                    if (day.Date.DayOfWeek == DayOfWeek.Sunday && day.WorkingHours > 0)
                    {
                        CountSunday++;
                    }
                }
            }
            DateTime     begin;
            IEmployeeDay day_item = null;

            for (int i = 1; i <= 7; i++)
            {
                begin = CurrentMonday.AddDays(-i);
                if (_days_diction.TryGetValue(begin, out day_item) && day_item.WorkingHours > 0)
                {
                    WorkingDaysBefore++;
                }
                else
                {
                    break;
                }
            }
            DateTime sunday = DateTimeHelper.GetSunday(CurrentMonday);

            for (int i = 1; i <= 7; i++)
            {
                begin = sunday.AddDays(i);
                if (_days_diction.TryGetValue(begin, out day_item) && day_item.WorkingHours > 0)
                {
                    WorkingDaysAfter++;
                }
                else
                {
                    break;
                }
            }


            //Debug.Assert(week.WorkingTimeByMonth == SumOfPlannedHoursByMonth);
            //Debug.Assert(week.CountSaturday == (byte)CountSaturday);
            //Debug.Assert(week.CountSunday == (byte)CountSunday);
            //Debug.Assert(week.WorkingDaysBefore == (byte)WorkingDaysBefore);
            //Debug.Assert(week.WorkingDaysAfter == (byte)WorkingDaysAfter);


            week.WorkingTimeByMonth = SumOfPlannedHoursByMonth;
            week.CountSaturday      = (byte)CountSaturday;
            week.CountSunday        = (byte)CountSunday;

            week.WorkingDaysBefore = (byte)WorkingDaysBefore;
            week.WorkingDaysAfter  = (byte)WorkingDaysAfter;
        }