本文整理汇总了C#中ForumPost类的典型用法代码示例。如果您正苦于以下问题:C# ForumPost类的具体用法?C# ForumPost怎么用?C# ForumPost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ForumPost类属于命名空间,在下文中一共展示了ForumPost类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(int subforumID, int userID, string threadTitle, string threadContent)
{
if (!SessionHandler.Logon)
return RedirectToAction("Index", "Login");
User user = db.Users.SingleOrDefault(i => i.id == SessionHandler.UID);
if (user.is_banned)
return View("Error", new ArgumentException("You cannot add new threads or posts while banned."));
ForumThread ft = new ForumThread();
ft.author_id = userID;
ft.datetime_posted = DateTime.Now;
ft.num_hits = 1;
ft.title = SecurityHelper.StripHTML(threadTitle);
ft.subforum_id = subforumID;
db.ForumThreads.Add(ft);
db.SaveChanges();
ForumPost fp = new ForumPost();
fp.author_id = userID;
fp.datetime_posted = DateTime.Now;
fp.thread_id = ft.id;
fp.text = SecurityHelper.StripHTMLExceptAnchor(threadContent);
db.ForumPosts.Add(fp);
db.SaveChanges();
return RedirectToAction("Index", "Posts", new { threadID = ft.id });
}
开发者ID:jotsb,项目名称:CST-Life-No-More-C--MVC4,代码行数:33,代码来源:AddThreadController.cs
示例2: AddPost
public ActionResult AddPost(int parentThread, string postContent)
{
//checks if the user has been authenticated
if (!SessionHandler.Logon)
return RedirectToAction("Index", "Login");
//checks if the user is banned
User user = _db.Users.SingleOrDefault(i => i.id == SessionHandler.UID);
if (user.is_banned)
return View("Error", new ArgumentException("You cannot add new threads or posts while banned."));
//creates a new forum posts and adds it to the database
ForumPost fp = new ForumPost();
fp.thread_id = parentThread;
fp.author_id = SessionHandler.UID;
fp.text = SecurityHelper.StripHTMLExceptAnchor(postContent);
fp.datetime_posted = DateTime.Now;
_db.ForumPosts.Add(fp);
_db.SaveChanges();
return RedirectToAction("Index", new { threadID = parentThread });
}
开发者ID:jotsb,项目名称:CST-Life-No-More-C--MVC4,代码行数:25,代码来源:PostsController.cs
示例3: addPost
private void addPost( object[] args, object target ) {
OpenComment comment = args[0] as OpenComment;
if (comment == null || comment.Id <= 0) return;
// 只监控论坛评论,其他所有评论跳过
if (comment.TargetDataType != typeof( ForumTopic ).FullName) return;
// 附属信息
ForumTopic topic = commentService.GetTarget( comment ) as ForumTopic;
User creator = comment.Member;
IMember owner = getOwner( topic );
IApp app = ForumApp.findById( topic.AppId );
// 内容
ForumPost post = new ForumPost();
post.ForumBoardId = topic.ForumBoard.Id;
post.TopicId = topic.Id;
post.ParentId = getParentId( comment, topic );
post.Title = "re:" + topic.Title;
post.Content = comment.Content;
post.Ip = comment.Ip;
// 保存
// 因为comment本身已有通知,所以论坛不再发通知
postService.InsertNoNotification( post, creator, owner, app );
// 同步表
CommentSync objSync = new CommentSync();
objSync.Post = post;
objSync.Comment = comment;
objSync.insert();
}
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:35,代码来源:CommentObserver.cs
示例4: GetPostEdit
public static String GetPostEdit( List<ForumBoard> boards, ForumPost post, MvcContext ctx )
{
StringBuilder sb = getBuilder( boards, ctx );
sb.AppendFormat( "<span style=\"margin-left:5px;\">" + alang( ctx, "pPostEdit" ) + ": <a href=\"{0}\">{1}</a></span>", alink.ToAppData( post ), post.Title );
sb.Append( "</div></div>" );
return sb.ToString();
}
开发者ID:robin88,项目名称:wojilu,代码行数:7,代码来源:ForumLocationUtil.cs
示例5: boardError
private Boolean boardError( ForumPost post ) {
if (ctx.GetLong( "boardId" ) != post.ForumBoardId) {
echoRedirect( lang( "exNoPermission" ) + ": borad id error" );
return true;
}
return false;
}
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:7,代码来源:PostController.cs
示例6: GetPostIdsPages
public static List<ForumPost> GetPostIdsPages()
{
List<ForumPost> postInfoList = new List<ForumPost>();
using (SqlConnection con = new SqlConnection(connectstring))
{
try
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = @"select distinct ThreadID,PageCount from [dbo].[FirstPostTemp] where PageCount>1";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
ForumPost post = new ForumPost();
post.ThreadID = int.Parse(reader["ThreadID"].ToString());
post.PageCount = int.Parse(reader["PageCount"].ToString());
postInfoList.Add(post);
}
}
catch (SqlException e)
{
throw e;
}
finally
{
con.Close();
con.Dispose();
}
return postInfoList;
}
}
开发者ID:misun-ms,项目名称:TinctV2,代码行数:32,代码来源:CSDNAssist.cs
示例7: hasAdminPermission
private Boolean hasAdminPermission( ForumPost post )
{
ForumBoard board = boardService.GetById( post.ForumBoardId, ctx.owner.obj );
IList adminCmds = PermissionUtil.GetTopicAdminCmds( (User)ctx.viewer.obj, board, ctx );
return adminCmds.Count > 0;
}
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:8,代码来源:TagAdminController.cs
示例8: getTopicLastPage
private string getTopicLastPage( ForumPost post ) {
String lnk = to( new wojilu.Web.Controller.Forum.TopicController().Show, post.TopicId );
int pageNo = postService.GetPageCount( post.TopicId, getPageSize( ctx.app.obj ) );
lnk = PageHelper.AppendNo( lnk, pageNo );
lnk = lnk + "?rd=" + getRandomStr() + "#post" + post.Id;
return lnk;
}
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:9,代码来源:PostController.cs
示例9: AddDiscussionAjax
public string AddDiscussionAjax(int topicid = 0, string addtitle = "", string post = "", string name = "", string email = "", string company = "", bool notify = false, string recaptcha_challenge_field = "", string recaptcha_response_field = "")
{
CurtDevDataContext db = new CurtDevDataContext();
JavaScriptSerializer js = new JavaScriptSerializer();
#region trycatch
try {
string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"];
if (!(Models.ReCaptcha.ValidateCaptcha(recaptcha_challenge_field, recaptcha_response_field, remoteip))) {
throw new Exception("The Captcha was incorrect. Try again please!");
}
if (topicid == 0) { throw new Exception("The topic was invalid."); }
if (addtitle.Trim() == "") { throw new Exception("Title is required."); }
if (post.Trim() == "") { throw new Exception("Post is required"); }
if (email.Trim() != "" && (!IsValidEmail(email.Trim()))) { throw new Exception("Your email address was not a valid address."); }
if (notify == true && email.Trim() == "") { throw new Exception("You cannot be notified by email without an email address."); }
if(checkIPAddress(remoteip)) { throw new Exception("You cannot post because your IP Address is blocked by our server."); }
bool moderation = Convert.ToBoolean(ConfigurationManager.AppSettings["ForumModeration"]);
ForumThread t = new ForumThread {
topicID = topicid,
active = true,
closed = false,
createdDate = DateTime.Now,
};
db.ForumThreads.InsertOnSubmit(t);
db.SubmitChanges();
ForumPost p = new ForumPost {
threadID = t.threadID,
title = addtitle,
post = post,
name = name,
email = email,
notify = notify,
approved = !moderation,
company = company,
createdDate = DateTime.Now,
flag = false,
active = true,
IPAddress = remoteip,
parentID = 0,
sticky = false
};
db.ForumPosts.InsertOnSubmit(p);
db.SubmitChanges();
Post newpost = ForumModel.GetPost(p.postID);
return js.Serialize(newpost);
} catch (Exception e) {
return "{\"error\": \"" + e.Message + "\"}";
}
#endregion
}
开发者ID:janiukjf,项目名称:curtmfg,代码行数:57,代码来源:ForumController.cs
示例10: getPostHTML
private string getPostHTML(ForumPost post)
{
String HTML = "<h1>" + post.topic.title + "</h1>";
List<Comment> comments = post.comments;
foreach (Comment c in comments)
{
HTML += getCommentHTML(c);
}
return HTML;
}
开发者ID:craig-smith,项目名称:CISSeniorProjectTest,代码行数:11,代码来源:forums.aspx.cs
示例11: updatePost
private static void updatePost( ForumPost post ) {
if (post.OwnerType != typeof( Site ).FullName) return;
IMember owner = Site.Instance;
int appId = post.AppId;
IndexViewCacher.Update( owner, appId );
BoardViewCacher.Update( owner, appId, post.ForumBoardId, 1 );
RecentViewCacher.Update( owner, appId, "Post" );
}
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:11,代码来源:ForumInterceptor.cs
示例12: BanPost
public void BanPost( ForumPost post )
{
// post 所在分页列表失效
String turl = controller.to( new TopicController().Show, post.TopicId );
int pageNumber = getPostPage( post.Id, post.TopicId, 10 ); // 所属主题详细页的分页页面失效
if (pageNumber > 1) {
turl = Link.AppendPage( turl, pageNumber );
}
removeCacheSingle( turl );
String url = controller.to( new PostController().Show, post.Id );
removeCacheSingle( url );
}
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:13,代码来源:ForumCacheRemove.cs
示例13: AddPost
public ActionResult AddPost(int id = 0, string titlestr = "", string post = "", bool sticky = false)
{
string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"];
try {
if (id == 0) throw new Exception("Topic is required.");
if (titlestr.Trim().Length == 0) throw new Exception("Title is required.");
if (post.Trim().Length == 0) throw new Exception("Post content is required.");
CurtDevDataContext db = new CurtDevDataContext();
ForumThread t = new ForumThread {
topicID = id,
active = true,
closed = false,
createdDate = DateTime.Now
};
db.ForumThreads.InsertOnSubmit(t);
db.SubmitChanges();
user u = Users.GetUser(Convert.ToInt32(Session["userID"]));
ForumPost p = new ForumPost {
threadID = t.threadID,
title = titlestr,
post = post,
IPAddress = remoteip,
createdDate = DateTime.Now,
approved = true,
active = true,
flag = false,
notify = false,
parentID = 0,
name = u.fname + " " + u.lname,
company = "CURT Manufacturing",
email = u.email,
sticky = sticky
};
db.ForumPosts.InsertOnSubmit(p);
db.SubmitChanges();
return RedirectToAction("threads", new { id = id });
} catch (Exception e) {
FullTopic topic = ForumModel.GetTopic(id);
ViewBag.topic = topic;
ViewBag.error = e.Message;
ViewBag.titlestr = titlestr;
ViewBag.post = post;
ViewBag.sticky = sticky;
return View();
}
}
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:50,代码来源:ForumController.cs
示例14: Create
public int Create(string title, string content, int categoryId, string userId)
{
ForumPost newPost = new ForumPost()
{
Title = title,
Content = content,
CategoryId = categoryId,
CreatedOn = DateTime.Now,
UserId = userId,
};
this.forumRepository.Add(newPost);
this.forumRepository.Save();
return newPost.Id;
}
开发者ID:M-Yankov,项目名称:UniversityStudentSystem,代码行数:16,代码来源:ForumService.cs
示例15: bindPostOne
private void bindPostOne( IBlock block, ForumPost post )
{
String title = post.Title;
if (strUtil.IsNullOrEmpty( title )) {
ForumTopic topic = topicService.GetByPost( post.Id );
if (topic == null) return;
title = "re:" + topic.Title;
}
block.Set( "p.Titile", title );
block.Set( "p.Url", Link.To( post.OwnerType, post.OwnerUrl, new PostController().Show, post.Id, post.AppId ) );
block.Set( "p.CreateTime", post.Created );
block.Next();
}
开发者ID:robin88,项目名称:wojilu,代码行数:19,代码来源:ForumController.cs
示例16: CreatePost
// 创建回帖
public void CreatePost( ForumPost post )
{
ForumTopic topic = topicService.GetById( post.TopicId, owner );
List<String> urls = new List<String>();
urls.Add( controller.to( new ForumController().Index ) ); // 论坛首页失效
ForumBoard bd = boardService.GetById( topic.ForumBoard.Id, owner );
addBoardUrl( urls, bd, 0 ); // 所在版块失效(帖子被顶到前面)
removeCacheList( urls );
//-------------------------------------------------
// 修改 forum 和 topic 的 timestamp,让论坛最新主题、所有主题的回帖列表失效
String forumKey = "forum_" + controller.ctx.app.Id;
cacheHelper.SetTimestamp( forumKey, DateTime.Now );
String topicKey = "forumtopic_" + topic.Id;
cacheHelper.SetTimestamp( topicKey, DateTime.Now );
}
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:21,代码来源:ForumCacheRemove.cs
示例17: addNotificationToParentCreator
private void addNotificationToParentCreator( ForumTopic topic, ForumPost post )
{
User creator = post.Creator;
if (post.ParentId <= 0) return;
// 如果不清理缓存,则parent.Creator就是null(受制于ORM查询的关联深度只有2级)
ForumPost parent = db.nocache.findById<ForumPost>( post.ParentId );
if (parent == null) return;
User parentUser = userService.GetById( parent.Creator.Id );
if (parentUser == null) return;
int parentReceiverId = parent.Creator.Id;
parentReceiverId = parent.Creator.Id;
int topicReceiverId = topic.Creator.Id;
if (parentReceiverId == creator.Id || parentReceiverId == topicReceiverId) return;
String msgToParent = "<a href=\"" + Link.ToMember( creator ) + "\">" + creator.Name + "</a> " + alang.get( typeof( ForumApp ), "replyYourPost" ) + " <a href=\"" + alink.ToAppData( post ) + "\">" + topic.Title + "</a>";
notificationService.send( parentReceiverId, typeof( User ).FullName, msgToParent, NotificationType.Comment );
}
开发者ID:happyYao,项目名称:wojilu,代码行数:20,代码来源:ForumPostService.cs
示例18: addNotification
private void addNotification( ForumPost post )
{
ForumTopic topic = ForumTopic.findById( post.TopicId );
if (topic == null) return;
// 给主题的作者发送通知
addNotificationToTopicCreator( topic, post );
// 给父帖的作者发送通知
addNotificationToParentCreator( topic, post );
}
开发者ID:happyYao,项目名称:wojilu,代码行数:11,代码来源:ForumPostService.cs
示例19: addFeedInfo
private void addFeedInfo( ForumPost data )
{
// 回复论坛帖子:不再加入feed中
String lnkPost = alink.ToAppData( data );
//String msg = string.Format( "<div class=\"feed-item-title\">回复了论坛帖子 <a href=\"{0}\">{1}</a></div>", lnkPost, data.Title );
//msg += string.Format( "<div class=\"feed-item-body\"><div class=\"feed-item-quote\">{0}</div></div>", strUtil.ParseHtml( data.Content, MicroblogAppSetting.Instance.MicroblogContentMax ) );
//microblogService.Add( data.Creator, msg, typeof( ForumPost ).FullName, data.Id, data.Ip );
}
开发者ID:happyYao,项目名称:wojilu,代码行数:10,代码来源:ForumPostService.cs
示例20: Update
public virtual Result Update( ForumPost post, User editor )
{
post.EditTime = DateTime.Now;
post.EditCount++;
post.EditMemberId = editor.Id;
return db.update( post );
}
开发者ID:happyYao,项目名称:wojilu,代码行数:7,代码来源:ForumPostService.cs
注:本文中的ForumPost类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论