📄 producthtml.aspx.cs
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
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.StaticHtml;
using PowerEasy.Web.UI;
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class ProductHtml : AdminPage
{
protected Button BtnCreate;
protected Button BtnCreateAll;
protected Button BtnDelete;
protected DropDownList DropRescentQuery;
protected ExtendedGridView EgvContents;
protected HiddenField HdnCreated;
protected HiddenField HdnListType;
private bool m_Administrator;
private string m_arrContentNodeIdManage = "";
protected Dictionary<int, NodeInfo> m_NodeNameDictionary = new Dictionary<int, NodeInfo>();
protected ObjectDataSource OdsContents;
protected RadioButtonList RadlCreated;
protected ScriptManager ScriptManageContent;
protected ExtendedSiteMapPath SmpNavigator;
protected void BtnCreate_Click(object sender, EventArgs e)
{
HtmlContent content = new HtmlContent();
content.CreateMethod = CreateContentType.CreateByGeneralId;
content.NodeIdArray = string.Empty;
content.ContentGeneralIdArray = this.EgvContents.SelectList.ToString();
content.CommonCreateHtml();
BasePage.ResponseRedirect("CreateHtmlProgress.aspx?workId=" + content.CreateId);
}
protected void BtnCreateAll_Click(object sender, EventArgs e)
{
HtmlContent content = new HtmlContent();
content.CreateMethod = CreateContentType.CreateAll;
content.NodeIdArray = BasePage.RequestString("NodeID", string.Empty);
content.CommonCreateHtml();
BasePage.ResponseRedirect("CreateHtmlProgress.aspx?workId=" + content.CreateId);
}
protected void BtnDelete_Click(object sender, EventArgs e)
{
this.DeleteHtml(this.EgvContents.SelectList.ToString());
this.EgvContents.DataBind();
}
private void DeleteHtml(string generalId)
{
IList<CommonModelInfo> commonModelInfoList = ContentManage.GetCommonModelInfoList(BasePage.RequestString("NodeID"), generalId);
string str = base.Server.MapPath("~/" + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath));
foreach (CommonModelInfo info2 in commonModelInfoList)
{
string file = str;
if (info2.CreateTime.HasValue && (info2.CreateTime.Value >= info2.UpdateTime))
{
NodeInfo cacheNodeById = Nodes.GetCacheNodeById(info2.NodeId);
file = file + HtmlContent.ContentHtmlName(info2, cacheNodeById, 0);
if (FileSystemObject.IsExist(file, FsoMethod.File))
{
FileSystemObject.Delete(file, FsoMethod.File);
}
DateTime? createTime = null;
ContentManage.UpdateCreateTime(info2.GeneralId, createTime);
}
}
}
protected void DropSelectedIndex_Changed(object sender, EventArgs e)
{
this.HdnListType.Value = this.DropRescentQuery.SelectedValue;
this.EgvContents.PageIndex = 0;
}
protected void EgvContents_RowCommand(object sender, CommandEventArgs e)
{
int num = DataConverter.CLng(e.CommandArgument.ToString());
string commandName = e.CommandName;
if (commandName != null)
{
if (!(commandName == "CreateHtml"))
{
if (!(commandName == "DeleteHtml"))
{
return;
}
}
else
{
HtmlContent content = new HtmlContent();
content.CreateMethod = CreateContentType.CreateByGeneralId;
content.NodeIdArray = string.Empty;
content.ContentGeneralIdArray = e.CommandArgument.ToString();
content.CommonCreateHtml();
BasePage.ResponseRedirect("CreateHtmlProgress.aspx?workId=" + content.CreateId);
return;
}
this.DeleteHtml(num.ToString());
this.EgvContents.DataBind();
}
}
protected void EgvContents_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CommonModelInfo commonModelInfo = new CommonModelInfo();
commonModelInfo = (CommonModelInfo) e.Row.DataItem;
int nodeId = BasePage.RequestInt32("NodeID");
string s = "";
NodeInfo cacheNodeById = new NodeInfo(true);
if (commonModelInfo.NodeId != nodeId)
{
nodeId = commonModelInfo.NodeId;
if (this.m_NodeNameDictionary.ContainsKey(commonModelInfo.NodeId))
{
cacheNodeById = this.m_NodeNameDictionary[commonModelInfo.NodeId];
s = cacheNodeById.NodeName;
}
else
{
cacheNodeById = Nodes.GetCacheNodeById(commonModelInfo.NodeId);
if (cacheNodeById != null)
{
s = cacheNodeById.NodeName;
this.m_NodeNameDictionary.Add(commonModelInfo.NodeId, cacheNodeById);
}
}
Label label = e.Row.FindControl("LblNodeLink") as Label;
label.Text = "<strong>[<a href=\"ProductHtml.aspx?NodeID=" + commonModelInfo.NodeId.ToString() + "&NodeName=" + base.Server.UrlEncode(s) + "\">" + s + "</a>]</strong>";
}
Image image = e.Row.FindControl("ImgItemIcon") as Image;
string itemIcon = ModelManager.GetCacheModelById(commonModelInfo.ModelId).ItemIcon;
if (string.IsNullOrEmpty(itemIcon))
{
itemIcon = "Product.gif";
}
image.ImageUrl = "~/Images/ModelIcon/" + itemIcon;
if (commonModelInfo.LinkType == 0)
{
e.Row.FindControl("PlhLink").Visible = false;
}
Label label2 = e.Row.FindControl("LblIsCreateHtml") as Label;
if (!commonModelInfo.CreateTime.HasValue || (commonModelInfo.CreateTime.Value <= commonModelInfo.UpdateTime))
{
label2.Text = "<span style=\"color:Red\"><b>\x00d7</b></span>";
((HyperLink) e.Row.FindControl("LnkHtmlView")).Enabled = false;
((LinkButton) e.Row.FindControl("LnkDeleteHtml")).Enabled = false;
}
else
{
if (this.m_NodeNameDictionary.ContainsKey(commonModelInfo.NodeId))
{
cacheNodeById = this.m_NodeNameDictionary[commonModelInfo.NodeId];
}
else
{
cacheNodeById = Nodes.GetCacheNodeById(commonModelInfo.NodeId);
if (!cacheNodeById.IsNull)
{
s = cacheNodeById.NodeName;
this.m_NodeNameDictionary.Add(commonModelInfo.NodeId, cacheNodeById);
}
}
label2.Text = "<b>√</b>";
((HyperLink) e.Row.FindControl("LnkHtmlView")).NavigateUrl = "~/" + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + HtmlContent.ContentHtmlName(commonModelInfo, cacheNodeById, 0);
}
if (!this.m_Administrator)
{
string str3 = nodeId.ToString();
if (cacheNodeById.IsNull)
{
cacheNodeById = Nodes.GetCacheNodeById(nodeId);
}
if (cacheNodeById.ParentId > 0)
{
str3 = str3 + "," + cacheNodeById.ParentPath;
}
if (!RolePermissions.CheckNodePurview(str3, this.m_arrContentNodeIdManage))
{
((LinkButton) e.Row.FindControl("LnkCreateHtml")).Enabled = false;
((HyperLink) e.Row.FindControl("LnkHtmlView")).Enabled = false;
((LinkButton) e.Row.FindControl("LnkDeleteHtml")).Enabled = false;
}
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (PEContext.Current.Admin.IsSuperAdmin)
{
this.m_Administrator = true;
}
if (!base.IsPostBack)
{
int nodeId = BasePage.RequestInt32("NodeID");
if (nodeId > 0)
{
this.SmpNavigator.AdditionalNode = Nodes.ShowNodeNavigation(nodeId, "ProductHtml.aspx");
}
if (!this.m_Administrator)
{
this.m_arrContentNodeIdManage = RolePermissions.GetRoleNodeId(PEContext.Current.Admin.Roles, OperateCode.NodeContentManage);
bool flag = false;
if (nodeId > 0)
{
string str = nodeId.ToString();
NodeInfo cacheNodeById = Nodes.GetCacheNodeById(nodeId);
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.BtnCreateAll.Enabled = false;
this.BtnCreate.Enabled = false;
this.BtnDelete.Enabled = false;
}
}
}
}
protected void RadlCreated_SelectedIndexChanged(object sender, EventArgs e)
{
this.HdnCreated.Value = this.RadlCreated.SelectedValue;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -