Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TesterController" /> class.
 /// </summary>
 public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
                         IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
                         IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger <TesterController> log, IEmailProvider provider,
                         ICouchPotatoApi cpApi, ITelegramNotification telegram, ISickRageApi srApi, INewsletterJob newsletter, IMobileNotification mobileNotification,
                         ILidarrApi lidarrApi, IGotifyNotification gotifyNotification)
 {
     Service                = service;
     DiscordNotification    = notification;
     EmailNotification      = emailN;
     PushbulletNotification = pushbullet;
     SlackNotification      = slack;
     PushoverNotification   = po;
     MattermostNotification = mm;
     PlexApi                = plex;
     RadarrApi              = radarr;
     EmbyApi                = emby;
     SonarrApi              = sonarr;
     Log                  = log;
     EmailProvider        = provider;
     CouchPotatoApi       = cpApi;
     TelegramNotification = telegram;
     SickRageApi          = srApi;
     Newsletter           = newsletter;
     MobileNotification   = mobileNotification;
     LidarrApi            = lidarrApi;
     GotifyNotification   = gotifyNotification;
 }
        private void SendNotification(CalendarEventWithAdditionalData message, IEmailNotification notificationConfiguration)
        {
            var templateExpressionContext = new Dictionary <string, string>
            {
                ["employee"]   = message.Owner.Name,
                ["employeeId"] = message.Owner.EmployeeId,
                ["startDate"]  = message.Event.Dates.StartDate.ToString("dd/MM/yyyy"),
                ["endDate"]    = message.Event.Dates.EndDate.ToString("dd/MM/yyyy")
            };

            templateExpressionContext = new DictionaryMerge().Perform(
                templateExpressionContext,
                message.Event.AdditionalData.ToDictionary(x => x.Key, x => x.Value));

            var templateExpressionParser = new TemplateExpressionParser();

            var sender    = notificationConfiguration.NotificationSender;
            var recipient = message.Manager?.Email;
            var subject   = templateExpressionParser.Parse(notificationConfiguration.Subject, templateExpressionContext);
            var body      = templateExpressionParser.Parse(notificationConfiguration.Body, templateExpressionContext);

            Context.System.EventStream.Publish(
                new NotificationEventBusMessage(
                    new EmailNotification(sender, new[] { recipient }, subject, body)));
        }
Exemplo n.º 3
0
 public ContactModel(
     ILogger <ContactModel> logger,
     IEmailNotification emailNotification)
 {
     _logger            = logger;
     _emailNotification = emailNotification;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TesterController" /> class.
 /// </summary>
 public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
                         IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
                         IPlexApi plex, IEmbyApiFactory emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger <TesterController> log, IEmailProvider provider,
                         ICouchPotatoApi cpApi, ITelegramNotification telegram, ISickRageApi srApi, INewsletterJob newsletter, ILegacyMobileNotification mobileNotification,
                         ILidarrApi lidarrApi, IGotifyNotification gotifyNotification, IWhatsAppApi whatsAppApi, OmbiUserManager um, IWebhookNotification webhookNotification,
                         IJellyfinApi jellyfinApi)
 {
     Service                = service;
     DiscordNotification    = notification;
     EmailNotification      = emailN;
     PushbulletNotification = pushbullet;
     SlackNotification      = slack;
     PushoverNotification   = po;
     MattermostNotification = mm;
     PlexApi                = plex;
     RadarrApi              = radarr;
     EmbyApi                = emby;
     SonarrApi              = sonarr;
     Log                  = log;
     EmailProvider        = provider;
     CouchPotatoApi       = cpApi;
     TelegramNotification = telegram;
     SickRageApi          = srApi;
     Newsletter           = newsletter;
     MobileNotification   = mobileNotification;
     LidarrApi            = lidarrApi;
     GotifyNotification   = gotifyNotification;
     WhatsAppApi          = whatsAppApi;
     UserManager          = um;
     WebhookNotification  = webhookNotification;
     _jellyfinApi         = jellyfinApi;
 }
 public BookingRequestController(ILog log, IEmailNotification emailNotification, IBookingRequestRepository bookingRequestRepository, IBookingMainRepository mainRepository, ITransactionRepository transactionRepository)
 {
     _log = log;
     _emailNotification = emailNotification;
     _bookingRequestRepository = bookingRequestRepository;
     _mainRepository = mainRepository;
     _transactionRepository = transactionRepository;
 }
