当前位置: 首页>>代码示例>>C#>>正文


C# Services.YafTemplateEmail类代码示例

本文整理汇总了C#中YAF.Core.Services.YafTemplateEmail的典型用法代码示例。如果您正苦于以下问题:C# YafTemplateEmail类的具体用法?C# YafTemplateEmail怎么用?C# YafTemplateEmail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


YafTemplateEmail类属于YAF.Core.Services命名空间,在下文中一共展示了YafTemplateEmail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendRegistrationNotificationEmail

        /// <summary>
        /// The send registration notification email.
        /// </summary>
        /// <param name="user">The Membership User.</param>
        /// <param name="userID">The user identifier.</param>
        public static void SendRegistrationNotificationEmail([NotNull] MembershipUser user, [NotNull] int userID)
        {
            var emails = YafContext.Current.Get<YafBoardSettings>().NotificationOnUserRegisterEmailList.Split(';');

            var notifyAdmin = new YafTemplateEmail();

            var subject =
                YafContext.Current.Get<ILocalization>()
                    .GetText("COMMON", "NOTIFICATION_ON_USER_REGISTER_EMAIL_SUBJECT")
                    .FormatWith(YafContext.Current.Get<YafBoardSettings>().Name);

            notifyAdmin.TemplateParams["{adminlink}"] = YafBuildLink.GetLinkNotEscaped(
                ForumPages.admin_edituser,
                true,
                "u={0}",
                userID);
            notifyAdmin.TemplateParams["{user}"] = user.UserName;
            notifyAdmin.TemplateParams["{email}"] = user.Email;
            notifyAdmin.TemplateParams["{forumname}"] = YafContext.Current.Get<YafBoardSettings>().Name;

            string emailBody = notifyAdmin.ProcessTemplate("NOTIFICATION_ON_USER_REGISTER");

            foreach (string email in emails.Where(email => email.Trim().IsSet()))
            {
                YafContext.Current.GetRepository<Mail>()
                    .Create(YafContext.Current.Get<YafBoardSettings>().ForumEmail, email.Trim(), subject, emailBody);
            }
        }
开发者ID:hcn0843,项目名称:YAFNET,代码行数:33,代码来源:YafSingleSignOnUser.cs

示例2: Page_Load

    /// <summary>
    /// The page_ load.
    /// </summary>
    /// <param name="sender">
    /// The sender.
    /// </param>
    /// <param name="e">
    /// The e.
    /// </param>
    protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
    {
      if (this.Get<HttpRequestBase>().QueryString["t"] == null || !this.PageContext.ForumReadAccess ||
          !this.PageContext.BoardSettings.AllowEmailTopic)
      {
        YafBuildLink.AccessDenied();
      }

      if (!this.IsPostBack)
      {
        if (this.PageContext.Settings.LockedForum == 0)
        {
          this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
          this.PageLinks.AddLink(
            this.PageContext.PageCategoryName, 
            YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
        }

        this.PageLinks.AddForumLinks(this.PageContext.PageForumID);
        this.PageLinks.AddLink(
          this.PageContext.PageTopicName, YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID));

        this.SendEmail.Text = this.GetText("send");

        this.Subject.Text = this.PageContext.PageTopicName;

        var emailTopic = new YafTemplateEmail();

        emailTopic.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(
          ForumPages.posts, true, "t={0}", this.PageContext.PageTopicID);
        emailTopic.TemplateParams["{user}"] = this.PageContext.PageUserName;

        this.Message.Text = emailTopic.ProcessTemplate("EMAILTOPIC");
      }
    }
开发者ID:vzrus,项目名称:VZF,代码行数:44,代码来源:emailtopic.ascx.cs

示例3: SendVerificationEmail

        /// <summary>
        /// The send verification email.
        /// </summary>
        /// <param name="haveServiceLocator">
        /// The have service locator.
        /// </param>
        /// <param name="user"></param>
        public static void SendVerificationEmail(
            [NotNull] this IHaveServiceLocator haveServiceLocator, [NotNull] MembershipUser user, [NotNull] string email, int? userID, string newUsername = null)
        {
            CodeContracts.VerifyNotNull(email, "email");
            CodeContracts.VerifyNotNull(user, "user");
            CodeContracts.VerifyNotNull(haveServiceLocator, "haveServiceLocator");

            string hashinput = DateTime.UtcNow + email + Security.CreatePassword(20);
            string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5");

            // save verification record...
            haveServiceLocator.GetRepository<CheckEmail>().Save(userID, hash, user.Email);

            var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

            string subject = haveServiceLocator.Get<ILocalization>().GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", haveServiceLocator.Get<YafBoardSettings>().Name);

            verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(ForumPages.approve, true, "k={0}", hash);
            verifyEmail.TemplateParams["{key}"] = hash;
            verifyEmail.TemplateParams["{forumname}"] = haveServiceLocator.Get<YafBoardSettings>().Name;
            verifyEmail.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

            verifyEmail.SendEmail(new MailAddress(email, newUsername ?? user.UserName), subject, true);
        }
