Ejemplo n.º 1
0
        public static void ParseStl(PublishmentSystemInfo publishmentSystemInfo, PageInfo pageInfo, ContextInfo contextInfo, StringBuilder contentBuilder, string filePath, bool isDynamic)
        {
            if (contentBuilder.Length > 0)
            {
                StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo);
            }

            if (EFileSystemTypeUtils.IsHtml(PathUtils.GetExtension(filePath)))
            {
                if (pageInfo.TemplateInfo.TemplateType != ETemplateType.FileTemplate)
                {
                    AddSeoMetaToContent(pageInfo, contentBuilder);
                }

                AddAdvertisementsToContent(pageInfo);

                if (isDynamic)
                {
                    var    pageUrl        = PageUtils.AddProtocolToUrl(PageUtility.GetPublishmentSystemUrlByPhysicalPath(publishmentSystemInfo, filePath));
                    string templateString = $@"
<base href=""{pageUrl}"" />";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateBrowserNoCache)
                {
                    const string templateString = @"
<META HTTP-EQUIV=""Pragma"" CONTENT=""no-cache"">
<META HTTP-EQUIV=""Expires"" CONTENT=""-1"">";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateIe8Compatible)
                {
                    const string templateString = @"
<META HTTP-EQUIV=""x-ua-compatible"" CONTENT=""ie=7"" />";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateJsIgnoreError)
                {
                    const string templateString = @"
<script type=""text/javascript"">window.onerror=function(){return true;}</script>";
                    StringUtils.InsertAfter(new[] { "<head>", "<HEAD>" }, contentBuilder, templateString);
                }

                if (pageInfo.PageContentId > 0 && pageInfo.PublishmentSystemInfo.Additional.IsCountHits && !pageInfo.IsPageScriptsExists(PageInfo.JsAdStlCountHits))
                {
                    pageInfo.AddPageEndScriptsIfNotExists(PageInfo.JsAdStlCountHits, $@"
<script src=""{ActionsAddContentHits.GetUrl(pageInfo.ApiUrl, pageInfo.PublishmentSystemId, pageInfo.PageNodeId, pageInfo.PageContentId)}"" type=""text/javascript""></script>");
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsTracker && !pageInfo.IsPageScriptsExists(PageInfo.JsAdAddTracker))
                {
                    pageInfo.AddPageEndScriptsIfNotExists(PageInfo.JsAdAddTracker, $@"
<script src=""{SiteFilesAssets.Tracker.GetScriptUrl(pageInfo.ApiUrl)}"" type=""text/javascript""></script>
<script type=""text/javascript"">AddTrackerCount('{ActionsAddTrackerCount.GetUrl(pageInfo.ApiUrl, pageInfo.PublishmentSystemId, pageInfo.PageNodeId, pageInfo.PageContentId)}', {pageInfo.PublishmentSystemId});</script>");
                }

                var headScripts = StlParserManager.GetPageInfoHeadScript(pageInfo, contextInfo);
                if (!string.IsNullOrEmpty(headScripts))
                {
                    if (contentBuilder.ToString().IndexOf("</head>", StringComparison.Ordinal) != -1 || contentBuilder.ToString().IndexOf("</HEAD>", StringComparison.Ordinal) != -1)
                    {
                        StringUtils.InsertBefore(new[] { "</head>", "</HEAD>" }, contentBuilder, headScripts);
                    }
                    else
                    {
                        contentBuilder.Insert(0, headScripts);
                    }
                }

                var afterBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, true);

                if (!string.IsNullOrEmpty(afterBodyScripts))
                {
                    if (contentBuilder.ToString().IndexOf("<body", StringComparison.Ordinal) != -1 || contentBuilder.ToString().IndexOf("<BODY", StringComparison.Ordinal) != -1)
                    {
                        var index = contentBuilder.ToString().IndexOf("<body", StringComparison.Ordinal);
                        if (index == -1)
                        {
                            index = contentBuilder.ToString().IndexOf("<BODY", StringComparison.Ordinal);
                        }
                        index = contentBuilder.ToString().IndexOf(">", index, StringComparison.Ordinal);
                        contentBuilder.Insert(index + 1, StringUtils.Constants.ReturnAndNewline + afterBodyScripts + StringUtils.Constants.ReturnAndNewline);
                    }
                    else
                    {
                        contentBuilder.Insert(0, afterBodyScripts);
                    }
                }

                var beforeBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, false);

                if (!string.IsNullOrEmpty(beforeBodyScripts))
                {
                    if (contentBuilder.ToString().IndexOf("</body>", StringComparison.Ordinal) != -1 || contentBuilder.ToString().IndexOf("</BODY>", StringComparison.Ordinal) != -1)
                    {
                        var index = contentBuilder.ToString().IndexOf("</body>", StringComparison.Ordinal);
                        if (index == -1)
                        {
                            index = contentBuilder.ToString().IndexOf("</BODY>", StringComparison.Ordinal);
                        }
                        contentBuilder.Insert(index, StringUtils.Constants.ReturnAndNewline + beforeBodyScripts + StringUtils.Constants.ReturnAndNewline);
                    }
                    else
                    {
                        contentBuilder.Append(beforeBodyScripts);
                    }
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateDoubleClick)
                {
                    var fileTemplateId = 0;
                    if (pageInfo.TemplateInfo.TemplateType == ETemplateType.FileTemplate)
                    {
                        fileTemplateId = pageInfo.TemplateInfo.TemplateId;
                    }
                    var ajaxUrl = ActionsTrigger.GetUrl(pageInfo.PublishmentSystemInfo.Additional.ApiUrl, pageInfo.PublishmentSystemId, contextInfo.ChannelID, contextInfo.ContentID, fileTemplateId, true);
                    pageInfo.AddPageEndScriptsIfNotExists("CreateDoubleClick", $@"
<script type=""text/javascript"" language=""javascript"">document.ondblclick=function(x){{location.href = '{ajaxUrl}';}}</script>");
                }

                if (pageInfo.PageEndScriptKeys.Count > 0)
                {
                    var endScriptBuilder = new StringBuilder();
                    foreach (string scriptKey in pageInfo.PageEndScriptKeys)
                    {
                        endScriptBuilder.Append(pageInfo.GetPageEndScripts(scriptKey));
                    }
                    endScriptBuilder.Append(StringUtils.Constants.ReturnAndNewline);

                    //contentBuilder.Append(endScriptBuilder.ToString());
                    //StringUtils.InsertBeforeOrAppend(new string[] { "</body>", "</BODY>" }, contentBuilder, endScriptBuilder.ToString());
                    StringUtils.InsertAfterOrAppend(new[] { "</html>", "</html>" }, contentBuilder, endScriptBuilder.ToString());
                }

                if (pageInfo.PublishmentSystemInfo.Additional.IsCreateShowPageInfo)
                {
                    contentBuilder.Append($@"
<!-- {pageInfo.TemplateInfo.RelatedFileName}({ETemplateTypeUtils.GetText(pageInfo.TemplateInfo.TemplateType)}) -->");
                }
            }
        }
Ejemplo n.º 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            _templateType = Body.GetQueryString("templateType");
            _keywords     = Body.GetQueryString("keywords");

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdTemplate, "模板管理", AppManager.Cms.Permission.WebSite.Template);

                DdlTemplateType.Items.Add(new ListItem("<所有类型>", string.Empty));
                ETemplateTypeUtils.AddListItems(DdlTemplateType);
                ControlUtils.SelectListItems(DdlTemplateType, _templateType);

                TbKeywords.Text = _keywords;

                if (Body.IsQueryExists("Delete"))
                {
                    var templateId = Body.GetQueryInt("TemplateID");

                    try
                    {
                        var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                        if (templateInfo != null)
                        {
                            DataProvider.TemplateDao.Delete(PublishmentSystemId, templateId);
                            Body.AddSiteLog(PublishmentSystemId,
                                            $"删除{ETemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                            $"模板名称:{templateInfo.TemplateName}");
                        }
                        SuccessDeleteMessage();
                    }
                    catch (Exception ex)
                    {
                        FailDeleteMessage(ex);
                    }
                }
                else if (Body.IsQueryExists("SetDefault"))
                {
                    var templateId = Body.GetQueryInt("TemplateID");

                    try
                    {
                        var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                        if (templateInfo != null)
                        {
                            DataProvider.TemplateDao.SetDefault(PublishmentSystemId, templateId);
                            Body.AddSiteLog(PublishmentSystemId,
                                            $"设置默认{ETemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                            $"模板名称:{templateInfo.TemplateName}");
                        }
                        SuccessMessage();
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "操作失败");
                    }
                }

                if (string.IsNullOrEmpty(_templateType))
                {
                    LtlCommands.Text = $@"
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.IndexPageTemplate)}';"" value=""添加首页模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.ChannelTemplate)}';"" value=""添加栏目模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.ContentTemplate)}';"" value=""添加内容模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.FileTemplate)}';"" value=""添加单页模板"" />
";
                }
                else
                {
                    var eTemplateType = ETemplateTypeUtils.GetEnumType(_templateType);
                    LtlCommands.Text = $@"
<input type=""button"" class=""btn btn-success"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, eTemplateType)}';"" value=""添加{ETemplateTypeUtils.GetText(eTemplateType)}"" />
";
                }

                DgContents.DataSource     = DataProvider.TemplateDao.GetDataSource(PublishmentSystemId, _keywords, _templateType);
                DgContents.ItemDataBound += DgContents_ItemDataBound;
                DgContents.DataBind();
            }
        }
