public async Task SendEmailAsync(string userName, string email, SchedulerMessage message) { var emailMessage = new MimeMessage(); emailMessage.From.Add(new MailboxAddress("Eternal Store", smtpLogin)); emailMessage.To.Add(new MailboxAddress(userName, email)); emailMessage.Subject = message.Subject; emailMessage.Body = new TextPart(MimeKit.Text.TextFormat.Html) { Text = message.Body }; using var client = new SmtpClient(); await client.ConnectAsync(smtpAddress, smtpPort, useSsl); await client.AuthenticateAsync(smtpLogin, smtpPassword); await client.SendAsync(emailMessage); await client.DisconnectAsync(true); var dbEmailMessage = EmailMessage.Insert(smtpLogin, email, message); await emailMessageRepository.InsertAsync(dbEmailMessage); }
private bool Forward(SchedulerMessage <TJob, TIdentity> command) { Log.Info( "JobManager for Job of Name={0} is forwarding job command of Type={1} to JobScheduler at ActorPath={2}", Name, typeof(TJob).PrettyPrint(), JobScheduler.Path); JobScheduler.Forward(command); return(true); }
public void Consume_Sends_CheckForFilesCommand() { var fakeBus = MockRepository.GenerateStub<IServiceBus>(); var message = new SchedulerMessage(); var testObject = new SchedulerMessageConsumer(fakeBus); testObject.Consume(message); fakeBus.AssertWasCalled(x => x.Send(Arg<CheckForFilesCommand>.Is.NotNull)); }
public async Task <IActionResult> Post([FromBody] SchedulerMessage msg) { TimeSpan ts; IActionResult response = Ok(); JobManager.Initialize(); if (!TimeSpan.TryParse(msg.Time, out ts)) { response = BadRequest("Time span is not correct"); } else { // Send DM for all user every day at x:y (x:Hours, y:Minutes). JobManager.AddJob(() => SendDirectMessageToEveryone(msg.Message), s => s.ToRunEvery(1).Days().At(ts.Hours, ts.Minutes)); } return(response); }