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

📄 indexfileslist.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.Framework.Jobs;
using System.Xml;
using System.IO;

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

    }
    void ReBind()
    {
        DataTable cacheFiles = new DataTable();
        DataColumn column = new DataColumn();
        column.DataType = Type.GetType("System.String");
        column.ColumnName = "categoryPath";
        cacheFiles.Columns.Add(column);

        column = new DataColumn();
        column.DataType = Type.GetType("System.String");
        column.ColumnName = "LastAccessTime";
        cacheFiles.Columns.Add(column);

        column = new DataColumn();
        column.DataType = Type.GetType("System.Int64");
        column.ColumnName = "fileSize";
        cacheFiles.Columns.Add(column);

        XmlNodeList xnl = JobsConfiguration.GetJobsConfiguration().JobsList;
        foreach (XmlNode xn in xnl)
        {
            if (xn.NodeType != XmlNodeType.Comment)
            {
                XmlAttribute pathAttribute = xn.Attributes["path"];
                XmlAttribute typeAttribute = xn.Attributes["type"];

                Type jobType = Type.GetType(typeAttribute.Value);
                if (jobType.GetInterface("Zeroone.IndexEngine.IIndex") != null)
                {
                    string indexFileDirectory = Context.Request.PhysicalApplicationPath + "zeroone_searchIndexFile" + pathAttribute.Value + "indexFiles";
                    if (File.Exists(indexFileDirectory + "\\segments"))
                    {
                        DataRow dr = cacheFiles.NewRow();
                        dr["categoryPath"] = pathAttribute.Value;
                        dr["LastAccessTime"] = File.GetCreationTime(indexFileDirectory + "\\segments").ToString();
                        long fileSize = 0;
                        DirectoryInfo di = new DirectoryInfo(indexFileDirectory);
                        FileInfo[] fiArr = di.GetFiles();

                        foreach (FileInfo f in fiArr)
                        {
                            fileSize = fileSize + f.Length;
                        }
                        dr["fileSize"] = fileSize / 1024 + 1;

                       cacheFiles.Rows.Add(dr);
                    }
                }
            }
        }

        this.rptIndexFiles.DataSource = cacheFiles;
        this.rptIndexFiles.DataBind();
    }
    protected void rptIndexFiles_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string cateogryPath = e.CommandArgument.ToString();

        string indexFileDirectory = Context.Request.PhysicalApplicationPath + "zeroone_searchIndexFile" + cateogryPath + "indexFiles";
        Directory.Delete(indexFileDirectory, true);

        this.ReBind();
    }
}

⌨️ 快捷键说明

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