コード例 #1
0
ファイル: Email.cs プロジェクト: patel-pragnesh/fr8core-dev
        public void SendUserSettingsNotification(IUnitOfWork uow, Fr8AccountDO submittedDockyardAccountData)
        {
            EmailDO curEmail = new EmailDO();

            curEmail.From = submittedDockyardAccountData.EmailAddress;
            curEmail.AddEmailRecipient(EmailParticipantType.To, submittedDockyardAccountData.EmailAddress);
            curEmail.Subject = "DockYardAccount Settings Notification";
            //new Email(uow).SendTemplate(uow, "User_Settings_Notification", curEmail, null);
            //uow.EnvelopeRepository.ConfigureTemplatedEmail(curEmail, "User_Settings_Notification", null);
        }
コード例 #2
0
        public static EmailDO TestEmail1()
        {
            EmailDO curEmailDO = new EmailDO();

            curEmailDO.Id   = 1;
            curEmailDO.From = TestEmailAddress1();
            curEmailDO.AddEmailRecipient(EmailParticipantType.To, TestEmailAddress2());
            curEmailDO.Subject  = "Main Subject";
            curEmailDO.HTMLText = "This is the Body Text";
            return(curEmailDO);
        }
コード例 #3
0
        public static EmailDO TestEmail3()
        {
            EmailDO curEmailDO = new EmailDO();

            curEmailDO.Id   = 3;
            curEmailDO.From = TestEmailAddress3();
            curEmailDO.AddEmailRecipient(EmailParticipantType.To, TestEmailAddress3());
            curEmailDO.Subject  = "Main Subject";
            curEmailDO.HTMLText = "This Email is intended to be used with KwasantIntegration account ";
            return(curEmailDO);
        }
コード例 #4
0
        public void GenerateWelcomeEmail(string curUserId)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var     curUser  = uow.UserRepository.GetByKey(curUserId);
                EmailDO curEmail = new EmailDO();
                curEmail.From = uow.EmailAddressRepository.GetOrCreateEmailAddress(_configRepository.Get("EmailAddress_GeneralInfo"));
                curEmail.AddEmailRecipient(EmailParticipantType.To, curUser.EmailAddress);
                curEmail.Subject = "Welcome to Kwasant";

                //uow.EnvelopeRepository.ConfigureTemplatedEmail(curEmail, _configRepository.Get("welcome_to_kwasant_template"), null); //welcome to kwasant v2 template
                uow.SaveChanges();
            }
        }
コード例 #5
0
ファイル: Plan.cs プロジェクト: patel-pragnesh/fr8core-dev
        private async Task ReportAuthDeactivation(IUnitOfWork uow, PlanDO plan, InvalidTokenRuntimeException ex)
        {
            var activityTemplate = ex?.FailedActivityDTO.ActivityTemplate;

            string errorMessage = $"Activity {ex?.FailedActivityDTO.Label} was unable to authenticate with remote web-service.";

            errorMessage += $"Plan \"{plan.Name}\" which contains failed activity was deactivated.";

            _pusherNotifier.NotifyUser(new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericFailure,
                Subject          = "Plan Failed",
                Message          = errorMessage,
                Collapsed        = false
            }, plan.Fr8AccountId);

            //Sending an Email

            var account = uow.UserRepository.GetQuery().FirstOrDefault(a => a.Id == plan.Fr8AccountId);

            try
            {
                var userEmail = account.UserName;
                var emailDO   = new EmailDO();
                IConfigRepository configRepository = ObjectFactory.GetInstance <IConfigRepository>();
                string            fromAddress      = configRepository.Get("EmailAddress_GeneralInfo");
                var emailAddressDO = uow.EmailAddressRepository.GetOrCreateEmailAddress(fromAddress);
                emailDO.From   = emailAddressDO;
                emailDO.FromID = emailAddressDO.Id;
                emailDO.AddEmailRecipient(EmailParticipantType.To,
                                          uow.EmailAddressRepository.GetOrCreateEmailAddress(userEmail));
                emailDO.Subject = "Your plan was deactivated due to authentication expiration";
                string htmlText = $"Plan “{plan.Name}” was deactivated due to authentication problems. <br>If you would like to keep it active, please reauthenticate <a href='{Server.ServerUrl}dashboard/plans/{plan.Id}/builder?viewMode=plan'>here</a>";
                emailDO.HTMLText = htmlText;

                uow.EnvelopeRepository.ConfigureTemplatedEmail(emailDO, "PlanDeactivated_Template");
                uow.SaveChanges();

                await ObjectFactory.GetInstance <IEmailPackager>().Send(new EnvelopeDO {
                    Email = emailDO
                });
            }

            catch { Logger.GetLogger().Error($"Couldn't send email to user {account.Id} to notify him about plan deactivation"); }
        }
コード例 #6
0
        public async Task ForgotPasswordAsync(string userEmail)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var userManager = new DockyardIdentityManager(uow);
                var user        = await userManager.FindByEmailAsync(userEmail);

                if (user == null /* || !(await userManager.IsEmailConfirmedAsync(user.Id))*/)
                {
                    // Don't reveal that the user does not exist or is not confirmed
                    return;
                }

                var code = await userManager.GeneratePasswordResetTokenAsync(user.Id);

                code = HttpUtility.HtmlEncode(code);

                var callbackUrl = string.Format("{0}Account/ResetPassword?UserId={1}&code={2}", Server.ServerUrl,
                                                user.Id, code);

                var emailDO = new EmailDO();
                IConfigRepository configRepository = ObjectFactory.GetInstance <IConfigRepository>();
                string            fromAddress      = configRepository.Get("EmailAddress_GeneralInfo");
                var emailAddressDO = uow.EmailAddressRepository.GetOrCreateEmailAddress(fromAddress);
                emailDO.From   = emailAddressDO;
                emailDO.FromID = emailAddressDO.Id;
                emailDO.AddEmailRecipient(EmailParticipantType.To,
                                          uow.EmailAddressRepository.GetOrCreateEmailAddress(userEmail));
                emailDO.Subject = "Password Recovery Request";
                string htmlText = string.Format("Please reset your password by clicking this <a href='{0}'>link:</a> <br> <b>Note: </b> Reset password link will be expired after 24 hours.", callbackUrl);
                emailDO.HTMLText = htmlText;

                uow.EnvelopeRepository.ConfigureTemplatedEmail(emailDO, configRepository.Get("ForgotPassword_template"),
                                                               new Dictionary <string, object>()
                {
                    { "-callback_url-", callbackUrl }
                });
                uow.SaveChanges();

                await ObjectFactory.GetInstance <IEmailPackager>().Send(new EnvelopeDO {
                    Email = emailDO
                });
            }
        }
コード例 #7
0
        public Task SendAsync(IdentityMessage message)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                String senderMailAddress =
                    ObjectFactory.GetInstance <IConfigRepository>().Get("EmailAddress_GeneralInfo");

                EmailDO emailDO = new EmailDO();
                emailDO.AddEmailRecipient(EmailParticipantType.To,
                                          Email.GenerateEmailAddress(uow, new MailAddress(message.Destination)));
                emailDO.From = Email.GenerateEmailAddress(uow, new MailAddress(senderMailAddress));

                emailDO.Subject  = message.Subject;
                emailDO.HTMLText = message.Body;

                //uow.EnvelopeRepository.ConfigurePlainEmail(emailDO);
                uow.SaveChanges();
                return(Task.FromResult(0));
            }
        }