Beispiel #1
0
        public string GetDescription(EditionEntity edition, NotificationType notificationType)
        {
            var url = notificationType == NotificationType.EditionExistence
                ? _editionHelper.GetEditionListUrl(edition.Event, notificationType.GetAttribute <NotificationAttribute>().Fragment)
                : _editionHelper.GetEditionUrl(edition, notificationType.GetAttribute <NotificationAttribute>().Fragment);
            var name = _editionHelper.GetNameWithEditionNo(edition);
            var link = $"<a href=\"{url}\" target=\"_blank\"><b>{name}</b></a>";
            var desc = notificationType.GetDescription();

            return(string.Format(desc, link));
        }
Beispiel #2
0
        private void ProcessEditionNotifications(KeyValuePair <EditionEntity, NotificationType> editionNotification, int itemIndex, int totalItemsCount)
        {
            var edition          = editionNotification.Key;
            var notificationType = editionNotification.Value;

            // NEEDLESS!
            // STEP 2: Does it REQUIRE a NOTIFICATION?
            var requires = EditionServices.RequiresNotification(edition, notificationType);

            if (requires)
            {
                // STEP 3: Does NOTIFICATION already EXIST?
                //if (!NotificationAlreadyExists(edition, notificationType))
                {
                    if (WebConfigHelper.PrimaryDirectorNotifications)
                    {
                        var recipients = WebConfigHelper.PrimaryDirectorNotificationsUseMockRecipients
                            ? WebConfigHelper.AdminEmails
                            : EventDirectorServices.GetRecipientEmails(edition);

                        // STEP 3: CREATE NOTIFICATION
                        CreateInAppNotification(edition, notificationType, recipients, null);

                        PushRealTimeInAppNotification(edition, notificationType, recipients, CurrentCedUser?.CurrentUser?.Email);

                        // STEP 4: SEND EMAIL
                        var notifAttr = notificationType.GetAttribute <NotificationAttribute>();
                        var buttonUrl = notificationType == NotificationType.EditionExistence
                            ? _editionHelper.GetEditionListUrl(edition.Event, notifAttr.Fragment)
                            : _editionHelper.GetEditionUrl(edition, notifAttr.Fragment);

                        var emailResult = SendEmailNotification(edition, notificationType, recipients, null, null, buttonUrl);

                        // STEP 5: LOG EMAIL
                        if (emailResult.Sent)
                        {
                            LogEmail(edition.EditionId, recipients, emailResult.ErrorMessage, null, notificationType.ToString());
                        }
                        else
                        {
                            LogEmail(edition.EditionId, WebConfigHelper.AdminEmails, emailResult.ErrorMessage, null, notificationType.ToString(), ActionType.NotificationEmailSendFailure);
                        }
                    }
                }
            }
        }