Пример #1
0
        public static EmailTemplate LoadTemplate(IEmailContext context, IRepository<EmailTemplate> emailTemplateRepository)
        {
            try
            {
                EmailTemplate template = null;
                if (context.TemplateId.HasValue)
                {
                    var repository = (EmailTemplateRepository)emailTemplateRepository;
                    template = repository.GetById(context.TemplateId);
                }
                else
                {
                    template = emailTemplateRepository.GetByKey(context.TemplateKey);
                }

                if (template == null)
                {
                    throw new EmailTemplateNotFoundException(context.TemplateKey);
                }
                return template;
            }
            catch (ItemNotFoundException)
            {
                throw new EmailTemplateNotFoundException(context.TemplateKey);
            }
        }
Пример #2
0
 public EmailOutputComposite(
     IEmailContext emailContext,
     Dictionary <string, Func <IEmailOutputService> > emailOutputServices)
 {
     _emailContext        = emailContext;
     _emailOutputServices = emailOutputServices;
 }
Пример #3
0
 public EmailSpooler(IEmailSpoolerDependencies dependencies)
 {
     CheckDependencies(dependencies);
     _context        = dependencies.DbContext;
     _emailGenerator = dependencies.EmailGenerator;
     _config         = dependencies.EmailSpoolerConfig;
 }
Пример #4
0
 /// <summary>
 /// Processes the context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="builder">The Message Builder</param>
 public void Process(IEmailContext context, IMessageBuilder builder)
 {
     var message = builder.BuildMessage(context, _repository);
     if (message != null)
     {
         _sender.Send(message);
     }
 }
Пример #5
0
 public void Dispose()
 {
     lock (this)
     {
         _context?.Dispose();
         _context = null;
     }
 }
Пример #6
0
        private EmailSpooler Create(IEmailContext ctx, Func <IEmail> emailGenerator = null)
        {
            var deps = Substitute.For <IEmailSpoolerDependencies>();

            deps.EmailGenerator.ReturnsForAnyArgs(ci => emailGenerator ?? EmailGenerator);
            deps.DbContext.ReturnsForAnyArgs(ci => ctx);
            return(new EmailSpooler(deps));
        }
        public MailMessage BuildMessage(IEmailContext context, IRepository<EmailTemplate> repository)
        {
            var mailMessage = new MailMessage("*****@*****.**",_toAddress)
            {
                 Subject = "Clinical Trials - Prospective Investigator Form",
                 IsBodyHtml = true,
                 Body = BuildBody()
            };

            return mailMessage;
        }
        public MailMessage BuildMessage(IEmailContext context, IRepository<MEDSEEK.eHealth.Framework.Email.Common.EmailTemplate> repository)
        {
            var mailMessage = new MailMessage("*****@*****.**",_toAddress)
            {
                 Subject = "Appointment Request",
                 IsBodyHtml = true,
                 Body = BuildBody()
            };

            return mailMessage;
        }
        public override MailMessage BuildMessage(IEmailContext context, IRepository<EmailTemplate> repository)
        {
            var template = LoadTemplate(context, repository);

            var message = new MailMessage(template.FromAddress, context.ToAddress)
            {
                Subject = template.Subject,
                Body = ReplaceEventsInfoTokens(template, context.TokenData),
                IsBodyHtml = true
            };
            return message;
        }
        public override MailMessage BuildMessage(IEmailContext context, IRepository<EmailTemplate> repository)
        {
            var template = LoadTemplate(context, repository);

            var message = new MailMessage(template.FromAddress, context.ToAddress)
            {
                Subject = template.Subject,
                Body = PreProcessGroupsAndReplaceTokensInTemplate(template, context.TokenData),
                IsBodyHtml = true
            };

            foreach (var eventOccurance in _eventOccurrenceTable)
            {
                string schLocation = eventOccurance.EffectiveLocationName;
                string schSubject = eventOccurance.Event.Title;
                string schDescription = eventOccurance.Event.SummaryDescription;
                Attachment attachment = null;
                List<DateTime> schBeginDates = eventOccurance.EventOccurrenceDates.Select(e => e.StartDate).ToList();
                List<DateTime> schEndDates = eventOccurance.EventOccurrenceDates.Select(e => e.EndDate.Value).ToList();

                for (int i = 0; i < schBeginDates.Count; i++)
                {

                    String contents = string.Format(CultureInfo.InvariantCulture,
                                    "BEGIN:VCALENDAR{0}" +
                                    "VERSION:2.0{0}" +
                                    "BEGIN:VEVENT{0}" +
                                    "DTSTAMP:{1}{0}" +
                                    "STATUS:CONFIRMED{0}" +
                                    "DTSTART:{2}{0}" +
                                    "DTEND:{3}{0}" +
                                    "SUMMARY:{4}{0}" +
                                    "DESCRIPTION:{5}{0}" +
                                    "X-ALT-DESC;FMTTYPE=text/html:{5}{0}" +
                                    "LOCATION:{6}{0}" +
                                    "END:VEVENT" + "{0}" +
                                    "END:VCALENDAR{0}", Environment.NewLine, schBeginDates[i].ToString("yyyyMMdd\\THHmmss", CultureInfo.InvariantCulture),
                                    schBeginDates[i].ToString("yyyyMMdd\\THHmmss", CultureInfo.InvariantCulture),
                                    schEndDates[i].ToString("yyyyMMdd\\THHmmss", CultureInfo.InvariantCulture), schSubject, schDescription, schLocation);

                    MemoryStream mStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(contents));
                    attachment = new Attachment(mStream, "event.ics", MediaTypeNames.Application.Octet);

                    attachment.ContentDisposition.DispositionType = DispositionTypeNames.Attachment;
                    message.Attachments.Add(attachment);
                }
            }

            return message;
        }
