Ejemplo n.º 1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var gatherDatabaseRuleInfo = DataProvider.GatherDatabaseRuleDao.GetGatherDatabaseRuleInfo(_gatherRuleName, PublishmentSystemId);

            gatherDatabaseRuleInfo.NodeId    = TranslateUtils.ToInt(NodeIDDropDownList.SelectedValue);
            gatherDatabaseRuleInfo.GatherNum = TranslateUtils.ToInt(GatherNum.Text);
            DataProvider.GatherDatabaseRuleDao.Update(gatherDatabaseRuleInfo);

            PageUtils.Redirect(ModalProgressBar.GetRedirectUrlStringWithGatherDatabase(PublishmentSystemId, _gatherRuleName));
        }
Ejemplo n.º 2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isUpload = TranslateUtils.ToBool(rblImportType.SelectedValue);

            if (isUpload)
            {
                if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName)
                {
                    var filePath = myFile.PostedFile.FileName;
                    var sExt     = PathUtils.GetExtension(filePath);
                    if (!StringUtils.EqualsIgnoreCase(sExt, ".zip"))
                    {
                        FailMessage("站点模板压缩包为zip格式,请选择有效的文件上传");
                        return;
                    }
                    try
                    {
                        var directoryName = PathUtils.GetFileNameWithoutExtension(filePath);
                        var directoryPath = PathUtility.GetSiteTemplatesPath(directoryName);
                        if (DirectoryUtils.IsDirectoryExists(directoryPath))
                        {
                            FailMessage($"站点模板导入失败,文件夹{directoryName}已存在");
                            return;
                        }
                        var localFilePath = PathUtility.GetSiteTemplatesPath(directoryName + ".zip");
                        FileUtils.DeleteFileIfExists(localFilePath);

                        myFile.PostedFile.SaveAs(localFilePath);

                        ZipUtils.UnpackFiles(localFilePath, directoryPath);

                        PageUtils.CloseModalPageAndRedirect(Page, PageSiteTemplate.GetRedirectUrl());
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "文件上传失败!");
                    }
                }
            }
            else
            {
                var sExt = PathUtils.GetExtension(tbDownloadUrl.Text);
                if (!StringUtils.EqualsIgnoreCase(sExt, ".zip"))
                {
                    FailMessage("站点模板压缩包为zip格式,请输入有效文件地址");
                    return;
                }
                var directoryName = PathUtils.GetFileNameWithoutExtension(tbDownloadUrl.Text);
                PageUtils.Redirect(ModalProgressBar.GetRedirectUrlStringWithSiteTemplateDownload(tbDownloadUrl.Text, directoryName));
            }
        }
Ejemplo n.º 3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            TemplateInfo templateInfo = null;

            if (AuthRequest.GetQueryInt("TemplateID") > 0)
            {
                var templateId = AuthRequest.GetQueryInt("TemplateID");
                _isCopy      = AuthRequest.GetQueryBool("IsCopy");
                templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId);
                if (templateInfo != null)
                {
                    _templateType = templateInfo.TemplateType;
                }
            }
            else
            {
                _templateType = TemplateTypeUtils.GetEnumType(Request.QueryString["TemplateType"]);
            }

            if (_templateType == TemplateType.IndexPageTemplate || _templateType == TemplateType.FileTemplate)
            {
                PhCreatedFileFullName.Visible = true;
            }
            else
            {
                PhCreatedFileFullName.Visible = false;
            }

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.SitePermissions.Templates);

            LtlTemplateType.Text = TemplateTypeUtils.GetText(_templateType);

            LtlPageTitle.Text = AuthRequest.GetQueryInt("TemplateID") > 0 ? "编辑模板" : "添加模板";

            var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;

            BtnEditorType.Text   = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
            PhCodeMirror.Visible = isCodeMirror;

            EFileSystemTypeUtils.AddWebPageListItems(DdlCreatedFileExtName);

            ECharsetUtils.AddListItems(DdlCharset);

            if (AuthRequest.GetQueryInt("TemplateID") > 0)
            {
                if (templateInfo == null)
                {
                    return;
                }

                TbContent.Text = TemplateManager.GetTemplateContent(SiteInfo, templateInfo);

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

                    LtlCommands.Text += $@"
<button class=""btn"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(SiteId, templateInfo.Id)}"">生成页面</button>
<button class=""btn"" onclick=""{ModalTemplateRestore.GetOpenWindowString(SiteId, templateInfo.Id, string.Empty)}"">还原历史版本</button>";

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

                ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, ECharsetUtils.GetValue(templateInfo.Charset));

                ControlUtils.SelectSingleItem(DdlCreatedFileExtName, GetTemplateFileExtension(templateInfo));
                HihTemplateType.Value = templateInfo.TemplateType.Value;
            }
            else
            {
                TbRelatedFileName.Text     = "T_";
                TbCreatedFileFullName.Text = _templateType == TemplateType.ChannelTemplate ? "index" : "@/";
                ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, SiteInfo.Additional.Charset);
                ControlUtils.SelectSingleItem(DdlCreatedFileExtName, EFileSystemTypeUtils.GetValue(EFileSystemType.Html));
                HihTemplateType.Value = AuthRequest.GetQueryString("TemplateType");
            }
        }
