public MailerScheduledTaskHandler(IOrchardServices orchardServices, IMailCommunicationService mailCommunicationService, ShellSettings shellSettings, ICommunicationService communicationService, ITemplateService templateService, IScheduledTaskManager taskManager, IClock clock, ICommonsServices commonServices) { _orchardServices = orchardServices; _mailCommunicationService = mailCommunicationService; _shellSettings = shellSettings; _communicationService = communicationService; _templateService = templateService; _taskManager = taskManager; _commonServices = commonServices; _clock = clock; Logger = NullLogger.Instance; }
public MailCommunicationPartHandler(IControllerContextAccessor controllerContextAccessor, INotifier notifier, ITemplateService templateService, IOrchardServices orchardServices, IMailCommunicationService mailCommunicationService, IRepository <CommunicationEmailRecord> repoMail, IRepository <TitlePartRecord> repoTitle, ITransactionManager transactionManager, ICommunicationService communicationService, ShellSettings shellSetting, IScheduledTaskManager taskManager) { _repoMail = repoMail; _repoTitle = repoTitle; _controllerContextAccessor = controllerContextAccessor; _transactionManager = transactionManager; _notifier = notifier; _templateService = templateService; _orchardServices = orchardServices; _mailCommunicationService = mailCommunicationService; _communicationService = communicationService; _shellSettings = shellSetting; _taskManager = taskManager; T = NullLocalizer.Instance; OnUpdated <MailCommunicationPart>((context, part) => { if (_orchardServices.WorkContext.HttpContext.Request.Form["submit.Save"] == "submit.MailTest") { if (part.SendToTestEmail && part.EmailForTest != string.Empty) { dynamic content = context.ContentItem; string host = string.Format("{0}://{1}{2}", _orchardServices.WorkContext.HttpContext.Request.Url.Scheme, _orchardServices.WorkContext.HttpContext.Request.Url.Host, _orchardServices.WorkContext.HttpContext.Request.Url.Port == 80 ? string.Empty : ":" + _orchardServices.WorkContext.HttpContext.Request.Url.Port); var urlHelper = new UrlHelper(_orchardServices.WorkContext.HttpContext.Request.RequestContext); Dictionary <string, object> similViewBag = new Dictionary <string, object>(); similViewBag.Add("CampaignLink", _communicationService.GetCampaignLink("Email", part)); // Place Holder List <TemplatePlaceHolderViewModel> listaPH = new List <TemplatePlaceHolderViewModel>(); string unsubscribe = T("Click here to stop receiving email for commercial use").Text; string linkUnsubscribe = "<a href='" + string.Format("{0}{1}", host, urlHelper.UnsubscribeMailCommunication()) + "'>" + unsubscribe + "</a>"; TemplatePlaceHolderViewModel ph = new TemplatePlaceHolderViewModel(); ph.Name = "[UNSUBSCRIBE]"; ph.Value = linkUnsubscribe; ph.ShowForce = true; listaPH.Add(ph); if (((Laser.Orchard.TemplateManagement.Models.CustomTemplatePickerPart)content.CustomTemplatePickerPart).SelectedTemplate != null) { _templateService.SendTemplatedEmail(content, ((Laser.Orchard.TemplateManagement.Models.CustomTemplatePickerPart)content.CustomTemplatePickerPart).SelectedTemplate.Id, null, new List <string> { part.EmailForTest }, similViewBag, false, listaPH); _notifier.Information(T("Sent e-mail test!")); } else { _notifier.Error(T("Select or create a template for e-mail")); } } } }); OnPublished <MailCommunicationPart>((context, part) => { if (part.SendOnNextPublish && !part.MailMessageSent) { ContentItem ci = _orchardServices.ContentManager.Get(part.ContentItem.Id); dynamic content = ci; if (((Laser.Orchard.TemplateManagement.Models.CustomTemplatePickerPart)content.CustomTemplatePickerPart).SelectedTemplate != null) { _taskManager.CreateTask("Laser.Orchard.MailCommunication.Task", DateTime.UtcNow.AddMinutes(1), ci); part.MailMessageSent = true; } else { _notifier.Error(T("Select or create a template for e-mail")); } } }); }
public CountPanelController(IMailCommunicationService mailCommunicationService) { _mailCommunicationService = mailCommunicationService; }