Пример #11
0
        public SyncEmail(IEmailContext emailContext, ISyncReview review, IUserInfo user = null)
            : base(emailContext)
        {
            _review = review ?? throw new ArgumentNullException(nameof(review));

            if (user != null)
            {
                AddLine($"Sync initiated by {user.Email}");
            }

            string summary = _review.GetSummary();

            if (!string.IsNullOrWhiteSpace(summary))
            {
                AddLine(summary);
            }
        }
Пример #12
0
        public virtual MailMessage BuildMessage(IEmailContext context, IRepository<EmailTemplate> repository)
        {
            var template = LoadTemplate(context, repository);
            var message = new MailMessage(template.FromAddress, context.ToAddress)
            {
                Subject = ProcessTemplate(context.TokenData, template.Subject),
                Body = ProcessTemplate(context.TokenData, template.Body),
                IsBodyHtml = true
            };

            if (context.Attachments != null && context.Attachments.Any())
            {
                foreach (var item in context.Attachments)
                {
                    message.Attachments.Add(item);
                }
            }

            return message;
        }
Пример #13
0
 public ApiPropertyService(IEmailService emailService, IApiPropertyProvider apiPropertyProvider, IApiPropertyDataProvider apiPropertyDataProvider, IDiskStorageProvider storageProvider, ILicenseSettings licenseSettings, IEmailContext emailContext, ILog log)
 {
     _emailService            = emailService ?? throw new ArgumentNullException(nameof(emailService));
     _apiPropertyProvider     = apiPropertyProvider ?? throw new ArgumentNullException(nameof(apiPropertyProvider));
     _apiPropertyDataProvider = apiPropertyDataProvider ?? throw new ArgumentNullException(nameof(apiPropertyDataProvider));
     _storageProvider         = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider));
     _licenseSettings         = licenseSettings ?? throw new ArgumentNullException(nameof(licenseSettings));
     _emailContext            = emailContext ?? throw new ArgumentNullException(nameof(emailContext));
     _log = log ?? throw new ArgumentNullException(nameof(log));
 }
Пример #14
0
 /// <summary>
 /// Processes the context.
 /// </summary>
 /// <param name="context">The context.</param>
 public void Process(IEmailContext context)
 {
     Process(context, _builder);
 }
Пример #15
0
 public EmailService(IEmailContext emailContext)
 {
     _emailContext = emailContext;
 }
Пример #16
0
 public EnquiryEmail(IEmailContext emailContext, EnquiryEntity enquiry, string to, string subject)
     : base(_resource, emailContext.EmailSettings.FromEmail, to, subject)
 {
     Model = enquiry;
 }
Пример #17
0
 public EnquiryEmail(IEmailContext emailContext, EnquiryEntity enquiry, string emailKey)
     : this(emailContext, enquiry, emailContext.EmailSettings.GetAddress(emailKey).EmailAddress, GetSubject(emailContext.LicenseSettings))
 {
 }
Пример #18
0
 public FakeEmailSpoolerDependenciesBuilder WithDbContext(IEmailContext dbContext)
 {
     _dbContext = dbContext;
     return(this);
 }
        public EmailRepository(IEmailContext emailContext)
        {
            Check.If(emailContext).IsNotNull();

            _emailContext = emailContext;
        }
 public ContactService(IEmailService emailService, IContactDataProvider contactDataProvider, IEmailContext emailContext)
 {
     _emailService        = emailService ?? throw new ArgumentNullException(nameof(emailService));
     _contactDataProvider = contactDataProvider ?? throw new ArgumentNullException(nameof(contactDataProvider));
     _emailContext        = emailContext ?? throw new ArgumentNullException(nameof(emailContext));
 }