Ejemplo n.º 1
0
        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 + ContentManage.ContentHtmlName(info2, cacheNodeById, 0);
                    if (FileSystemObject.IsExist(file, FsoMethod.File))
                    {
                        FileSystemObject.Delete(file, FsoMethod.File);
                    }
                    DateTime?createTime = null;
                    ContentManage.UpdateCreateTime(info2.GeneralId, createTime);
                }
            }
        }
Ejemplo n.º 2
0
 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             = "";
         int      length        = 0;
         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);
                 }
             }
             ExtendedHyperLink link = e.Row.FindControl("LnkNodeLink") as ExtendedHyperLink;
             link.BeginTag    = "<strong>[";
             link.Text        = s;
             link.EndTag      = "]</strong>";
             link.NavigateUrl = "ContentHtml.aspx?NodeID=" + commonModelInfo.NodeId.ToString() + "&NodeName=" + base.Server.UrlEncode(s);
             length           = StringHelper.SubStringLength(s) + 2;
         }
         LinkImage image    = e.Row.FindControl("LinkImageModel") as LinkImage;
         string    itemIcon = ModelManager.GetCacheModelById(commonModelInfo.ModelId).ItemIcon;
         if (string.IsNullOrEmpty(itemIcon))
         {
             itemIcon = "Default.gif";
         }
         image.Icon = itemIcon;
         if (commonModelInfo.LinkType != 0)
         {
             image.IsShowLink = true;
         }
         HyperLink link2 = e.Row.FindControl("HypTitle") as HyperLink;
         if (this.m_ModelPreviewDictionary.ContainsKey(commonModelInfo.ModelId))
         {
             link2.NavigateUrl = this.m_ModelPreviewDictionary[commonModelInfo.ModelId] + "?GeneralID=" + commonModelInfo.GeneralId;
         }
         else
         {
             ModelInfo modelInfoById = ModelManager.GetModelInfoById(commonModelInfo.ModelId);
             link2.NavigateUrl = modelInfoById.PreviewInfoFilePath + "?GeneralID=" + commonModelInfo.GeneralId;
             this.m_ModelPreviewDictionary.Add(commonModelInfo.ModelId, modelInfoById.PreviewInfoFilePath);
         }
         commonModelInfo.Title = commonModelInfo.Title;
         length        = 0x25 - length;
         link2.Text    = StringHelper.SubString(commonModelInfo.Title, length, "...");
         link2.ToolTip = commonModelInfo.Title;
         Label label = e.Row.FindControl("LblIsCreateHtml") as Label;
         if (!commonModelInfo.CreateTime.HasValue || (commonModelInfo.CreateTime.Value <= commonModelInfo.UpdateTime))
         {
             label.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);
                 }
             }
             label.Text = "<b>√</b>";
             string str3 = (SiteConfig.SiteInfo.VirtualPath + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + ContentManage.ContentHtmlName(commonModelInfo, cacheNodeById, 0)).Replace("//", "/");
             ((HyperLink)e.Row.FindControl("LnkHtmlView")).NavigateUrl = str3;
         }
         if (!this.m_Administrator)
         {
             string checkStr = nodeId.ToString();
             if (cacheNodeById.IsNull)
             {
                 cacheNodeById = Nodes.GetCacheNodeById(nodeId);
             }
             if (cacheNodeById.ParentId > 0)
             {
                 checkStr = checkStr + "," + cacheNodeById.ParentPath;
             }
             if (!StringHelper.FoundCharInArr(checkStr, this.m_arrContentNodeIdManage))
             {
                 ((LinkButton)e.Row.FindControl("LnkCreateHtml")).Enabled = false;
                 ((HyperLink)e.Row.FindControl("LnkHtmlView")).Enabled    = false;
                 ((LinkButton)e.Row.FindControl("LnkDeleteHtml")).Enabled = false;
             }
         }
     }
 }
Ejemplo n.º 3
0
        public void CreateContentHtml(CommonModelInfo commonModelInfo)
        {
            NodeInfo cacheNodeById = EasyOne.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);
                }
                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 });
                }
                finally
                {
                    string str      = string.Empty;
                    string pageName = string.Empty;
                    pageNum = templateInfo.PageNum;
                    HtmlAbstract.AddHeardRunatServer(templateInfo, pageName);
                    if (templateInfo.TemplateContent.IndexOf("$$$EasyOne.ChargeTips$$$", StringComparison.Ordinal) > 0)
                    {
                        string newValue = ChargeTipsMessage(commonModelInfo.GeneralId, commonModelInfo.ModelId);
                        templateInfo.TemplateContent = templateInfo.TemplateContent.Replace("$$$EasyOne.ChargeTips$$$", newValue);
                        pageNum = 0;
                    }
                    pageName = ContentManage.ContentHtmlName(commonModelInfo, cacheNodeById, 0);
                    str      = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + pageName;
                    FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + str, templateInfo.TemplateContent);
                    string str4 = (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteInfo.VirtualPath) + str).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=", str4, ">", 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 str5 = ContentManage.ContentHtmlName(commonModelInfo, cacheNodeById, i + 1);
                        HtmlAbstract.AddHeardRunatServer(templateInfo, str5);
                        string str6 = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + str5;
                        FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + str6, templateInfo.TemplateContent);
                        string str7 = (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteInfo.VirtualPath) + str6).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=", str7, ">", commonModelInfo.Title, "</a></li>", this.CreateMessage });
                        if ((i % 20) == 0)
                        {
                            this.CreateMessage = "为了缓解服务器压力,暂停一秒生成";
                            Thread.Sleep(0x3e8);
                        }
                    }
                }
                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 = EasyOne.Contents.Nodes.GetCacheNodeById(-2);
                    category2.CreateNodesHtml(nodeInfo);
                }
            }
        }