本文整理汇总了C#中Discuz.Entity.TopicInfo类的典型用法代码示例。如果您正苦于以下问题:C# TopicInfo类的具体用法?C# TopicInfo怎么用?C# TopicInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TopicInfo类属于Discuz.Entity命名空间,在下文中一共展示了TopicInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: CreateTopic
/// <summary>
/// 创建新主题
/// </summary>
/// <param name="originalTopicInfo">主题信息</param>
/// <returns>返回主题ID</returns>
public static int CreateTopic(TopicInfo topicinfo)
{
lock (lockHelper)
{
return (topicinfo != null ? Data.Topics.CreateTopic(topicinfo) : 0);
}
}
示例3: CloseBonus
/// <summary>
/// 结束悬赏并给分
/// </summary>
/// <param name="topicinfo">主题信息</param>
/// <param name="userid">当前执行此操作的用户Id</param>
/// <param name="postIdArray">帖子Id数组</param>
/// <param name="winerIdArray">获奖者Id数组</param>
/// <param name="winnerNameArray">获奖者的用户名数组</param>
/// <param name="costBonusArray">奖励积分数组</param>
/// <param name="valuableAnswerArray">有价值答案的pid数组</param>
/// <param name="bestAnswer">最佳答案的pid</param>
public static void CloseBonus(TopicInfo topicinfo, int userid, int[] postIdArray, int[] winerIdArray, string[] winnerNameArray, string[] costBonusArray, string[] valuableAnswerArray, int bestAnswer)
{
topicinfo.Special = 3;
Topics.UpdateSpecial(topicinfo);//更新标志位为已结帖状态
//开始给分和记录
int winerId = 0, isbest = 0, postid = 0, bonus=0;
string winnerName = string.Empty;
for (int i = 0; i < winerIdArray.Length; i++)
{
winerId = winerIdArray[i];
bonus = Utils.StrToInt(costBonusArray[i], 0);
winnerName = winnerNameArray[i];
postid = postIdArray[i];
if (winerId > 0 && bonus > 0)
{
Users.UpdateUserExtCredits(winerId, Scoresets.GetCreditsTrans(), bonus);
}
if (Utils.InArray(postid.ToString(), valuableAnswerArray))
{
isbest = 1;
}
if (postid == bestAnswer)
{
isbest = 2;
}
AddLog(topicinfo.Tid, topicinfo.Posterid, winerId, winnerName, postid, bonus, isbest);
}
}
示例4: CreateTopic
/// <summary>
/// 创建新主题
/// </summary>
/// <param name="topicInfo">主题信息</param>
/// <returns>返回主题ID</returns>
public static int CreateTopic(TopicInfo topicInfo)
{
topicInfo.Tid = DatabaseProvider.GetInstance().CreateTopic(topicInfo);
if (appDBCache)
ITopicService.CreateTopic(topicInfo);
return topicInfo.Tid;
}
示例5: UpdateTopicAllInfo
/// <summary>
///
/// </summary>
/// <param name="topicinfo"></param>
/// <returns></returns>
public static bool UpdateTopicAllInfo(TopicInfo topicinfo)
{
try
{
Topics.UpdateTopic(topicinfo);
return true;
}
catch
{
return false;
}
}
示例6: 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);
}
示例7: GetRelatedTopicList
/// <summary>
/// 根据主题的Tag获取相关主题(游客可见级别的)
/// </summary>
/// <param name="topicid">主题Id</param>
/// <returns></returns>
public static Discuz.Common.Generic.List<TopicInfo> GetRelatedTopicList(int topicId, int count)
{
IDataReader reader = DatabaseProvider.GetInstance().GetRelatedTopics(topicId, count);
Discuz.Common.Generic.List<TopicInfo> topics = new Discuz.Common.Generic.List<TopicInfo>();
while (reader.Read())
{
TopicInfo topic = new TopicInfo();
topic.Tid = TypeConverter.ObjectToInt(reader["linktid"]);
topic.Title = reader["linktitle"].ToString();
topics.Add(topic);
}
reader.Close();
return topics;
}
示例8: CloseBonus
/// <summary>
/// 结束悬赏并给分
/// </summary>
/// <param name="topicinfo">主题信息</param>
/// <param name="userid">当前执行此操作的用户Id</param>
/// <param name="postIdArray">帖子Id数组</param>
/// <param name="winerIdArray">获奖者Id数组</param>
/// <param name="winnerNameArray">获奖者的用户名数组</param>
/// <param name="costBonusArray">奖励积分数组</param>
/// <param name="valuableAnswerArray">有价值答案的pid数组</param>
/// <param name="bestAnswer">最佳答案的pid</param>
public static void CloseBonus(TopicInfo topicinfo, int userid, int[] postIdArray, int[] winerIdArray, string[] winnerNameArray, string[] costBonusArray, string[] valuableAnswerArray, int bestAnswer)
{
int isbest = 0, bonus = 0;
topicinfo.Special = 3;//标示为悬赏主题
Topics.UpdateTopic(topicinfo);//更新标志位为已结帖状态
//开始给分和记录
for (int i = 0; i < winerIdArray.Length; i++)
{
bonus = TypeConverter.StrToInt(costBonusArray[i]);
if (winerIdArray[i] > 0 && bonus > 0)
Users.UpdateUserExtCredits(winerIdArray[i], Scoresets.GetBonusCreditsTrans(), bonus);
if (Utils.InArray(postIdArray[i].ToString(), valuableAnswerArray))
isbest = 1;
if (postIdArray[i] == bestAnswer)
isbest = 2;
Discuz.Data.Bonus.AddLog(topicinfo.Tid, topicinfo.Posterid, winerIdArray[i], winnerNameArray[i], postIdArray[i], bonus, Scoresets.GetBonusCreditsTrans(), isbest);
}
}
示例9: PostReply
public static bool PostReply(ForumInfo forum, int userid, UserGroupInfo usergroupinfo, TopicInfo topic)
{
bool canreply = (usergroupinfo.Radminid == 1);
//是否有回复的权限
if (topic.Closed == 0)
{
if (userid > -1 && Forums.AllowReplyByUserID(forum.Permuserlist, userid))
{
canreply = true;
}
else
{
if (Utils.StrIsNullOrEmpty(forum.Replyperm)) //权限设置为空时,根据用户组权限判断
{
// 验证用户是否有发表主题的权限
if (usergroupinfo.Allowreply == 1)
canreply = true;
}
else if (Forums.AllowReply(forum.Replyperm, usergroupinfo.Groupid))
canreply = true;
}
}
return canreply;
}
示例10: NeedAudit
/// <summary>
/// 发回复是否需要审核
/// </summary>
/// <param name="forum">主题所在的版块</param>
/// <param name="useradminid">用户的管理组ID</param>
///<param name="topicInfo">所回复的主题信息</param>
/// <param name="userid">用户ID</param>
/// <param name="disablepost">是否受灌水限制</param>
/// <returns>true需要审核;false不需要审核</returns>
public static bool NeedAudit(ForumInfo forum, int useradminid, TopicInfo topicInfo, int userid, int disablepost, UserGroupInfo userGroup)
{
if (useradminid == 1 || Moderators.IsModer(useradminid, userid, forum.Fid))
return false;
if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postmodperiods))
return true;
if (forum.Modnewposts == 1 || userGroup.ModNewPosts == 1)
return true;
else if (topicInfo.Displayorder == -2)
return true;
return false;
//bool needaudit = false; //是否需要审核
//if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postmodperiods))
//{
// needaudit = true;
//}
//else
//{
// if (forum.Modnewposts == 1 && useradminid != 1)
// {
// if (useradminid > 1)
// {
// if (disablepost == 1 && topicInfo.Displayorder != -2)
// {
// if (useradminid == 3 && !Moderators.IsModer(useradminid, userid, forum.Fid))
// needaudit = true;
// }
// else
// needaudit = true;
// }
// else
// needaudit = true;
// }
// else if (userGroup.ModNewPosts == 1 && !Moderators.IsModer(useradminid, userid, forum.Fid) && useradminid != 1)
// needaudit = true;
// else if (useradminid != 1 && topicInfo.Displayorder == -2)
// needaudit = true;
//}
//return needaudit;
}
示例11: ShowPage
protected override void ShowPage()
{
if (topicid == -1)
{
AddErrLine("无效的主题ID");
return;
}
topic = Topics.GetTopicInfo(topicid);
if (topic == null)
{
AddErrLine("不存在的主题ID");
return;
}
topictitle = Utils.StrIsNullOrEmpty(topic.Title) ? "" : topic.Title;
forumid = topic.Fid;
ForumInfo forum = Forums.GetForumInfo(forumid);
pagetitle = Utils.RemoveHtml(forum.Name);
forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
if (topic.Special != 1)
{
AddErrLine("不存在的投票ID");
return;
}
if (usergroupinfo.Allowvote != 1)
{
AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有投票的权限");
return;
}
if (Convert.ToDateTime(Polls.GetPollEnddatetime(topic.Tid)).Date < DateTime.Today)
{
AddErrLine("投票已经过期");
return;
}
if (userid != -1 && !Polls.AllowVote(topicid, username))
{
AddErrLine("你已经投过票");
return;
}
else if (Utils.InArray(topic.Tid.ToString(), ForumUtils.GetCookie("dnt_polled")))
{
AddErrLine("你已经投过票");
return;
}
//当未选择任何投票项时
if(Utils.StrIsNullOrEmpty(DNTRequest.GetString("pollitemid")))
{
AddErrLine("您未选择任何投票项!");
return;
}
if (DNTRequest.GetString("pollitemid").Split(',').Length > Polls.GetPollInfo(topicid).Maxchoices)
{
AddErrLine("您的投票项多于最大投票数");
return;
}
if (Polls.UpdatePoll(topicid, DNTRequest.GetString("pollitemid"), userid == -1 ? string.Format("{0} [{1}]", usergroupinfo.Grouptitle, DNTRequest.GetIP()) : username) < 0)
{
AddErrLine("提交投票信息中包括非法内容");
return;
}
if (userid == -1) ForumUtils.WriteCookie("dnt_polled", string.Format("{0},{1}", (userid != -1 ? "" : ForumUtils.GetCookie("dnt_polled")), topic.Tid));
SetUrl(base.ShowTopicAspxRewrite(topicid, 0));
SetMetaRefresh();
SetShowBackLink(false);
MsgForward("poll_succeed");
AddMsgLine("投票成功, 返回主题");
CreditsFacade.Vote(userid);
// 删除主题游客缓存
ForumUtils.DeleteTopicCacheFile(topicid);
}
示例12: PostTopicSucceed
/// <summary>
/// 发帖成功
/// </summary>
/// <param name="values">版块积分设置</param>
/// <param name="topicinfo">主题信息</param>
/// <param name="topicid">主题ID</param>
private void PostTopicSucceed(float[] values, TopicInfo topicinfo, int topicid)
{
if (values != null) ///使用版块内积分
UserCredits.UpdateUserExtCredits(userid, values);
else ///使用默认积分
UserCredits.UpdateUserCreditsByPostTopic(userid);
//当使用伪aspx
if (config.Aspxrewrite == 1)
SetUrl(topicinfo.Special == 4 ? ShowDebateAspxRewrite(topicid) : ShowTopicAspxRewrite(topicid, 0));
else
SetUrl((topicinfo.Special == 4 ? ShowDebateAspxRewrite(topicid) : ShowTopicAspxRewrite(topicid, 0)) + "&forumpage=" + forumpageid);
SetMetaRefresh();
AddMsgLine("发表主题成功, 返回该主题<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, forumpageid) + "\">点击这里返回 " + forum.Name + "</a>)<br />");
}
示例13: UpdateTopic
public int UpdateTopic(int tid, TopicInfo __topicinfo)
{
IDataParameter[] prams =
{
DbHelper.MakeInParam("@tid", (DbType)SqlDbType.Int, 4, tid),
DbHelper.MakeInParam("@lastpostid", (DbType)SqlDbType.Int, 4, __topicinfo.Lastpostid),
DbHelper.MakeInParam("@lastposterid", (DbType)SqlDbType.Int, 4, __topicinfo.Lastposterid),
DbHelper.MakeInParam("@lastpost", (DbType)SqlDbType.DateTime, 8, DateTime.Parse(__topicinfo.Lastpost)),
DbHelper.MakeInParam("@lastposter", (DbType)SqlDbType.NChar, 20, __topicinfo.Lastposter),
DbHelper.MakeInParam("@replies", (DbType)SqlDbType.Int, 4, __topicinfo.Replies)
};
return DbHelper.ExecuteNonQuery(CommandType.Text, "UPDATE [" + BaseConfigs.GetTablePrefix + "topics] SET [lastpostid] = @lastpostid,[lastposterid] = @lastposterid, [lastpost] = @lastpost, [lastposter] = @lastposter, [replies] = [replies] + @replies WHERE [tid] = @tid", prams);
}
示例14: ShowPage
protected override void ShowPage()
{
// 获取主题ID
topicid = DNTRequest.GetInt("topicid", -1);
forumnav = "";
// 如果主题ID非数字
if (topicid == -1)
{
AddErrLine("无效的主题ID");
return;
}
// 获取该主题的信息
topic = Topics.GetTopicInfo(topicid);
// 如果该主题不存在
if (topic == null)
{
AddErrLine("不存在的主题ID");
return;
}
topictitle = topic.Title;
forumid = topic.Fid;
ForumInfo forum = Forums.GetForumInfo(forumid);
forumname = forum.Name;
pagetitle = Utils.RemoveHtml(forum.Name);
forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);
if (topic.Special != 1)
{
AddErrLine("不存在的投票ID");
return;
}
if (usergroupinfo.Allowvote != 1)
{
AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有投票的权限");
return;
}
if (Convert.ToDateTime(Polls.GetPollEnddatetime(topic.Tid)).Date < DateTime.Today)
{
AddErrLine("投票已经过期");
return;
}
string polled = string.Empty;
if (userid != -1)
{
if (!Polls.AllowVote(topicid, username))
{
AddErrLine("你已经投过票");
return;
}
}
else
{
//写cookie
polled = ForumUtils.GetCookie(POLLED_COOKIENAME);
if (Utils.InArray(topic.Tid.ToString(), polled))
{
AddErrLine("你已经投过票");
return;
}
}
//当未选择任何投票项时
if(Utils.StrIsNullOrEmpty(DNTRequest.GetString("pollitemid")))
{
AddErrLine("您未选择任何投票项!");
return;
}
if (Polls.UpdatePoll(topicid, DNTRequest.GetString("pollitemid"), userid == -1 ? string.Format("{0} [{1}]", usergroupinfo.Grouptitle, DNTRequest.GetIP()) : username) < 0)
{
AddErrLine("提交投票信息中包括非法内容");
return;
}
if (userid == -1)
{
ForumUtils.WriteCookie(POLLED_COOKIENAME, string.Format("{0},{1}", polled, topic.Tid));
}
SetUrl(base.ShowTopicAspxRewrite(topicid, 0));
SetMetaRefresh();
SetShowBackLink(false);
if (userid != -1)
{
UserCredits.UpdateUserCreditsByVotepoll(userid);
}
// 删除主题游客缓存
ForumUtils.DeleteTopicCacheFile(topicid);
//.........这里部分代码省略.........
示例15: CreateTopic
/// <summary>
/// 创建主题信息
/// </summary>
/// <param name="admininfo"></param>
/// <param name="postmessage"></param>
/// <param name="isbonus"></param>
/// <param name="topicprice"></param>
/// <returns></returns>
public TopicInfo CreateTopic(AdminGroupInfo admininfo, string postmessage, bool isbonus, int topicprice)
{
TopicInfo topicinfo = new TopicInfo();
topicinfo.Fid = forumid;
topicinfo.Iconid = (DNTRequest.GetInt("iconid", 0) < 0 || DNTRequest.GetInt("iconid", 0) > 15) ? 0 :
DNTRequest.GetInt("iconid", 0);
message = Posts.GetPostMessage(usergroupinfo, admininfo, postmessage,
(TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1));
topicinfo.Title = (useradminid == 1) ? Utils.HtmlEncode(DNTRequest.GetString("title")) :
Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title")));
if (useradminid != 1 && (ForumUtils.HasBannedWord(topicinfo.Title) || ForumUtils.HasBannedWord(message)))
{
AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!"); return topicinfo;
}
topicinfo.Typeid = DNTRequest.GetInt("typeid", 0);
if (usergroupinfo.Allowsetreadperm == 1)
topicinfo.Readperm = DNTRequest.GetInt("topicreadperm", 0) > 255 ? 255 : DNTRequest.GetInt("topicreadperm", 0);
topicinfo.Price = topicprice;
topicinfo.Poster = username;
topicinfo.Posterid = userid;
topicinfo.Postdatetime = curdatetime;
topicinfo.Lastpost = curdatetime;
topicinfo.Lastposter = username;
topicinfo.Displayorder = Topics.GetTitleDisplayOrder(usergroupinfo, useradminid, forum, topicinfo, message, disablepost);
string htmltitle = DNTRequest.GetString("htmltitle").Trim();
if (!Utils.StrIsNullOrEmpty(htmltitle) && Utils.HtmlDecode(htmltitle).Trim() != topicinfo.Title)
{
//按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 例: 11001
topicinfo.Magic = 11000;
}
//标签(Tag)操作
string tags = DNTRequest.GetString("tags").Trim();
string[] tagArray = null;
if (enabletag && !Utils.StrIsNullOrEmpty(tags))
{
if (ForumUtils.InBanWordArray(tags))
{
AddErrLine("标签中含有系统禁止词语,请修改");
return topicinfo;
}
tagArray = Utils.SplitString(tags, " ", true, 2, 10);
if (tagArray.Length > 0 && tagArray.Length <= 5)
{
if (topicinfo.Magic == 0)
topicinfo.Magic = 10000;
topicinfo.Magic = Utils.StrToInt(topicinfo.Magic.ToString() + "1", 0);
}
else
{
AddErrLine("超过标签数的最大限制或单个标签长度没有介于2-10之间,最多可填写 5 个标签");
return topicinfo;
}
}
if (isbonus)
{
topicinfo.Special = 2;
//检查积分是否足够
if (mybonustranscredits < topicprice && usergroupinfo.Radminid != 1)
{
AddErrLine(string.Format("无法进行悬赏<br /><br />您当前的{0}为 {1} {3}<br/>悬赏需要{0} {2} {3}", bonusextcreditsinfo.Name, mybonustranscredits, topicprice, bonusextcreditsinfo.Unit));
return topicinfo;
}
else
Users.UpdateUserExtCredits(topicinfo.Posterid, Scoresets.GetBonusCreditsTrans(),
-topicprice * (Scoresets.GetCreditsTax() + 1)); //计算税后的实际支付
}
if (type == "poll")
topicinfo.Special = 1;
if (type == "debate") //辩论帖
topicinfo.Special = 4;
if (!Moderators.IsModer(useradminid, userid, forumid))
topicinfo.Attention = 1;
if (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1)
topicinfo.Hide = 1;
topicinfo.Tid = Topics.CreateTopic(topicinfo);
canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup);
//.........这里部分代码省略.........