public Config(string tenant, IEmailProcessor processor) { if(processor != null) { this.Tenant = tenant; this.Enabled = processor.IsEnabled; this.FromEmail = processor.Config.FromEmail; this.FromName = processor.Config.FromName; return; } //We do not have transactional email processor. //Fall back to SMTP configuration var smtp = GetSmtpConfigAsync(tenant).Result; if(smtp == null) { return; } this.Tenant = tenant; this.Enabled = smtp.Enabled; this.FromName = smtp.FromDisplayName; this.FromEmail = smtp.FromEmailAddress; this.SmtpHost = smtp.SmtpHost; this.EnableSsl = smtp.SmtpEnableSsl; this.SmtpPort = smtp.SmtpPort; this.SmtpUsername = smtp.SmtpUsername; this.SmtpUserPassword = this.GetSmtpUserPassword(smtp.SmtpPassword); }
public Config(string tenant, IEmailProcessor processor) { if (processor != null) { this.Tenant = tenant; this.Enabled = processor.IsEnabled; this.FromEmail = processor.Config.FromEmail; this.FromName = processor.Config.FromName; return; } //We do not have transactional email processor. //Fall back to SMTP configuration var smtp = GetSmtpConfigAsync(tenant).Result; if (smtp == null) { return; } this.Tenant = tenant; this.Enabled = smtp.Enabled; this.FromName = smtp.FromDisplayName; this.FromEmail = smtp.FromEmailAddress; this.SmtpHost = smtp.SmtpHost; this.EnableSsl = smtp.SmtpEnableSsl; this.SmtpPort = smtp.SmtpPort; this.SmtpUsername = smtp.SmtpUsername; this.SmtpUserPassword = this.GetSmtpUserPassword(smtp.SmtpPassword); }
public async Task <bool> ProcessMessageAsync(MessageModel message) { var messageType = message.MessageType; IList <Task> tasks = new List <Task>(); if ((messageType & MessageType.Email) == MessageType.Email) { IEmailProcessor processor = ActorProxy.Create <IEmailProcessor>(ActorId.CreateRandom(), applicationName: "ServiceFabricTestApp", serviceName: "EmailProcessorActorService"); tasks.Add(processor.SendEmailAsync(message)); } if ((messageType & MessageType.Push) == MessageType.Push) { IPushProcessor processor = ActorProxy.Create <IPushProcessor>(ActorId.CreateRandom(), applicationName: "ServiceFabricTestApp", serviceName: "PushProcessorActorService"); tasks.Add(processor.SendPushAsync(message)); } if ((messageType & MessageType.SMS) == MessageType.SMS) { ISMSProcessor processor = ActorProxy.Create <ISMSProcessor>(ActorId.CreateRandom(), applicationName: "ServiceFabricTestApp", serviceName: "SMSProcessorActorService"); tasks.Add(processor.SendSMSAsync(message)); } await Task.WhenAll(tasks); return(true); }
public void Add() { this.Processor = EmailProcessor.GetDefault(this.Database); if (!this.IsEnabled()) { return; } var config = new Config(this.Database, this.Processor); this.Email.ReplyTo = this.Email.ReplyTo.Or(""); this.Email.ReplyToName = this.Email.ReplyToName.Or(""); if (string.IsNullOrWhiteSpace(this.Email.FromName)) { this.Email.FromName = config.FromName; } if (string.IsNullOrWhiteSpace(this.Email.FromEmail)) { this.Email.FromEmail = config.FromEmail; } var sysConfig = MessagingConfig.Get(this.Database); if (sysConfig.TestMode) { this.Email.IsTest = true; } if (this.IsValidEmail(this.Email.FromEmail) && this.IsValidEmail(this.Email.SendTo)) { MailQueue.AddToQueue(this.Database, this.Email); } }
public async Task ProcessMailQueueAsync(IEmailProcessor processor) { IEnumerable <EmailQueue> queue = MailQueue.GetMailInQueue(Catalog).ToList(); var config = new Config(Catalog); if (IsEnabled()) { foreach (var mail in queue) { var message = EmailHelper.GetMessage(config, mail); var host = EmailHelper.GetSmtpHost(config); var credentials = EmailHelper.GetCredentials(config); var attachments = mail.Attachments?.Split(',').ToArray(); bool success = await processor.SendAsync(message, host, credentials, false, attachments); if (!success) { continue; } mail.Delivered = true; mail.DeliveredOn = DateTime.UtcNow; MailQueue.SetSuccess(this.Catalog, mail.QueueId); } } }
public async Task ProcessMailQueueAsync(IEmailProcessor processor) { var queue = await MailQueue.GetMailInQueueAsync(this.Database).ConfigureAwait(false); var config = new Config(this.Database, this.Processor); if (this.IsEnabled()) { foreach (var mail in queue) { var message = EmailHelper.GetMessage(config, mail); var attachments = mail.Attachments?.Split(',').ToArray(); bool success = await processor.SendAsync(message, false, attachments).ConfigureAwait(false); if (!success) { continue; } mail.Delivered = true; mail.DeliveredOn = DateTimeOffset.UtcNow; await MailQueue.SetSuccessAsync(this.Database, mail.QueueId).ConfigureAwait(false); } } }
// // GET: /ForgetPassword/ public ForgetPasswordController(IEmailProcessor email, IUsersRepository userrepo, IForgetPasswordRepository forgetpsd) { emailProcessor = email; userRepository = userrepo; forgetPasswordRepository = forgetpsd; }
public async Task ProcessQueueAsync(IEmailProcessor processor, bool deleteAttachments = false) { var queue = await MailQueue.GetMailInQueueAsync(this.Database).ConfigureAwait(false); var config = new EmailConfig(this.Database, this.Processor); this.Processor = processor; if (this.IsEnabled()) { foreach (var mail in queue) { var message = EmailHelper.GetMessage(config, mail); var attachments = mail.Attachments?.Split(',').ToArray(); await processor.SendAsync(message, deleteAttachments, attachments).ConfigureAwait(false); if (message.Status == Status.Completed) { mail.Delivered = true; mail.DeliveredOn = DateTimeOffset.UtcNow; await MailQueue.SetSuccessAsync(this.Database, mail.QueueId).ConfigureAwait(false); } } } }
public async Task ProcessMailQueueAsync(IEmailProcessor processor) { IEnumerable<EmailQueue> queue = MailQueue.GetMailInQueue(this.Catalog).ToList(); var config = new Config(this.Catalog); if (this.IsEnabled()) { foreach (var mail in queue) { var message = EmailHelper.GetMessage(config, mail); var attachments = mail.Attachments?.Split(',').ToArray(); bool success = await processor.SendAsync(message, false, attachments); if (!success) { continue; } mail.Delivered = true; mail.DeliveredOn = DateTime.UtcNow; MailQueue.SetSuccess(this.Catalog, mail.QueueId); } } }
public void Execute() { IEnumerable <Message> messages = _gmailClient .GetRecentMessages(); using (Database db = new Database()) { foreach (var message in messages) { ForwardedEmail email = null; try { email = new ForwardedEmail(message); db.ForwardedEmails.Add(email); db.SaveChanges(); if (email.Status == Constants.Error) { throw new ParsingFailedException(email.Subject); } IEmailProcessor emailProcessor = _emailProcessorFactory.GetEmailProcessor(email.Operation); emailProcessor.Process(email, db); email.Status = Constants.Processed; db.SaveChanges(); _logger.Information($"{Constants.Processed} - {{GoodleId}} sucessfully", email.GoodleId); } catch (ParsingFailedException ex) { _logger.Error(ex, "An error occued while parsing subject: {subject}", email.Subject); } catch (RecordSkippedException ex) { email.Status = $"{Constants.Skipped}"; _logger.Warning(ex, $"{Constants.Skipped} - {{message}}", ex.Message); _logger.Verbose("{subject}", email.Subject); } catch (Exception ex) { email.Status = $"{Constants.Error} - {ex.Message}"; _logger.Error(ex, "{message} - {subject}", ex.Message, email.Subject); } finally { try { db.SaveChanges(); } catch { _logger.Error("Could not save to database"); } } } } }
public IEmailProcessor GetEmailProcessor(string operation) { IEmailProcessor emailProcessor = null; _processors.TryGetValue(operation, out emailProcessor); return(emailProcessor ?? new NoImplementationProcessor()); }
public void Listen(SmtpConfig smtpConfig) { EmailProcessor = new EmailProcessor(smtpConfig); ListenQueue(ProcessEmailItem); //ListenQueue(); //_log.Info(DeliverTag); //_channel.BasicAck(deliveryTag: DeliverTag, multiple: true); }
public static void Register(IEmailProcessor handler) { if (handler == null) { throw new ArgumentNullException("handler"); } _handlers.Register(handler); }
public BusinessLogic(ILogger logger, IScriptProcessor scriptProcessor, IFileProcessor fileProcessor, IEmailProcessor emailProcessor, IDatabaseLogic databaseLogic) { this.logger = logger; this.scriptProcessor = scriptProcessor; this.fileProcessor = fileProcessor; this.emailProcessor = emailProcessor; this.databaseLogic = databaseLogic; curlDetails = new CurlDetails(); }
private EmailQueue GetEmail(IEmailProcessor processor, Registration model, string subject, string message) { return new EmailQueue { AddedOn = DateTimeOffset.UtcNow, FromName = processor.Config.FromName, ReplyTo = processor.Config.FromEmail, ReplyToName = processor.Config.FromName, Subject = subject, Message = message, SendTo = model.Email, SendOn = DateTimeOffset.UtcNow }; }
private EmailQueue GetEmail(IEmailProcessor processor, Registration model, string subject, string message) { return(new EmailQueue { AddedOn = DateTimeOffset.UtcNow, FromName = processor.Config.FromName, ReplyTo = processor.Config.FromEmail, ReplyToName = processor.Config.FromName, Subject = subject, Message = message, SendTo = model.Email, SendOn = DateTimeOffset.UtcNow }); }
public void Start() { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); dataSource = new DetectedMessageRepository(); processor = new EmailProcessor(dataSource); _log.Info("Service started"); Thread thread = new Thread(new ThreadStart(processor.StartProcessMessages)); thread.Start(); }
public async Task AddAsync() { this.Processor = EmailProcessor.GetDefault(this.Database); if(!this.IsEnabled()) { return; } var config = new Config(this.Database, this.Processor); this.Email.ReplyTo = this.Email.ReplyTo.Or(""); this.Email.ReplyToName = this.Email.ReplyToName.Or(""); if(string.IsNullOrWhiteSpace(this.Email.FromName)) { this.Email.FromName = config.FromName; } if(string.IsNullOrWhiteSpace(this.Email.FromEmail)) { this.Email.FromEmail = config.FromEmail; } var sysConfig = MessagingConfig.Get(this.Database); if(sysConfig.TestMode) { this.Email.IsTest = true; } if(this.IsValidEmail(this.Email.FromEmail) && this.IsValidEmail(this.Email.SendTo)) { await MailQueue.AddToQueueAsync(this.Database, this.Email).ConfigureAwait(false); } }
/// <summary> /// Initializes a new instance of the <see cref="MemberService"/> class. /// </summary> public EmailService(IEmailProcessor mailProcessor, ILog logger) { _log = logger; _mailProcessor = mailProcessor; }
public FileContentService(IEmailProcessor emailProcessor, IAzureFileProcessor azureFileProcessor) { _emailProcessor = emailProcessor ?? throw new ArgumentNullException(nameof(emailProcessor)); _azureFileProcessor = azureFileProcessor ?? throw new ArgumentNullException(nameof(azureFileProcessor)); }
public static void Register(IEmailProcessor handler) { if (handler == null) throw new ArgumentNullException("handler"); _handlers.Register(handler); }
public UserController(IUserRepository repository, IEmailProcessor emailProcessor) { this.repository = repository; this.emailProcessor = emailProcessor; }
public void SetUp() { _mailServiceMock = new Mock <IMailService>(); _emailProcessor = new EmailProcessor(_mailServiceMock.Object); }
public async Task ProcessMailQueueAsync(IEmailProcessor processor) { var queue = await MailQueue.GetMailInQueueAsync(this.Database).ConfigureAwait(false); var config = new Config(this.Database, this.Processor); if(this.IsEnabled()) { foreach(var mail in queue) { var message = EmailHelper.GetMessage(config, mail); var attachments = mail.Attachments?.Split(',').ToArray(); bool success = await processor.SendAsync(message, false, attachments).ConfigureAwait(false); if(!success) { continue; } mail.Delivered = true; mail.DeliveredOn = DateTimeOffset.UtcNow; await MailQueue.SetSuccessAsync(this.Database, mail.QueueId).ConfigureAwait(false); } } }
public static void HandleEventOccurrenceNotificationEmails(EventOccurrence eventOccurrence, IEmailProcessor emailProcessor, string hostUrl) { var contactEmails = !string.IsNullOrEmpty(eventOccurrence.Event.ContactEmail) ? eventOccurrence.Event.ContactEmail.Split(';').Select(e => e.Trim()) : new List<string>(); if (eventOccurrence.IsNotifyContactEnabled && !string.IsNullOrEmpty(eventOccurrence.ContactEmail)) contactEmails = contactEmails.Union(eventOccurrence.ContactEmail.Split(';').Select(e => e.Trim())); var attachmentList = new List<Attachment>(); attachmentList.Add(BuildRegistrantCsv(eventOccurrence)); List<IEmailContext> emailList = new List<IEmailContext>(); foreach (var email in contactEmails) { int remainingSeats = -1; if (eventOccurrence.MaximumAttendees.HasValue) remainingSeats = eventOccurrence.MaximumAttendees.Value - eventOccurrence.EventOccurrenceAttendees.Count; var contactEmail = new RegistrationNotificationEmail(email, eventOccurrence.Event.Title, eventOccurrence.StartDate, eventOccurrence.OrgUnit.Name, remainingSeats, hostUrl + "/sites/staff/_layouts/MEDSEEK/ENRS/Admin/Reports/ConsolidatedReport.aspx?Keyword=" + HttpUtility.UrlEncode(eventOccurrence.Event.Title)); contactEmail.Attachments = attachmentList; emailList.Add(contactEmail); } emailProcessor.ProcessBatch(emailList); }