⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recycles.aspx.cs

📁 ASP.NET多线程编程(二),ASP.NET多线程编程(二) .
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Zeroone.FileSystem;

public partial class Admin_Recycles : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            ReBind();

    }
    void ReBind()
    {
        string path = CategoryController.SystemRecyclePath;
        int pageIndex = Request.QueryString["pageIndex"] == null ? 0 : int.Parse(Request.QueryString["pageIndex"]) - 1;
        int pageSize = 40;
        if (CategoryController.Exists(path))
        {
            DocumentSet ds = DocumentController.GetDocuments(path, pageIndex, pageSize);
            pager.PageIndex = pageIndex;
            pager.PageSize = pageSize;
            pager.TotalRecords = ds.TotalRecords;
            pager.PageButtonCount = 5;
            //pager.UrlPattern = Zeroone.Globals.ApplicationPath + "/admin/Recycles/{0}.aspx";

            rptDocuments.DataSource = ds.Documents;
            rptDocuments.DataBind();
        }
    }
    protected void lbtnClear_Click(object sender, EventArgs e)
    {
        CategoryCollection cc = CategoryController.GetChildCategories(CategoryController.SystemRecyclePath);
        foreach (Category c in cc)
        {
            c.Delete();
        }

        ReBind();
    }
    protected void lbtnResume_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in this.rptDocuments.Items)
        {
            if ((item.ItemType == ListItemType.AlternatingItem) || (item.ItemType == ListItemType.Item))
            {
                System.Web.UI.HtmlControls.HtmlInputCheckBox htmlCB = (HtmlInputCheckBox)item.FindControl("documentCheck");
                if (htmlCB.Checked)
                {
                    string value = htmlCB.Value;
                    string path = value.Substring(0, value.LastIndexOf("/") + 1);
                    string docName = value.Substring(path.Length);

                    Document d = DocumentController.GetDocument(path, docName);
                    d.Path = path.Substring(CategoryController.SystemRecyclePath.Length - 1);
                    d.Update(d.Path, d.Name);
                }
            }
        }

        //重新绑定
        ReBind();

    }
    protected void lbtnDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in this.rptDocuments.Items)
        {
            if ((item.ItemType == ListItemType.AlternatingItem) || (item.ItemType == ListItemType.Item))
            {
                System.Web.UI.HtmlControls.HtmlInputCheckBox htmlCB = (HtmlInputCheckBox)item.FindControl("documentCheck");
                if (htmlCB.Checked)
                {
                    string value = htmlCB.Value;
                    string path = value.Substring(0, value.LastIndexOf("/") + 1);
                    string docName = value.Substring(path.Length);

                    Document d = DocumentController.GetDocument(path, docName);
                    d.Delete();

                    //----------删除该文档的评论、分页---------
                    string deletePath = d.Path + d.Name + "/";
                    deletePath = deletePath.Substring(CategoryController.SystemRecyclePath.Length - 1);
                    ////首先判断是否是未审核文档
                    //if (deletePath.StartsWith(CategoryController.SystemAuditPath))
                    //{
                    //    deletePath = deletePath.Substring(CategoryController.SystemAuditPath.Length - 1);
                    //}
                    //判断该文档是否有分页
                    if (CategoryController.Exists(CategoryController.SystemPagesPath + deletePath.Substring(1)))
                    {
                        CategoryController.Delete(CategoryController.SystemPagesPath + deletePath.Substring(1));
                    }
                    //判断该文档是否有评论信息
                    if (CategoryController.Exists(CategoryController.SystemCommentPath + deletePath.Substring(1)))
                    {
                        CategoryController.Delete(CategoryController.SystemCommentPath + deletePath.Substring(1));
                    }
                    //--------------------------------------------
                }
            }
        }

        //重新绑定
        ReBind();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -