예제 #1
0
        public void SendEmailMessage(Guid id)
        {
            var emailMessage = _repository.GetAll().FirstOrDefault(x => x.Id == id);

            if (emailMessage != null && !emailMessage.SentDateTime.HasValue)
            {
                try
                {
                    _emailNotification.Send(new Infrastructure.Notification.Email.EmailMessageDTO
                    {
                        From    = emailMessage.From,
                        Tos     = emailMessage.Tos,
                        CCs     = emailMessage.CCs,
                        BCCs    = emailMessage.BCCs,
                        Subject = emailMessage.Subject,
                        Body    = emailMessage.Body,
                    });

                    _repository.UpdateSent(emailMessage.Id);
                }
                catch (Exception ex)
                {
                    _repository.UpdateFailed(emailMessage.Id, Environment.NewLine + Environment.NewLine + ex.ToString());
                }
            }
        }
        public void SendEmailMessage(Guid id)
        {
            var emailMessage = _repository.GetAll().FirstOrDefault(x => x.Id == id);

            if (emailMessage != null && !emailMessage.SentDateTime.HasValue)
            {
                try
                {
                    _emailNotification.Send(emailMessage);
                    _repository.UpdateSent(emailMessage.Id);
                }
                catch (Exception ex)
                {
                    _repository.UpdateFailed(emailMessage.Id, Environment.NewLine + Environment.NewLine + ex.ToString());
                }
            }
        }
예제 #3
0
        protected override void OnReceive(object message)
        {
            Console.WriteLine($"Message received {message}");
            emailNotification.Send(message.ToString());


            if (message.ToString().ToLower().Equals("object"))
            {
                message = new TextMessage
                {
                    txt = "TextMessage Object Snd Test"
                };
            }


            // Infor Text Actor
            childActor.Tell(message);
        }
예제 #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ContactViewModel.ContactType == ContactType.Demo)
            {
                var result = await _userService.Register(ContactViewModel.Email);

                if (result.Succeed)
                {
                    _logger.LogInformation($"User: {ContactViewModel.Email} created.");

                    return(RedirectToPage("/ThankYou", "UserCreated"));
                }
                else
                {
                    _logger.LogError($"Error: {result.Message} for user: {ContactViewModel.Email}.");

                    return(RedirectToPage("/Error", "UserError", new { message = result.Message }));
                }
            }
            else
            {
                var emailSent = _emailNotification.Send(
                    $"[PM] {ContactViewModel.Subject}",
                    $"{ContactViewModel.Email} pisze: {ContactViewModel.Message}",
                    $"{ContactViewModel.Email} pisze: {ContactViewModel.Message}",
                    new string[] { "*****@*****.**" }
                    );

                if (emailSent.IsSuccess)
                {
                    _logger.LogInformation($"{emailSent.Message}");

                    return(RedirectToPage("/ThankYou", "MailSent"));
                }
                else
                {
                    _logger.LogError($"Error: {emailSent.Message} for user: {ContactViewModel.Email}.");

                    return(RedirectToPage("/Error", "UserError", new { message = emailSent.Message }));
                }
            }
        }
예제 #5
0
 protected override void OnReceive(object message)
 {
     Console.WriteLine($"Message received: {message}");
     emailNotification.Send(message?.ToString());
     childActor.Tell(message);
 }
예제 #6
0
 protected override void OnReceive(object message)
 {
     _logger.LogInformation($"Inside of NotificationActor - Message received: {message}");
     emailNotification.Send(message?.ToString());
     childActor.Tell(message);
 }
예제 #7
0
        public async Task <UserRegisterResponse> Register(string email)
        {
            var exist = (await _userRepository.FindByAsync(u => string.Equals(u.Email, email.ToLowerInvariant())))
                        .FirstOrDefault();

            if (!(exist is null))
            {
                return(UserRegisterResponse.Error("Podany adres email, został już zarejestrowany w systemie"));
            }

            try
            {
                var guid = Guid.NewGuid().ToString().ToUpperInvariant();

                var newUserId = await _userRepository.CreateAsync(
                    new User { Email = email, Guid = guid });

                if (newUserId > 0)
                {
                    var emailUI = new EmailUI(guid);

                    var emailToSend = emailUI.Prepare();

                    if (emailUI.CanBeSend)
                    {
                        var emailToUser = _emailNotification.Send(
                            emailToSend.Title,
                            emailToSend.RawMessage,
                            emailToSend.HtmlMessage,
                            new string[] { email });

                        if (emailToUser.IsSuccess)
                        {
                            var msg = $"Utworzono użytkownika: {email} i wysłano wiadomość.";

                            _logger.LogInformation(msg);
                            _pushOverNotification.Send("[PewneMieszkanie.pl] - Sukces", msg);

                            return(UserRegisterResponse.Success());
                        }
                        else
                        {
                            _logger.LogInformation(emailToUser.Message);
                            _pushOverNotification.Send("[PewneMieszkanie.pl] - Błąd", emailToUser.Message);

                            return(UserRegisterResponse.Error(emailToUser.Message));
                        }
                    }
                    else
                    {
                        return(UserRegisterResponse.Error($"Wiadomość do {email} nie może zostać wysłana."));
                    }
                }
                else
                {
                    var msg = $"Błąd przy tworzeniu użytkownika - {email}.";

                    _logger.LogError(msg);

                    return(UserRegisterResponse.Error(msg));
                }
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.GetFullMessage());

                return(UserRegisterResponse.Error(ex.GetFullMessage()));
            }
        }