Esempio n. 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));
        }