Ejemplo n.º 3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            TemplateInfo templateInfo = null;

            if (Body.GetQueryInt("TemplateID") > 0)
            {
                var templateId = Body.GetQueryInt("TemplateID");
                _isCopy      = Body.GetQueryBool("IsCopy");
                templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                if (templateInfo != null)
                {
                    _theTemplateType = templateInfo.TemplateType;
                }
            }
            else
            {
                _theTemplateType = ETemplateTypeUtils.GetEnumType(Request.QueryString["TemplateType"]);
            }
            TemplateTypeString = ETemplateTypeUtils.GetText(_theTemplateType);

            if (_theTemplateType == ETemplateType.IndexPageTemplate || _theTemplateType == ETemplateType.FileTemplate)
            {
                CreatedFileFullNameRow.Visible = true;
            }
            else
            {
                CreatedFileFullNameRow.Visible = false;
            }

            if (!IsPostBack)
            {
                var pageTitle = Body.GetQueryInt("TemplateID") > 0 ? "编辑模板" : "添加模板";
                BreadCrumb(AppManager.Cms.LeftMenu.IdTemplate, pageTitle, AppManager.Cms.Permission.WebSite.Template);

                ltlPageTitle.Text = pageTitle;

                var isCodeMirror = PublishmentSystemInfo.Additional.ConfigTemplateIsCodeMirror;
                btnEditorType.Text   = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
                phCodeMirror.Visible = isCodeMirror;

                EFileSystemTypeUtils.AddWebPageListItems(CreatedFileExtNameDropDownList);

                ECharsetUtils.AddListItems(Charset);

                if (Body.GetQueryInt("TemplateID") > 0)
                {
                    if (templateInfo != null)
                    {
                        Content.Text = StlCacheManager.FileContent.GetTemplateContent(PublishmentSystemInfo, templateInfo);

                        if (_isCopy)
                        {
                            TemplateName.Text        = templateInfo.TemplateName + "_复件";
                            RelatedFileName.Text     = PathUtils.RemoveExtension(templateInfo.RelatedFileName) + "_复件";
                            CreatedFileFullName.Text = PathUtils.RemoveExtension(templateInfo.CreatedFileFullName) + "_复件";
                        }
                        else
                        {
                            TemplateName.Text        = templateInfo.TemplateName;
                            RelatedFileName.Text     = PathUtils.RemoveExtension(templateInfo.RelatedFileName);
                            CreatedFileFullName.Text = PathUtils.RemoveExtension(templateInfo.CreatedFileFullName);

                            LtlCommands.Text +=
                                $@"<a href=""javascript:;"" class=""btn btn-info"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(PublishmentSystemId, templateInfo.TemplateId)}"">生成页面</a><a href=""javascript:;"" class=""btn btn-info"" onclick=""{ModalTemplateRestore.GetOpenLayerString(PublishmentSystemId, templateInfo.TemplateId, string.Empty)}"">还原历史版本</a>";

                            if (Body.GetQueryInt("TemplateLogID") > 0)
                            {
                                var templateLogId = Body.GetQueryInt("TemplateLogID");
                                if (templateLogId > 0)
                                {
                                    Content.Text = DataProvider.TemplateLogDao.GetTemplateContent(templateLogId);
                                    SuccessMessage("已导入历史版本的模板内容,点击确定保存模板");
                                }
                            }
                        }

                        ControlUtils.SelectListItemsIgnoreCase(Charset, ECharsetUtils.GetValue(templateInfo.Charset));

                        ControlUtils.SelectListItems(CreatedFileExtNameDropDownList, GetTemplateFileExtension(templateInfo));
                        TemplateType.Value = ETemplateTypeUtils.GetValue(templateInfo.TemplateType);
                    }
                }
                else
                {
                    RelatedFileName.Text = "T_";
                    if (_theTemplateType == ETemplateType.ChannelTemplate)
                    {
                        CreatedFileFullName.Text = "index";
                    }
                    else
                    {
                        CreatedFileFullName.Text = "@/";
                    }
                    ControlUtils.SelectListItemsIgnoreCase(Charset, PublishmentSystemInfo.Additional.Charset);
                    ControlUtils.SelectListItems(CreatedFileExtNameDropDownList, EFileSystemTypeUtils.GetValue(EFileSystemType.Html));
                    TemplateType.Value = Body.GetQueryString("TemplateType");
                }
            }
        }