Exemplo n.º 6
0
 public ContactController(
     ILogger <ContactController> logger,
     IDataRepository dataRepository,
     IEmailNotification emailNotification)
 {
     _logger            = logger;
     _dataRepository    = dataRepository;
     _emailNotification = emailNotification;
 }
Exemplo n.º 7
0
 public ContactModel(
     ILogger <ContactModel> logger,
     IEmailNotification emailNotification,
     IUserService userService)
 {
     _logger            = logger;
     _emailNotification = emailNotification;
     _userService       = userService;
 }
Exemplo n.º 8
0
 public void Send(IEmailNotification message)
 {
     try {
         var email = message.CreateMailNotification(Encoding.UTF8, true);
         m_smtpClient.Send(email);
     }
     catch (SmtpException ex) {
         throw new CommunicationException(ex.Message, ex);
     }
 }
Exemplo n.º 9
0
 public WCFKSystem(ISensorDryRepository sensorDryRepository,
     IHouseRepository houseRepository,
     IEmailNotification emailNotification,
     IUserRepository userRepository)
 {
     SensorDryRepository = sensorDryRepository;
     HouseRepository = houseRepository;
     EmailNotification = emailNotification;
     UserRepository = userRepository;
 }
        public EventAssignedToApproverEmailNotificationActor(
            IEmailNotification emailNotificationConfig,
            IActorRef organizationActor,
            IActorRef userPreferencesActor)
        {
            this.emailNotificationConfig = emailNotificationConfig;
            this.organizationActor       = organizationActor;
            this.userPreferencesActor    = userPreferencesActor;

            Context.System.EventStream.Subscribe <CalendarEventAssignedToApprover>(this.Self);
        }
Exemplo n.º 11
0
 public UserService(
     ILogger <UserService> logger,
     IUserRepository userRepository,
     IPushOverNotification pushOverNotification,
     IEmailNotification emailNotification)
 {
     _logger               = logger;
     _userRepository       = userRepository;
     _pushOverNotification = pushOverNotification;
     _emailNotification    = emailNotification;
 }
Exemplo n.º 12
0
        public EventStatusChangedEmailNotificationActor(
            IEmailNotification emailNotificationConfig,
            IActorRef organizationActor,
            IActorRef userPreferencesActor)
        {
            this.emailNotificationConfig = emailNotificationConfig;
            this.organizationActor       = organizationActor;
            this.userPreferencesActor    = userPreferencesActor;

            Context.System.EventStream.Subscribe <CalendarEventChanged>(this.Self);
        }
Exemplo n.º 13
0
 public CallbacksModel(
     ILogger <CallbacksModel> logger,
     IDataRepository dataRepository,
     IEmailNotification emailNotification,
     IPushoverNotification pushoverNotification)
 {
     _logger               = logger;
     _dataRepository       = dataRepository;
     _emailNotification    = emailNotification;
     _pushoverNotification = pushoverNotification;
 }
 public EmailMessageService(ILogger <EmailMessageService> logger,
                            IEmailMessageRepository repository,
                            IDomainEvents domainEvents,
                            IEmailNotification emailNotification,
                            IDateTimeProvider dateTimeProvider)
     : base(repository, domainEvents)
 {
     _logger            = logger;
     _repository        = repository;
     _emailNotification = emailNotification;
     _dateTimeProvider  = dateTimeProvider;
 }
