コード例 #1
0
        public static bool CheckNotificationValidOptions(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate, out NotificationOptions validOptions)
        {
            var isValid     = false;
            var lastNow     = now.AddMinutes(notificationDefinition.SendStartDuration);
            var lastNowTime = lastNow.TimeOfDay;


            NotificationDateValidationInfo DateValidInfo = new NotificationDateValidationInfo();

            foreach (var rule in Rules)
            {
                DateValidInfo = rule.DecideNotificationTimeValidation(notificationDefinition, notificationOptions, now, requestDate);
                if (DateValidInfo.isValid || IsRequestDateLessThanNow(notificationDefinition, requestDate, now))
                {
                    break;
                }
            }

            validOptions = new NotificationOptions()
            {
                SendStartTime = DateTime.MinValue,
                SendEndTime   = DateTime.MinValue
            };

            //Control if decision starttime expire options endTime
            if (!NotificationDateValidator.IsNotificationOptionsNullOrEmpty(notificationOptions) && notificationOptions.ControlWithNotificationSchedule)
            {
                if (!DateValidInfo.SendStartTime.IsLessThan(notificationOptions.SendEndTime) && DateValidInfo.SendStartTime != DateTime.MinValue)
                {
                    return(isValid);
                }
                if (DateValidInfo.isValid)
                {
                    validOptions.SendEndTime = notificationOptions.SendEndTime;
                }
            }

            validOptions.SendStartTime = DateValidInfo.SendStartTime;
            if (validOptions.SendEndTime == DateTime.MinValue)
            {
                validOptions.SendEndTime = DateValidInfo.SendEndTime;
            }

            isValid = DateValidInfo.isValid;

            //validOptions.SendEndTime = ControlProcessTimeDayOut(validOptions, isValid, notificationDefinition, now);

            return(isValid);
        }
コード例 #2
0
        public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate)
        {
            bool     isValid   = false;
            DateTime startTime = new DateTime();
            DateTime endTime   = new DateTime();

            if (!NotificationDateValidator.IsNotificationOptionsNullOrEmpty(notificationOptions) && !notificationOptions.ControlWithNotificationSchedule)
            {
                startTime = notificationOptions.SendStartTime;
                endTime   = notificationOptions.SendEndTime;
                isValid   = now.IsLessThanOrEquals(endTime);
            }

            return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid));
        }