示例#1
0
        protected string FormatValue(UserAccountEvent evt, string value)
        {
            if (value == null) return null;

            var tokenizer = GetTokenizer(evt);
            return tokenizer.Tokenize(evt, this.ApplicationInformation, value);
        }
 public virtual void Process(UserAccountEvent evt, string phone = null)
 {
     var msg = CreateMessage(evt, phone);
     if (msg != null)
     {
         SendSms(msg);
     }
 }
 protected virtual Message CreateMessage(UserAccountEvent evt, string phone)
 {
     var msg = this.messageFormatter.Format(evt);
     if (msg != null)
     {
         msg.To = phone ?? evt.Account.MobilePhoneNumber;
     }
     return msg;
 }
示例#4
0
        private string GetMessageBody(UserAccountEvent accountEvent)
        {
            var txt = LoadTemplate();

            txt = txt.Replace("{applicationName}", ApplicationInformation.ApplicationName);
            txt = txt.Replace("{code}", accountEvent.Account.MobileCode);

            return txt;
        }
示例#5
0
        public Message Format(UserAccountEvent accountEvent)
        {
            if (accountEvent == null) throw new ArgumentNullException("accountEvent");

            var message = GetMessageBody(accountEvent);
            return new Message
            {
                Subject = message,
                Body = message
            };
        }
示例#6
0
 protected virtual Tokenizer GetTokenizer(UserAccountEvent evt)
 {
     Type type = evt.GetType();
     if (type == typeof(EmailChangeRequestedEvent)) return new EmailChangeRequestedTokenizer();
     if (type == typeof(EmailChangedEvent)) return new EmailChangedTokenizer();
     if (type == typeof(CertificateAddedEvent)) return new CertificateAddedTokenizer();
     if (type == typeof(CertificateRemovedEvent)) return new CertificateRemovedTokenizer();
     if (type == typeof(LinkedAccountAddedEvent)) return new LinkedAccountAddedTokenizer();
     if (type == typeof(LinkedAccountRemovedEvent)) return new LinkedAccountRemovedTokenizer();
     return new Tokenizer();
 }
示例#7
0
 protected virtual string GetSubject(UserAccountEvent evt)
 {
     return FormatValue(evt, LoadSubjectTemplate(evt));
 }
示例#8
0
 protected virtual string GetBody(UserAccountEvent evt)
 {
     return FormatValue(evt, LoadBodyTemplate(evt));
 }
示例#9
0
 public Message Format(UserAccountEvent accountEvent)
 {
     if (accountEvent == null) throw new ArgumentNullException("accountEvent");
     return CreateMessage(GetSubject(accountEvent), GetBody(accountEvent));
 }
示例#10
0
 public override string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
 {
     var evt = (LinkedAccountRemovedEvent)accountEvent;
     msg = base.Tokenize(accountEvent, appInfo, msg);
     msg = msg.Replace("{provider}", evt.LinkedAccount.ProviderName);
     return msg;
 }
示例#11
0
            public virtual string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
            {
                var user = accountEvent.Account;

                msg = msg.Replace("{username}", user.Username);
                msg = msg.Replace("{email}", user.Email);
                msg = msg.Replace("{mobile}", user.MobilePhoneNumber);

                msg = msg.Replace("{applicationName}", appInfo.ApplicationName);
                msg = msg.Replace("{emailSignature}", appInfo.EmailSignature);
                msg = msg.Replace("{loginUrl}", appInfo.LoginUrl);

                msg = msg.Replace("{confirmAccountCreateUrl}", appInfo.VerifyAccountUrl + user.VerificationKey);
                msg = msg.Replace("{cancelNewAccountUrl}", appInfo.CancelNewAccountUrl + user.VerificationKey);

                msg = msg.Replace("{confirmPasswordResetUrl}", appInfo.ConfirmPasswordResetUrl + user.VerificationKey);
                msg = msg.Replace("{confirmChangeEmailUrl}", appInfo.ConfirmChangeEmailUrl + user.VerificationKey);

                return msg;
            }
示例#12
0
 public override string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
 {
     var evt = (EmailChangeRequestedEvent)accountEvent;
     msg = base.Tokenize(accountEvent, appInfo, msg);
     msg = msg.Replace("{newEmail}", evt.NewEmail);
     msg = msg.Replace("{oldEmail}", accountEvent.Account.Email);
     return msg;
 }
示例#13
0
 public override string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
 {
     var evt = (CertificateRemovedEvent)accountEvent;
     msg = base.Tokenize(accountEvent, appInfo, msg);
     msg = msg.Replace("{thumbprint}", evt.Certificate.Thumbprint);
     msg = msg.Replace("{subject}", evt.Certificate.Subject);
     return msg;
 }
示例#14
0
 protected virtual string LoadSubjectTemplate(UserAccountEvent evt)
 {
     return LoadTemplate(evt.GetType().Name + "_Subject");
 }
示例#15
0
 protected virtual string LoadBodyTemplate(UserAccountEvent evt)
 {
     return LoadTemplate(evt.GetType().Name + "_Body");
 }
 public virtual void Process(UserAccountEvent evt, string email = null)
 {
     var msg = this.messageFormatter.Format(evt);
     if (msg != null)
     {
         msg.To = email ?? evt.Account.Email;
         this.messageDelivery.Send(msg);
     }
 }