protected void btnSavePost_Click(object sender, EventArgs e) { try { int iFileID = 0; int.TryParse(Request["FileID"], out iFileID); BSPost bsPost = BSPost.GetPost(iFileID); bsPost.Content = tmceContent.Content; bsPost.State = (PostStates)Convert.ToInt16(ddState.SelectedValue); bsPost.AddComment = cblAddComment.Checked; bsPost.UpdateDate = DateTime.Now; Categories1.SaveData(bsPost.PostID); Tags1.SaveTags(bsPost.PostID); if (bsPost.Save()) { Response.Redirect("Library.aspx?FileID=" + bsPost.PostID + "&Message=1"); } else { MessageBox1.Message = "Error"; MessageBox1.Type = MessageBox.ShowType.Error; } } catch (Exception ex) { MessageBox1.Message = ex.Message; MessageBox1.Type = MessageBox.ShowType.Error; } }
private void SavePost() { try { BSPost bsPost = new BSPost(); bsPost.UserID = Blogsa.ActiveUser.UserID; bsPost.Title = txtTitle.Text; bsPost.Code = BSHelper.CreateCode(txtTitle.Text); bsPost.Content = tmcePostContent.Content; bsPost.State = bucPostSettings.State; bsPost.AddComment = bucPostSettings.AddComment; bsPost.LanguageCode = bucPostSettings.LanguageCode; bsPost.Date = bucPostSettings.Date; if (bsPost.Save()) { bucPostSettings.Save(bsPost.PostID); Response.Redirect("Posts.aspx?PostID=" + bsPost.PostID + "&Message=1"); } else { MessageBox1.Message = "Error"; MessageBox1.Type = MessageBox.ShowType.Error; } } catch (Exception ex) { MessageBox1.Message = ex.Message; MessageBox1.Type = MessageBox.ShowType.Error; } }
protected void btnSavePage_Click(object sender, EventArgs e) { int iPostID = 0; int.TryParse(Request["PostID"], out iPostID); if (iPostID != 0) { BSPost bsPost = BSPost.GetPost(iPostID); bsPost.Title = txtTitle.Text; bsPost.Code = BSHelper.CreateCode(txtTitle.Text); bsPost.Content = tmcePageContent.Content; bsPost.State = (PostStates)short.Parse(ddState.SelectedValue); bsPost.AddComment = cblAddComment.Checked; bsPost.UpdateDate = DateTime.Now; if (bsPost.Save()) { MessageBox1.Message = Language.Admin["PageSaved"]; MessageBox1.Type = MessageBox.ShowType.Information; } else { MessageBox1.Message = Language.Admin["PageError"]; } } }
private void SavePost(PostStates state) { BSPost bsPost = new BSPost(); bsPost.UserID = Blogsa.ActiveUser.UserID; bsPost.Title = txtPostTitle.Text; bsPost.Code = BSHelper.CreateCode(txtPostTitle.Text); bsPost.Content = txtPostContent.Text; bsPost.State = state; bsPost.Date = DateTime.Now; if (bsPost.Save()) { SaveTags(bsPost.PostID); Response.Redirect("Posts.aspx?PostID=" + bsPost.PostID + "&Message=1"); } }
protected void btnCreatePost_Click(object sender, EventArgs e) { int iCount = Convert.ToInt32(tbCount.Text); for (int i = 0; i < iCount; i++) { BSPost post = new BSPost(); post.Title = String.Format("{0}-{1}", tbTitle.Text, i + 1); post.Content = tbContent.Text; post.AddComment = true; post.Code = BSHelper.CreateCode(post.Title); post.Date = DateTime.Now; post.Type = PostTypes.Article; post.UserID = 1; post.State = PostStates.Published; post.Save(); } }
/// <summary> /// Save Post(s) click action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSavePost_Click(object sender, EventArgs e) { try { string PostID = Request.QueryString["PostID"]; int iPostID = 0; int.TryParse(PostID, out iPostID); BSPost bsPost = BSPost.GetPost(iPostID); bsPost.Title = txtTitle.Text; bsPost.Code = BSHelper.CreateCode(txtTitle.Text); bsPost.Content = tmceContent.Content; bsPost.State = (PostStates)Convert.ToInt16(ddState.SelectedValue); bsPost.AddComment = cblAddComment.Checked; bsPost.UpdateDate = DateTime.Now; if (rblDate.SelectedValue == "1") { bsPost.Date = dtsDateTime.SelectedDateTime; } Categories1.SaveData(bsPost.PostID); Tags1.SaveTags(bsPost.PostID); if (bsPost.Save()) { Response.Redirect("Posts.aspx?PostID=" + PostID + "&Message=1"); } else { MessageBox1.Message = Language.Admin["PostError"]; MessageBox1.Type = MessageBox.ShowType.Error; } } catch (Exception ex) { MessageBox1.Message = ex.Message; MessageBox1.Type = MessageBox.ShowType.Error; } }
protected void Page_Load(object sender, EventArgs e) { string tag = Request["Tag"]; string postID = Request["PostID"]; string postCode = Request["Code"]; string category = Request["Category"]; string fileID = Request["FileID"]; string langCode = Request["Language"]; if (!string.IsNullOrEmpty(fileID)) { postID = fileID; } int iPostID = 0; int.TryParse(postID, out iPostID); BSPost bsPost = null; if (iPostID != 0) { bsPost = BSPost.GetPost(iPostID); } else if (!string.IsNullOrEmpty(postCode)) { bsPost = BSPost.GetPost(postCode); } if (bsPost != null) { if (bsPost.State == PostStates.Published && (bsPost.Type != PostTypes.AutoSave)) { PostDetail = true; bsPost.ReadCount++; bsPost.Save(); this.Page.Title = Blogsa.Title + " - " + bsPost.Title; BSHelper.AddHeader(this.Page, "keywords", bsPost.GetTagsWithComma()); System.Web.UI.HtmlControls.HtmlGenericControl gc = new System.Web.UI.HtmlControls.HtmlGenericControl(); gc.InnerHtml = bsPost.Content; BSHelper.AddHeader(this.Page, "description", gc.InnerText.Length > 160 ? gc.InnerText.Substring(0, 160) : gc.InnerText); BSHelper.AddHeader(this.Page, "robots", "index,follow"); List <BSPost> posts = new List <BSPost>(); posts.Add(bsPost); rpPosts.DataSource = posts; rpPosts.DataBind(); } } else if (tag != null) { tag = BSHelper.CreateCode(tag); List <BSPost> posts = BSPost.GetPostsByTerm(0, tag, TermTypes.Tag, PostTypes.Article, PostStates.Published); ObjectPager pager = new ObjectPager(); int pageCount = pager.PageCount(posts, 10); rpPosts.DataSource = pager.GetPage(posts, 0, 10); rpPosts.DataBind(); } else if (category != null) { category = BSHelper.CreateCode(category); List <BSPost> posts = BSPost.GetPostsByTerm(0, category, TermTypes.Category, PostTypes.Article, PostStates.Published); ObjectPager pager = new ObjectPager(); int pageCount = pager.PageCount(posts, 10); rpPosts.DataSource = pager.GetPage(posts, 0, 10); rpPosts.DataBind(); } else { int iCurrentPage = 0; int.TryParse(Request["Page"], out iCurrentPage); if (iCurrentPage <= 0) { iCurrentPage = 1; } List <BSPost> posts = BSPost.GetPosts(PostTypes.Article, PostStates.Published, 0); Panel pnlPaging = new Panel(); pnlPaging.CssClass = "paging"; Literal ltPaging = new Literal(); pnlPaging.Controls.Add(ltPaging); BSPlaceHolderPaging.Controls.Add(pnlPaging); rpPosts.DataSource = Data.Paging(posts, iCurrentPage, ltPaging); rpPosts.DataBind(); } if (rpPosts.Items.Count == 0) { Literal l = new Literal(); l.Text = Language.Get["NoWrite"]; Controls.AddAt(0, l); } }