Exemplo n.º 1
0
        public void RemoveTaskFromPerson(Task task)
        {
            if (task == null || task.Assignees.Count == 0)
            {
                return;
            }

            //enter email address here
            const string boardEmailAddress = "*****@*****.**";

            int personId = task.Assignees[0].ID;
            int taskId   = task.Id;
            var pt       = _dbContext.PersonTasks.FirstOrDefault(x => x.Person_ID == personId && x.Task_ID == taskId);

            if (pt == null)
            {
                return;
            }
            _dbContext.PersonTasks.Remove(pt);
            _dbContext.SaveChanges();

            var unAssignedTask = _dbContext.Tasks.FirstOrDefault(t => t.ID == taskId);

            IMailService mailService = new SmtpMailService();

            mailService.SendTaskRevokeMail(unAssignedTask, boardEmailAddress);
        }
Exemplo n.º 2
0
        private IMailService GetService(Guid token)
        {
            Logger.Current.Verbose("Request received for getting mail-service with token :" + token);
            var service  = default(IMailService);
            var provider = MailProvider.Undefined;

            var registration = unitOfWork.MailRegistrationsRepository.FirstOrDefault(ft => ft.Guid == token);

            if (registration != null)
            {
                provider = registration.MailProviderID;
            }

            switch (provider)
            {
            case MailProvider.Smtp:
                service = new SmtpMailService(unitOfWork, token);
                Logger.Current.Informational("smtp mail service is configured for the above token");
                break;

            case MailProvider.SendGrid:
                service = new SendGridMailService(unitOfWork, token);
                Logger.Current.Informational("SendGrid mail service is configured for the above token");
                break;

            case MailProvider.SmartTouch:
                service = new VmtaMailService(unitOfWork, token);
                Logger.Current.Informational("VMTA mail service is configured for the above token");
                break;

            default:
                break;
            }
            return(service);
        }
Exemplo n.º 3
0
        public void AssignTaskToPerson(Task task)
        {
            if (task == null || task.Assignees.Count == 0)
            {
                return;
            }

            if (task.Id == 0 || task.Assignees[0].ID == 0)
            {
                return;
            }

            var personId = task.Assignees[0].ID;

            Data.Task   assignedTask;
            Data.Person assignedPerson;

            var t = new Data.PersonTask {
                Person_ID = task.Assignees[0].ID, Task_ID = task.Id
            };

            _dbContext.PersonTasks.Add(t);
            _dbContext.SaveChanges();

            assignedTask   = _dbContext.Tasks.FirstOrDefault(at => at.ID == task.Id);
            assignedPerson = _dbContext.People.FirstOrDefault(ap => ap.ID == personId);

            IMailService mailService = new SmtpMailService();

            mailService.SendTaskRegistrationMail(assignedTask, assignedPerson.Email);
        }
Exemplo n.º 4
0
        public void ResetPassword(string emailAddress, string temporaryPassword, string temporaryPasswordHash)
        {
            if (String.IsNullOrEmpty(emailAddress))
            {
                throw new ArgumentNullException(emailAddress, "email address must be provided.");
            }

            var bcAttendee =
                _dbContext.People.SingleOrDefault(p => p.Email == emailAddress);

            if (bcAttendee == null)
            {
                throw new ArgumentOutOfRangeException(emailAddress, "attendee was not found.");
            }
            bcAttendee.LoginProvider = "internal";
            if (!String.IsNullOrEmpty(temporaryPasswordHash))
            {
                bcAttendee.PasswordHash = temporaryPasswordHash;
            }
            _dbContext.SaveChanges();

            IMailService svc = new SmtpMailService();

            svc.SendPasswordResetMail(emailAddress, temporaryPassword);
        }
Exemplo n.º 5
0
 private void TimerOnTick(object sender, ElapsedEventArgs e)
 {
     try
     {
         //var db = new DataContextConnection();
         //var _playerService = new PlayerService(db);
         //var gameweekOpenEmailRecipients = _playerService.GetPlayersEmailsAcceptedAlerts();
         //var _gameEmailService = new GameEmailService(new SmtpMailService());
         //var gs = new GameService.GameService(db, _gameEmailService);
         //Action gameweekUpdatedAction = () =>
         //{
         //    Parallel.ForEach(gameweekOpenEmailRecipients, (address) =>
         //    {
         //        _gameEmailService.SendGameweekOpenEmail(address, Url.Action("Index", "Home", null, Request.Url.Scheme));
         //    });
         //};
         //gs.UpdateApiData(gameweekUpdatedAction);
         //gs.UpdateResults();
     }
     catch (Exception ex)
     {
         var mailSvc = new SmtpMailService();
         mailSvc.Send("*****@*****.**", "CalledThat Service Exception", ex.ToString());
     }
 }
Exemplo n.º 6
0
        public static void SendAnfrageFormularMail(MailJson mm)
        {
            // https://github.com/Antaris/RazorEngine
            var msgToSend = Engine.Razor.RunCompile(AnfrageTemplate, "anfrageTemplateKey", null, mm);

            var emailSvc = new SmtpMailService(new ConfigurationService());
            emailSvc.SendMail("myhaflinger.com Kontaktformular", msgToSend, isBodyHtml:true);
        }
