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

📄 htmlcontent.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace PowerEasy.StaticHtml
{
    using PowerEasy.Common;
    using PowerEasy.CommonModel;
    using PowerEasy.Components;
    using PowerEasy.Contents;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.CommonModel;
    using PowerEasy.Model.Contents;
    using PowerEasy.Model.TemplateProc;
    using PowerEasy.Templates;
    using System;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Data;
    using System.Web;

    public class HtmlContent : HtmlAbstract
    {
        private IList<CommonModelInfo> m_CommonList;
        private DateTime m_ContentBeginTime;
        private DateTime m_ContentEndTime;
        private string m_ContentGeneralIdArray;
        private int m_ContentMaxId;
        private int m_ContentMinId;
        private bool m_EnableCreateIndexPage;
        private bool m_EnableCreateNodePage;
        private int m_LatestNumber;
        private string m_NodeIdArray;
        private string msg;

        public static string ContentHtmlName(CommonModelInfo commonModelInfo, NodeInfo node, int pageIndex)
        {
            string str = node.ContentPageHtmlRule.ToLower().Replace("{$categorydir}", node.ParentDir + node.NodeDir).Replace("{$year}", commonModelInfo.InputTime.Year.ToString("0000")).Replace("{$month}", commonModelInfo.InputTime.Month.ToString("00")).Replace("{$day}", commonModelInfo.InputTime.Day.ToString("00")).Replace("{$time}", commonModelInfo.InputTime.Hour.ToString("00") + commonModelInfo.InputTime.Minute.ToString("00") + commonModelInfo.InputTime.Second.ToString("00"));
            if (pageIndex > 0)
            {
                return str.Replace("{$infoid}", commonModelInfo.GeneralId.ToString() + "_" + pageIndex.ToString());
            }
            return str.Replace("{$infoid}", commonModelInfo.GeneralId.ToString());
        }

        private static void CreateContenAndNode(NodeInfo nodeInfo, DataTable dataTable)
        {
            if (nodeInfo.IsCreateContentPage)
            {
                CreateContent(dataTable);
            }
        }

        private static void CreateContenAndNodeAndParentNode(NodeInfo nodeInfo, DataTable dataTable)
        {
            CreateContenAndNode(nodeInfo, dataTable);
            if (nodeInfo.IsCreateListPage)
            {
                HtmlCategory category = new HtmlCategory();
                category.NodeIdArray = nodeInfo.NodeId.ToString();
                category.CommonCreateHtml();
            }
            if (nodeInfo.ParentId > 0)
            {
                HtmlCategory category2 = new HtmlCategory();
                category2.NodeIdArray = nodeInfo.ParentPath;
                category2.CommonCreateHtml();
            }
        }

        private static void CreateContenAndNodeAndParentNodeExtracted(IList<NodeInfo> nodeList)
        {
            HtmlCategory category = new HtmlCategory();
            foreach (NodeInfo info in nodeList)
            {
                if (info.IsCreateListPage)
                {
                    category.CreateNodesHtml(info);
                }
            }
        }

        private static void CreateContent(DataTable dataTable)
        {
            int generalId = GetGeneralId(dataTable);
            HtmlContent content = new HtmlContent();
            content.CreateMethod = CreateContentType.CreateByGeneralId;
            content.NodeIdArray = string.Empty;
            content.ContentGeneralIdArray = generalId.ToString();
            content.CommonCreateHtml();
        }

        private static void CreateContentAndNodeAndParentNodeAndSpecial(NodeInfo nodeInfo, DataTable dataTable)
        {
            CreateContenAndNodeAndParentNode(nodeInfo, dataTable);
            string filterExpression = "FieldLevel=1 AND FieldName = 'specialid'";
            DataRow[] rowArray = dataTable.Select(filterExpression);
            if (rowArray.Length > 0)
            {
                int specialId = DataConverter.CLng(rowArray[0]["specialid"].ToString());
                if (Special.GetSpecialInfoById(specialId).IsCreateListPage)
                {
                    HtmlSpecial special = new HtmlSpecial();
                    special.SpecialIdArray = specialId.ToString();
                    special.CommonCreateHtml();
                }
            }
        }

        private static void CreateContentAndRelateNode(NodeInfo nodeInfo, DataTable dataTable)
        {
            if (!string.IsNullOrEmpty(nodeInfo.RelateNode))
            {
                HtmlCategory category = new HtmlCategory();
                category.NodeIdArray = nodeInfo.RelateNode;
                category.CommonCreateHtml();
            }
            if (!string.IsNullOrEmpty(nodeInfo.RelateSpecial))
            {
                HtmlSpecial special = new HtmlSpecial();
                special.SpecialIdArray = nodeInfo.RelateSpecial;
                special.CommonCreateHtml();
            }
            CreateContent(dataTable);
        }

        public void CreateContentHtml(CommonModelInfo commonModelInfo)
        {
            NodeInfo cacheNodeById = PowerEasy.Contents.Nodes.GetCacheNodeById(commonModelInfo.NodeId);
            if (cacheNodeById.IsCreateContentPage && (cacheNodeById.PurviewType <= 0))
            {
                TemplateInfo templateInfo = new TemplateInfo();
                NameValueCollection values = new NameValueCollection();
                values.Add("id", commonModelInfo.GeneralId.ToString());
                values.Add("page", "1");
                templateInfo.QueryList = values;
                templateInfo.CurrentPage = 1;
                templateInfo.RootPath = this.PhysicalApplicationPath;
                templateInfo.SiteUrl = this.SiteUrl;
                templateInfo.IsDynamicPage = false;
                templateInfo.PageType = 0;
                templateInfo.PageName = this.TemplatePageName(commonModelInfo, cacheNodeById);
                templateInfo.TemplateContent = Template.GetTemplateContent(ItemTemplateFilePath(commonModelInfo), this.PhysicalApplicationPath);
                int pageNum = 0;
                try
                {
                    TemplateTransform.GetHtml(templateInfo);
                    pageNum = templateInfo.PageNum;
                    string pageName = ContentHtmlName(commonModelInfo, cacheNodeById, 0);
                    HtmlAbstract.AddHeardRunatServer(templateInfo, pageName);
                    string str2 = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + pageName;
                    FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + str2, templateInfo.TemplateContent);
                    string str3 = (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteInfo.VirtualPath) + str2).Replace("//", "/");
                    this.CreateMessage = string.Concat(new object[] { "<li>成功生成第<font color='blue'><b>", this.CreateCompleted + 1, "</b></font>条信息。&nbsp;&nbsp;ID:", commonModelInfo.GeneralId.ToString(), "&nbsp;&nbsp;标题:<a target=_blank href=", str3, ">", commonModelInfo.Title, "</a></li>", this.CreateMessage });
                }
                catch
                {
                    this.CreateMessage = string.Concat(new object[] { "<li>第<font color='red'><b>", this.CreateCompleted + 1, "</b></font>条信息生成失败。&nbsp;&nbsp;ID:", commonModelInfo.GeneralId.ToString(), "&nbsp;&nbsp;标题:<a target=_blank href=#>", commonModelInfo.Title, "</a>内容解析出现异常,跳过生成</li>", this.CreateMessage });
                }
                if (pageNum > 1)
                {
                    for (int i = 1; i < pageNum; i++)
                    {
                        templateInfo.TemplateContent = Template.GetTemplateContent(ItemTemplateFilePath(commonModelInfo), this.PhysicalApplicationPath);
                        values = new NameValueCollection();
                        values.Add("id", commonModelInfo.GeneralId.ToString());
                        values.Add("page", (i + 1).ToString());
                        templateInfo.QueryList = values;
                        templateInfo.PageName = this.TemplatePageName(commonModelInfo, cacheNodeById);
                        templateInfo.CurrentPage = i + 1;
                        TemplateTransform.GetHtml(templateInfo);
                        string str4 = ContentHtmlName(commonModelInfo, cacheNodeById, i + 1);
                        HtmlAbstract.AddHeardRunatServer(templateInfo, str4);
                        string str5 = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + str4;
                        FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + str5, templateInfo.TemplateContent);
                        string str6 = (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteInfo.VirtualPath) + str5).Replace("//", "/");
                        this.CreateMessage = string.Concat(new object[] { "<li>成功生成第<font color='blue'><b>", this.CreateCompleted + 1, "</b></font>篇文章的第<font color='red'><b>", i, "</b></font>个分页。。&nbsp;&nbsp;ID:", commonModelInfo.GeneralId.ToString(), "&nbsp;&nbsp;标题:<a target=_blank href=", str6, ">", commonModelInfo.Title, "</a></li>", this.CreateMessage });
                    }
                }
                this.CreateMessage = this.CreateMessage + this.msg;
                this.msg = "";
                ContentManage.UpdateCreateTime(commonModelInfo.GeneralId, new DateTime?(DateTime.Now));
                if (this.m_EnableCreateNodePage)
                {
                    HtmlCategory category = new HtmlCategory();
                    category.PhysicalApplicationPath = this.PhysicalApplicationPath;
                    category.SiteUrl = this.SiteUrl;
                    category.CreateNodesHtml(cacheNodeById);
                }
                if (this.m_EnableCreateIndexPage)
                {
                    HtmlCategory category2 = new HtmlCategory();
                    category2.PhysicalApplicationPath = this.PhysicalApplicationPath;
                    category2.SiteUrl = this.SiteUrl;
                    NodeInfo nodeInfo = PowerEasy.Contents.Nodes.GetCacheNodeById(-2);
                    category2.CreateNodesHtml(nodeInfo);
                }
            }
        }

        public static void CreateHtml(DataTable dataTable)
        {
            string filterExpression = "FieldLevel=0 AND FieldName = 'Status'";
            DataRow[] rowArray = dataTable.Select(filterExpression);
            if ((rowArray.Length > 0) && (DataConverter.CLng(rowArray[0]["FieldValue"].ToString()) == 0x63))
            {
                rowArray = dataTable.Select("FieldLevel=0 AND FieldName = 'NodeId'");
                if (rowArray.Length != 0)
                {
                    NodeInfo cacheNodeById = PowerEasy.Contents.Nodes.GetCacheNodeById(DataConverter.CLng(rowArray[0]["FieldValue"]));
                    if (cacheNodeById.IsCreateContentPage)
                    {
                        GetGeneralId(dataTable);
                        switch (cacheNodeById.AutoCreateHtmlType)
                        {
                            case AutoCreateHtmlType.None:
                                return;

                            case AutoCreateHtmlType.Content:
                                CreateContent(dataTable);
                                return;

                            case AutoCreateHtmlType.ContentAndNode:
                                CreateContenAndNode(cacheNodeById, dataTable);
                                return;

                            case AutoCreateHtmlType.ContentAndNodeAndParentNode:
                                CreateContenAndNodeAndParentNode(cacheNodeById, dataTable);
                                return;

                            case AutoCreateHtmlType.ContentAndNodeAndParentNodeAndSpecial:
                                CreateContentAndNodeAndParentNodeAndSpecial(cacheNodeById, dataTable);
                                return;

⌨️ 快捷键说明

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