本文整理汇总了C#中Discuz.Entity.PostInfo类的典型用法代码示例。如果您正苦于以下问题:C# PostInfo类的具体用法?C# PostInfo怎么用?C# PostInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PostInfo类属于Discuz.Entity命名空间,在下文中一共展示了PostInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLastPostByTid
public static PostInfo GetLastPostByTid(int tid, string tableName)
{
PostInfo postinfo = new PostInfo();
DataTable dt = DatabaseProvider.GetInstance().GetLastPostByTid(tid, tableName);
if (dt.Rows.Count > 0)
{
postinfo.Pid = TypeConverter.ObjectToInt(dt.Rows[0]["pid"]);
postinfo.Tid = TypeConverter.ObjectToInt(dt.Rows[0]["tid"]);
postinfo.Title = dt.Rows[0]["title"].ToString().Trim();
postinfo.Postdatetime = dt.Rows[0]["postdatetime"].ToString().Trim();
postinfo.Poster = dt.Rows[0]["poster"].ToString().Trim();
postinfo.Posterid = TypeConverter.ObjectToInt(dt.Rows[0]["posterid"]);
postinfo.Topictitle = Topics.GetTopicInfo(postinfo.Tid, 0, 0).Title;
}
else
{
postinfo.Pid = 0;
postinfo.Tid = 0;
postinfo.Title = "从未";
postinfo.Topictitle = "从未";
postinfo.Postdatetime = "1900-1-1";
postinfo.Poster = "";
postinfo.Posterid = 0;
}
dt.Dispose();
return postinfo;
}
示例2: CreatePost
/// <summary>
/// 创建帖子
/// </summary>
/// <param name="postInfo">帖子信息</param>
/// <param name="postTableId">分表ID</param>
/// <returns>帖子ID</returns>
public static int CreatePost(PostInfo postInfo, string postTableId)
{
int postId = DatabaseProvider.GetInstance().CreatePost(postInfo, postTableId);
//更新TTCache缓存中的用户信息
if (postInfo.Invisible == 0 && Users.appDBCache && Users.IUserService != null)
{
UserInfo userInfo = Users.IUserService.GetUserInfo(postInfo.Posterid);
if (userInfo != null)
{
userInfo.Lastpost = postInfo.Postdatetime;
userInfo.Lastpostid = postId;
userInfo.Lastposttitle = postInfo.Title;
userInfo.Posts = userInfo.Posts + 1;
userInfo.Lastactivity = DateTime.Now.ToString();
userInfo.Newpm = 1;
Users.IUserService.UpdateUser(userInfo);
}
}
//更新Cache缓存中的用户信息
if (postInfo.Invisible == 0 && Topics.appDBCache && Topics.ITopicService != null)
Topics.ITopicService.ResetTopicByTid(postInfo.Tid);
//创建Cache缓存中的帖子信息(权限于当前正在使用的分表)
if (appDBCache && IPostService != null && PostTables.GetPostTableId(postInfo.Tid) == postTableId)
{
postInfo.Pid = postId;
IPostService.CreatePost(postInfo, postTableId);
}
return postId;
}
示例3: SendPostReplyNotice
/// <summary>
/// 发送回复通知
/// </summary>
/// <param name="postinfo">回复信息</param>
/// <param name="topicinfo">所属主题信息</param>
/// <param name="replyuserid">回复的某一楼的作者</param>
public static void SendPostReplyNotice(PostInfo postinfo, TopicInfo topicinfo, int replyuserid)
{
NoticeInfo noticeinfo = new NoticeInfo();
noticeinfo.Note = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 给您回帖, <a href =\"showtopic.aspx?topicid={2}&postid={3}#{3}\">{4}</a>.", postinfo.Posterid, postinfo.Poster, topicinfo.Tid, postinfo.Pid, topicinfo.Title));
noticeinfo.Type = NoticeType.PostReplyNotice;
noticeinfo.New = 1;
noticeinfo.Posterid = postinfo.Posterid;
noticeinfo.Poster = postinfo.Poster;
noticeinfo.Postdatetime = Utils.GetDateTime();
noticeinfo.Fromid = topicinfo.Tid;
noticeinfo.Uid = replyuserid;
//当回复人与帖子作者不是同一人时,则向帖子作者发送通知
if (postinfo.Posterid != replyuserid && replyuserid > 0)
{
Notices.CreateNoticeInfo(noticeinfo);
}
//当上面通知的用户与该主题作者不同,则还要向主题作者发通知
if (postinfo.Posterid != topicinfo.Posterid && topicinfo.Posterid != replyuserid && topicinfo.Posterid > 0)
{
noticeinfo.Uid = topicinfo.Posterid;
Notices.CreateNoticeInfo(noticeinfo);
}
}
示例4: GetPostInfo
public static PostInfo GetPostInfo(string postTableId, int pid)
{
PostInfo postInfo = new PostInfo();
IDataReader reader = DatabaseProvider.GetInstance().GetPostInfo(postTableId, pid);
if (reader.Read())
{
postInfo = LoadSinglePostInfo(reader);
reader.Close();
return postInfo;
}
reader.Close();
return null;
}
示例5: OnTopicCreated
protected override void OnTopicCreated(TopicInfo topic, PostInfo post, AttachmentInfo[] attachs)
{
SpacePostInfo spacepost = new SpacePostInfo();
spacepost.Author = post.Poster;
string content = Posts.GetPostMessageHTML(post, attachs);
spacepost.Category = "";
spacepost.Content = content;
spacepost.Postdatetime = DateTime.Now;
spacepost.PostStatus = 1;
spacepost.PostUpDateTime = DateTime.Now;
spacepost.Title = post.Title;
spacepost.Uid = post.Posterid;
DbProvider.GetInstance().AddSpacePost(spacepost);
}
示例6: GetPostListFromFile
/// <summary>
/// 获得推荐的论坛主题帖对象数组
/// </summary>
/// <param name="nodename">节点名称</param>
/// <returns></returns>
public PostInfo[] GetPostListFromFile(string nodeName)
{
if (postInfos != null)
return postInfos;
XmlNodeList xmlnodelist = xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/Forum/Topiclist/Topic");
postInfos = new PostInfo[xmlnodelist.Count];
int rowcount = 0;
foreach (XmlNode xmlnode in xmlnodelist)
{
postInfos[rowcount] = new PostInfo();
postInfos[rowcount].Tid = TypeConverter.ObjectToInt(xmlDoc.GetSingleNodeValue(xmlnode, "topicid"));
postInfos[rowcount].Title = (xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "title");
postInfos[rowcount].Poster = (xmlDoc.GetSingleNodeValue(xmlnode, "poster") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "poster");
postInfos[rowcount].Posterid = TypeConverter.ObjectToInt(xmlDoc.GetSingleNodeValue(xmlnode, "posterid"));
postInfos[rowcount].Postdatetime = (xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime");
postInfos[rowcount].Message = (xmlDoc.GetSingleNodeValue(xmlnode, "shortdescription") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "shortdescription");
postInfos[rowcount].Fid = TypeConverter.ObjectToInt(xmlDoc.GetSingleNodeValue(xmlnode, "fid"));
postInfos[rowcount].Forumname = (xmlDoc.GetSingleNodeValue(xmlnode, "forumname") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "forumname");
postInfos[rowcount].ForumRewriteName = (xmlDoc.GetSingleNodeValue(xmlnode, "forumrewritename") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "forumrewritename");
rowcount++;
}
return postInfos;
}
示例7: UpdatePost
/// <summary>
/// 更新指定帖子信息
/// </summary>
/// <param name="postsInfo">帖子信息</param>
/// <returns>更新数量</returns>
public static int UpdatePost(PostInfo postInfo)
{
if (postInfo == null || postInfo.Pid < 1)
return 0;
RemoveShowTopicCache(postInfo.Tid.ToString());
return Data.Posts.UpdatePost(postInfo, GetPostTableId(postInfo.Tid));
}
示例8: CreatePost
/// <summary>
/// 创建帖子
/// </summary>
/// <param name="postInfo">帖子信息类</param>
/// <returns>返回帖子id</returns>
public static int CreatePost(PostInfo postInfo)
{
int pid = Data.Posts.CreatePost(postInfo, GetPostTableId(postInfo.Tid));
//本帖具有正反方立场
if (postInfo.Debateopinion > 0)
{
DebatePostExpandInfo dpei = new DebatePostExpandInfo();
dpei.Tid = postInfo.Tid;
dpei.Pid = pid;
dpei.Opinion = postInfo.Debateopinion;
dpei.Diggs = 0;
Data.Debates.CreateDebateExpandInfo(dpei);
}
RemoveShowTopicCache(postInfo.Tid.ToString());
return pid;
}
示例9: ShowPage
protected override void ShowPage()
{
//pagetitle = "编辑帖子";
#region 判断是否是灌水
AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
this.disablepostctrl = 0;
if (admininfo != null)
disablepostctrl = admininfo.Disablepostctrl;
#endregion
if (userid == -1)
{
forum = new ForumInfo();
topic = new TopicInfo();
postinfo = new PostInfo();
AddErrLine("您尚未登录");
return;
}
#region 获取帖子和主题相关信息
// 如果帖子ID非数字
if (postid == -1)
{
AddErrLine("无效的帖子ID");
return;
}
postinfo = Posts.GetPostInfo(topicid, postid);
// 如果帖子不存在
if (postinfo == null)
{
AddErrLine("不存在的帖子ID");
return;
}
pagetitle = (postinfo.Title == "") ? "编辑帖子" : postinfo.Title;
htmlon = postinfo.Htmlon;
message = postinfo.Message;
isfirstpost = postinfo.Layer == 0;
// 获取主题ID
if (topicid != postinfo.Tid || postinfo.Tid == -1)
{
AddErrLine("无效的主题ID");
return;
}
// 获取该主题的信息
topic = Topics.GetTopicInfo(postinfo.Tid);
// 如果该主题不存在
if (topic == null)
{
AddErrLine("不存在的主题ID");
return;
}
if (topic.Special == 1 && postinfo.Layer == 0)
{
pollinfo = Polls.GetPollInfo(topic.Tid);
polloptionlist = Polls.GetPollOptionList(topic.Tid);
}
if (topic.Special == 4 && postinfo.Layer == 0)
{
debateinfo = Debates.GetDebateTopic(topic.Tid);
}
#endregion
#region 获取并检查版块信息
///得到所在版块信息
forumid = topic.Fid;
forum = Forums.GetForumInfo(forumid);
needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepostctrl, usergroupinfo);
// 如果该版块不存在
if (forum == null || forum.Layer == 0)
{
AddErrLine("版块已不存在");
forum = new ForumInfo();
return;
}
if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password"))
{
AddErrLine("本版块被管理员设置了密码");
SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
return;
}
if (forum.Applytopictype == 1) //启用主题分类
topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
customeditbuttons = Caches.GetCustomEditButtonList();
#endregion
//是否有编辑帖子的权限
if (!UserAuthority.CanEditPost(postinfo, userid, useradminid, ref msg))
{
AddErrLine(msg);
return;
}
#region 附件信息绑定
//.........这里部分代码省略.........
示例10: UpdateLastPost
public void UpdateLastPost(ForumInfo forumInfo, PostInfo postInfo)
{
UpdateLastPost(postInfo.Tid, postInfo.Topictitle, postInfo.Postdatetime.ToString(), postInfo.Posterid, postInfo.Poster, forumInfo.Fid, forumInfo.Parentidlist);
}
示例11: GetPostMessageHTML
/// <summary>
/// 得到空间格式的帖子内容
/// </summary>
/// <param name="postinfo">帖子描述</param>
/// <param name="attArray">附件集合</param>
/// <returns>空间格式</returns>
public static string GetPostMessageHTML(PostInfo postInfo, AttachmentInfo[] attachmentArray)
{
string message = "";
PostpramsInfo postpramsInfo = new PostpramsInfo();
//处理帖子内容
postpramsInfo.Smileyoff = postInfo.Smileyoff;
postpramsInfo.Bbcodeoff = postInfo.Bbcodeoff;
postpramsInfo.Parseurloff = postInfo.Parseurloff;
postpramsInfo.Allowhtml = postInfo.Htmlon;
postpramsInfo.Sdetail = postInfo.Message;
postpramsInfo.Showimages = 1 - postInfo.Smileyoff;
postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo();
postpramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
postpramsInfo.Pid = postInfo.Pid;
//强制隐藏hide内容
postpramsInfo.Hide = 1;
//设定这是为个人空间进行的解析
postpramsInfo.Isforspace = 1;
//先简单判断是否是动网兼容模式
if (!postpramsInfo.Ubbmode)
message = UBB.UBBToHTML(postpramsInfo);
else
message = Utils.HtmlEncode(postInfo.Message);
if (postpramsInfo.Jammer == 1)
message = ForumUtils.AddJammer(postInfo.Message);
if (postInfo.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message))
{
//获取在[hide]标签中的附件id
string[] attHidArray = GetHiddenAttachIdList(postpramsInfo.Sdetail, postpramsInfo.Hide);
ShowtopicPagePostInfo info = new ShowtopicPagePostInfo();
info.Posterid = postInfo.Posterid;
info.Pid = postInfo.Pid;
for (int i = 0; i < attachmentArray.Length; i++)
{
ShowtopicPageAttachmentInfo sAtt = new ShowtopicPageAttachmentInfo();
sAtt.Aid = attachmentArray[i].Aid;
sAtt.Attachment = attachmentArray[i].Attachment;
sAtt.Description = attachmentArray[i].Description;
sAtt.Downloads = attachmentArray[i].Downloads;
sAtt.Filename = attachmentArray[i].Filename;
sAtt.Filesize = attachmentArray[i].Filesize;
sAtt.Filetype = attachmentArray[i].Filetype;
sAtt.Pid = attachmentArray[i].Pid;
sAtt.Postdatetime = attachmentArray[i].Postdatetime;
sAtt.Readperm = attachmentArray[i].Readperm;
sAtt.Sys_index = attachmentArray[i].Sys_index;
sAtt.Sys_noupload = attachmentArray[i].Sys_noupload;
sAtt.Tid = attachmentArray[i].Tid;
sAtt.Uid = attachmentArray[i].Uid;
message = Attachments.GetMessageWithAttachInfo(postpramsInfo, 1, attHidArray, info, sAtt, message);
}
}
return message;
}
示例12: CreatePost
/// <summary>
/// 创建帖子
/// </summary>
/// <param name="postInfo">帖子信息类</param>
/// <returns>返回帖子id</returns>
public static int CreatePost(PostInfo postInfo)
{
int pid = 0;
lock (lockHelper)
{
pid = Data.Posts.CreatePost(postInfo, GetPostTableId(postInfo.Tid));
}
//本帖具有正反方立场
if (postInfo.Debateopinion > 0)
{
DebatePostExpandInfo dpei = new DebatePostExpandInfo();
dpei.Tid = postInfo.Tid;
dpei.Pid = pid;
dpei.Opinion = postInfo.Debateopinion;
dpei.Diggs = 0;
Data.Debates.CreateDebateExpandInfo(dpei);
}
//将数据同步到sphinx增量表中
if (pid > 0 && EntLibConfigs.GetConfig() != null && EntLibConfigs.GetConfig().Sphinxconfig.Enable)
{
GetSphinxSqlService().CreatePost(GetPostTableName(), pid, postInfo.Tid, postInfo.Fid, postInfo.Posterid, postInfo.Postdatetime, postInfo.Title, postInfo.Message);
}
return pid;
}
示例13: LoadSinglePostInfo
/// <summary>
/// 装帖子信息
/// </summary>
/// <param name="reader"></param>
/// <returns></returns>
private static PostInfo LoadSinglePostInfo(IDataReader reader)
{
PostInfo postInfo = new PostInfo();
postInfo.Pid = TypeConverter.ObjectToInt(reader["pid"]);
postInfo.Fid = TypeConverter.ObjectToInt(reader["fid"]);
postInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]);
postInfo.Parentid = TypeConverter.ObjectToInt(reader["parentid"]);
postInfo.Layer = TypeConverter.ObjectToInt(reader["layer"]);
postInfo.Poster = reader["poster"].ToString();
postInfo.Posterid = TypeConverter.ObjectToInt(reader["posterid"]);
postInfo.Title = reader["title"].ToString();
postInfo.Postdatetime = reader["postdatetime"].ToString();
postInfo.Message = reader["message"].ToString();
postInfo.Ip = reader["ip"].ToString();
postInfo.Lastedit = reader["lastedit"].ToString();
postInfo.Invisible = TypeConverter.ObjectToInt(reader["invisible"]);
postInfo.Usesig = TypeConverter.ObjectToInt(reader["usesig"]);
postInfo.Htmlon = TypeConverter.ObjectToInt(reader["htmlon"]);
postInfo.Smileyoff = TypeConverter.ObjectToInt(reader["smileyoff"]);
postInfo.Bbcodeoff = TypeConverter.ObjectToInt(reader["bbcodeoff"]);
postInfo.Parseurloff = TypeConverter.ObjectToInt(reader["parseurloff"]);
postInfo.Attachment = TypeConverter.ObjectToInt(reader["attachment"]);
postInfo.Rate = TypeConverter.ObjectToInt(reader["rate"]);
postInfo.Ratetimes = TypeConverter.ObjectToInt(reader["ratetimes"]);
return postInfo;
}
示例14: ShowPage
protected override void ShowPage()
{
if (postid == -1)
{
AddErrLine("无效的帖子ID");
return;
}
// 获取该帖子的信息
post = Posts.GetPostInfo(topicid, postid);
if (post == null)
{
AddErrLine("不存在的帖子ID");
return;
}
// 获取该主题的信息
topic = Topics.GetTopicInfo(topicid);
if (topic == null)
{
AddErrLine("不存在的主题ID");
return;
}
if (topicid != post.Tid)
{
AddErrLine("主题ID无效");
return;
}
topictitle = topic.Title;
forumid = topic.Fid;
forum = Forums.GetForumInfo(forumid);
forumname = forum.Name;
pagetitle = string.Format("删除{0}", post.Title);
forumnav = ShowForumAspxRewrite(forum.Pathlist.Trim(), forumid, forumpageid);
if (!CheckPermission(post,DNTRequest.GetInt("opinion", -1))) return;
if (!allowDelPost)
{
AddErrLine("当前不允许删帖");
return;
}
// 通过验证的用户可以删除帖子,如果是主题帖则另处理
if (post.Layer == 0)
{
TopicAdmins.DeleteTopics(topicid.ToString(), byte.Parse(forum.Recyclebin.ToString()), false);
//重新统计论坛帖数
Forums.SetRealCurrentTopics(forum.Fid);
ForumTags.DeleteTopicTags(topicid);
}
else
{
int reval;
if (topic.Special == 4)
{
if (DNTRequest.GetInt("opinion", -1) != 1 && DNTRequest.GetInt("opinion", -1) != 2)
{
AddErrLine("参数错误");
return;
}
reval = Posts.DeletePost(Posts.GetPostTableId(topicid), postid, false, true);
Debates.DeleteDebatePost(topicid, DNTRequest.GetInt("opinion", -1), postid);
}
else
reval = Posts.DeletePost(Posts.GetPostTableId(topicid), postid, false, true);
Posts.RemoveShowTopicCache(topicid.ToString());
// 删除主题游客缓存
ForumUtils.DeleteTopicCacheFile(topicid);
//再次确保回复数精确
Topics.UpdateTopicReplyCount(topic.Tid);
//更新指定版块的最新发帖数信息
Forums.UpdateLastPost(forum);
if (reval > 0 && Utils.StrDateDiffHours(post.Postdatetime, config.Losslessdel * 24) < 0)
UserCredits.UpdateUserCreditsByPosts(post.Posterid, -1);
}
SetUrl(post.Layer == 0 ? base.ShowForumAspxRewrite(post.Fid, 0) : Urls.ShowTopicAspxRewrite(post.Tid, 1));
SetMetaRefresh();
SetShowBackLink(false);
AddMsgLine("删除帖子成功, 返回主题");
}
示例15: GetTopicPostInfo
/// <summary>
/// 通过主题ID得到主帖内容,此方法可继续扩展
/// </summary>
/// <param name="tid"></param>
/// <returns>ShowtopicPagePostInfo</returns>
public static PostInfo GetTopicPostInfo(int tid)
{
PostInfo postInfo = new PostInfo();
IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(tid, PostTables.GetPostTableId(tid));
if (reader.Read())
{
postInfo = LoadSinglePostInfo(reader);
}
reader.Close();
return postInfo;
}