开发者ID:RH-Code,项目名称:YAFNET,代码行数:31,代码来源:EmailHelper.cs

示例4: SendRegistrationNotificationToUser

        /// <summary>
        /// Send an Email to the Newly Created User with
        /// his Account Info (Pass, Security Question and Answer)
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="pass">
        /// The pass.
        /// </param>
        /// <param name="securityAnswer">
        /// The security answer.
        /// </param>
        /// <param name="templateName">
        /// The template Name.
        /// </param>
        public void SendRegistrationNotificationToUser(
            [NotNull] MembershipUser user,
            [NotNull] string pass,
            [NotNull] string securityAnswer,
            string templateName)
        {
            var notifyUser = new YafTemplateEmail();

            var subject =
                this.Get<ILocalization>()
                    .GetText("COMMON", "NOTIFICATION_ON_NEW_FACEBOOK_USER_SUBJECT")
                    .FormatWith(this.BoardSettings.Name);

            notifyUser.TemplateParams["{user}"] = user.UserName;
            notifyUser.TemplateParams["{email}"] = user.Email;
            notifyUser.TemplateParams["{pass}"] = pass;
            notifyUser.TemplateParams["{answer}"] = securityAnswer;
            notifyUser.TemplateParams["{forumname}"] = this.BoardSettings.Name;

            var emailBody = notifyUser.ProcessTemplate(templateName);

            this.GetRepository<Mail>()
                .Create(
                    user.Email,
                    user.UserName,
                    subject,
                    emailBody);
        }
开发者ID:viniciustodesco,项目名称:YAFNET,代码行数:44,代码来源:YafSendNotification.cs

示例5: ToWatchingUsers

        /// <summary>
        /// The to watching users.
        /// </summary>
        /// <param name="newMessageId">
        /// The new message id.
        /// </param>
        public void ToWatchingUsers(int newMessageId)
        {
            IList<User> usersWithAll = new List<User>();

            if (this.BoardSettings.AllowNotificationAllPostsAllTopics)
            {
                usersWithAll = this.GetRepository<User>()
                    .FindUserTyped(filter: false, notificationType: UserNotificationSetting.AllTopics.ToInt());
            }

            // TODO : Rewrite Watch Topic code to allow watch mails in the users language, as workaround send all messages in the default board language
            var languageFile = this.BoardSettings.Language;
            var boardName = this.BoardSettings.Name;
            var forumEmail = this.BoardSettings.ForumEmail;

            var message = LegacyDb.MessageList(newMessageId).FirstOrDefault();

            var messageAuthorUserID = message.UserID ?? 0;

            var watchEmail = new YafTemplateEmail("TOPICPOST") { TemplateLanguageFile = languageFile };

            // cleaned body as text...
            var bodyText =
                BBCodeHelper.StripBBCode(HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(message.Message)))
                    .RemoveMultipleWhitespace();

            // Send track mails
            var subject =
                this.Get<ILocalization>()
                    .GetText("COMMON", "TOPIC_NOTIFICATION_SUBJECT", languageFile)
                    .FormatWith(boardName);

            watchEmail.TemplateParams["{forumname}"] = boardName;
            watchEmail.TemplateParams["{topic}"] = HttpUtility.HtmlDecode(message.Topic);
            watchEmail.TemplateParams["{postedby}"] = UserMembershipHelper.GetDisplayNameFromID(messageAuthorUserID);
            watchEmail.TemplateParams["{body}"] = bodyText;
            watchEmail.TemplateParams["{bodytruncated}"] = bodyText.Truncate(160);
            watchEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(
                ForumPages.posts,
                true,
                "m={0}#post{0}",
                newMessageId);

            watchEmail.CreateWatch(
                message.TopicID ?? 0,
                messageAuthorUserID,
                new MailAddress(forumEmail, boardName),
                subject);

            // create individual watch emails for all users who have All Posts on...
            foreach (var user in usersWithAll.Where(x => x.UserID != messageAuthorUserID && x.ProviderUserKey != null))
            {
                var membershipUser = UserMembershipHelper.GetUser(user.Name);

                if (membershipUser == null || membershipUser.Email.IsNotSet())
                {
                    continue;
                }

                watchEmail.TemplateLanguageFile = user.LanguageFile.IsSet()
                                                      ? user.LanguageFile
                                                      : this.Get<ILocalization>().LanguageFileName;
                watchEmail.SendEmail(
                    new MailAddress(forumEmail, boardName),
                    new MailAddress(membershipUser.Email, membershipUser.UserName),
                    subject,
                    true);
            }
        }