Exemplo n.º 15
0
 public async Task SendNotificationAsync(IEmailNotification emailNotification)
 {
     await SendEmailAsync(new SendEmailDto
     {
         FromName   = _emailConfiguration.SenderName,
         FromEmail  = _emailConfiguration.SenderEmail,
         Subject    = emailNotification.Subject,
         Recipients = emailNotification.Recipients,
         Text       = emailNotification.Text,
         HtmlText   = emailNotification.GetHtml()
     });
 }
 public EmailMessageService(ILogger <EmailMessageService> logger,
                            IEmailMessageRepository repository,
                            IMessageSender <EmailMessageCreatedEvent> emailMessageCreatedEventSender,
                            IEmailNotification emailNotification,
                            IDateTimeProvider dateTimeProvider
                            )
 {
     _logger     = logger;
     _repository = repository;
     _emailMessageCreatedEventSender = emailMessageCreatedEventSender;
     _emailNotification = emailNotification;
     _dateTimeProvider  = dateTimeProvider;
 }
 public EmailMessageService(ILogger <EmailMessageService> logger,
                            IEmailMessageRepository repository,
                            IEmailNotification emailNotification,
                            IDateTimeProvider dateTimeProvider,
                            ICircuitBreakerManager circuitBreakerManager,
                            IDistributedLock distributedLock)
 {
     _logger                = logger;
     _repository            = repository;
     _emailNotification     = emailNotification;
     _dateTimeProvider      = dateTimeProvider;
     _circuitBreakerManager = circuitBreakerManager;
     _distributedLock       = distributedLock;
 }
        public void SendEmail(IEmailNotification mail)
        {
            try
            {
                var message = BuildMail(mail);

                SendEmailInternal(message);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, ex.StackTrace);
                throw;
            }
        }