Ejemplo n.º 4
0
        private void DgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var templateId          = SqlUtils.EvalInt(e.Item.DataItem, "TemplateID");
                var templateType        = ETemplateTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, "TemplateType"));
                var templateName        = SqlUtils.EvalString(e.Item.DataItem, "TemplateName");
                var createdFileFullName = SqlUtils.EvalString(e.Item.DataItem, "CreatedFileFullName");
                var isDefault           = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, "IsDefault"));

                var ltlTemplateName = (Literal)e.Item.FindControl("ltlTemplateName");
                var ltlFileName     = (Literal)e.Item.FindControl("ltlFileName");
                var ltlUseCount     = (Literal)e.Item.FindControl("ltlUseCount");
                var ltlTemplateType = (Literal)e.Item.FindControl("ltlTemplateType");
                var ltlDefaultUrl   = (Literal)e.Item.FindControl("ltlDefaultUrl");
                var ltlCopyUrl      = (Literal)e.Item.FindControl("ltlCopyUrl");
                var ltlLogUrl       = (Literal)e.Item.FindControl("ltlLogUrl");
                var ltlCreateUrl    = (Literal)e.Item.FindControl("ltlCreateUrl");
                var ltlDeleteUrl    = (Literal)e.Item.FindControl("ltlDeleteUrl");

                var templateAddUrl = PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, templateId, templateType);
                ltlTemplateName.Text = $@"<a href=""{templateAddUrl}"">{templateName}</a>";

                if (templateType == ETemplateType.IndexPageTemplate || templateType == ETemplateType.FileTemplate)
                {
                    var url = PageUtility.ParseNavigationUrl(PublishmentSystemInfo, createdFileFullName);
                    ltlFileName.Text = $"<a href='{url}' target='_blank'>{createdFileFullName}</a>";
                }

                ltlUseCount.Text = DataProvider.TemplateDao.GetTemplateUseCount(PublishmentSystemId, templateId, templateType, isDefault).ToString();

                ltlTemplateType.Text = ETemplateTypeUtils.GetText(templateType);

                if (templateType != ETemplateType.FileTemplate)
                {
                    if (isDefault)
                    {
                        ltlDefaultUrl.Text = "默认模板";
                    }
                    else
                    {
                        var defaultUrl = PageUtils.GetCmsUrl(nameof(PageTemplate), new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "TemplateID", templateId.ToString() },
                            { "SetDefault", true.ToString() }
                        });
                        ltlDefaultUrl.Text =
                            $@"<a href=""{defaultUrl}"" onClick=""javascript:return confirm('此操作将把此模板设为默认,确认吗?');"">设为默认</a>";
                    }
                }

                var copyUrl = PageTemplateAdd.GetRedirectUrlToCopy(PublishmentSystemId, templateId);
                ltlCopyUrl.Text = $@"<a href=""{copyUrl}"">快速复制</a>";

                var logUrl = PageTemplateLog.GetRedirectUrl(PublishmentSystemId, templateId);
                ltlLogUrl.Text = $@"<a href=""{logUrl}"">修订历史</a>";

                ltlCreateUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(
                        PublishmentSystemId, templateId)}"">生成页面</a>";

                if (!isDefault)
                {
                    var deleteUrl = PageUtils.GetCmsUrl(nameof(PageTemplate), new NameValueCollection
                    {
                        { "PublishmentSystemID", PublishmentSystemId.ToString() },
                        { "TemplateID", templateId.ToString() },
                        { "Delete", true.ToString() }
                    });
                    ltlDeleteUrl.Text =
                        $@"<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除模板“{templateName}”,确认吗?');"">删除</a>";
                }
            }
        }
