Ejemplo n.º 1
0
        public void UploadFile(FtpOutboundData jobItem)
        {
            var settings       = _settingsManager.Load <FtpConnectionSettings>(jobItem.SettingSource, jobItem.SettingKey);
            var attachmentData = _ravenManager.GetAttachment(jobItem.AttachmentId);

            _ftpCommunicator.UploadFile(jobItem.SettingSource, jobItem.SettingKey, jobItem.TargetFileName, jobItem.TargetDirectory, attachmentData);
        }
Ejemplo n.º 2
0
        public void ProcessItem(EmailJobData jobItem)
        {
            var emailConnectionSettings = _connectionSettingsManager.Load <EmailConnectionSettings>(jobItem.SettingsSource, jobItem.SettingsKey);
            var emailServerSettings     = new EmailServerSettings
            {
                Host     = emailConnectionSettings.Host,
                Port     = emailConnectionSettings.Port,
                UserName = emailConnectionSettings.UserName,
                Password = emailConnectionSettings.Password
            };
            string overrideEmailAddress = ConfigurationManager.AppSettings["OverrideAllEmailAddress"];
            var    toAddressList        = DataServiceMailAddress.ToMailAddressList(jobItem.ToAddressList);

            if (!string.IsNullOrWhiteSpace(overrideEmailAddress))
            {
                toAddressList = new List <MailAddress>()
                {
                    new MailAddress(overrideEmailAddress)
                };
            }
            string subject = FilterSubject(jobItem.Subject);

            try
            {
                EmailAttachmentData[] attachments = null;
                if (jobItem.Attachments != null)
                {
                    attachments = jobItem.Attachments.ToArray();
                }
                _emailSender.SendEmail(emailServerSettings, subject, jobItem.Body, toAddressList, jobItem.FromAddress.ToMailAddress(), attachments);
            }
            catch (RazorEngine.Templating.TemplateCompilationException ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine("Error(s) compiling template for email: ");
                foreach (var item in ex.Errors)
                {
                    sb.AppendLine("-" + item.Line.ToString() + ": " + item.ErrorText);
                }
                throw new Exception(sb.ToString(), ex);
            }
        }