Exemplo n.º 1
0
        public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate)
        {
            bool     isValid   = false;
            DateTime startTime = new DateTime();
            DateTime endTime   = new DateTime();
            //lastNow degerini kullaniyoruz. DateTime.Now'a eklenen sure ile gun bilgisi degisebilir
            var lastNow     = now.AddMinutes(notificationDefinition.SendStartDuration);
            var lastNowTime = lastNow.TimeOfDay;

            if (NotificationDateValidator.IsExistSchedule(notificationDefinition))
            {
                foreach (var scheduleItem in notificationDefinition.Schedules)
                {
                    if (scheduleItem.StartTime < scheduleItem.EndTime)
                    {
                        var residualMinutes = scheduleItem.StartTime.Subtract(now.TimeOfDay).TotalMinutes;
                        residualMinutes = Math.Abs(residualMinutes);

                        if (residualMinutes < notificationDefinition.SendEndDuration && scheduleItem.Days.Contains((int)lastNow.DayOfWeek))
                        {
                            startTime = lastNow.AddMinutes(residualMinutes);
                            endTime   = lastNow.AddMinutes(notificationDefinition.SendEndDuration);
                            isValid   = true;
                            break;
                        }
                    }
                }
            }

            return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid));
        }
Exemplo n.º 2
0
        public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate)
        {
            bool     isValid     = false;
            DateTime startTime   = new DateTime();
            DateTime endTime     = new DateTime();
            var      lastNow     = now.AddMinutes(notificationDefinition.SendStartDuration);
            var      lastNowTime = lastNow.TimeOfDay;

            if (NotificationDateValidator.IsExistSchedule(notificationDefinition))
            {
                foreach (var scheduleItem in notificationDefinition.Schedules)
                {
                    if (scheduleItem.StartTime < scheduleItem.EndTime)
                    {
                        var tempEndDate = new DateTime(lastNow.Year, lastNow.Month, lastNow.Day, scheduleItem.EndTime.Hours, scheduleItem.EndTime.Minutes, scheduleItem.EndTime.Seconds);
                        var minEndTime = new DateTime[] { now.AddMinutes(notificationDefinition.SendEndDuration), tempEndDate }.Min();
                        if (lastNowTime.IsBetween(scheduleItem.StartTime, scheduleItem.EndTime) && scheduleItem.Days.Contains((int)lastNow.DayOfWeek))
                        {
                            startTime = lastNow;
                            endTime   = minEndTime;
                            isValid   = true;
                            break;
                        }
                    }
                }
            }

            return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid));
        }
Exemplo n.º 3
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.IsNotificationDateDefinitionEmpty(notificationDefinition))
            {
                startTime = notificationDefinition.SendStartTime;
                endTime   = notificationDefinition.SendEndTime;
                isValid   = now.IsLessThanOrEquals(endTime);
            }

            return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid));
        }
Exemplo n.º 4
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.IsRequestDateNullOrEmpty(requestDate))
            {
                if (requestDate.AddMinutes(notificationDefinition.SendEndDuration).IsLessThan(now))
                {
                    startTime = DateTime.MinValue;
                    endTime   = DateTime.MinValue;
                    isValid   = false;
                }
            }

            return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid));
        }
Exemplo n.º 5
0
        public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate)
        {
            bool     isValid   = false;
            DateTime startTime = new DateTime();
            DateTime endTime   = new DateTime();

            var lastNow = now.AddMinutes(notificationDefinition.SendStartDuration);

            if (NotificationDateValidator.IsExistSchedule(notificationDefinition))
            {
                foreach (var scheduleItem in notificationDefinition.Schedules)
                {
                    if (scheduleItem.StartTime == scheduleItem.EndTime && scheduleItem.Days.Contains((int)lastNow.DayOfWeek))
                    {
                        startTime = lastNow;
                        endTime   = startTime.AddMinutes(notificationDefinition.SendEndDuration);
                        isValid   = true;
                        break;
                    }
                }
            }

            return(NotificationDateValidator.SetValidDateInfos(startTime, endTime, isValid));
        }
Exemplo n.º 6
0
        //Takvim saatleri dýþýnda öncesinde ve sonrasýnda gelen istekleri yönet
        public NotificationDateValidationInfo DecideNotificationTimeValidation(NotificationDefinition notificationDefinition, NotificationOptions notificationOptions, DateTime now, DateTime requestDate)
        {
            bool     isValid   = false;
            DateTime startTime = new DateTime();
            DateTime endTime   = new DateTime();
            //lastNow degerini kullaniyoruz. DateTime.Now'a eklenen sure ile gun bilgisi degisebilir
            var      lastNow     = now.AddMinutes(notificationDefinition.SendStartDuration);
            var      lastNowTime = lastNow.TimeOfDay;
            TimeSpan midNight    = new TimeSpan(23, 59, 59);

            if (NotificationDateValidator.IsExistSchedule(notificationDefinition))
            {
                if (NotificationDateValidator.GetSchedulingWaitingStatus(notificationDefinition))
                {
                    foreach (var scheduleItem in notificationDefinition.Schedules)
                    {
                        if (!lastNowTime.IsBetween(scheduleItem.StartTime, scheduleItem.EndTime))
                        {
                            //16:00-21:00 takvimi için ör istek saati : 15:00
                            //08:00-17:00 takvimi için ör istek saati : 07:00
                            if (lastNowTime < scheduleItem.StartTime)
                            {
                                var newDate = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00);
                                startTime = newDate + scheduleItem.StartTime;
                                endTime   = startTime.AddMinutes(notificationDefinition.SendEndDuration);
                                isValid   = true;
                                break;
                            }


                            if (lastNowTime > scheduleItem.EndTime)
                            {
                                //16:00-21:00 takvimi için ör istek saati : 22:00
                                //08:00-17:00 takvimi için ör istek saati : 18:00
                                if (lastNowTime.IsBetween(scheduleItem.EndTime, midNight))
                                {
                                    var newDate = new DateTime(now.Year, now.Month, now.Day, 00, 00, 00);
                                    newDate   = newDate.AddDays(1);
                                    startTime = newDate + scheduleItem.StartTime;
                                    endTime   = startTime.AddMinutes(notificationDefinition.SendEndDuration);
                                    isValid   = true;
                                    break;
                                }


                                //16:00-21:00 takvimi için ör istek saati : 00:00 'dan sonra 16:00'a kadar. Ör: 00:40 veya 02:00
                                //08:00-17:00 takvimi için ör istek saati : 00:00 'dan sonra 08:00'a kadar. Ör: 00:40 veya 02:00
                                if (lastNowTime.IsLessThanOrEquals(midNight))
                                {
                                    var newDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 00, 00, 00);
                                    startTime = newDate + scheduleItem.StartTime;
                                    endTime   = startTime.AddMinutes(notificationDefinition.SendEndDuration);
                                    isValid   = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

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