📄 documentslist.aspx.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;
using Zeroone.Security.Permissions;
using Zeroone.Framework.Jobs;
using System.Xml;
public partial class Admin_DocumentsList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Path.CheckRepairPath(Request.QueryString["path"]) == "/")
{
Response.Redirect("welcome.html");
}
else
{
ReBind();
}
}
}
void ReBind()
{
string path = Path.CheckRepairPath(Request.QueryString["path"]);
int pageIndex = Request.QueryString["pageIndex"] == null ? 0 : int.Parse(Request.QueryString["pageIndex"]) - 1;
int pageSize = 40;
Category c = CategoryController.GetCategory(path);
if (c.IsAuthorization(PermissionController.ListDocuments))
{
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" + path + "DocumentsList/{0}.aspx";
rptDocuments.DataSource = ds.Documents;
rptDocuments.DataBind();
}
}
protected void ltbnDelete_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 + "/";
////首先判断是否是未审核文档
//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));
}
//--------------------------------------------
//-----------维护索引---------------------
JobsConfiguration jobsConfig = JobsConfiguration.GetJobsConfiguration();
foreach (XmlNode jobNode in jobsConfig.JobsList)
{
if (jobNode.NodeType != XmlNodeType.Comment)
{
XmlAttribute pathAttribute = jobNode.Attributes["path"];
if (pathAttribute != null)
{
string indexFileDirectory = Context.Request.PhysicalApplicationPath + "zeroone_searchIndexFile" + pathAttribute.Value + "indexFiles";
if (System.IO.File.Exists(indexFileDirectory + "\\segments"))
{
string indexCategoryPath = pathAttribute.Value;
if (path.StartsWith(indexCategoryPath))
Zeroone.Data.DocumentDataProvider.Instance().Indexer_AddDocument(d.DocumentID, indexCategoryPath);
}
}
}
}
//------------------------------------
}
}
}
//重新绑定
ReBind();
}
protected void ltbnRecycleBin_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.RecycleBin();
//-----------维护索引---------------------
JobsConfiguration jobsConfig = JobsConfiguration.GetJobsConfiguration();
foreach (XmlNode jobNode in jobsConfig.JobsList)
{
if (jobNode.NodeType != XmlNodeType.Comment)
{
XmlAttribute pathAttribute = jobNode.Attributes["path"];
if (pathAttribute != null)
{
string indexFileDirectory = Context.Request.PhysicalApplicationPath + "zeroone_searchIndexFile" + pathAttribute.Value + "indexFiles";
if (System.IO.File.Exists(indexFileDirectory + "\\segments"))
{
string indexCategoryPath = pathAttribute.Value;
if (path.StartsWith(indexCategoryPath))
Zeroone.Data.DocumentDataProvider.Instance().Indexer_AddDocument(d.DocumentID, indexCategoryPath);
}
}
}
}
//------------------------------------
}
}
}
//重新绑定
ReBind();
}
protected void btnPaster_Click(object sender, EventArgs e)
{
string targetPath = Path.CheckRepairPath(tbTarget.Text);
Category c = CategoryController.GetCategory(targetPath);
if (!c.IsAuthorization(PermissionController.CreateDocument))
{
throw new CategoryAccessDeniedException(string.Format("您没有在 {0} 栏目下创建文档的权限;",targetPath));
}
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.MoveTo(targetPath);
//----------更新该文档的评论、分页---------
//判断该文档是否有分页
if (CategoryController.Exists(CategoryController.SystemPagesPath + value.Substring(1)))
{
CategoryController.CreateDirectory(CategoryController.SystemPagesPath + targetPath.Substring(1));
Category targetPagePath = CategoryController.GetCategory(CategoryController.SystemPagesPath + value.Substring(1));
targetPagePath.Path = CategoryController.SystemPagesPath + targetPath.Substring(1) + docName;
targetPagePath.Update();
CategoryController.Delete(CategoryController.SystemPagesPath + value.Substring(1));
}
//判断该文档是否有评论信息
if (CategoryController.Exists(CategoryController.SystemCommentPath + value.Substring(1)))
{
CategoryController.CreateDirectory(CategoryController.SystemCommentPath + targetPath.Substring(1));
Category targetCommentPath = CategoryController.GetCategory(CategoryController.SystemCommentPath + value.Substring(1));
targetCommentPath.Path = CategoryController.SystemCommentPath + targetPath.Substring(1) + docName;
targetCommentPath.Update();
CategoryController.Delete(CategoryController.SystemCommentPath + value.Substring(1));
}
//-----------维护索引---------------------
JobsConfiguration jobsConfig = JobsConfiguration.GetJobsConfiguration();
foreach (XmlNode jobNode in jobsConfig.JobsList)
{
if (jobNode.NodeType != XmlNodeType.Comment)
{
XmlAttribute pathAttribute = jobNode.Attributes["path"];
if (pathAttribute != null)
{
string indexFileDirectory = Context.Request.PhysicalApplicationPath + "zeroone_searchIndexFile" + pathAttribute.Value + "indexFiles";
if (System.IO.File.Exists(indexFileDirectory + "\\segments"))
{
string indexCategoryPath = pathAttribute.Value;
if (path.StartsWith(indexCategoryPath))
Zeroone.Data.DocumentDataProvider.Instance().Indexer_AddDocument(d.DocumentID, indexCategoryPath);
}
}
}
}
//------------------------------------
}
}
}
//重新绑定
ReBind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -