protected override string GetBody(UserAccountEvent <HierarchicalUserAccount> evt, IDictionary <string, string> values) { string msgBody = string.Empty; switch (_msgBodyType) { case AuthCentralSmtpMessageDelivery.MsgBodyTypes.MultipartAlternativeAsJson: { var multipartMsgBody = new MultipartMessageBody() { PlainText = FormatValue(evt, LoadBodyTemplate(evt, PLAIN_TEXT_FILE_EXTENSION), values), Html = FormatValue(evt, LoadBodyTemplate(evt, HTML_FILE_EXTENSION), values), }; msgBody = JsonConvert.SerializeObject(multipartMsgBody); break; } case AuthCentralSmtpMessageDelivery.MsgBodyTypes.Html: { msgBody = FormatValue(evt, LoadBodyTemplate(evt, HTML_FILE_EXTENSION), values); break; } default: { msgBody = FormatValue(evt, LoadBodyTemplate(evt, PLAIN_TEXT_FILE_EXTENSION), values); break; } } return(msgBody); }
protected override string LoadSubjectTemplate(UserAccountEvent <HierarchicalUserAccount> evt) { ResolveSubjectTemplateName resolveSubjectTemplateName; if (!SubjectTemplateNameResolverOverrides.TryGetValue(evt.GetType(), out resolveSubjectTemplateName)) { resolveSubjectTemplateName = DefaultSubjectTemplateNameResolver; } string templateName = resolveSubjectTemplateName(evt); return(LoadTemplate(templateName)); }
protected override string GetBody(UserAccountEvent <CustomUserAccount> evt, IDictionary <string, string> values) { if (evt is EmailVerifiedEvent <CustomUserAccount> ) { return("your account was verified with " + this.ApplicationInformation.ApplicationName + ". good for you."); } if (evt is AccountClosedEvent <CustomUserAccount> ) { return(FormatValue(evt, "your account was closed with {applicationName}. good riddance.", values)); } return(base.GetBody(evt, values)); }
protected override string GetBody(UserAccountEvent evt) { if (evt is AccountVerifiedEvent) { return("your account was verified with " + this.ApplicationInformation.ApplicationName + ". good for you."); } if (evt is AccountClosedEvent) { return(FormatValue(evt, "your account was closed with {applicationName}. good riddance.")); } return(base.GetBody(evt)); }
private DateTime VerificationExpirationTimestamp(DateTime?verificationSent, UserAccountEvent <HierarchicalUserAccount> accountEvent) { if (!verificationSent.HasValue) { _logger.LogError($"VerificationSent not set for account {accountEvent.Account.ID}. Verification set for {accountEvent.Account.VerificationPurpose}."); return(DateTime.Now); } DateTime sent = verificationSent.Value; TimeZoneInfo mountainZone = TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time"); sent = TimeZoneInfo.ConvertTime(sent.ToUniversalTime(), TimeZoneInfo.Utc, mountainZone); return(sent.Add(_config.VerificationKeyLifetime)); }
protected override string GetBody(UserAccountEvent <CustomUserAccount> evt, dynamic extra) { if (evt is AccountVerifiedEvent <CustomUserAccount> ) { return("your account was verified with " + this.ApplicationInformation.ApplicationName + ". good for you."); } if (evt is AccountClosedEvent <CustomUserAccount> ) { return(FormatValue(evt, "your account was closed with {applicationName}. good riddance.", extra)); } Func <UserAccountEvent <CustomUserAccount>, dynamic, string> f = base.GetBody; return(f(evt, extra)); }
public virtual string LoadBodyTemplate(UserAccountEvent <HierarchicalUserAccount> evt, string extension) { ResolveBodyTemplateName resolveBodyTemplateName; if (!BodyTemplateNameResolverOverrides.TryGetValue(evt.GetType(), out resolveBodyTemplateName)) { resolveBodyTemplateName = DefaultBodyTemplateNameResolver; } string templateName = resolveBodyTemplateName(evt, extension); StringBuilder bodyTemplate = new StringBuilder(LoadTemplate(templateName)); if (extension == HTML_FILE_EXTENSION) { bodyTemplate.Insert(0, LoadTemplate("CommonHeader_Body.html")); bodyTemplate.Append(LoadTemplate("CommonFooter_Body.html")); } return(bodyTemplate.ToString()); }
protected override string GetSubject(UserAccountEvent <HierarchicalUserAccount> evt, IDictionary <string, string> values) { return(FormatValue(evt, LoadSubjectTemplate(evt), values)); }
private static string DefaultBodyTemplateNameResolver(UserAccountEvent <HierarchicalUserAccount> evt, string fileExtension) { return(CleanGenericName(evt.GetType()) + "_Body." + fileExtension); }
private static string DefaultSubjectTemplateNameResolver(UserAccountEvent <HierarchicalUserAccount> evt) { return(CleanGenericName(evt.GetType()) + "_Subject." + PLAIN_TEXT_FILE_EXTENSION); }
#pragma warning disable CS0114 // Member hides inherited member; missing override keyword protected string LoadBodyTemplate(UserAccountEvent <HierarchicalUserAccount> evt) { #pragma warning restore CS0114 // Member hides inherited member; missing override keyword throw new NotImplementedException(); }
protected override string LoadSubjectTemplate(UserAccountEvent <UserAccount> evt) { return(LoadTemplate(CleanGenericName(evt.GetType()) + "_Subject")); }
public void Handle(UserAccountEvent <TAccount> evt) { _a?.Invoke(evt); }