Ejemplo n.º 4
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var templateId          = SqlUtils.EvalInt(e.Item.DataItem, nameof(TemplateInfo.Id));
            var templateType        = TemplateTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.TemplateType)));
            var templateName        = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.TemplateName));
            var relatedFileName     = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.RelatedFileName));
            var createdFileFullName = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.CreatedFileFullName));
            var isDefault           = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.IsDefault)));

            var ltlTemplateName    = (Literal)e.Item.FindControl("ltlTemplateName");
            var ltlRelatedFileName = (Literal)e.Item.FindControl("ltlRelatedFileName");
            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(SiteId, templateId, templateType);

            ltlTemplateName.Text    = $@"<a href=""{templateAddUrl}"">{templateName}</a>";
            ltlRelatedFileName.Text = relatedFileName;

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

            ltlUseCount.Text = DataProvider.ChannelDao.GetTemplateUseCount(SiteId, templateId, templateType, isDefault).ToString();

            ltlTemplateType.Text = TemplateTypeUtils.GetText(templateType);

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

            var copyUrl = PageTemplateAdd.GetRedirectUrlToCopy(SiteId, templateId);

            ltlCopyUrl.Text = $@"<a href=""{copyUrl}"">快速复制</a>";

            var logUrl = PageTemplateLog.GetRedirectUrl(SiteId, templateId);

            ltlLogUrl.Text = $@"<a href=""{logUrl}"">修订历史</a>";

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

            if (!isDefault)
            {
                var deleteUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageTemplate), new NameValueCollection
                {
                    { "TemplateID", templateId.ToString() },
                    { "Delete", true.ToString() },
                    { "TemplateType", templateType.Value }
                });

                ltlDeleteUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{AlertUtils.ConfirmDelete("删除文件", $"此操作将删除模板“{templateName}”,确认吗?", deleteUrl)}"">删除</a>";
            }
        }
