protected override void Page_Show() { pagetitle = "投递文章"; UserInfo userinfo = GetUserInfo(); if (userinfo == null) { ShowError("投递文章", "请登录后再投递文章,谢谢~", "", "login.aspx"); } columnlist = Columns.GetColumnCollection(); if (YRequest.IsPost()) { int columnid = YRequest.GetInt("columnid", 0); string title = Utils.RemoveHtml(YRequest.GetString("title")); string summary = Utils.RemoveHtml(YRequest.GetString("summary")); string content = Utils.RemoveUnsafeHtml(YRequest.GetString("content")); ArticleInfo articleinfo = new ArticleInfo(); articleinfo.Columnid = columnid; articleinfo.Title = title; //articleinfo.Highlight = ddlHightlight.SelectedValue; articleinfo.Summary = summary.Length > 160 ? summary.Substring(0, 159) : summary; articleinfo.Content = content; articleinfo.Postdate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); articleinfo.Uid = userinfo.Uid; articleinfo.Username = userinfo.Username; Articles.CreateArticle(articleinfo); Articles.RemoveArtilceCache(); ShowMsg("投递文章", "发布成功,跳转到栏目列表.", "", string.Format("showcolumn-{0}-1.aspx", articleinfo.Columnid)); } }
protected void btnSubmit_Click(object sender, EventArgs e) { ArticleInfo articleinfo = new ArticleInfo(); articleinfo.Columnid = Convert.ToInt32(ddlColumns.SelectedValue); articleinfo.Title = tbxTitle.Text.Trim(); articleinfo.Highlight = ddlHightlight.SelectedValue; articleinfo.Summary = tbxSummary.Text.TrimEnd(); articleinfo.Content = tbxContent.Text.TrimEnd(); articleinfo.Postdate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); articleinfo.Recommend = Convert.ToInt32(ckbxRecommand.Checked); articleinfo.Uid = userinfo.Uid; articleinfo.Username = userinfo.Username; if (articleid > 0) { articleinfo.Articleid = articleid; Articles.EditArticle(articleinfo); } else { Articles.CreateArticle(articleinfo); } Articles.RemoveArtilceCache(); ShowMsg("���¹���", "�����ύ�ɹ�.", "", "articlelist.aspx?cid=" + articleinfo.Columnid, true); //Response.Redirect("articlelist.aspx?cid=" + articleinfo.Columnid); }
protected override void Page_Show() { int articleid = YRequest.GetQueryInt("id", 1); articleinfo = Articles.GetArticleInfo(articleid); if (articleinfo == null) { ShowError("查看文章", "错误,不存在的文章!", "", ""); } pagetitle = string.Format("{0} - {1}", Natsuhime.Web.Utils.RemoveHtml(articleinfo.Title), articleinfo.Columnname); int commentpageid=YRequest.GetQueryInt("commentpageid", 1); commentlist = Comments.GetCommentCollection(articleid, 8, commentpageid); int commentpagecount = Comments.GetCommentCollectionPageCount(articleid, 8); commentcounthtml = config.Urlrewrite == 1 ? Natsuhime.Web.Utils.GetStaticPageNumbersHtml(commentpageid, commentpagecount, string.Format("showarticle-{0}", articleid), ".aspx", 8) : Utils.GetPageNumbersHtml(commentpageid, commentpagecount, string.Format("showarticle.aspx?id={0}", articleid), 8, "commentpageid", ""); }
protected void Page_Load(object sender, EventArgs e) { articleid = Convert.ToInt32(Request.QueryString["articleid"]); articleinfo = Articles.GetArticleInfo(articleid); if (articleinfo != null) { lbMessage.Text = string.Format("ȷ��ɾ������: {0} ��?", articleinfo.Title); } else { lbMessage.Text = "�����ڴ�����,�뷵��!"; btnYes.Visible = false; btnCancel.Visible = false; } }
public void CreateArticle(ArticleInfo articleinfo) { DbParameter[] prams = { DbHelper.MakeInParam("@title", DbType.String, 100,articleinfo.Title), DbHelper.MakeInParam("@columnid", DbType.Int32, 4,articleinfo.Columnid), DbHelper.MakeInParam("@highlight", DbType.String, 20,articleinfo.Highlight), DbHelper.MakeInParam("@summary", DbType.String, 160,articleinfo.Summary), DbHelper.MakeInParam("@content", DbType.String, 5000,articleinfo.Content), DbHelper.MakeInParam("@postdate", DbType.DateTime, 8,articleinfo.Postdate), DbHelper.MakeInParam("@uid", DbType.Int32, 4,articleinfo.Uid), DbHelper.MakeInParam("@username", DbType.String, 20,articleinfo.Username), DbHelper.MakeInParam("@recommend", DbType.Int32, 4,articleinfo.Recommend) }; DbHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO wy_articles(title,columnid,highlight,summary,content,postdate,uid,username,recommend) VALUES(@title,@columnid,@highlight,@summary,@content,@postdate,@uid,@username,@recommend)", prams); }
public void EditArticle(ArticleInfo articleinfo) { DbParameter[] prams = { DbHelper.MakeInParam("@title", DbType.String, 100,articleinfo.Title), DbHelper.MakeInParam("@columnid", DbType.Int32, 4,articleinfo.Columnid), DbHelper.MakeInParam("@highlight", DbType.String, 20,articleinfo.Highlight), DbHelper.MakeInParam("@summary", DbType.String, 160,articleinfo.Summary), DbHelper.MakeInParam("@content", DbType.String, 5000,articleinfo.Content), DbHelper.MakeInParam("@postdate", DbType.DateTime, 8,articleinfo.Postdate), DbHelper.MakeInParam("@uid", DbType.Int32, 4,articleinfo.Uid), DbHelper.MakeInParam("@username", DbType.String, 20,articleinfo.Username), DbHelper.MakeInParam("@articleid", DbType.Int32, 4,articleinfo.Articleid), DbHelper.MakeInParam("@recommend", DbType.Int32, 4,articleinfo.Recommend) }; DbHelper.ExecuteNonQuery(CommandType.Text, "UPDATE wy_articles SET title=@title,columnid=@columnid,highlight=@highlight,summary=@summary,content=@content,postdate=@postdate,uid=@uid,username=@username,recommend=@recommend WHERE articleid=@articleid", prams); }
public void EditArticle(ArticleInfo articleinfo) { DbParameter[] prams = { DbHelper.MakeInParam("?title", (DbType)MySqlDbType.String, 100,articleinfo.Title), DbHelper.MakeInParam("?columnid", (DbType)MySqlDbType.Int32, 4,articleinfo.Columnid), DbHelper.MakeInParam("?highlight", (DbType)MySqlDbType.String, 20,articleinfo.Highlight), DbHelper.MakeInParam("?summary", (DbType)MySqlDbType.String, 160,articleinfo.Summary), DbHelper.MakeInParam("?content", (DbType)MySqlDbType.String, 5000,articleinfo.Content), DbHelper.MakeInParam("?postdate", (DbType)MySqlDbType.Datetime, 8,articleinfo.Postdate), DbHelper.MakeInParam("?uid", (DbType)MySqlDbType.Int32, 4,articleinfo.Uid), DbHelper.MakeInParam("?username", (DbType)MySqlDbType.String, 20,articleinfo.Username), DbHelper.MakeInParam("?articleid", (DbType)MySqlDbType.Int32, 4,articleinfo.Articleid), DbHelper.MakeInParam("?recommend", (DbType)MySqlDbType.Int32, 4,articleinfo.Recommend) }; DbHelper.ExecuteNonQuery(CommandType.Text, "UPDATE wy_articles SET title=?title,columnid=?columnid,highlight=?highlight,summary=?summary,content=?content,postdate=?postdate,uid=?uid,username=?username,recommend=?recommend WHERE articleid=?articleid", prams); }
/// <summary> /// 将DataReader的Article转换为ArticleInfo泛型列表 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static ArticleInfo DataReader2ArticleInfo(IDataReader reader) { ArticleInfo info = new ArticleInfo(); info.Articleid = Convert.ToInt32(reader["articleid"]); info.Columnid = Convert.ToInt32(reader["columnid"]); info.Title = reader["title"].ToString(); info.Badcount = Convert.ToInt32(reader["badcount"]); info.Goodcount = Convert.ToInt32(reader["goodcount"]); info.Commentcount = Convert.ToInt32(reader["commentcount"]); info.Viewcount = Convert.ToInt32(reader["viewcount"]); info.Sort = Convert.ToInt32(reader["sort"]); info.Highlight = reader["highlight"].ToString(); info.Summary = reader["summary"].ToString(); info.Content = reader["content"].ToString(); info.Image = reader["image"].ToString(); info.Uid = Convert.ToInt32(reader["uid"]); info.Username = reader["username"].ToString(); info.Ip = reader["ip"].ToString(); info.Postdate = Convert.ToDateTime(reader["postdate"]).ToString("yyyy-MM-dd"); info.Del = Convert.ToInt32(reader["del"]); info.Recommend = Convert.ToInt32(reader["recommend"]); //高亮主题 if (info.Highlight != "") { info.Title = string.Format("<span style=\"{0}\">{1}</span>", info.Highlight, info.Title); } //文章的栏目前缀 if (info.Columnid > 0) { info.Columnname = Columns.GetColumnName(info.Columnid); } else { info.Columnname = ""; } return info; }
/// <summary> /// 编辑文章 /// </summary> /// <param name="articleinfo"></param> public static void EditArticle(ArticleInfo articleinfo) { DatabaseProvider.GetInstance().EditArticle(articleinfo); }
/// <summary> /// 发布新文章 /// </summary> /// <param name="articleinfo"></param> public static void CreateArticle(ArticleInfo articleinfo) { DatabaseProvider.GetInstance().CreateArticle(articleinfo); }
/// <summary> /// 取得文章内容 /// </summary> /// <param name="articleid">文章id</param> /// <returns>AritlceInfo</returns> public static ArticleInfo GetArticleInfo(int articleid) { ArticleInfo info = new ArticleInfo(); IDataReader reader = DatabaseProvider.GetInstance().GetArticleInfo(articleid); if (reader.Read()) { info = DataReader2ArticleInfo(reader); } else { info = null; } reader.Close(); return info; }