Exemplo n.º 7
0
        public static bool SendNewRegInfoToRegDesk(string to, Registration reg)
        {
            string templateHtml = ReadHtmlTemplate("Anmeldung_New_2RegDesk.html");
            var msgToSend = Engine.Razor.RunCompile(templateHtml, "anmeldungRegDeskInfoTemplateKey", null, reg);

            var emailSvc = new SmtpMailService(new ConfigurationService());
            return emailSvc.SendMail("Neue Anmeldung", msgToSend, true, to);
        }
Exemplo n.º 8
0
        public static bool SendRegCompleteMailToParticipant(Registration reg)
        {
            string templateHtml = ReadHtmlTemplate("Anmeldung_FinalStep.html");
            var msgToSend = Engine.Razor.RunCompile(templateHtml, "anmeldungFinalStepTemplateKey", null, reg);

            var emailSvc = new SmtpMailService(new ConfigurationService());
            return emailSvc.SendMail("Anmeldebestätigung", msgToSend, true, reg.EmailAddress);
        }
Exemplo n.º 9
0
        public static bool SendStep1Mail(string urlForContinuation, string to)
        {
            string templateHtml = ReadHtmlTemplate("Anmeldung_Step1_Email.html");
            var msgToSend = Engine.Razor.RunCompile(templateHtml, "anmeldungStep1TemplateKey", null, new { LinkToForm = urlForContinuation });

            var emailSvc = new SmtpMailService(new ConfigurationService());
            return emailSvc.SendMail("Emailadresse validiert, Haflingertreffen Salzkammergut", msgToSend, true, to);
        }
Exemplo n.º 10
0
        public Task SendAsync(IdentityMessage message)
        {
            // Plug in your email service here to send an email.
            var mail = new SmtpMailService();

            return(Task.Run(() => mail.Send(message.Destination, message.Subject, message.Body)));
            //return Task.FromResult(0);
        }
Exemplo n.º 11
0
 public Task SendAsync(IdentityMessage message)
 {
     try
     {
         SmtpMailService.SendtoMail(message.Destination, message.Subject, message.Body);
         return(Task.FromResult(0));
     }
     catch (Exception)
     {
         return(Task.FromResult(99));
     }
 }
Exemplo n.º 12
0
        public void SendtoMail(string tosend, string family)
        {
            StringBuilder text = new StringBuilder();

            text.AppendLine("La familia " + family + " te a envíado una invitación para compartir esta aplicación");
            text.AppendLine("Ingresa en el siguiente link para confirmar la invitación, registrandote en el sistema si aún no lo has hecho");
            text.AppendLine("Link: " + ConfigurationManager.AppSettings["WebApp"] + "confirmInvitation?family=" + family);
            string subject = "La familia " + family + " te a envíado una invitación";
            string body    = "Body";

            SmtpMailService.SendtoMail(tosend, subject, body);
        }
Exemplo n.º 13
0
        public void GetSender_TypeIsMailSender()
        {
            var stub = Mock.Of <IStatistic>();

            _MailService = new SmtpMailService(stub);
            var address  = "*****@*****.**";
            var port     = 25;
            var useSsl   = true;
            var login    = "******";
            var password = "******".Encrypt();

            var actual = _MailService.GetSender(address, port, useSsl, login, password);

            Assert.IsInstanceOfType(actual, typeof(IMailSender));
        }
Exemplo n.º 14
0
        public void GetSender_Give_NotNull_Stub_Test()
        {
            var stub = Mock.Of <IStatistic>();

            _MailService = new SmtpMailService(stub);
            var address  = "*****@*****.**";
            var port     = 25;
            var useSsl   = true;
            var login    = "******";
            var password = "******".Encrypt();
            var expected = new SmtpSender(address, port, useSsl, login, password, stub);

            var actual = _MailService.GetSender(address, port, useSsl, login, password);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemplo n.º 15
0
        public void ChangePassword(int id, string oldPasswordHash, string newPasswordHash)
        {
            var p = _dbContext.People.Find(id);

            if (String.IsNullOrEmpty(p.PasswordHash))
            {
                throw new ArgumentNullException(oldPasswordHash);
            }
            if (p.PasswordHash == oldPasswordHash)
            {
                p.PasswordHash = newPasswordHash;
            }
            _dbContext.SaveChanges();

            IMailService svc = new SmtpMailService();

            svc.SendPasswordChangeMail(p.Email);
        }
Exemplo n.º 16
0
 public static void Test()
 {
     string          json     = SQL.ExecuteScalar("SELECT TOP 1 FC_Value FROM T_FMS_Configuration WHERE FC_Key LIKE 'SMTP'");;
     MailSettings    settings = MailSettings.FromJson(json);
     SmtpMailService ms       = new SmtpMailService(settings);
 }