开发者ID:viniciustodesco,项目名称:YAFNET,代码行数:75,代码来源:YafSendNotification.cs

示例6: SendVerificationEmail

        /// <summary>
        /// The send verification email.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="userID">
        /// The user id.
        /// </param>
        private void SendVerificationEmail([NotNull] MembershipUser user, int? userID)
        {
            var emailTextBox = (TextBox)this.CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
              string email = emailTextBox.Text.Trim();

              string hashinput = DateTime.UtcNow + email + Security.CreatePassword(20);
              string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5");

              // save verification record...
              LegacyDb.checkemail_save(userID, hash, user.Email);

              var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

              string subject = this.GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", this.Get<YafBoardSettings>().Name);

              verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(ForumPages.approve, true, "k={0}", hash);
              verifyEmail.TemplateParams["{key}"] = hash;
              verifyEmail.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
              verifyEmail.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

              verifyEmail.SendEmail(new MailAddress(email, user.UserName), subject, true);
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:31,代码来源:register.ascx.cs

示例7: PasswordRecovery1_SendingMail

        /// <summary>
        /// Handles the SendingMail event of the PasswordRecovery1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MailMessageEventArgs"/> instance containing the event data.</param>
        protected void PasswordRecovery1_SendingMail([NotNull] object sender, [NotNull] MailMessageEventArgs e)
        {
            // get the username and password from the body
            var body = e.Message.Body;

            // remove first line...
            body = body.Remove(0, body.IndexOf('\n') + 1);

            // remove "Username: "
            body = body.Remove(0, body.IndexOf(": ", StringComparison.Ordinal) + 2);

            // get first line which is the username
            var userName = body.Substring(0, body.IndexOf('\n'));

            // delete that same line...
            body = body.Remove(0, body.IndexOf('\n') + 1);

            // remove the "Password: " part
            body = body.Remove(0, body.IndexOf(": ", StringComparison.Ordinal) + 2);

            // the rest is the password...
            var password = body.Substring(0, body.IndexOf('\n'));

            // get the e-mail ready from the real template.
            var passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL");

            var subject = this.GetTextFormatted("PASSWORDRETRIEVAL_EMAIL_SUBJECT", this.Get<YafBoardSettings>().Name);

            var userIpAddress = this.Get<HttpRequestBase>().GetUserRealIPAddress();

            passwordRetrieval.TemplateParams["{username}"] = userName;
            passwordRetrieval.TemplateParams["{password}"] = password;
            passwordRetrieval.TemplateParams["{ipaddress}"] = userIpAddress;
            passwordRetrieval.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
            passwordRetrieval.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

            passwordRetrieval.SendEmail(e.Message.To[0], subject, true);

            // log password reset attempt
            this.Logger.Log(
                userName,
                "{0} Requested a Password Reset".FormatWith(userName),
                "The user {0} with the IP address: '{1}' requested a password reset.".FormatWith(
                    userName,
                    userIpAddress),
                EventLogTypes.Information);

            // manually set to success...
            e.Cancel = true;
            this.PasswordRecovery1.TabIndex = 3;
        }
开发者ID:JP58,项目名称:YAFNET,代码行数:56,代码来源:recoverpassword.ascx.cs

示例8: PasswordRecovery1_SendingMail

        /// <summary>
        /// The password recovery 1_ sending mail.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void PasswordRecovery1_SendingMail([NotNull] object sender, [NotNull] MailMessageEventArgs e)
        {
            // get the username and password from the body
            string body = e.Message.Body;

            // remove first line...
            body = body.Remove(0, body.IndexOf('\n') + 1);

            // remove "Username: "
            body = body.Remove(0, body.IndexOf(": ") + 2);

            // get first line which is the username
            string userName = body.Substring(0, body.IndexOf('\n'));

            // delete that same line...
            body = body.Remove(0, body.IndexOf('\n') + 1);

            // remove the "Password: " part
            body = body.Remove(0, body.IndexOf(": ") + 2);

            // the rest is the password...
            string password = body.Substring(0, body.IndexOf('\n'));

            // get the e-mail ready from the real template.
            var passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL");

            string subject = this.GetTextFormatted("PASSWORDRETRIEVAL_EMAIL_SUBJECT", this.Get<YafBoardSettings>().Name);

            passwordRetrieval.TemplateParams["{username}"] = userName;
            passwordRetrieval.TemplateParams["{password}"] = password;
            passwordRetrieval.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
            passwordRetrieval.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

            passwordRetrieval.SendEmail(e.Message.To[0], subject, true);

            // manually set to success...
            e.Cancel = true;
            this.PasswordRecovery1.TabIndex = 3;
        }
开发者ID:umityildiz,项目名称:YAFNET,代码行数:48,代码来源:recoverpassword.ascx.cs

示例9: SendEmailVerification

        /// <summary>
        /// The send email verification.
        /// </summary>
        /// <param name="newEmail">
        /// The new email.
        /// </param>
        private void SendEmailVerification([NotNull] string newEmail)
        {
            string hashinput = DateTime.UtcNow + this.Email.Text + Security.CreatePassword(20);
            string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5");

            // Create Email
            var changeEmail = new YafTemplateEmail("CHANGEEMAIL");

            changeEmail.TemplateParams["{user}"] = this.PageContext.PageUserName;
            changeEmail.TemplateParams["{link}"] =
                "{0}\r\n\r\n".FormatWith(YafBuildLink.GetLinkNotEscaped(ForumPages.approve, true, "k={0}", hash));
            changeEmail.TemplateParams["{newemail}"] = this.Email.Text;
            changeEmail.TemplateParams["{key}"] = hash;
            changeEmail.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
            changeEmail.TemplateParams["{forumlink}"] = YafForumInfo.ForumURL;

            // save a change email reference to the db
            this.GetRepository<CheckEmail>().Save(this.currentUserID, hash, newEmail);

            // send a change email message...
            changeEmail.SendEmail(new MailAddress(newEmail), this.GetText("COMMON", "CHANGEEMAIL_SUBJECT"), true);

            // show a confirmation
            this.PageContext.AddLoadMessage(this.GetText("PROFILE", "mail_sent").FormatWith(this.Email.Text));
        }
开发者ID:umityildiz,项目名称:YAFNET,代码行数:31,代码来源:EditUsersProfile.ascx.cs

示例10: SendUserWelcomeNotification

        /// <summary>
        /// Sends the user welcome notification.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="userId">The user identifier.</param>
        public void SendUserWelcomeNotification([NotNull] MembershipUser user, int? userId)
        {
            if (this.BoardSettings.SendWelcomeNotificationAfterRegister.Equals(0))
            {
                return;
            }

            var notifyUser = new YafTemplateEmail();

            var subject =
                this.Get<ILocalization>()
                    .GetText("COMMON", "NOTIFICATION_ON_WELCOME_USER_SUBJECT")
                    .FormatWith(this.BoardSettings.Name);

            notifyUser.TemplateParams["{user}"] = user.UserName;

            notifyUser.TemplateParams["{forumname}"] = this.BoardSettings.Name;
            notifyUser.TemplateParams["{forumurl}"] = YafForumInfo.ForumURL;

            var emailBody = notifyUser.ProcessTemplate("NOTIFICATION_ON_WELCOME_USER");

            var messageFlags = new MessageFlags { IsHtml = false, IsBBCode = true };

            if (this.BoardSettings.AllowPrivateMessages
                && this.BoardSettings.SendWelcomeNotificationAfterRegister.Equals(2))
            {
                var users = LegacyDb.UserList(YafContext.Current.PageBoardID, null, true, null, null, null).ToList();

                var hostUser = users.FirstOrDefault(u => u.IsHostAdmin > 0);

                LegacyDb.pmessage_save(hostUser.UserID.Value, userId, subject, emailBody, messageFlags.BitValue, -1);
            }
            else
            {
                this.GetRepository<Mail>()
                    .Create(
                        user.Email,
                        user.UserName,
                        subject,
                        emailBody);
            }
        }
开发者ID:viniciustodesco,项目名称:YAFNET,代码行数:47,代码来源:YafSendNotification.cs

示例11: SendRegistrationMessageToUser

        /// <summary>
        /// Send an Private Message to the Newly Created User with
        /// his Account Info (Pass, Security Question and Answer)
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="pass">
        /// The pass.
        /// </param>
        /// <param name="securityAnswer">
        /// The security answer.
        /// </param>
        /// <param name="userId">
        /// The user Id.
        /// </param>
        /// <param name="oAuth">
        /// The o Auth.
        /// </param>
        private static void SendRegistrationMessageToUser([NotNull] MembershipUser user, [NotNull] string pass, [NotNull] string securityAnswer, [NotNull] int userId, OAuthTwitter oAuth)
        {
            var notifyUser = new YafTemplateEmail();

            string subject =
                YafContext.Current.Get<ILocalization>().GetText("COMMON", "NOTIFICATION_ON_NEW_FACEBOOK_USER_SUBJECT").FormatWith(
                    YafContext.Current.Get<YafBoardSettings>().Name);

            notifyUser.TemplateParams["{user}"] = user.UserName;
            notifyUser.TemplateParams["{email}"] = user.Email;
            notifyUser.TemplateParams["{pass}"] = pass;
            notifyUser.TemplateParams["{answer}"] = securityAnswer;
            notifyUser.TemplateParams["{forumname}"] = YafContext.Current.Get<YafBoardSettings>().Name;

            string emailBody = notifyUser.ProcessTemplate("NOTIFICATION_ON_FACEBOOK_REGISTER");

            var messageFlags = new MessageFlags { IsHtml = false, IsBBCode = true };

            // Send Message also as DM to Twitter.
            var tweetApi = new TweetAPI(oAuth);

            if (YafContext.Current.Get<YafBoardSettings>().AllowPrivateMessages)
            {
                LegacyDb.pmessage_save(2, userId, subject, emailBody, messageFlags.BitValue);

                string message = "{0}. {1}".FormatWith(
                subject, YafContext.Current.Get<ILocalization>().GetText("LOGIN", "TWITTER_DM"));

                tweetApi.SendDirectMessage(TweetAPI.ResponseFormat.json, user.UserName, message.Truncate(140));
            }
            else
            {
                string message = YafContext.Current.Get<ILocalization>().GetTextFormatted(
                    "LOGIN", "TWITTER_DM", YafContext.Current.Get<YafBoardSettings>().Name, user.UserName, pass);

                tweetApi.SendDirectMessage(TweetAPI.ResponseFormat.json, user.UserName, message.Truncate(140));
            }
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:57,代码来源:YafSingleSignOnUser.cs

示例12: ToWatchingUsers

        /// <summary>
        /// The to watching users.
        /// </summary>
        /// <param name="newMessageId">
        /// The new message id.
        /// </param>
        public void ToWatchingUsers(int newMessageId)
        {
            IEnumerable<TypedUserFind> usersWithAll = new List<TypedUserFind>();

            if (this.Get<YafBoardSettings>().AllowNotificationAllPostsAllTopics)
            {
                // TODO: validate permissions!
                usersWithAll = CommonDb.UserFind(YafContext.Current.PageModuleID, YafContext.Current.PageBoardID,
                    false,
                    null,
                    null,
                    null,
                    UserNotificationSetting.AllTopics.ToInt(),
                    null);
            }

            // TODO : Rewrite Watch Topic code to allow watch mails in the users language, as workaround send all messages in the default board language
            var languageFile =  this.Get<YafBoardSettings>().Language;

            foreach (var message in CommonDb.MessageList(YafContext.Current.PageModuleID, newMessageId))
            {
                int userId = message.UserID ?? 0;

                var watchEmail = new YafTemplateEmail("TOPICPOST") { TemplateLanguageFile = languageFile };

                // cleaned body as text...
                var bodyText =
                    StringExtensions.RemoveMultipleWhitespace(
                        BBCodeHelper.StripBBCode(HtmlHelper.StripHtml(HtmlHelper.CleanHtmlString(message.Message))));

                // Send track mails
                var subject =
                    this.Get<ILocalization>().GetText("COMMON", "TOPIC_NOTIFICATION_SUBJECT", languageFile).FormatWith(
                        this.Get<YafBoardSettings>().Name);

                watchEmail.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
                watchEmail.TemplateParams["{topic}"] = HttpUtility.HtmlDecode(message.Topic);
                watchEmail.TemplateParams["{postedby}"] = UserMembershipHelper.GetDisplayNameFromID(userId);
                watchEmail.TemplateParams["{body}"] = bodyText;
                watchEmail.TemplateParams["{bodytruncated}"] = bodyText.Truncate(160);
                watchEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(
                    ForumPages.posts, true, "m={0}#post{0}", newMessageId);

                watchEmail.CreateWatch(
                    message.TopicID ?? 0,
                    userId,
                    new MailAddress(this.Get<YafBoardSettings>().ForumEmail, this.Get<YafBoardSettings>().Name),
                    subject);

                // create individual watch emails for all users who have All Posts on...
                foreach (var user in usersWithAll.Where(x => x.UserID.HasValue && x.UserID.Value != userId))
                {
                    // Make sure its not a guest
                    if (user.ProviderUserKey == null)
                    {
                        continue;
                    }

                    var membershipUser = UserMembershipHelper.GetUser(user.ProviderUserKey);

                    if (!membershipUser.Email.IsSet())
                    {
                        continue;
                    }

                    watchEmail.TemplateLanguageFile = !string.IsNullOrEmpty(user.LanguageFile)
                                                          ? user.LanguageFile
                                                          : this.Get<ILocalization>().LanguageFileName;
                    watchEmail.SendEmail(
                        new MailAddress(this.Get<YafBoardSettings>().ForumEmail, this.Get<YafBoardSettings>().Name),
                        new MailAddress(membershipUser.Email, membershipUser.UserName),
                        subject,
                        true);
                }
            }
        }
开发者ID:vzrus,项目名称:VZF,代码行数:82,代码来源:YafSendNotification.cs

示例13: ForumRegister_Click

        /// <summary>
        /// The forum register_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void ForumRegister_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.Page.IsValid)
            {
            return;
            }

            string newEmail = this.Email.Text.Trim();
            string newUsername = this.UserName.Text.Trim();

            if (!ValidationHelper.IsValidEmail(newEmail))
            {
            this.PageContext.AddLoadMessage(this.GetText("ADMIN_REGUSER", "MSG_INVALID_MAIL"));
            return;
            }

            if (UserMembershipHelper.UserExists(this.UserName.Text.Trim(), newEmail))
            {
            this.PageContext.AddLoadMessage(this.GetText("ADMIN_REGUSER", "MSG_NAME_EXISTS"));
            return;
            }

            string hashinput = DateTime.UtcNow + newEmail + Security.CreatePassword(20);
            string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5");

            MembershipCreateStatus status;
            MembershipUser user = this.Get<MembershipProvider>().CreateUser(
            newUsername,
            this.Password.Text.Trim(),
            newEmail,
            this.Question.Text.Trim(),
            this.Answer.Text.Trim(),
            !this.Get<YafBoardSettings>().EmailVerification,
            null,
            out status);

            if (status != MembershipCreateStatus.Success)
            {
            // error of some kind
            this.PageContext.AddLoadMessage(this.GetText("ADMIN_REGUSER", "MSG_ERROR_CREATE").FormatWith(status));
            return;
            }

            // setup inital roles (if any) for this user
            RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, newUsername);

            // create the user in the YAF DB as well as sync roles...
            int? userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID);

            // create profile
            YafUserProfile userProfile = YafUserProfile.GetProfile(newUsername);

            // setup their inital profile information
            userProfile.Location = this.Location.Text.Trim();
            userProfile.Homepage = this.HomePage.Text.Trim();
            userProfile.Save();

            // save the time zone...
            LegacyDb.user_save(
            UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey),
            this.PageContext.PageBoardID,
            null,
            null,
            null,
            this.TimeZones.SelectedValue.ToType<int>(),
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null);

            if (this.Get<YafBoardSettings>().EmailVerification)
            {
            // save verification record...
            LegacyDb.checkemail_save(userID, hash, user.Email);

            // send template email
            var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

            verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLink(ForumPages.approve, true, "k={0}", hash);
            verifyEmail.TemplateParams["{key}"] = hash;
            verifyEmail.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
            verifyEmail.TemplateParams["{forumlink}"] = "{0}".FormatWith(this.ForumURL);

//.........这里部分代码省略.........
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:101,代码来源:reguser.ascx.cs

示例14: btnChangePassword_Click

    /// <summary>
    /// The btn change password_ click.
    /// </summary>
    /// <param name="sender">
    /// The sender.
    /// </param>
    /// <param name="e">
    /// The e.
    /// </param>
    protected void btnChangePassword_Click([NotNull] object sender, [NotNull] EventArgs e)
    {
      if (!this.Page.IsValid)
      {
        return;
      }

      // change password...
      try
      {
        SitecoreMembershipUser user = UserMembershipHelper.GetMembershipUserById(this.CurrentUserID.Value);

        if (user != null)
        {
          // new password...
          string newPass = this.txtNewPassword.Text.Trim();

          // reset the password...
          user.UnlockUser();
          string tempPass = user.ResetPassword();

          // change to new password...
          user.ChangePassword(tempPass, newPass);

          if (this.chkEmailNotify.Checked)
          {
            // email a notification...
            var passwordRetrieval = new YafTemplateEmail("PASSWORDRETRIEVAL");

            string subject =
              this.Get<ILocalization>().GetText("RECOVER_PASSWORD", "PASSWORDRETRIEVAL_EMAIL_SUBJECT").FormatWith(
                this.PageContext.BoardSettings.Name);

            passwordRetrieval.TemplateParams["{username}"] = user.UserName;
            passwordRetrieval.TemplateParams["{password}"] = newPass;
            passwordRetrieval.TemplateParams["{forumname}"] = this.Get<YafBoardSettings>().Name;
            passwordRetrieval.TemplateParams["{forumlink}"] = "{0}".FormatWith(YafForumInfo.ForumURL);

            passwordRetrieval.SendEmail(new MailAddress(user.Email, user.UserName), subject, true);

            this.PageContext.AddLoadMessage(this.Get<ILocalization>().GetText("ADMIN_EDITUSER", "MSG_PASS_CHANGED_NOTI"));
          }
          else
          {
            this.PageContext.AddLoadMessage(this.Get<ILocalization>().GetText("ADMIN_EDITUSER", "MSG_PASS_CHANGED"));
          }
        }
      }
      catch (Exception x)
      {
        this.PageContext.AddLoadMessage("Exception: {0}".FormatWith(x.Message));
      }
    }
开发者ID:unstab1e,项目名称:sitecoreyaf8,代码行数:62,代码来源:EditUsersResetPass.ascx.cs

示例15: ToUserWithNewMedal

        /// <summary>
        /// Sends notification that the User was awarded with a Medal
        /// </summary>
        /// <param name="toUserId">To user id.</param>
        /// <param name="medalName">Name of the medal.</param>
        public void ToUserWithNewMedal([NotNull] int toUserId, [NotNull] string medalName)
        {
            var userList = LegacyDb.UserList(YafContext.Current.PageBoardID, toUserId, true, null, null, null).ToList();

            TypedUserList toUser;

            if (userList.Any())
            {
                toUser = userList.First();
            }
            else
            {
                return;
            }

            var languageFile = UserHelper.GetUserLanguageFile(toUser.UserID.ToType<int>());

            var notifyUser = new YafTemplateEmail("NOTIFICATION_ON_MEDAL_AWARDED")
                                 {
                                     TemplateLanguageFile = languageFile
                                 };

            var subject =
                this.Get<ILocalization>()
                    .GetText("COMMON", "NOTIFICATION_ON_MEDAL_AWARDED_SUBJECT", languageFile)
                    .FormatWith(this.BoardSettings.Name);

            notifyUser.TemplateParams["{user}"] = this.BoardSettings.EnableDisplayName
                                                      ? toUser.DisplayName
                                                      : toUser.Name;
            notifyUser.TemplateParams["{medalname}"] = medalName;
            notifyUser.TemplateParams["{forumname}"] = this.BoardSettings.Name;

            notifyUser.SendEmail(
                new MailAddress(toUser.Email, this.BoardSettings.EnableDisplayName ? toUser.DisplayName : toUser.Name),
                subject,
                true);
        }
开发者ID:viniciustodesco,项目名称:YAFNET,代码行数:43,代码来源:YafSendNotification.cs


注:本文中的YAF.Core.Services.YafTemplateEmail类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。