コード例 #1
0
        public SubscriptionSchedule(QuerySchedule schedule)
        {
            schedule ??= new QuerySchedule();

            _seconds    = ScheduleEntry.Parse(schedule.Second, 0, 59);
            _minutes    = ScheduleEntry.Parse(schedule.Minute, 0, 59);
            _hours      = ScheduleEntry.Parse(schedule.Hour, 0, 23);
            _dayOfMonth = ScheduleEntry.Parse(schedule.DayOfMonth, 1, 31);
            _month      = ScheduleEntry.Parse(schedule.Month, 1, 12);
            _dayOfWeek  = ScheduleEntry.Parse(schedule.DayOfWeek, 1, 7);
        }
コード例 #2
0
ファイル: Mapper.cs プロジェクト: k4st0r42/epcis
        public static SubscriptionSchedule MapToSchedule(this QuerySchedule schedule)
        {
            if (schedule == null)
            {
                return(new SubscriptionSchedule());
            }

            return(new SubscriptionSchedule
            {
                Seconds = schedule.Second ?? string.Empty,
                Minutes = schedule.Minute ?? string.Empty,
                Hours = schedule.Hour ?? string.Empty,
                Month = schedule.Month ?? string.Empty,
                DayOfWeek = schedule.DayOfWeek ?? string.Empty,
                DayOfMonth = schedule.DayOfMonth ?? string.Empty
            });
        }
コード例 #3
0
        private void ValidateRequest(Subscription subscription)
        {
            var query = _queries.FirstOrDefault(q => q.Name == subscription.QueryName);

            if (query == null)
            {
                throw new EpcisException(ExceptionType.NoSuchNameException, $"Query with name '{subscription.QueryName}' is not implemented");
            }
            else if (!query.AllowSubscription)
            {
                throw new EpcisException(ExceptionType.SubscribeNotPermittedException, $"Query with name '{subscription.QueryName}' does not allow subscription");
            }
            else if (!(subscription.Schedule == null ^ string.IsNullOrEmpty(subscription.Trigger)))
            {
                throw new EpcisException(ExceptionType.SubscriptionControlsException, "Only one of the schedule and trigger must be provided");
            }
            else if (!QuerySchedule.IsValid(subscription.Schedule))
            {
                throw new EpcisException(ExceptionType.SubscriptionControlsException, "Provided schedule parameters are invalid");
            }

            EnsureDestinationIsValidURI(subscription);
            EnsureDestinationHasEndSlash(subscription);
        }