コード例 #1
0
        public JsonResult NotifyAboutMissingEditionImages(string key, string connectionId)
        {
            if (key == WebConfigHelper.TaskSchedulerSecretKey)
            {
                try
                {
                    var editions = TaskServices.GetEditionsWithMissingImages();

                    var pattern = "<a href='{0}'>{1}</a>";

                    var body = "<table>";

                    for (var i = 0; i < editions.Count; i++)
                    {
                        var edition = editions[i];

                        var url = _editionHelper.GetEditionUrl(new EditionEntity
                        {
                            EditionId   = edition.EditionId,
                            EditionName = edition.EventName,
                            Status      = edition.Status.ToEnum <EditionStatusType>()
                        });

                        body += "<tr><td class='font-lato' style='font-size: 14px; color: #888794'>" + string.Format(pattern, url, edition.EventName);
                        body += edition.EventBackGroundImage == null ? " [People Image] " : "";
                        body += edition.EventImage == null ? " [Web Logo] " : "";
                        body += edition.IconFileName == null ? " [Icon] " : "";
                        body += edition.MasterLogoFileName == null ? " [Master Logo] " : "";
                        body += edition.ProductImageFileName == null ? " [Product Image] " : "";
                        body += "</td></tr>";

                        if (!string.IsNullOrWhiteSpace(connectionId))
                        {
                            ProgressHub.SendProgress(connectionId, "Detecting missing images...", i + 1, editions.Count, TaskType.NotifyAboutMissingEditionImages.GetHashCode());
                        }
                    }

                    body += "</table>";

                    var subject    = "Events with Missing Images";
                    var recipients = WebConfigHelper.MarketingAdminEmails;

                    _emailNotificationHelper.Send(NotificationType.MissingEditionImages, subject, body, recipients);

                    var log = CreateInternalLog("The task NotifyAboutMissingEditionImages completed.", AutoIntegrationUser);
                    ExternalLogHelper.Log(log, LoggingEventType.Information);

                    return(Json("", JsonRequestBehavior.AllowGet));
                }
                catch (Exception exc)
                {
                    var message = "The task NotifyAboutMissingEditionImages failed! " + exc.GetFullMessage();
                    ExternalLogHelper.Log(message, LoggingEventType.Error);

                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(false, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        private EmailResult SendNotificationEmailForEditionNameUpdate(EditionEntity edition, EditionTranslationEntity editionTranslation, EditionMailTemplate emailTemplate)
        {
            if (!WebConfigHelper.TrackEditionNameUpdate)
            {
                return new EmailResult {
                           Sent = false, ErrorMessage = "Tracking disabled."
                }
            }
            ;

            // ADDITIONAL RECIPIENTS
            if (!WebConfigHelper.IsLocal && !WebConfigHelper.IsTest)
            {
                emailTemplate.Recipients += "," + WebConfigHelper.TrackEditionNameUpdateAdditionalRecipients;
            }

            if (!string.IsNullOrWhiteSpace(emailTemplate.Recipients))
            {
                const NotificationType notificationType = NotificationType.EditionNameUpdated;

                var recipientFullName = emailTemplate.RecipientFullName;
                var body = $"Dear {recipientFullName} ," +
                           "<br/><br/>" +
                           $"This is to inform you that there have been some changes to the event name information for {edition.EditionName}." +
                           @"<br/><br/>
                You may want to log in and double check whether this change causes inconsistency on any information. 
                <br/><br/>
                To do so please click the button below to go to event's page.";

                var buttonUrl = _editionHelper.GetEditionUrl(edition);

                return(_emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, emailTemplate.Recipients,
                                                     buttonUrl, emailTemplate.UnsubscriptionUrl));
            }

            return(new EmailResult {
                Sent = false, ErrorMessage = "Event doesn't fit the necessary criteria for emailing."
            });
        }
コード例 #3
0
        /* EMAIL NOTIFICATION */
        public EmailResult SendEmailNotification(EditionEntity edition, NotificationType notificationType, string recipients, UserEntity actor, string body,
                                                 string buttonUrl, string unsubscribingUrl = null)
        {
            //if (string.IsNullOrWhiteSpace(recipients))
            //{
            //    var message = $"{notificationType} type of notification email could not be sent since edition {edition.EditionId} - {edition.EditionName} has no recipients.";
            //    var log = CreateInternalLog(message, actor);
            //    ExternalLogHelper.Log(log, LoggingEventType.Warning);
            //    return new EmailResult { Sent = false, ErrorMessage = message };
            //}

            if (WebConfigHelper.RemoveActorUserFromNotificationRecipients)
            {
                recipients = NotificationControllerHelper.RemoveCurrentUserFromRecipients(recipients, actor?.Email);
            }

            //if (string.IsNullOrWhiteSpace(recipients))
            //    return false;

            try
            {
                var recipientFullName = _editionHelper.GetRecipientFullName(edition);

                var sendEmailAttr = notificationType.GetAttribute <NotificationAttribute>().SendEmail;
                if (sendEmailAttr)
                {
                    var editionTranslation =
                        edition.EditionTranslations.SingleOrDefault(x => string.Equals(x.LanguageCode,
                                                                                       LanguageHelper.GetBaseLanguageCultureName(), StringComparison.CurrentCultureIgnoreCase));

                    var emailResult = _emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, recipients,
                                                                    buttonUrl, unsubscribingUrl);

                    //// EMAIL LOGGING
                    //if (sent)
                    //LogEmail(edition.EditionId, recipients, body, actor?.Email, notificationType.ToString());

                    return(emailResult);
                }
            }
            catch (Exception exc)
            {
                var log = CreateInternalLog(exc, actor);
                ExternalLogHelper.Log(log, LoggingEventType.Error);
            }

            return(new EmailResult {
                Sent = false, ErrorMessage = ""
            });
        }