Esempio n. 1
0
        public IList <EditionEntity> GetEditionsToNotify(NotificationType notificationType)
        {
            IList <EditionEntity> editions;

            if (WebConfigHelper.IsLocal || WebConfigHelper.IsTest)
            {
                editions = EditionServices.GetEditionsByEvent(248);
            }
            else
            {
                var deviationInDays = WebConfigHelper.EditionNotificationDeviationInDays;
                if (notificationType.GetAttribute <NotificationAttribute>().CheckDaysType == NotificationAttribute.CheckDaysTypes.Passed)
                {
                    deviationInDays *= -1;
                }
                var checkDays = _emailNotificationHelper.GetCheckDays(notificationType).Select(x => x - deviationInDays).ToList();

                var minFinancialYear = WebConfigHelper.MinFinancialYear;
                var statuses         = Utility.Constants.DefaultValidEditionStatusesForCed;
                var eventTypes       = notificationType.GetAttribute <NotificationAttribute>().EventTypes.Select(x => x.GetDescription()).ToArray();
                var eventActivities  = Utility.Constants.ValidEventActivitiesToNotify;

                editions = EditionServices.GetEditionsByNotificationType(checkDays, null, notificationType, minFinancialYear, statuses, eventTypes, eventActivities);
            }

            return(editions);
        }
Esempio n. 2
0
        private IList <EmailNotificationListItemModel> GetEmailNotificationListItems(EmailNotificationSearchModel model)
        {
            var notifications = new List <EmailNotificationListItemModel>();

            if (model.NotificationTypes == null)
            {
                model.NotificationTypes = EditionCompletenessNotificationTypes().ToArray();
            }

            if (model.DayRange > 0)
            {
                model.EmailSendingDate = null;
            }

            foreach (var notifType in model.NotificationTypes)
            {
                var deviationInDays = Convert.ToInt32((DateTime.Today - model.EmailSendingDate).GetValueOrDefault().TotalDays);
                if (notifType.GetAttribute <NotificationAttribute>().CheckDaysType == NotificationAttribute.CheckDaysTypes.Passed)
                {
                    deviationInDays *= -1;
                }

                if (notifType.GetAttribute <CompletenessNotificationTypeAttribute>() != null)
                {
                    var minFinancialYear = WebConfigHelper.MinFinancialYear;
                    var statuses         = Utility.Constants.DefaultValidEditionStatusesForCed;
                    var eventTypes       = notifType.GetAttribute <NotificationAttribute>().EventTypes.Select(x => x.GetDescription()).ToArray();
                    var eventActivities  = Utility.Constants.ValidEventActivitiesToNotify;
                    var checkDays        = _emailNotificationHelper.GetCheckDays(notifType);

                    foreach (var checkDay in checkDays)
                    {
                        var editionsToNotify = EditionServices.GetEditionsByNotificationType(checkDay - deviationInDays, model.DayRange, notifType, minFinancialYear, statuses, eventTypes, eventActivities, model.EventId);

                        AddEditionsToNotificationList(notifications, editionsToNotify, notifType, checkDay);
                    }
                }
            }

            return(notifications);
        }