public ActionResult GeneralInfoCompleteness(int editionId)
        {
            var edition          = EditionServices.GetEditionById(editionId);
            var notificationAttr = NotificationType.PostShowMetricsInfoCompleteness.GetAttribute <NotificationAttribute>();
            var buttonUrl        = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);

            SendEmailNotification(edition, NotificationType.PostShowMetricsInfoCompleteness, WebConfigHelper.AdminEmails, CurrentCedUser.CurrentUser, "test", buttonUrl);

            return(View());
        }
示例#2
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));
        }
示例#3
0
        private EditionMailTemplate GetEmailTemplateForEditionUpdateNotification(EditionEntity edition)
        {
            var recipients        = _eventDirectorServices.GetRecipientEmails(edition);
            var recipientFullName = _editionHelper.GetEventDirectorFullName(edition);
            var notificationAttr  = NotificationType.EditionLocationUpdated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
示例#4
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);
                        }
                    }
                }
            }
        }
        /* NOTIFICATION - COMMON */
        protected void PushEditionUpdateNotifications(EditionEntity edition, string updatedFields)
        {
            if (WebConfigHelper.TrackEditionUpdate && !string.IsNullOrWhiteSpace(updatedFields))
            {
                var subscribers = GetSubscriberEmails(edition.EditionId);
                var inAppNotificationRecipients = subscribers;
                var emailRecipients             = WebConfigHelper.TrackEditionUpdateUseMockRecipients
                    ? WebConfigHelper.AdminEmails
                    : subscribers;

                var body = $"Field(s) updated by {CurrentCedUser.CurrentUser.FullName} on {edition.UpdateTime}:<br/><br/>";
                body += updatedFields;

                const NotificationType notificationType = NotificationType.EditionUpdated;
                var notifAttr         = notificationType.GetAttribute <NotificationAttribute>();
                var buttonUrl         = _editionHelper.GetEditionUrl(edition);
                var unsubscriptionUrl = notifAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;

                CreateInAppNotification(edition, notificationType, inAppNotificationRecipients, CurrentCedUser.CurrentUser.Email);

                PushRealTimeInAppNotification(edition, notificationType, inAppNotificationRecipients, CurrentCedUser.CurrentUser.Email);

                var emailResult = SendEmailNotification(edition, notificationType, emailRecipients, CurrentCedUser.CurrentUser, body,
                                                        buttonUrl, unsubscriptionUrl);

                // STEP 5: LOG EMAIL
                if (emailResult.Sent)
                {
                    LogEmail(edition.EditionId, inAppNotificationRecipients, body, CurrentCedUser.CurrentUser.Email, notificationType.ToString());
                }
                else
                {
                    LogEmail(edition.EditionId, WebConfigHelper.AdminEmails, emailResult.ErrorMessage, null, notificationType.ToString());
                }
            }
        }