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

📄 contentrecycle.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Contents
{
    using PowerEasy.AccessManage;
    using PowerEasy.Common;
    using PowerEasy.CommonModel;
    using PowerEasy.Components;
    using PowerEasy.Contents;
    using PowerEasy.Controls;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.Contents;
    using PowerEasy.ModelControls;
    using PowerEasy.Web.UI;
    using PowerEasy.WebSite.Controls;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class ContentRecycle : AdminPage
    {
        protected Button BtnClear;
        protected Button BtnRecycle;
        protected ContentManageNavigation Cmn;
        protected DropDownList DropRescentQuery;
        protected Button EBtnDelete;
        protected Button EBtnRestore;
        protected ExtendedGridView EgvContentRecycle;
        protected HiddenField HdnListType;
        protected HiddenField HdnStatus;
        private bool m_Administrator;
        private string m_arrContentNodeIdManage = "";
        protected Dictionary<int, string> m_NodeNameDictionary = new Dictionary<int, string>();
        private int nodeId;
        protected ObjectDataSource OdsContents;
        protected ScriptManager ScriptManageContent;
        protected ExtendedSiteMapPath SmpNavigator;

        protected void BtnClear_Click(object sender, EventArgs e)
        {
            if (this.nodeId > 0)
            {
                ContentManage.DeleteByNodeId(Nodes.GetCacheNodeById(this.nodeId).ArrChildId, -3);
                AdminPage.WriteSuccessMsg("<li>删除成功!</li>", "ContentRecycle.aspx?NodeID=" + this.nodeId);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (CommonModelInfo info2 in ContentManage.GetCommonModelInfoList(0, 0, -1, ContentSortType.None, -3))
                {
                    StringHelper.AppendString(sb, info2.GeneralId.ToString());
                }
                ContentManage.Delete(sb.ToString());
                AdminPage.WriteSuccessMsg("<li>删除成功!</li>", "ContentRecycle.aspx");
            }
        }

        protected void BtnRecycle_Click(object sender, EventArgs e)
        {
            if (this.nodeId > 0)
            {
                ContentManage.RecycleAll(Nodes.GetCacheNodeById(this.nodeId).ArrChildId);
                AdminPage.WriteSuccessMsg("<li>还原成功!</li>", "ContentRecycle.aspx?NodeID=" + this.nodeId);
            }
            else
            {
                ContentManage.RecycleAll("0");
                AdminPage.WriteSuccessMsg("<li>还原成功!</li>", "ContentRecycle.aspx");
            }
        }

        protected void DropRescentQuerySelectedIndex_Changed(object sender, EventArgs e)
        {
            this.HdnListType.Value = this.DropRescentQuery.SelectedValue;
            this.EgvContentRecycle.PageIndex = 0;
        }

        protected void EBtnDelete_Click(object sender, EventArgs e)
        {
            if (ContentManage.Delete(this.EgvContentRecycle.SelectList.ToString()))
            {
                AdminPage.WriteSuccessMsg("<li>彻底删除成功</li>", "ContentRecycle.aspx?NodeID=" + BasePage.RequestInt32("NodeID"));
            }
            else
            {
                AdminPage.WriteErrMsg("<li>彻底删除失败</li>");
            }
        }

        protected void EBtnRestore_Click(object sender, EventArgs e)
        {
            string[] strArray = this.EgvContentRecycle.SelectList.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < strArray.Length; i++)
            {
                ContentManage.UpdateStatus(DataConverter.CLng(strArray[i]), 0);
            }
            AdminPage.WriteSuccessMsg("<li>还原成功</li>", "ContentRecycle.aspx?NodeID=" + this.nodeId);
        }

        protected void EgvContentRecycle_RowCommand(object sender, CommandEventArgs e)
        {
            int generalId = DataConverter.CLng(e.CommandArgument.ToString());
            if (e.CommandName == "RestoreContent")
            {
                if (ContentManage.UpdateStatus(generalId, 0))
                {
                    AdminPage.WriteSuccessMsg("<li>还原成功!</li>", "ContentRecycle.aspx?NodeID=" + this.nodeId);
                }
                else
                {
                    AdminPage.WriteErrMsg("<li>还原失败!</li>");
                }
            }
            if (e.CommandName == "DeleteContent")
            {
                if (ContentManage.Delete(generalId.ToString()))
                {
                    AdminPage.WriteSuccessMsg("<li>删除成功!</li>", "ContentRecycle.aspx?NodeID=" + this.nodeId);
                }
                else
                {
                    AdminPage.WriteErrMsg("<li>删除失败!</li>");
                }
            }
        }

        protected void EgvContentRecycle_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                CommonModelInfo dataItem = new CommonModelInfo();
                dataItem = (CommonModelInfo) e.Row.DataItem;
                NodeInfo cacheNodeById = new NodeInfo(true);
                int length = 0;
                string nodeName = "";
                if (dataItem.NodeId != this.nodeId)
                {
                    this.nodeId = dataItem.NodeId;
                    if (this.m_NodeNameDictionary.ContainsKey(dataItem.NodeId))
                    {
                        nodeName = this.m_NodeNameDictionary[dataItem.NodeId];
                    }
                    else
                    {
                        cacheNodeById = Nodes.GetCacheNodeById(dataItem.NodeId);
                        if (cacheNodeById != null)
                        {
                            nodeName = cacheNodeById.NodeName;
                            this.m_NodeNameDictionary.Add(dataItem.NodeId, nodeName);
                        }
                    }
                    Label label = e.Row.FindControl("LblNodeLink") as Label;
                    label.Text = "<strong>[<a href=\"ContentRecycle.aspx?NodeID=" + dataItem.NodeId.ToString() + "&NodeName=" + base.Server.UrlEncode(nodeName) + "\">" + nodeName + "</a>]</strong>";
                    length = StringHelper.SubStringLength(DataSecurity.HtmlDecode(nodeName)) + 2;
                }
                HyperLink link = e.Row.FindControl("HypTitle") as HyperLink;
                length = 0x25 - length;
                link.Text = DataSecurity.HtmlEncode(StringHelper.SubString(DataSecurity.HtmlDecode(dataItem.Title), length, "..."));
                link.ToolTip = dataItem.Title;
                link.NavigateUrl = "ContentView.aspx?GeneralID=" + dataItem.GeneralId.ToString();
                Label label2 = e.Row.FindControl("LblIsCreateHtml") as Label;
                label2.Text = "<span style=\"color:Red\"><b>\x00d7</b></span>";
                LinkImage image = e.Row.FindControl("LinkImageModel") as LinkImage;
                string itemIcon = ModelManager.GetCacheModelById(dataItem.ModelId).ItemIcon;
                if (string.IsNullOrEmpty(itemIcon))
                {
                    itemIcon = "Default.gif";
                }
                image.Icon = itemIcon;
                if (dataItem.LinkType != 0)
                {
                    image.IsShowLink = true;
                }
                if (!this.m_Administrator)
                {
                    string str3 = this.nodeId.ToString();
                    if (cacheNodeById.IsNull)
                    {
                        cacheNodeById = Nodes.GetCacheNodeById(this.nodeId);
                    }
                    if (cacheNodeById.ParentId > 0)
                    {
                        str3 = str3 + "," + cacheNodeById.ParentPath;
                    }
                    if (!RolePermissions.CheckNodePurview(str3, this.m_arrContentNodeIdManage))
                    {
                        ((LinkButton) e.Row.FindControl("DeleteContent")).Enabled = false;
                        ((LinkButton) e.Row.FindControl("RestoreContent")).Enabled = false;
                    }
                }
            }
        }

        protected string GetStatusShow(string status)
        {
            int num = DataConverter.CLng(status);
            switch (num)
            {
                case -3:
                    return "回收站中";

                case -2:
                    return "退稿";

                case -1:
                    return "草稿";

                case 0:
                    return "待审核";

                case 0x63:
                    return "终审通过";
            }
            return "审核中";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (PEContext.Current.Admin.IsSuperAdmin)
            {
                this.m_Administrator = true;
            }
            this.nodeId = BasePage.RequestInt32("NodeID");
            if (!base.IsPostBack)
            {
                NodeInfo cacheNodeById = new NodeInfo(true);
                if (this.nodeId > 0)
                {
                    this.SmpNavigator.AdditionalNode = Nodes.ShowNodeNavigation(this.nodeId, "ContentRecycle.aspx");
                    cacheNodeById = Nodes.GetCacheNodeById(this.nodeId);
                    this.BtnClear.Text = "清空" + cacheNodeById.NodeName + "下的信息";
                    this.BtnRecycle.Text = "还原" + cacheNodeById.NodeName + "下的信息";
                }
                this.DropRescentQuery.SelectedValue = BasePage.RequestStringToLower("ListType");
                this.HdnListType.Value = BasePage.RequestStringToLower("ListType");
                if (!this.m_Administrator)
                {
                    this.m_arrContentNodeIdManage = RolePermissions.GetRoleNodeId(PEContext.Current.Admin.Roles, OperateCode.NodeContentManage);
                    bool flag = false;
                    if (this.nodeId > 0)
                    {
                        string str = this.nodeId.ToString();
                        if (cacheNodeById.IsNull)
                        {
                            AdminPage.WriteErrMsg("当前栏目不存在,可能被删除了请返回!");
                        }
                        if (cacheNodeById.ParentId > 0)
                        {
                            str = str + "," + cacheNodeById.ParentPath;
                        }
                        if (RolePermissions.CheckNodePurview(this.m_arrContentNodeIdManage, str))
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        flag = RolePermissions.AccessCheckNodePermission(OperateCode.NodeContentManage, -1);
                    }
                    if (!flag)
                    {
                        this.EBtnDelete.Enabled = false;
                        this.EBtnRestore.Enabled = false;
                        this.BtnClear.Enabled = false;
                        this.BtnRecycle.Enabled = false;
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

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