📄 weblogemails.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web.Mail;
using CommunityServer;
using CommunityServer.Components;
namespace CommunityServer.Blogs.Components
{
/// <summary>
/// Summary description for WeblogEmails.
/// </summary>
internal class WeblogEmails : Emails
{
private WeblogEmails()
{
}
public static void WeblogTracking(WeblogPost post, WeblogPost parent, Weblog weblog)
{
SectionTracking(post,new EnquePostEmails(CreateWeblogPost),CreatePostFormatList(weblog,post,parent) );
}
private static FormatList CreatePostFormatList(Weblog weblog, WeblogPost post, WeblogPost parent)
{
FormatList list = new FormatList();
list.Add("blogName", weblog.Name);
list.Add("blogUrl", Globals.FullPath(BlogUrls.Instance().HomePage(weblog.ApplicationKey)));
//list.Add("postedBy", post.Username);
if(post.BlogPostType == BlogPostType.Comment)
{
if(post.HasSubmittedUserName)
list.Add("postedBy", post.SubmittedUserName);
else
list.Add("postedBy", post.Username);
}
else if(post.BlogPostType == BlogPostType.Trackback)
{
list.Add("postedBy", post.TrackBackName);
}
list.Add("postedDate", post.BloggerTime.ToString("f"));
list.Add("Title", post.Subject);
list.Add("subscriptionLink", Globals.FullPath(BlogUrls.Instance().EmailSubscriptions(weblog.ApplicationKey)));
if(parent != null)
{
list.Add("postLink", Globals.FullPath(BlogUrls.Instance().Post(parent,weblog,post)));
list.Add("titleUrl", post.TitleUrl);
list.Add("originalPostName",parent.Subject);
}
else
{
list.Add("postLink", Globals.FullPath(BlogUrls.Instance().Post(post,weblog)));
}
return list;
}
private static MailMessage CreateWeblogPost(Post post, User user, FormatList formats)
{
string emailType = null;
if(post.PostLevel != 0)
{
emailType = "WeblogComment";
}
else
{
emailType = "WeblogNewPost";
}
MailMessage email = GenericEmail(emailType,user,null,null,false,user.EnableHtmlEmail);
email.From = formats.Format(email.From);
email.Body = formats.Format(email.Body);
email.Subject = formats.Format(email.Subject);
email.To = user.Email;
string postbody = null;
// if the user doesn't want HTML and the post is HTML, then strip it
if (!user.EnableHtmlEmail && post.PostType == PostType.HTML)
postbody = Emails.FormatHtmlAsPlainText(post.FormattedBody);
else
postbody = post.FormattedBody;
postbody.Trim();
email.Body = FormatList.Format(email.Body, "postbody", postbody);
return email;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -