예제 #1
0
    public void Update_Article(Object s, EventArgs e)
    {
        ArticleRepository Article = new ArticleRepository();

        Article.ID = (int)Util.Val(Request.QueryString["aid"]);
        Article.UID = int.Parse(Request.Form["Userid"]);
        Article.Title = Request.Form["Title"];
        Article.Content = Request.Form["Content"];
        Article.CatID = int.Parse(Request.Form["ddlarticlecategory"]);
        Article.Keyword = Request.Form["Keyword"];
        Article.Summary = Request.Form["Summary"];

        //Refresh cache
        Caching.PurgeCacheItems("Newest_Articles");
        Caching.PurgeCacheItems("ArticleCategory_SideMenu");

        //Notify user if error occured.
        if (Article.Update(Article) != 0)
        {
            JSLiteral.Text = Util.JSProcessingErrorAlert;
            return;
        }

        //Release allocated memory
        Article = null;

        //If success, redirect to article update confirmation page.
        Util.PageRedirect(7);

        Util = null;
    }
예제 #2
0
    //Handle delete button click event
    public void ApprovedDelete_Article(Object sender, RepeaterCommandEventArgs e)
    {
        if ((e.CommandName == "Delete"))
        {
            ArticleRepository Article = new ArticleRepository();

            string[] commandArgsDelete = e.CommandArgument.ToString().Split(new char[] { ',' });
            Article.ID = int.Parse(commandArgsDelete[0].ToString()); // Article ID
            int User_ID = int.Parse(commandArgsDelete[1].ToString()); // Get the UserID

            Caching.PurgeCacheItems("Newest_Articles");
            Caching.PurgeCacheItems("ArticleCategory_SideMenu");
            Caching.PurgeCacheItems("Last5_ArticlePublishedByUser_" + User_ID);

            //Perform delete
            Article.Delete(Article);

            //Release allocated memory
            Article = null;

            //Redirect to confirm delete page
            Response.Redirect("articlemanager.aspx");
        }

        if ((e.CommandName == "Approved"))
        {
            string[] commandArgsApproved = e.CommandArgument.ToString().Split(new char[] { ',' });
            int ArticleID = int.Parse(commandArgsApproved[0].ToString()); // Get the Article ID
            int UserID = int.Parse(commandArgsApproved[1].ToString()); // Get the UserID

            //Refresh cache
            Caching.PurgeCacheItems("Newest_Articles");
            Caching.PurgeCacheItems("ArticleCategory_SideMenu");
            Caching.PurgeCacheItems("Last5_ArticlePublishedByUser_" + UserID);

            int Err = Blogic.ActionProcedureDataProvider.FinalizeAddArticle(ArticleID);

            // If error occured, stop further processing and notify user.
            if (Err != 0)
            {
                JSLiteral.Text = "Error occured while processing your submit.";
                return;
            }

            //Redirect to confirm delete page
            Response.Redirect("articlemanager.aspx");
        }
    }
예제 #3
0
    //Handle add new category
    public void Add_Category(Object s, EventArgs e)
    {
        ArticleRepository Category = new ArticleRepository();

        Category.Category = Request.Form["CategoryName"];

        Caching.PurgeCacheItems("ArticleCategory_SideMenu");

        //Notify user if error occured.
        if (Category.AddCategory(Category) != 0)
        {
            JSLiteral.Text = "Error occured while processing your submit.";
            return;
        }

        Category = null;

        Response.Redirect("confirmarticlecatedit.aspx?catname=" + Request.Form["CategoryName"] + "&mode=add");
    }
예제 #4
0
    public void Add_Article(Object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            Utility Util = new Utility();

            ArticleRepository Article = new ArticleRepository();

            Article.UID = UserIdentity.UserID;
            Article.Author = UserIdentity.UserName;
            Article.Title = Util.FormatTextForInput(Request.Form["Title"]);
            Article.Summary = Util.FormatTextForInput(Request.Form["Summary"]);
            Article.Content = Request.Form["Content"];
            Article.CatID = Int32.Parse(Request.Form["ddlarticlecategory"]);
            Article.Keyword = Util.FormatTextForInput(Request.Form["Keyword"]);

            #region Form Input Validator
            if (Article.Title.Length == 0)
            {
                lbvalenght.Text = "<br>Lỗi: Tiêu đề chưa có, Hãy nhập tiêu đề bài viết vào.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.CatID == 0)
            {
                lbvalenght.Text = "<br>Lỗi: Bạn phải chọn một chuyên mục, nơi mà bài viết hiển thị";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length == 0)
            {
                lbvalenght.Text = "<br>Lõi: Nội dung tóm tắt chưa có, hãy nhập nội dung tóm tắt vào.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Content.Length == 0)
            {
                lbvalenght.Text = "<br>Lõi: Nội dung bài viết chưa có, hãy nhập nội dung bài viết vào.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length == 0)
            {
                lbvalenght.Text = "<br>Lỗi: Từ khóa cho bài viết chưa có, hãy nhập từ khóa vào.";
                lbvalenght.Visible = true;
                return;
            }
            //if (Article.Content.Length > 8000)
            //{
            //    lbvalenght.Text = "<br>Error: Content is too long, max of 8000 characters including HTML formatting.";
            //    lbvalenght.Visible = true;
            //    return;
            //}
            if (Article.Title.Length > 65)
            {
                lbvalenght.Text = "<br>Lỗi: Tiêu đề quá dài, nó không thể lớn hơn 65 ký tự.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length > 350)
            {
                lbvalenght.Text = "<br>Lỗi: Nội dung tóm tắt quá dài, nó không thể vượt quá 350 ký tự.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length > 80)
            {
                lbvalenght.Text = "<br>Lỗi: Từ khóa quá dài, nó không thể vượt quá 80 ký tự.";
                lbvalenght.Visible = true;
                return;
            }

            #endregion

            if (Article.Add(Article) != 0)
            {
                JSLiteral.Text = "Quá trình sử lý thất bại.";
                return;
            }

            Article = null;
            Util = null;

            Response.Redirect("confirmsubmitarticle.aspx?mode=Added");
        }
    }
예제 #5
0
    //Handle the delete button click event
    public void Delete_Category(Object sender, RepeaterCommandEventArgs e)
    {
        if ((e.CommandName == "Delete"))
        {
            ArticleRepository Category = new ArticleRepository();

            Category.CatID = Convert.ToInt32(e.CommandArgument);

            Caching.PurgeCacheItems("ArticleCategory_SideMenu");

            //Perform delete
            Category.DeleteCategory(Category);

            //Redirect to confirm delete page
            Response.Redirect("confirmarticlecatedit.aspx?catname=ArticleCategoryID" + Category.CatID + "&mode=del");
        }
    }
예제 #6
0
    //Handle the delete button click event
    public void Delete_Article(Object sender, RepeaterCommandEventArgs e)
    {
        if ((e.CommandName == "Delete"))
        {
            ArticleRepository DeleteArticle = new ArticleRepository();

            DeleteArticle.ID = Convert.ToInt32(e.CommandArgument);

            Caching.PurgeCacheItems("Newest_Articles");
            Caching.PurgeCacheItems("ArticleCategory_SideMenu");

            //Perform delete
            DeleteArticle.Delete();

            //Release allocated memory
            DeleteArticle = null;

            //Redirect to confirm delete page
            Response.Redirect("articlemanager.aspx");
        }
    }
예제 #7
0
    public void Update_Article(Object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            ArticleRepository Article = new ArticleRepository();

            Article.UID = UserIdentity.UserID;
            Article.ID = (int)Util.Val(Request.QueryString["aid"]);
            Article.Title = Util.FormatTextForInput(Request.Form["Title"]);
            Article.Summary = Util.FormatTextForInput(Request.Form["Summary"]);
            Article.Content = Request.Form["Content"];
            Article.CatID = Int32.Parse(Request.Form["ddlarticlecategory"]);
            Article.Keyword = Util.FormatTextForInput(Request.Form["Keyword"]);

            #region Form Input Validator
            if (Article.Title.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Title is blank, please enter a title.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Summary is blank, please enter a summary.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Content.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Content is blank, please enter a content.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length == 0)
            {
                lbvalenght.Text = "<br>Error: Keyword is blank, please enter a keyword.";
                lbvalenght.Visible = true;
                return;
            }
            //if (Article.Content.Length > 8000)
            //{
            //    lbvalenght.Text = "<br>Error: Content is too long, max of 8000 characters including HTML formatting.";
            //    lbvalenght.Visible = true;
            //    return;
            //}
            if (Article.Title.Length > 65)
            {
                lbvalenght.Text = "<br>Error: Title is too long, should not exceed 65 characters.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length > 800)
            {
                lbvalenght.Text = "<br>Error: Summary is too long, max of 350 characters.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length > 80)
            {
                lbvalenght.Text = "<br>Error: Keyword is too long, max of 80 characters.";
                lbvalenght.Visible = true;
                return;
            }

            #endregion

            //Refresh cache
            Caching.PurgeCacheItems("Newest_Articles");
            Caching.PurgeCacheItems("ArticleCategory_SideMenu");

            if (Article.Update(Article) != 0)
            {
                JSLiteral.Text = "Error occured while processing your article submission.";
                return;
            }

            Article = null;

            Response.Redirect("confirmsubmitarticle.aspx?mode=Updated");
        }
    }