Exemplo n.º 19
0
        public Task SendAsync(IEmailNotification message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            return(_emailService.SendAsync(new SendEmailDto
            {
                Subject = message.FormatSubject(),
                Recipients = message.Recipients,
                Text = message.Text,
                HtmlText = message.GetHtml()
            }));
        }
        public SickLeaveManagerEmailNotificationActor(
            IEmailNotification createdEmailNotificationConfig,
            IEmailNotification prolongedEmailNotificationConfig,
            IEmailNotification cancelledEmailNotificationConfig,
            IActorRef organizationActor,
            IActorRef userPreferencesActor)
        {
            this.createdEmailNotificationConfig   = createdEmailNotificationConfig;
            this.prolongedEmailNotificationConfig = prolongedEmailNotificationConfig;
            this.cancelledEmailNotificationConfig = cancelledEmailNotificationConfig;
            this.organizationActor    = organizationActor;
            this.userPreferencesActor = userPreferencesActor;

            Context.System.EventStream.Subscribe <CalendarEventCreated>(this.Self);
            Context.System.EventStream.Subscribe <CalendarEventChanged>(this.Self);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Constructor to Inject Service Dependecies
 /// </summary>
 /// <param name="agent"></param>
 /// <param name="department"></param>
 /// <param name="emailNotification"></param>
 /// <param name="membership"></param>
 /// <param name="membershipUpgrade"></param>
 /// <param name="order"></param>
 /// <param name="packingSlip"></param>
 /// <param name="packingSlipRoyaltyDep"></param>
 /// <param name="payment"></param>
 /// <param name="product"></param>
 /// <param name="shipping"></param>
 /// <param name="user"></param>
 /// <param name="videoSubscription"></param>
 public PaymentController(IAgent agent, IDepartment department, IEmailNotification emailNotification,
                          IMembership membership, IMembershipUpgrade membershipUpgrade, IOrder order, IPackingSlip packingSlip,
                          IPackingSlipRoyaltyDep packingSlipRoyaltyDep, IPayment payment, IProduct product, IShipping shipping,
                          IUser user, IVideoSubscription videoSubscription)
 {
     _agent                 = agent;
     _department            = department;
     _emailNotification     = emailNotification;
     _membership            = membership;
     _membershipUpgrade     = membershipUpgrade;
     _order                 = order;
     _packingSlip           = packingSlip;
     _packingSlipRoyaltyDep = packingSlipRoyaltyDep;
     _payment               = payment;
     _product               = product;
     _shipping              = shipping;
     _user = user;
     _videoSubscription = videoSubscription;
 }
        public void Notify(IEmailNotification emailNotification)
        {
            using (var mail = new MailMessage())
             {
            mail.To.Add(emailNotification.To);
            mail.From = new MailAddress(emailNotification.To);
            mail.Subject = emailNotification.Subject;
            mail.Body = emailNotification.Body;
            mail.IsBodyHtml = true;

            try
            {
               var sc = new SmtpClient(MailServer);
               sc.Send(mail);
            }
            catch (SmtpException)
            {
               throw new NotificationException();
            }
             }
        }
Exemplo n.º 23
0
        public void Notify(IEmailNotification emailNotification)
        {
            using (var mail = new MailMessage())
            {
                mail.To.Add(emailNotification.To);
                mail.From       = new MailAddress(emailNotification.To);
                mail.Subject    = emailNotification.Subject;
                mail.Body       = emailNotification.Body;
                mail.IsBodyHtml = true;

                try
                {
                    var sc = new SmtpClient(MailServer);
                    sc.Send(mail);
                }
                catch (SmtpException)
                {
                    throw new NotificationException();
                }
            }
        }
        /// <summary>
        /// Build a EmailMessage
        /// </summary>
        /// <param name="mail">notification</param>
        /// <returns></returns>
        private EmailMessage BuildMail(IEmailNotification mail)
        {
            if (mail == null)
            {
                throw new ArgumentNullException(nameof(mail));
            }

            if (mail.To == null || !mail.To.Any())
            {
                throw new InvalidOperationException("there are no recipients");
            }

            var exchangeService = new ExchangeService(ExchangeVersion.Exchange2016);

            exchangeService.Credentials  = new WebCredentials(userMail, userPass);
            exchangeService.TraceEnabled = true;
            exchangeService.TraceFlags   = TraceFlags.All;
            exchangeService.AutodiscoverUrl(userMail, RedirectionUrlValidationCallback);
            exchangeService.Timeout = 50000;


            var message = new EmailMessage(exchangeService)
            {
                Subject = mail.Subject,
                Body    = new MessageBody(mail.IsHtml ? BodyType.HTML : BodyType.Text, mail.Body),
            };

            message.ToRecipients.AddRange(
                mail.To.Select(to => new EmailAddress(to))
                );

            if (mail.Cc != null && mail.Cc.Any())
            {
                message.CcRecipients.AddRange(
                    mail.Cc.Select(cc => new EmailAddress(cc))
                    );
            }

            return(message);
        }
        public void SendEmail(IEmailNotification mail, IEnumerable <IEmailAttachment> emailAttachments)
        {
            try
            {
                var message = BuildMail(mail);

                if (emailAttachments.Any())
                {
                    foreach (var emailAttachment in emailAttachments)
                    {
                        message.Attachments.AddFileAttachment(emailAttachment.FileName, emailAttachment.ContentBytes);
                    }
                }

                SendEmailInternal(message);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, ex.StackTrace);
                throw;
            }
        }
Exemplo n.º 26
0
 public NotificationActor(IEmailNotification emailNotification)
 {
     this.emailNotification = emailNotification;
     this.childActor        = Context.ActorOf(Context.System.DI().Props <TextNotificationActor>());
 }
