void Comment_Approved(object sender, EventArgs e) { BSComment bsComment = (BSComment)sender; if (bsComment.Approve) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("PostID", bsComment.PostID); dp.AddParameter("NotifyMe", true); dp.AddParameter("Approve", true); dp.ExecuteReader("SELECT DISTINCT Email FROM Comments WHERE PostID=@PostID AND NotifyMe=@NotifyMe AND Approve=@Approve"); if (dp.Return.Status == DataProcessState.Success) { BSPost bsPost = BSPost.GetPost(bsComment.PostID); using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { string strEmail = (string)dr["Email"]; System.Threading.ThreadPool.QueueUserWorkItem(delegate { BSHelper.SendMail(Language.Get["NewCommentNotice"], Blogsa.Settings["smtp_email"].ToString(), Blogsa.Settings["smtp_name"].ToString() , strEmail, "", Language.Get["NewCommentNoticeDescription"] + "<br><br><a href=\"" + bsPost.Link + "\">" + bsPost.Title + "</a>", true); }); } } } } } }
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; } }
public static void OnSaving(BSPost BsPost, CancelEventArgs e) { if (Saving != null) { Saving(BsPost, e); } }
public static List <BSPost> GetPostsByTitle(string title, int iUserId) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Title", title); if (iUserId == 0) { dp.ExecuteReader("SELECT * FROM [Posts] WHERE [Title] LIKE '%' + @Title + '%' ORDER By [CreateDate] DESC,[Title]"); } else { dp.AddParameter("UserID", iUserId); dp.ExecuteReader("SELECT * FROM [Posts] WHERE [Title] LIKE '%' + @Title + '%' AND [UserID]=@UserID ORDER By [CreateDate] DESC,[Title]"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
public static void FillPost(IDataReader dr, BSPost bsPost) { bsPost.Title = dr["Title"].ToString(); bsPost.PostID = Convert.ToInt32(dr["PostID"]); bsPost.Code = dr["Code"].ToString(); bsPost.Content = dr["Content"].ToString(); bsPost.State = (PostStates)Convert.ToInt16(dr["State"]); bsPost.AddComment = Convert.ToBoolean(dr["AddComment"]); bsPost.Categories = bsPost.GetCategoriesHtml(); bsPost.Tags = bsPost.GetTagsHtml(); bsPost.CommentCount = bsPost.GetComments(CommentStates.Approved).Count; bsPost.ReadCount = Convert.ToInt32(dr["ReadCount"]); bsPost.UserID = Convert.ToInt32(dr["UserID"]); bsPost.UserName = BSUser.GetUser(bsPost.UserID).UserName; bsPost.Date = Convert.ToDateTime(dr["CreateDate"]); bsPost.UpdateDate = dr["ModifyDate"] == DBNull.Value ? Convert.ToDateTime(dr["CreateDate"]) : Convert.ToDateTime(dr["ModifyDate"]); bsPost.Link = BSHelper.GetLink(bsPost); bsPost.Type = (PostTypes)Convert.ToInt16(dr["Type"]); bsPost.Show = (PostVisibleTypes)Convert.ToInt16(dr["Show"]); bsPost.ParentID = Convert.ToInt32(dr["ParentID"]); bsPost.LanguageCode = Convert.ToString(dr["LanguageCode"]); bsPost.Metas = BSMeta.GetMetas(bsPost.PostID); }
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"]; } } }
public static string GetLink(BSPost bsPost) { string strExpression = Blogsa.Settings["permaexpression"].ToString(); Dictionary <string, string> dicExpressions = new Dictionary <string, string>(); dicExpressions.Add("{author}", bsPost.UserName); dicExpressions.Add("{name}", bsPost.Code); dicExpressions.Add("{year}", bsPost.Date.Year.ToString()); dicExpressions.Add("{month}", bsPost.Date.Month.ToString("00")); dicExpressions.Add("{day}", bsPost.Date.Day.ToString("00")); dicExpressions.Add("{id}", bsPost.PostID.ToString()); Regex rex = new Regex("({(.+?)})/"); if (bsPost.Type == PostTypes.Page) { strExpression = strExpression.Replace("{name}", bsPost.Code); strExpression = strExpression.Replace("{id}", bsPost.PostID.ToString()); strExpression = rex.Replace(strExpression, ""); } else { foreach (string key in dicExpressions.Keys) { strExpression = strExpression.Replace(key, dicExpressions[key]); } } return(Blogsa.Url + strExpression); }
protected void Page_PreRender(object sender, EventArgs e) { try { int sFilter = 1; string s = Request["s"]; int.TryParse(s, out sFilter); FileTypes fileType = (FileTypes)(short)sFilter; rpFiles.DataSource = BSPost.GetPosts(PostTypes.File, PostVisibleTypes.All, fileType, 0); rpFiles.DataBind(); if (rpFiles.Items.Count == 0) { ltNoFile.Text = "<span style=\"padding:5px;margin:5px;text-align:center;display:block;border:1px solid #e7e7e7;background:#f4f4f4;font-weight:bold\">" + Language.Admin["NoMedia"] + "</span>"; } } catch (System.Exception ex) { ltNoFile.Text = ex.Message; } }
protected void btnDelete_Click(object sender, EventArgs e) { bool bRemoved = false; for (int i = 0; i < gvPosts.Rows.Count; i++) { CheckBox cb = gvPosts.Rows[i].FindControl("cb") as CheckBox; if (cb.Checked) { Literal literal = gvPosts.Rows[i].FindControl("PostID") as Literal; if (literal != null) { int iPostID = 0; int.TryParse(literal.Text, out iPostID); bRemoved = BSPost.GetPost(iPostID).Remove(); } } } if (bRemoved) { MessageBox1.Message = Language.Admin["PageDeleted"]; MessageBox1.Type = MessageBox.ShowType.Information; MessageBox1.Visible = true; gvPosts.DataBind(); } }
public static void OnDeleting(BSPost BsPost, CancelEventArgs e) { if (Deleting != null) { Deleting(BsPost, e); } }
public static void OnSaved(BSPost BsPost, EventArgs e) { if (Saved != null) { Saved(BsPost, e); } }
public static void OnDeleted(BSPost BsPost, EventArgs e) { if (Deleted != null) { Deleted(BsPost, e); } }
/// <summary> /// Delete Post(s) click action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbDelete_Click(object sender, EventArgs e) { bool bRemove = false; for (int i = 0; i < gvPosts.Rows.Count; i++) { CheckBox cb = gvPosts.Rows[i].FindControl("cb") as CheckBox; if (cb.Checked) { string PostID = (gvPosts.Rows[i].FindControl("PostID") as Literal).Text; int iPostID = 0; int.TryParse(PostID, out iPostID); BSPost bsPost = BSPost.GetPost(iPostID); bRemove = bsPost.Remove(); } } if (bRemove) { MessageBox1.Message = Language.Admin["PostDeleted"]; MessageBox1.Type = MessageBox.ShowType.Information; gvPosts.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { btnDelete.OnClientClick = "return confirm('" + Language.Admin["CategoryDeleteConfirm"] + "');"; HideAll(); int iFileID = 0; int.TryParse(Request["FileID"], out iFileID); if (!string.IsNullOrEmpty(Request["p"]) && Request["p"].Equals("new")) { divAddMedia.Visible = true; } else if (iFileID != 0) { divEditMedia.Visible = true; divEditMediaSide.Visible = true; divEditMedia.Visible = true; divEditMediaSide.Visible = true; if (!IsPostBack) { BSPost bsPost = BSPost.GetPost(iFileID); if (bsPost != null) { tmceContent.Content = bsPost.Content; txtTitle.Text = bsPost.Title; cblAddComment.Checked = bsPost.AddComment; ddState.SelectedValue = bsPost.State.ToString(); Categories1.TermType = TermTypes.Category; Categories1.LoadData(bsPost.PostID); Tags1.LoadTags(bsPost.PostID); ddState.Items[0].Text = Language.Admin["HiddenFile"]; ddState.Items[1].Text = Language.Admin["PublicFile"]; cblAddComment.Text = Language.Admin["CommentAdd"]; string strFolder = bsPost.Show == PostVisibleTypes.Hidden ? "Files/" : bsPost.Show == PostVisibleTypes.Public ? "Images/" : "Files/"; ltOpenAddress.Text = "Upload/" + strFolder + bsPost.Title; ltShowAddress.Text = "?FileID=" + bsPost.PostID; ltDownloadAdress.Text = "FileHandler.ashx?FileID=" + bsPost.PostID; } else { Response.Redirect("Library.aspx"); } } } else { if (!IsPostBack) { gvPosts.DataBind(); } divLibrary.Visible = true; } }
/// <summary> /// Post's grid view data binding. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvPosts_DataBinding(object sender, EventArgs e) { int iUserID = 0; int.TryParse(Request["UserID"], out iUserID); int iState = -1; if (!String.IsNullOrEmpty(Request["state"])) { int.TryParse(Request["state"], out iState); } PostStates postState; switch (iState) { case 1: postState = PostStates.Published; break; case 0: postState = PostStates.Draft; break; case 2: postState = PostStates.Removed; break; default: postState = PostStates.All; break; } string searchText = Request["Search"]; List <BSPost> posts; GridView gv = (GridView)sender; if (!String.IsNullOrEmpty(searchText)) { posts = User.IsInRole("editor") ? BSPost.GetPostsByTitle(searchText, Blogsa.ActiveUser.UserID) : BSPost.GetPostsByTitle(searchText, 0); } else if (User.IsInRole("editor")) { posts = BSPost.GetPostsByColumnValue("UserID", Blogsa.ActiveUser.UserID, 0, String.Empty, PostTypes.Article, postState); } else if (Request["UserID"] != null && iUserID != 0) { posts = BSPost.GetPostsByColumnValue("UserID", Blogsa.ActiveUser.UserID, 0, String.Empty, PostTypes.Article, postState); } else { posts = BSPost.GetPosts(PostTypes.Article, postState, 0); } gv.DataSource = posts; gv.Attributes.Add("totalItemCount", posts.Count.ToString(CultureInfo.InvariantCulture)); }
protected void Page_Load(object sender, EventArgs e) { rpPopuler5Post.DataSource = BSPost.GetPosts(PostTypes.Article, PostStates.Published, 5); rpPopuler5Post.DataBind(); if (rpPopuler5Post.Items.Count == 0) { ltNoData.Text = Language.Admin["NoPost"]; } }
protected void btnDeleteAllAutoSave_Click(object sender, EventArgs e) { List <BSPost> posts = BSPost.GetPosts(PostTypes.AutoSave, PostStates.Draft, 10); foreach (BSPost post in posts) { post.Remove(); } Response.Redirect("AutoSaves.aspx"); }
public static List <BSPost> GetPosts(PostTypes postType, PostVisibleTypes postVisibleType, FileTypes fileType, int postCount) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Type", (short)postType); if (postVisibleType != PostVisibleTypes.All) { if (fileType != FileTypes.All) { dp.AddParameter("State", (short)postVisibleType); dp.AddParameter("Show", (short)fileType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State AND [Show]=@Show ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } else { dp.AddParameter("State", (short)postVisibleType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } } else { if (fileType != FileTypes.All) { dp.AddParameter("Show", (short)fileType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [Show]=@Show ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } else { dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
public static List <BSPost> GetPostsByColumnValue(string column, object value, int postCount, string orderBy, PostTypes postType, PostStates postState) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { string top = postCount > 0 ? "TOP " + postCount : String.Empty; if (!String.IsNullOrEmpty(column) && value != null) { dp.AddParameter("Type", (short)postType); dp.AddParameter(column, value); if (postState == PostStates.All) { dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} {2}", column, top, orderBy)); } else { dp.AddParameter("State", (short)postState); dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} AND [State]=@State {2}", column, top, orderBy)); } } else { dp.AddParameter("Type", (short)postType); if (postState == PostStates.All) { dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type {1}", top, orderBy)); } else { dp.AddParameter("State", (short)postState); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State {1}", top, orderBy)); } } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(SearchText)) { Response.Redirect("~/"); } using (DataProcess dp = new DataProcess()) { try { dp.AddParameter("Content", SearchText); dp.ExecuteReader("SELECT * FROM Posts WHERE Type = 0 AND State = 1 AND (Content LIKE @Content + ' %' OR Content LIKE '% ' + @Content OR Content LIKE '% ' + @Content + ' %')"); int p = 0; int.TryParse(Request["p"], out p); p = p == 0 ? 1 : p; IDataReader dr = dp.Return.Value as IDataReader; List <BSPost> posts = new List <BSPost>(); while (dr.Read()) { BSPost post = new BSPost(); BSPost.FillPost(dr, post); posts.Add(post); } if (posts.Count > 0) { ltResult.Text = String.Format(Language.Get["SearchFoundedItemCount"], String.Format("<b>{0}</b>", posts.Count)); } else { ltResult.Text = Language.Get["SearchNotFound"]; } ltPaging.Visible = posts.Count > 0; rpSearch.DataSource = Data.Paging(posts, p, ltPaging); rpSearch.DataBind(); } catch (Exception) { } } }
/// <summary> /// Page Pre Render /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_PreRender(object sender, EventArgs e) { GetControlsLanguage(); string Msg = Request.QueryString["Message"]; switch (Msg) { case "1": BSPost p = BSPost.GetPost(Convert.ToInt32(Request["PostID"])); MessageBox1.Message = Language.Admin["PostSaved"] + " - <a class=\"sbtn bsdarkblue\" href=\"" + p.Link + "\"><span>" + Language.Admin["ShowPost"] + "</span></a>"; break; default: break; } ClientScript.RegisterClientScriptBlock(this.GetType(), "autosavemode", "autosavemode=true;", true); }
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> /// Page Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { gvhDefault.SearchButton.Click += new EventHandler(lbSearch_Click); GenerateHeaderButtons(); if (!Page.IsPostBack) { HideAll(); string PostID = Request.QueryString["PostID"]; int iPostID = 0; int.TryParse(PostID, out iPostID); if (iPostID > 0) { BSPost bsPost = BSPost.GetPost(iPostID); divAddPost.Visible = true; divAddPostSide.Visible = true; if (bsPost != null) { tmceContent.Content = bsPost.Content; txtTitle.Text = bsPost.Title; cblAddComment.Checked = bsPost.AddComment; ddState.SelectedValue = bsPost.State.ToString(); Categories1.TermType = TermTypes.Category; Categories1.LoadData(bsPost.PostID); Tags1.LoadTags(bsPost.PostID); rblDate.Items[0].Text = Language.Admin["NowPublish"]; rblDate.Items[1].Text = Language.Admin["ChangeDateTime"]; dtsDateTime.SelectedDateTime = bsPost.Date; } else { Response.Redirect("Posts.aspx"); } } else { divPosts.Visible = true; gvPosts.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(SearchText)) Response.Redirect("~/"); using (DataProcess dp = new DataProcess()) { try { dp.AddParameter("Content", SearchText); dp.ExecuteReader("SELECT * FROM Posts WHERE Type = 0 AND State = 1 AND (Content LIKE @Content + ' %' OR Content LIKE '% ' + @Content OR Content LIKE '% ' + @Content + ' %')"); int p = 0; int.TryParse(Request["p"], out p); p = p == 0 ? 1 : p; IDataReader dr = dp.Return.Value as IDataReader; List<BSPost> posts = new List<BSPost>(); while (dr.Read()) { BSPost post = new BSPost(); BSPost.FillPost(dr, post); posts.Add(post); } if (posts.Count > 0) { ltResult.Text = String.Format(Language.Get["SearchFoundedItemCount"], String.Format("<b>{0}</b>", posts.Count)); } else ltResult.Text = Language.Get["SearchNotFound"]; ltPaging.Visible = posts.Count > 0; rpSearch.DataSource = Data.Paging(posts, p, ltPaging); rpSearch.DataBind(); } catch (Exception) { } } }
public static List <BSPost> GetPostsByTerm(int termId, string code, TermTypes termType, PostTypes postType, PostStates postState) { List <BSPost> posts = new List <BSPost>(); using (DataProcess dp = new DataProcess()) { BSTerm bsTerm = null; bsTerm = termId != 0 ? BSTerm.GetTerm(termId) : BSTerm.GetTerm(code, termType); if (bsTerm != null) { dp.AddParameter("TermID", bsTerm.TermID); if (postState != PostStates.All) { dp.AddParameter("State", (short)postState); dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [State]=@State ORDER By [CreateDate] DESC"); } else { dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [Type]=@Type ORDER By [CreateDate] DESC"); } } else { return(posts); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return(posts); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string commentID = Request["CommentID"]; int iCommentID = 0; int.TryParse(commentID, out iCommentID); if (iCommentID > 0) { divComments.Visible = false; divEditComment.Visible = true; divSideEditComment.Visible = true; BSComment bsComment = BSComment.GetComment(iCommentID); txtName.Text = bsComment.UserName; txtWebSite.Text = bsComment.WebPage; txtComment.Text = bsComment.Content; txtEMail.Text = bsComment.Email; ltIP.Text = bsComment.IP; rblState.SelectedValue = bsComment.Approve ? "1" : "0"; ltCommentedPost.Text = BSPost.GetPost(bsComment.PostID).LinkedTitle; // DateTime txtDateDay.Text = bsComment.Date.Day.ToString("00"); txtDateMonth.Text = bsComment.Date.Month.ToString("00"); txtDateYear.Text = bsComment.Date.Year.ToString("0000"); txtTimeHour.Text = bsComment.Date.Hour.ToString("00"); txtTimeMinute.Text = bsComment.Date.Minute.ToString("00"); txtTimeSecond.Text = bsComment.Date.Second.ToString("00"); } else { divComments.Visible = true; divEditComment.Visible = false; divSideEditComment.Visible = false; gvItems.DataBind(); } } btnDelete.OnClientClick = "return confirm('" + Language.Admin["CommentDeleteConfirm"] + "');"; }
/// <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; } }
void Post_Saved(object sender, EventArgs e) { BSPost bsPost = ((BSPost)sender); for (int i = 0; i < strPingList.Length; i++) { try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(strPingList[i]); req.Method = "POST"; req.ContentType = "text/xml"; req.ProtocolVersion = HttpVersion.Version11; req.Headers["Accept-Language"] = "en-us"; AddRequestXml(bsPost.Link, req); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); resp.Close(); } catch { } } }
public static BSPost GetPost(string code) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("Code", code); dp.ExecuteReader("SELECT * FROM Posts WHERE [Code]=@Code"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); return(bsPost); } } } } return(null); }
protected void Page_Load(object sender, EventArgs e) { try { List<BSPost> posts = new List<BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("PostID", BSPost.CurrentPost.PostID); dp.AddParameter("Title", BSPost.CurrentPost.Title); dp.ExecuteReader("SELECT TOP 5 * FROM Posts WHERE [PostID]<>@PostID AND [Type]=0 AND [State]=1 AND ([Title] Like '%'+@Title+'%' OR Content Like '%'+@Title+'%') ORDER BY [CreateDate] DESC"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { BSPost bsPost = new BSPost(); BSPost.FillPost(dr, bsPost); posts.Add(bsPost); } } } } if (posts.Count > 0) { rpRelatedPosts.DataSource = posts; rpRelatedPosts.DataBind(); } else this.Visible = false; } catch (System.Exception ex) { } }
public static string GetLink(BSPost bsPost) { string strExpression = Blogsa.Settings["permaexpression"].ToString(); Dictionary<string, string> dicExpressions = new Dictionary<string, string>(); dicExpressions.Add("{author}", bsPost.UserName); dicExpressions.Add("{name}", bsPost.Code); dicExpressions.Add("{year}", bsPost.Date.Year.ToString()); dicExpressions.Add("{month}", bsPost.Date.Month.ToString("00")); dicExpressions.Add("{day}", bsPost.Date.Day.ToString("00")); dicExpressions.Add("{id}", bsPost.PostID.ToString()); Regex rex = new Regex("({(.+?)})/"); if (bsPost.Type == PostTypes.Page) { strExpression = strExpression.Replace("{name}", bsPost.Code); strExpression = strExpression.Replace("{id}", bsPost.PostID.ToString()); strExpression = rex.Replace(strExpression, ""); } else foreach (string key in dicExpressions.Keys) strExpression = strExpression.Replace(key, dicExpressions[key]); return Blogsa.Url + strExpression; }
public static List<BSPost> GetPosts(PostTypes postType, PostVisibleTypes postVisibleType, FileTypes fileType, int postCount) { List<BSPost> posts = new List<BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Type", (short)postType); if (postVisibleType != PostVisibleTypes.All) { if (fileType != FileTypes.All) { dp.AddParameter("State", (short)postVisibleType); dp.AddParameter("Show", (short)fileType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State AND [Show]=@Show ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } else { dp.AddParameter("State", (short)postVisibleType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } } else { if (fileType != FileTypes.All) { dp.AddParameter("Show", (short)fileType); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [Show]=@Show ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } else { dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type ORDER By [CreateDate] DESC,[Title]" , postCount == 0 ? String.Empty : "TOP " + postCount)); } } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return posts; }
public static BSPost GetPost(string code) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("Code", code); dp.ExecuteReader("SELECT * FROM Posts WHERE [Code]=@Code"); if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { if (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); return bsPost; } } } } return null; }
public static List<BSPost> GetPostsByTerm(int termId, string code, TermTypes termType, PostTypes postType, PostStates postState) { List<BSPost> posts = new List<BSPost>(); using (DataProcess dp = new DataProcess()) { BSTerm bsTerm = null; bsTerm = termId != 0 ? BSTerm.GetTerm(termId) : BSTerm.GetTerm(code, termType); if (bsTerm != null) { dp.AddParameter("TermID", bsTerm.TermID); if (postState != PostStates.All) { dp.AddParameter("State", (short)postState); dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [State]=@State ORDER By [CreateDate] DESC"); } else { dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [Type]=@Type ORDER By [CreateDate] DESC"); } } else return posts; if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return posts; }
public static List<BSPost> GetPostsByColumnValue(string column, object value, int postCount, string orderBy, PostTypes postType, PostStates postState) { List<BSPost> posts = new List<BSPost>(); using (DataProcess dp = new DataProcess()) { string top = postCount > 0 ? "TOP " + postCount : String.Empty; if (!String.IsNullOrEmpty(column) && value != null) { dp.AddParameter("Type", (short)postType); dp.AddParameter(column, value); if (postState == PostStates.All) { dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} {2}", column, top, orderBy)); } else { dp.AddParameter("State", (short)postState); dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} AND [State]=@State {2}", column, top, orderBy)); } } else { dp.AddParameter("Type", (short)postType); if (postState == PostStates.All) dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type {1}", top, orderBy)); else { dp.AddParameter("State", (short)postState); dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State {1}", top, orderBy)); } } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return posts; }
public static List<BSPost> GetPostsByTitle(string title, int iUserId) { List<BSPost> posts = new List<BSPost>(); using (DataProcess dp = new DataProcess()) { dp.AddParameter("Title", title); if (iUserId == 0) { dp.ExecuteReader("SELECT * FROM [Posts] WHERE [Title] LIKE '%' + @Title + '%' ORDER By [CreateDate] DESC,[Title]"); } else { dp.AddParameter("UserID", iUserId); dp.ExecuteReader("SELECT * FROM [Posts] WHERE [Title] LIKE '%' + @Title + '%' AND [UserID]=@UserID ORDER By [CreateDate] DESC,[Title]"); } if (dp.Return.Status == DataProcessState.Success) { using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr != null && dr.Read()) { BSPost bsPost = new BSPost(); FillPost(dr, bsPost); posts.Add(bsPost); } } } } return posts; }
public static void OnShowed(BSPost BsPost, EventArgs e) { if (Showed != null) { Showed(BsPost, e); } }
public static void OnShowing(BSPost BsPost, CancelEventArgs e) { if (Showing != null) { Showing(BsPost, e); } }