コード例 #1
0
        public IList <TSHoursRecord> GetRecordsForWeek(int year, int week, int employeeId)
        {
            var startWeekDate = DateTimeExtention.FirstDateOfWeekISO8601(year, week);
            var endWeekDate   = DateTimeExtention.LastDateOfWeekISO8601(year, week);

            return(Get(records => records.Where(x => x.RecordDate >= startWeekDate && x.RecordDate <= endWeekDate && x.EmployeeID == employeeId).ToList()));
        }
コード例 #2
0
        public ProductionCalendarRecord GetSpecifiedWorkDayInSelectedWeek(int numberWorkDay, DateTime dateTime)
        {
            //получить эту неделю
            var currentYear       = dateTime.Year;
            var currentWeekNumber = DateTimeExtention.GetIso8601WeekOfYear(dateTime);

            var currentWeekStart = DateTimeExtention.FirstDateOfWeekISO8601(currentYear, currentWeekNumber);
            var currentWeekEnd   = DateTimeExtention.LastDateOfWeekISO8601(currentYear, currentWeekNumber);

            ProductionCalendarRecord foundWorkingCalendarDay = null;
            var currentWeekDateRange = currentWeekStart.Range(currentWeekEnd);

            foreach (var date in RepositoryFactory.GetRepository <IProductionCalendarRepository>().GetQueryable().Where(x => currentWeekDateRange.Any(o => x.CalendarDate == o)))
            {
                if (date.WorkingHours > 0)
                {
                    --numberWorkDay;
                }

                if (numberWorkDay == 0)
                {
                    foundWorkingCalendarDay = date;
                    break;
                }
            }
            return(foundWorkingCalendarDay);
        }