Exemplo n.º 27
0
 public async Task NotifyAsync <TContent>(IEmailNotification notification)
     where TContent : IEmail
 {
     await _client.NotifyAsync <TContent>(notification);
 }
    public static bool NotifyEmail(this IEmailNotification obj)
    {
        var sender = new SendEmail();

        return(sender.Send(obj));
    }
        public void Flush(object sender, EventArgs e)
        {
            // If there's no work to do, just stop here
            if (_backlog.Count <= 0)
            {
                return;
            }

            using (FormFactory factory = new FormFactory())
            {
                using (SmtpClient smtpClient = new SmtpClient(_smtpConnectionDetails.Host)
                {
                    Port = _smtpConnectionDetails.Port,
                    UseDefaultCredentials = false,
                    EnableSsl = true,
                    Credentials = new NetworkCredential(_smtpConnectionDetails.Username, _smtpConnectionDetails.Password)
                })
                {
                    foreach (INotifiable form in _backlog)
                    {
                        // Determine recipients of the message
                        List <string> recipients = new List <string>();
                        foreach (SelectedSchool selectedSchool in form.GetNotifySchools())
                        {
                            if (_schoolEmailsByDAN.ContainsKey(selectedSchool.DAN))
                            {
                                if (!recipients.Contains(_schoolEmailsByDAN[selectedSchool.DAN]))
                                {
                                    recipients.Add(_schoolEmailsByDAN[selectedSchool.DAN]);
                                }
                            }
                        }

                        // Handle the form based on what kind of form it is
                        IEmailNotification emailNotification = null;

                        if (form.GetType() == typeof(SubmittedPreKApplicationForm))
                        {
                            emailNotification = new PreKEmailNotification((SubmittedPreKApplicationForm)form, factory, _timeZone);
                        }

                        if (form.GetType() == typeof(SubmittedGeneralRegistrationForm))
                        {
                            emailNotification = new GeneralRegistrationEmailNotification((SubmittedGeneralRegistrationForm)form, factory, _timeZone);
                        }

                        if (emailNotification != null)
                        {
                            MailMessage msg = new MailMessage();
                            foreach (string addr in recipients)
                            {
                                msg.To.Add(addr);
                            }

                            msg.Body    = emailNotification.Body;
                            msg.Subject = emailNotification.Subject;
                            msg.From    = new MailAddress(_smtpConnectionDetails.FromAddress, "LSSD Registration Site");
                            msg.ReplyToList.Add(new MailAddress(_smtpConnectionDetails.ReplyToAddress, "LSSD Registration Site"));
                            msg.IsBodyHtml = true;

                            try
                            {
                                if (!string.IsNullOrEmpty(emailNotification.AttachmentFilename))
                                {
                                    using (Attachment fileAttachment = new Attachment(emailNotification.AttachmentFilename)
                                    {
                                        Name = emailNotification.FriendlyAttachmentName
                                    }) {
                                        msg.Attachments.Add(fileAttachment);
                                        smtpClient.Send(msg);
                                    }
                                }
                                else
                                {
                                    smtpClient.Send(msg);
                                }

                                form.NotificationSent = true;
                            }
                            catch (Exception ex) {
                                //TODO: Log this better
                                Console.WriteLine($"EXCEPTION: {ex.Message}");
                            }
                        }
                    }

                    // Empty the queue. Some may have failed, but they won't be marked as notified in the DB, so the next run will catch them.
                    // This prevents an SMTP outage from enqueuing the same email hundreds of times.
                    _backlog.Clear();
                }
            }
        }
Exemplo n.º 30
0
 public NotificationActor(IEmailNotification emailNotification, ILoggerAdapter <NotificationActor> logger)
 {
     this.emailNotification = emailNotification;
     this._logger           = logger;
     this.childActor        = Context.ActorOf(Context.System.DI().Props <LogNotificationActor>());
 }
 public void Send(IEmailNotification notification)
 {
     _factory.GetHandler <IEmailNotification>().Handle(notification);
 }
Exemplo n.º 32
0
 public ForgotPasswordNotificationHandler(IEmailNotification emailNotification)
 {
     _emailNotification = emailNotification;
 }
Exemplo n.º 33
0
 public ActivityProcessor(IDomainContext context, IEmailNotification notification)
 {
     _context = context;
     _notification = notification;
 }
Exemplo n.º 34
0
        public override void Notify(INotification notification)
        {
            IEmailNotification emailNotification = notification as IEmailNotification;


        }
 public MessagingGateway(ITelegramNotification telegram, IEmailNotification emailNotification)
 {
     _telegram = telegram;
     _emailNotification = emailNotification;
 }