Ejemplo n.º 5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                if (_theTemplateType != ETemplateType.ChannelTemplate)
                {
                    if (!CreatedFileFullName.Text.StartsWith("~") && !CreatedFileFullName.Text.StartsWith("@"))
                    {
                        CreatedFileFullName.Text = PageUtils.Combine("@", CreatedFileFullName.Text);
                    }
                }
                else
                {
                    CreatedFileFullName.Text = CreatedFileFullName.Text.TrimStart('~', '@');
                    CreatedFileFullName.Text = CreatedFileFullName.Text.Replace("/", string.Empty);
                }

                if (Body.GetQueryInt("TemplateID") > 0 && _isCopy == false)
                {
                    var templateId   = Body.GetQueryInt("TemplateID");
                    var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                    if (templateInfo.TemplateName != TemplateName.Text)
                    {
                        var templateNameArrayList = DataProvider.TemplateDao.GetTemplateNameArrayList(PublishmentSystemId, templateInfo.TemplateType);
                        if (templateNameArrayList.IndexOf(TemplateName.Text) != -1)
                        {
                            FailMessage("模板修改失败,模板名称已存在!");
                            return;
                        }
                    }
                    TemplateInfo previousTemplateInfo = null;
                    var          isChanged            = false;
                    if (PathUtils.RemoveExtension(templateInfo.RelatedFileName) != PathUtils.RemoveExtension(RelatedFileName.Text))//文件名改变
                    {
                        var fileNameArrayList = DataProvider.TemplateDao.GetLowerRelatedFileNameArrayList(PublishmentSystemId, templateInfo.TemplateType);
                        foreach (string fileName in fileNameArrayList)
                        {
                            var fileNameWithoutExtension = PathUtils.RemoveExtension(fileName);
                            if (fileNameWithoutExtension == RelatedFileName.Text.ToLower())
                            {
                                FailMessage("模板修改失败,模板文件已存在!");
                                return;
                            }
                        }

                        isChanged = true;
                    }

                    if (GetTemplateFileExtension(templateInfo) != CreatedFileExtNameDropDownList.SelectedValue)//文件后缀改变
                    {
                        isChanged = true;
                    }

                    if (isChanged)
                    {
                        previousTemplateInfo = new TemplateInfo(templateInfo.TemplateId, templateInfo.PublishmentSystemId, templateInfo.TemplateName, templateInfo.TemplateType, templateInfo.RelatedFileName, templateInfo.CreatedFileFullName, templateInfo.CreatedFileExtName, templateInfo.Charset, templateInfo.IsDefault);
                    }

                    templateInfo.TemplateName        = TemplateName.Text;
                    templateInfo.RelatedFileName     = RelatedFileName.Text + CreatedFileExtNameDropDownList.SelectedValue;
                    templateInfo.CreatedFileExtName  = CreatedFileExtNameDropDownList.SelectedValue;
                    templateInfo.CreatedFileFullName = CreatedFileFullName.Text + CreatedFileExtNameDropDownList.SelectedValue;
                    templateInfo.Charset             = ECharsetUtils.GetEnumType(Charset.SelectedValue);
                    try
                    {
                        DataProvider.TemplateDao.Update(PublishmentSystemInfo, templateInfo, Content.Text, Body.AdministratorName);
                        if (previousTemplateInfo != null)
                        {
                            FileUtils.DeleteFileIfExists(TemplateManager.GetTemplateFilePath(PublishmentSystemInfo, previousTemplateInfo));
                        }
                        CreatePages(templateInfo);

                        Body.AddSiteLog(PublishmentSystemId,
                                        $"修改{ETemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                        $"模板名称:{templateInfo.TemplateName}");

                        SuccessMessage("模板修改成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "模板修改失败," + ex.Message);
                    }
                }
                else
                {
                    var templateNameArrayList = DataProvider.TemplateDao.GetTemplateNameArrayList(PublishmentSystemId, ETemplateTypeUtils.GetEnumType(TemplateType.Value));
                    if (templateNameArrayList.IndexOf(TemplateName.Text) != -1)
                    {
                        FailMessage("模板添加失败,模板名称已存在!");
                        return;
                    }
                    var fileNameArrayList = DataProvider.TemplateDao.GetLowerRelatedFileNameArrayList(PublishmentSystemId, ETemplateTypeUtils.GetEnumType(TemplateType.Value));
                    if (fileNameArrayList.IndexOf(RelatedFileName.Text.ToLower()) != -1)
                    {
                        FailMessage("模板添加失败,模板文件已存在!");
                        return;
                    }

                    var templateInfo = new TemplateInfo();
                    templateInfo.PublishmentSystemId = PublishmentSystemId;
                    templateInfo.TemplateName        = TemplateName.Text;
                    templateInfo.TemplateType        = ETemplateTypeUtils.GetEnumType(TemplateType.Value);

                    templateInfo.RelatedFileName     = RelatedFileName.Text + CreatedFileExtNameDropDownList.SelectedValue;
                    templateInfo.CreatedFileExtName  = CreatedFileExtNameDropDownList.SelectedValue;
                    templateInfo.CreatedFileFullName = CreatedFileFullName.Text + CreatedFileExtNameDropDownList.SelectedValue;
                    templateInfo.Charset             = ECharsetUtils.GetEnumType(Charset.SelectedValue);
                    templateInfo.IsDefault           = false;
                    try
                    {
                        templateInfo.TemplateId = DataProvider.TemplateDao.Insert(templateInfo, Content.Text, Body.AdministratorName);
                        CreatePages(templateInfo);
                        Body.AddSiteLog(PublishmentSystemId,
                                        $"添加{ETemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                        $"模板名称:{templateInfo.TemplateName}");
                        SuccessMessage("模板添加成功!");
                        AddWaitAndRedirectScript(PageTemplate.GetRedirectUrl(PublishmentSystemId));
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "模板添加失败," + ex.Message);
                    }
                }
            }
        }