Ejemplo n.º 5
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.º 6
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            if (Body.IsQueryExists("Delete"))
            {
                var gatherRuleName = Body.GetQueryString("GatherRuleName");
                try
                {
                    DataProvider.GatherRuleDao.Delete(gatherRuleName, PublishmentSystemId);
                    Body.AddSiteLog(PublishmentSystemId, "删除Web页面采集规则", $"采集规则:{gatherRuleName}");
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }

            if (Body.IsQueryExists("Copy"))
            {
                var gatherRuleName = Body.GetQueryString("GatherRuleName");
                try
                {
                    var gatherRuleInfo = DataProvider.GatherRuleDao.GetGatherRuleInfo(gatherRuleName, PublishmentSystemId);
                    gatherRuleInfo.GatherRuleName = gatherRuleInfo.GatherRuleName + "_复件";
                    gatherRuleInfo.LastGatherDate = DateUtils.SqlMinValue;

                    DataProvider.GatherRuleDao.Insert(gatherRuleInfo);
                    Body.AddSiteLog(PublishmentSystemId, "复制Web页面采集规则", $"采集规则:{gatherRuleName}");
                    SuccessMessage("采集规则复制成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "采集规则复制失败!");
                }
            }

            if (Body.IsQueryExists("Auto") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var gatherRuleNameCollection = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("GatherRuleNameCollection"));
                try
                {
                    foreach (string item in gatherRuleNameCollection)
                    {
                        var gatherRuleInfoTmp = DataProvider.GatherRuleDao.GetGatherRuleInfo(item, PublishmentSystemId);
                        gatherRuleInfoTmp.Additional.IsAutoCreate = true;
                        DataProvider.GatherRuleDao.Update(gatherRuleInfoTmp);
                    }

                    Body.AddSiteLog(PublishmentSystemId, "开启采集规则自动生成成功", $"采集规则:{gatherRuleNameCollection}");
                    SuccessMessage("开启采集规则自动生成成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "开启采集规则自动生成失败!");
                }
            }

            if (Body.IsQueryExists("NoAuto") && Body.IsQueryExists("GatherRuleNameCollection"))
            {
                var gatherRuleNameCollection = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("GatherRuleNameCollection"));
                try
                {
                    foreach (string item in gatherRuleNameCollection)
                    {
                        var gatherRuleInfoTmp = DataProvider.GatherRuleDao.GetGatherRuleInfo(item, PublishmentSystemId);
                        gatherRuleInfoTmp.Additional.IsAutoCreate = false;
                        DataProvider.GatherRuleDao.Update(gatherRuleInfoTmp);
                    }
                    Body.AddSiteLog(PublishmentSystemId, "关闭采集规则自动生成成功", $"采集规则:{gatherRuleNameCollection}");
                    SuccessMessage("关闭采集规则自动生成成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "关闭采集规则自动生成失败!");
                }
            }

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdFunction, AppManager.Cms.LeftMenu.Function.IdGather, "Web页面信息采集", AppManager.Cms.Permission.WebSite.Gather);

                var showPopWinString = ModalProgressBar.GetOpenWindowStringWithGather(PublishmentSystemId);
                Start.Attributes.Add("onclick", showPopWinString);

                showPopWinString = ModalExportMessage.GetOpenWindowStringToGatherRule(PublishmentSystemId, "GatherRuleNameCollection", "请选择需要导出的规则!");
                Export.Attributes.Add("onclick", showPopWinString);

                dgContents.DataSource     = DataProvider.GatherRuleDao.GetGatherRuleInfoArrayList(PublishmentSystemId);
                dgContents.ItemDataBound += dgContents_ItemDataBound;
                dgContents.DataBind();
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            if (Body.IsQueryExists("Delete"))
            {
                var gatherRuleName = Body.GetQueryString("GatherRuleName");
                try
                {
                    DataProvider.GatherDatabaseRuleDao.Delete(gatherRuleName, PublishmentSystemId);
                    Body.AddSiteLog(PublishmentSystemId, "删除数据库采集规则", $"采集规则:{gatherRuleName}");
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }

            if (Body.IsQueryExists("Copy"))
            {
                var gatherRuleName = Body.GetQueryString("GatherRuleName");
                try
                {
                    var gatherDatabaseRuleInfo = DataProvider.GatherDatabaseRuleDao.GetGatherDatabaseRuleInfo(gatherRuleName, PublishmentSystemId);
                    gatherDatabaseRuleInfo.GatherRuleName = gatherDatabaseRuleInfo.GatherRuleName + "_复件";
                    gatherDatabaseRuleInfo.LastGatherDate = DateUtils.SqlMinValue;

                    DataProvider.GatherDatabaseRuleDao.Insert(gatherDatabaseRuleInfo);
                    Body.AddSiteLog(PublishmentSystemId, "复制数据库采集规则", $"采集规则:{gatherRuleName}");
                    SuccessMessage("采集规则复制成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "采集规则复制失败!");
                }
            }

            if (Body.IsQueryExists("Auto") && Body.IsQueryExists("GatherDatabaseRuleNameCollection"))
            {
                var gatherDatabaseRuleNameCollection = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("GatherDatabaseRuleNameCollection"));
                try
                {
                    DataProvider.GatherDatabaseRuleDao.OpenAuto(PublishmentSystemId, gatherDatabaseRuleNameCollection);
                    Body.AddSiteLog(PublishmentSystemId, "开启采集规则自动生成成功",
                                    $"采集规则:{Body.GetQueryString("GatherDatabaseRuleNameCollection")}");
                    SuccessMessage("开启采集规则自动生成成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "开启采集规则自动生成失败!");
                }
            }

            if (Body.IsQueryExists("NoAuto") && Body.IsQueryExists("GatherDatabaseRuleNameCollection"))
            {
                var gatherDatabaseRuleNameCollection = TranslateUtils.StringCollectionToStringList(Body.GetQueryString("GatherDatabaseRuleNameCollection"));
                try
                {
                    DataProvider.GatherDatabaseRuleDao.CloseAuto(PublishmentSystemId, gatherDatabaseRuleNameCollection);
                    Body.AddSiteLog(PublishmentSystemId, "关闭采集规则自动生成成功",
                                    $"采集规则:{Body.GetQueryString("GatherDatabaseRuleNameCollection")}");
                    SuccessMessage("关闭采集规则自动生成成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "关闭采集规则自动生成失败!");
                }
            }

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdFunction, AppManager.Cms.LeftMenu.Function.IdGather, "数据库采集", AppManager.Cms.Permission.WebSite.Gather);

                var showPopWinString = ModalProgressBar.GetOpenWindowStringWithGatherDatabase(PublishmentSystemId);
                Start.Attributes.Add("onclick", showPopWinString);

                dgContents.DataSource = DataProvider.GatherDatabaseRuleDao.GetDataSource(PublishmentSystemId);
                dgContents.DataBind();
            }
        }
Ejemplo n.º 8
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (GatherUrlIsCollection.Checked)
            {
                if (string.IsNullOrEmpty(GatherUrlCollection.Text))
                {
                    FailMessage("必须填写起始网页地址!");
                    return;
                }
            }

            if (GatherUrlIsSerialize.Checked)
            {
                if (string.IsNullOrEmpty(GatherUrlSerialize.Text))
                {
                    FailMessage("必须填写起始网页地址!");
                    return;
                }

                if (GatherUrlSerialize.Text.IndexOf("*") == -1)
                {
                    FailMessage("起始网页地址必须带有 * 字符!");
                    return;
                }

                if (string.IsNullOrEmpty(SerializeFrom.Text) || string.IsNullOrEmpty(SerializeTo.Text))
                {
                    FailMessage("必须填写变动数字范围!");
                    return;
                }
                else
                {
                    if (TranslateUtils.ToInt(SerializeFrom.Text) < 0 || TranslateUtils.ToInt(SerializeTo.Text) < 0)
                    {
                        FailMessage("变动数字范围必须大于等于0!");
                        return;
                    }
                    if (TranslateUtils.ToInt(SerializeTo.Text) <= TranslateUtils.ToInt(SerializeFrom.Text))
                    {
                        FailMessage("变动数字范围结束必须大于开始!");
                        return;
                    }
                }

                if (string.IsNullOrEmpty(SerializeInterval.Text))
                {
                    FailMessage("必须填写数字变动倍数!");
                    return;
                }
                else
                {
                    if (TranslateUtils.ToInt(SerializeInterval.Text) <= 0)
                    {
                        FailMessage("数字变动倍数必须大于等于1!");
                        return;
                    }
                }
            }

            if (string.IsNullOrEmpty(UrlInclude.Text))
            {
                FailMessage("必须填写内容地址包含字符串!");
                return;
            }

            var gatherRuleInfo = DataProvider.GatherRuleDao.GetGatherRuleInfo(_gatherRuleName, PublishmentSystemId);

            gatherRuleInfo.GatherUrlIsCollection  = GatherUrlIsCollection.Checked;
            gatherRuleInfo.GatherUrlCollection    = GatherUrlCollection.Text;
            gatherRuleInfo.GatherUrlIsSerialize   = GatherUrlIsSerialize.Checked;
            gatherRuleInfo.GatherUrlSerialize     = GatherUrlSerialize.Text;
            gatherRuleInfo.SerializeFrom          = TranslateUtils.ToInt(SerializeFrom.Text);
            gatherRuleInfo.SerializeTo            = TranslateUtils.ToInt(SerializeTo.Text);
            gatherRuleInfo.SerializeInterval      = TranslateUtils.ToInt(SerializeInterval.Text);
            gatherRuleInfo.SerializeIsOrderByDesc = SerializeIsOrderByDesc.Checked;
            gatherRuleInfo.SerializeIsAddZero     = SerializeIsAddZero.Checked;
            gatherRuleInfo.UrlInclude             = UrlInclude.Text;

            gatherRuleInfo.NodeId = TranslateUtils.ToInt(NodeIDDropDownList.SelectedValue);
            gatherRuleInfo.Additional.GatherNum = TranslateUtils.ToInt(GatherNum.Text);
            DataProvider.GatherRuleDao.Update(gatherRuleInfo);

            PageUtils.Redirect(ModalProgressBar.GetRedirectUrlStringWithGather(PublishmentSystemId, _gatherRuleName));
        }
