public ShiftDay GetShiftDayforDateTime(DateTime timestamp) { if (Days != null && Days.Any() && Department != null) { var shiftStart = StartTime; if (String.IsNullOrWhiteSpace(shiftStart)) { shiftStart = "12:00 AM"; } var shiftDays = from sd in Days let shiftDayTime = DateTimeHelpers.ConvertStringTime(shiftStart, sd.Day, Department.Use24HourTime.GetValueOrDefault()) let shiftDayToCheck = timestamp.TimeConverter(Department) where shiftDayTime == shiftDayToCheck.Within(TimeSpan.FromMinutes(15)) select sd; if (shiftDays != null) { return(shiftDays.FirstOrDefault()); } } return(null); }
public DateTime?GetNextTime(DateTime current) { if (SecondType == CronFieldType.Specified && !Seconds.Any()) { throw new ArgumentException("Seconds are Empty."); } if (MinuteType == CronFieldType.Specified && !Minutes.Any()) { throw new ArgumentException("Minutes are Empty."); } if (HourType == CronFieldType.Specified && !Hours.Any()) { throw new ArgumentException("Hours are Empty."); } if (DayType == CronFieldType.Specified && !Days.Any()) { throw new ArgumentException("Days are Empty."); } if (MonthType == CronFieldType.Specified && !Months.Any()) { throw new ArgumentException("Months are Empty."); } if (DayOfWeekType == CronFieldType.Specified && !DayOfWeeks.Any()) { throw new ArgumentException("DayOfWeeks are Empty."); } if (YearType == CronFieldType.Specified && !Years.Any()) { throw new ArgumentException("Years are Empty."); } return(NextSecond(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second)); }
protected void SetDaysOfWeek(int[] daysOfWeek) { if (!daysOfWeek.Any()) { throw new DomainException($"{nameof(Days)} must have atleast one value!"); } if (daysOfWeek.Count() > 7) { throw new DomainException($"{nameof(Days)} cannot have more then 7!"); } foreach (var digit in daysOfWeek) { if (Days.Any(x => x.DayOfWeek == digit)) { throw new DomainException($"{nameof(Days)} already contains {digit}!"); } (Days as ICollection <Day>).Add(Day.CreateDay(digit)); } }
private bool CanExecuteAdd(object obj) { if (RateDetails.VehicleType <= 0) { return(false); } if (RateDetails.EndTime <= RateDetails.BeginTime) { return(false); } if (RateDetails.Mode == 0) { var CurVehicleRates = Rate.Rates.Where(x => x.VehicleType == RateDetails.VehicleType && x.EndTime == GlobalClass.EndTime); foreach (Day d in Days.Where(x => x.IsChecked)) { if (CurVehicleRates.Any(x => x.Day == d.DayId)) { return(false); } } } return(Days.Any(x => x.IsChecked)); }