public int CreatePhotoComment(PhotoCommentInfo pcomment) { DbParameter[] parms = { DbHelper.MakeInParam("@userid", (DbType)SqlDbType.Int, 4, pcomment.Userid), DbHelper.MakeInParam("@username", (DbType)SqlDbType.NVarChar, 20, pcomment.Username), DbHelper.MakeInParam("@photoid", (DbType)SqlDbType.Int, 4, pcomment.Photoid), DbHelper.MakeInParam("@postdatetime", (DbType)SqlDbType.SmallDateTime, 4, pcomment.Postdatetime), DbHelper.MakeInParam("@ip", (DbType)SqlDbType.VarChar, 100, pcomment.Ip), DbHelper.MakeInParam("@content", (DbType)SqlDbType.NVarChar, 2000, pcomment.Content) }; string commandText = string.Format("INSERT INTO [{0}photocomments]([userid], [username], [photoid], [postdatetime], [ip], [content]) VALUES(@userid, @username, @photoid, @postdatetime, @ip, @content);SELECT SCOPE_IDENTITY()", BaseConfigs.GetTablePrefix); return(TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.Text, commandText, parms), 0)); }
/// <summary> /// 发送相册图片评论通知 /// </summary> /// <param name="pcomment">评论信息</param> private void SendPhotoComment(PhotoCommentInfo pcomment) { //当回复人与相册所有人不是同一人时,则向相册所有人发送通知 if (album.Userid != pcomment.Userid && pcomment.Commentid > 0) { NoticeInfo noticeinfo = new NoticeInfo(); noticeinfo.Note = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 评论了您的{2}--\"{3}\" , 请<a href =\"showphoto.aspx?photoid={4}&reply={5}#comments\">点击这里</a>查看详情.", pcomment.Userid, pcomment.Username, config.Albumname, album.Title, pcomment.Photoid, pcomment.Commentid)); noticeinfo.Type = NoticeType.AlbumCommentNotice; noticeinfo.New = 1; noticeinfo.Posterid = pcomment.Userid; noticeinfo.Poster = pcomment.Username; noticeinfo.Postdatetime = Utils.GetDateTime(); noticeinfo.Uid = album.Userid; Notices.CreateNoticeInfo(noticeinfo); } }
public static Discuz.Common.Generic.List <PhotoCommentInfo> GetPhotoCommentCollection(int photoid) { Discuz.Common.Generic.List <PhotoCommentInfo> comments = new Discuz.Common.Generic.List <PhotoCommentInfo>(); IDataReader reader = Data.DbProvider.GetInstance().GetPhotoCommentCollection(photoid); while (reader.Read()) { PhotoCommentInfo comment = new PhotoCommentInfo(); comment.Commentid = TypeConverter.ObjectToInt(reader["commentid"]); comment.Content = Utils.RemoveHtml(reader["content"].ToString()); comment.Ip = reader["ip"].ToString(); comment.Photoid = TypeConverter.ObjectToInt(reader["photoid"]); comment.Postdatetime = Convert.ToDateTime(reader["postdatetime"]); comment.Userid = TypeConverter.ObjectToInt(reader["userid"]); comment.Username = reader["username"].ToString(); comments.Add(comment); } reader.Close(); return(comments); }
private void SavePhotoComment(string message) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (userid < 1) { AddErrLine("请登录后发表评论"); return; } if (userid != photo.Userid && photo.Commentstatus == PhotoStatus.Owner) { AddErrLine("此图片禁止评论"); return; } if (message.Length < 1) { AddErrLine("评论内容不能为空"); return; } AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admininfo == null || admininfo.Disablepostctrl != 1) { if (message.Length < config.Minpostsize) { AddErrLine("您发表的内容过少, 系统设置要求评论内容不得少于 " + config.Minpostsize.ToString() + " 字"); return; } else if (message.Length > 2000) { AddErrLine("您发表的内容过多, 系统设置要求评论内容不得多于 2000 字"); return; } int interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval); if (interval < 0) { AddErrLine("系统规定发帖间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (interval * -1).ToString() + " 秒"); return; } } PhotoCommentInfo pcomment = new PhotoCommentInfo(); pcomment.Content = Utils.RemoveHtml(ForumUtils.BanWordFilter(message)); pcomment.Ip = DNTRequest.GetIP(); pcomment.Parentid = DNTRequest.GetFormInt("parent", 0); pcomment.Photoid = photo.Photoid; pcomment.Postdatetime = DateTime.Now; pcomment.Userid = userid; pcomment.Username = username; pcomment.Commentid = DbProvider.GetInstance().CreatePhotoComment(pcomment); //更新最后发帖时间 //OnlineUsers.UpdatePostTime(olid); //更新评论数 DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, 1); //发送相册图片评论通知 if (DNTRequest.GetString("sendnotice") == "on") { SendPhotoComment(pcomment); } HttpContext.Current.Response.Redirect(string.Format("{0}showphoto.aspx?photoid={1}&reply=1#comments", BaseConfigs.GetForumPath, photo.Photoid)); }