Ejemplo n.º 9
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.º 10
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(GatherUrl.Text))
            {
                FailMessage("必须填写采集网页地址!");
                return;
            }

            if (PlaceHolder_File.Visible)
            {
                if (string.IsNullOrEmpty(FilePath.Text))
                {
                    FailMessage("必须填写采集到的文件地址!");
                    return;
                }
                else
                {
                    var isOk = false;
                    if (StringUtils.StringStartsWith(FilePath.Text, '~') || StringUtils.StringStartsWith(FilePath.Text, '@'))
                    {
                        if (!PathUtils.IsDirectoryPath(FilePath.Text))
                        {
                            isOk = true;
                        }
                    }
                    if (isOk == false)
                    {
                        FailMessage("采集到的文件地址不正确,必须填写有效的文件地址!");
                        return;
                    }
                }

                if (TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue))
                {
                    var isOk = false;
                    if (StringUtils.StringStartsWith(StyleDirectoryPath.Text, '~') || StringUtils.StringStartsWith(StyleDirectoryPath.Text, '@'))
                    {
                        if (PathUtils.IsDirectoryPath(StyleDirectoryPath.Text))
                        {
                            isOk = true;
                        }
                    }
                    if (isOk == false)
                    {
                        FailMessage("CSS样式保存地址不正确,必须填写有效的文件夹地址!");
                        return;
                    }
                    isOk = false;
                    if (StringUtils.StringStartsWith(ScriptDirectoryPath.Text, '~') || StringUtils.StringStartsWith(ScriptDirectoryPath.Text, '@'))
                    {
                        if (PathUtils.IsDirectoryPath(ScriptDirectoryPath.Text))
                        {
                            isOk = true;
                        }
                    }
                    if (isOk == false)
                    {
                        FailMessage("Js脚本保存地址不正确,必须填写有效的文件夹地址!");
                        return;
                    }
                    isOk = false;
                    if (StringUtils.StringStartsWith(ImageDirectoryPath.Text, '~') || StringUtils.StringStartsWith(ImageDirectoryPath.Text, '@'))
                    {
                        if (PathUtils.IsDirectoryPath(ImageDirectoryPath.Text))
                        {
                            isOk = true;
                        }
                    }
                    if (isOk == false)
                    {
                        FailMessage("图片保存地址不正确,必须填写有效的文件夹地址!");
                        return;
                    }
                }
            }

            var gatherFileRuleInfo = DataProvider.GatherFileRuleDao.GetGatherFileRuleInfo(_gatherRuleName, PublishmentSystemId);

            gatherFileRuleInfo.GatherUrl           = GatherUrl.Text;
            gatherFileRuleInfo.FilePath            = FilePath.Text;
            gatherFileRuleInfo.IsSaveRelatedFiles  = TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue);
            gatherFileRuleInfo.IsRemoveScripts     = TranslateUtils.ToBool(IsRemoveScripts.SelectedValue);
            gatherFileRuleInfo.StyleDirectoryPath  = StyleDirectoryPath.Text;
            gatherFileRuleInfo.ScriptDirectoryPath = ScriptDirectoryPath.Text;
            gatherFileRuleInfo.ImageDirectoryPath  = ImageDirectoryPath.Text;
            gatherFileRuleInfo.NodeId      = TranslateUtils.ToInt(NodeIDDropDownList.SelectedValue);
            gatherFileRuleInfo.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue);

            DataProvider.GatherFileRuleDao.Update(gatherFileRuleInfo);

            PageUtils.Redirect(ModalProgressBar.GetRedirectUrlStringWithGatherFile(PublishmentSystemId, _gatherRuleName));
        }