public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } PublishmentSystemInfo.PublishmentSystemUrl = TbPublishmentSystemUrl.Text; PublishmentSystemInfo.Additional.IsMultiDeployment = TranslateUtils.ToBool(DdlIsMultiDeployment.SelectedValue); PublishmentSystemInfo.Additional.SiteUrl = TbSiteUrl.Text; PublishmentSystemInfo.Additional.ApiUrl = TbApiUrl.Text; PublishmentSystemInfo.Additional.OuterSiteUrl = TbOuterSiteUrl.Text; PublishmentSystemInfo.Additional.InnerSiteUrl = TbInnerSiteUrl.Text; PublishmentSystemInfo.Additional.OuterApiUrl = TbOuterApiUrl.Text; PublishmentSystemInfo.Additional.InnerApiUrl = TbInnerApiUrl.Text; PublishmentSystemInfo.Additional.HomeUrl = TbHomeUrl.Text; if (PublishmentSystemInfo.Additional.Charset != DdlCharset.SelectedValue) { PublishmentSystemInfo.Additional.Charset = DdlCharset.SelectedValue; } PublishmentSystemInfo.Additional.PageSize = TranslateUtils.ToInt(TbPageSize.Text, PublishmentSystemInfo.Additional.PageSize); PublishmentSystemInfo.Additional.IsCountHits = TranslateUtils.ToBool(RblIsCountHits.SelectedValue); PublishmentSystemInfo.Additional.IsCountHitsByDay = TranslateUtils.ToBool(RblIsCountHitsByDay.SelectedValue); PublishmentSystemInfo.Additional.IsCountDownload = TranslateUtils.ToBool(RblIsCountDownload.SelectedValue); PublishmentSystemInfo.Additional.IsCreateDoubleClick = TranslateUtils.ToBool(RblIsCreateDoubleClick.SelectedValue); try { //修改所有模板编码 var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListByPublishmentSystemId(PublishmentSystemId); var charset = ECharsetUtils.GetEnumType(PublishmentSystemInfo.Additional.Charset); foreach (var templateInfo in templateInfoList) { if (templateInfo.Charset == charset) { continue; } var templateContent = StlCacheManager.FileContent.GetTemplateContent(PublishmentSystemInfo, templateInfo); templateInfo.Charset = charset; DataProvider.TemplateDao.Update(PublishmentSystemInfo, templateInfo, templateContent, Body.AdministratorName); } DataProvider.PublishmentSystemDao.Update(PublishmentSystemInfo); Body.AddSiteLog(PublishmentSystemId, "修改站点配置管理"); SuccessMessage("站点配置管理修改成功!"); } catch (Exception ex) { FailMessage(ex, "站点配置管理修改失败!"); } }
public IHttpActionResult Submit() { try { var request = new AuthenticatedRequest(); var siteId = request.SiteId; if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSitePermissions(siteId, ConfigManager.SitePermissions.ConfigSite)) { return(Unauthorized()); } var siteInfo = SiteManager.GetSiteInfo(siteId); var siteName = request.GetPostString("siteName"); var charset = ECharsetUtils.GetEnumType(request.GetPostString("charset")); var pageSize = request.GetPostInt("pageSize", siteInfo.Additional.PageSize); var isCreateDoubleClick = request.GetPostBool("isCreateDoubleClick"); siteInfo.SiteName = siteName; siteInfo.Additional.Charset = ECharsetUtils.GetValue(charset); siteInfo.Additional.PageSize = pageSize; siteInfo.Additional.IsCreateDoubleClick = isCreateDoubleClick; //修改所有模板编码 var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListBySiteId(siteId); foreach (var templateInfo in templateInfoList) { if (templateInfo.Charset == charset) { continue; } var templateContent = TemplateManager.GetTemplateContent(siteInfo, templateInfo); templateInfo.Charset = charset; DataProvider.TemplateDao.Update(siteInfo, templateInfo, templateContent, request.AdminName); } DataProvider.SiteDao.Update(siteInfo); request.AddSiteLog(siteId, "修改站点设置"); return(Ok(new { Value = siteInfo, Config = siteInfo.Additional, })); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void CreateDefaultTemplateInfo(int siteId, string administratorName) { var siteInfo = SiteManager.GetSiteInfo(siteId); var templateInfoList = new List <TemplateInfo>(); var charset = ECharsetUtils.GetEnumType(siteInfo.Additional.Charset); var templateInfo = new TemplateInfo(0, siteInfo.Id, "系统首页模板", TemplateType.IndexPageTemplate, "T_系统首页模板.html", "@/index.html", ".html", charset, true); templateInfoList.Add(templateInfo); templateInfo = new TemplateInfo(0, siteInfo.Id, "系统栏目模板", TemplateType.ChannelTemplate, "T_系统栏目模板.html", "index.html", ".html", charset, true); templateInfoList.Add(templateInfo); templateInfo = new TemplateInfo(0, siteInfo.Id, "系统内容模板", TemplateType.ContentTemplate, "T_系统内容模板.html", "index.html", ".html", charset, true); templateInfoList.Add(templateInfo); foreach (var theTemplateInfo in templateInfoList) { Insert(theTemplateInfo, theTemplateInfo.Content, administratorName); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } if (SiteInfo.Additional.Charset != DdlCharset.SelectedValue) { SiteInfo.Additional.Charset = DdlCharset.SelectedValue; } SiteInfo.Additional.PageSize = TranslateUtils.ToInt(TbPageSize.Text, SiteInfo.Additional.PageSize); SiteInfo.Additional.IsCreateDoubleClick = TranslateUtils.ToBool(DdlIsCreateDoubleClick.SelectedValue); //修改所有模板编码 var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListBySiteId(SiteId); var charset = ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset); foreach (var templateInfo in templateInfoList) { if (templateInfo.Charset == charset) { continue; } var templateContent = TemplateManager.GetTemplateContent(SiteInfo, templateInfo); templateInfo.Charset = charset; DataProvider.TemplateDao.Update(SiteInfo, templateInfo, templateContent, AuthRequest.AdminName); } DataProvider.SiteDao.Update(SiteInfo); AuthRequest.AddSiteLog(SiteId, "修改站点设置"); SuccessMessage("站点设置修改成功!"); }
public void CreateChannelTemplate_Click(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) { return; } var defaultChannelTemplateId = TemplateManager.GetDefaultTemplateId(SiteId, TemplateType.ChannelTemplate); var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateType.ChannelTemplate); var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateType.ChannelTemplate); foreach (ListItem item in LbChannelId.Items) { if (!item.Selected) { continue; } var channelId = int.Parse(item.Value); var channelTemplateId = -1; var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId); if (nodeInfo.ParentId > 0) { channelTemplateId = nodeInfo.ChannelTemplateId; } if (channelTemplateId != -1 && channelTemplateId != 0 && channelTemplateId != defaultChannelTemplateId) { if (TemplateManager.GetTemplateInfo(SiteId, channelTemplateId) == null) { channelTemplateId = -1; } } if (channelTemplateId != -1) { var templateInfo = new TemplateInfo(0, SiteId, nodeInfo.ChannelName, TemplateType.ChannelTemplate, "T_" + nodeInfo.ChannelName + ".html", "index.html", ".html", ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false); if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower())) { continue; } if (templateNameList.Contains(templateInfo.TemplateName)) { continue; } var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, AuthRequest.AdminName); if (nodeInfo.ParentId > 0) { nodeInfo.ChannelTemplateId = insertedTemplateId; DataProvider.ChannelDao.UpdateChannelTemplateId(nodeInfo); //TemplateManager.UpdateChannelTemplateId(SiteId, channelId, insertedTemplateId); //DataProvider.BackgroundNodeDAO.UpdateChannelTemplateID(channelId, insertedTemplateID); } } } AuthRequest.AddSiteLog(SiteId, "生成并匹配栏目模版", $"栏目:{GetNodeNames()}"); SuccessMessage("生成栏目模版并匹配成功!"); BindListBox(); }
public static ECharset GetFileCharset(string filePath) { Encoding encoding = EncodingType.GetType(filePath); return(ECharsetUtils.GetEnumType(encoding.BodyName)); }
public TemplateInfo GetTemplateById(int siteId, TemplateType type, string tId) { TemplateInfo info = null; var parms = new IDataParameter[] { GetParameter(ParmSiteId, DataType.Integer, siteId), GetParameter(ParmTemplateType, DataType.VarChar, 50, type.Value), GetParameter(ParmId, DataType.Integer, tId) }; using (var rdr = ExecuteReader(SqlSelectTemplateById, parms)) { if (rdr.Read()) { var i = 0; info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), TemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i)); } rdr.Close(); } return(info); }
public List <TemplateInfo> GetTemplateInfoListOfFile(int siteId) { var list = new List <TemplateInfo>(); string sqlString = $"SELECT Id, SiteId, TemplateName, TemplateType, RelatedFileName, CreatedFileFullName, CreatedFileExtName, Charset, IsDefault FROM siteserver_Template WHERE SiteId = {siteId} AND TemplateType = '{TemplateType.FileTemplate.Value}' ORDER BY RelatedFileName"; using (var rdr = ExecuteReader(sqlString)) { while (rdr.Read()) { var i = 0; var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), TemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i)); list.Add(info); } rdr.Close(); } return(list); }
public void ImportGatherRule(bool overwrite) { if (!FileUtils.IsFileExists(_filePath)) { return; } var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(_filePath)); foreach (AtomEntry entry in feed.Entries) { var gatherRuleName = AtomUtility.GetDcElementContent(entry.AdditionalElements, "GatherRuleName"); if (!string.IsNullOrEmpty(gatherRuleName)) { var gatherRuleInfo = new GatherRuleInfo(); gatherRuleInfo.GatherRuleName = gatherRuleName; gatherRuleInfo.PublishmentSystemId = _publishmentSystemId; gatherRuleInfo.CookieString = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "CookieString")); //解密 gatherRuleInfo.GatherUrlIsCollection = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "GatherUrlIsCollection")); gatherRuleInfo.GatherUrlCollection = AtomUtility.GetDcElementContent(entry.AdditionalElements, "GatherUrlCollection"); gatherRuleInfo.GatherUrlIsSerialize = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "GatherUrlIsSerialize")); gatherRuleInfo.GatherUrlSerialize = AtomUtility.GetDcElementContent(entry.AdditionalElements, "GatherUrlSerialize"); gatherRuleInfo.SerializeFrom = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "SerializeFrom")); gatherRuleInfo.SerializeTo = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "SerializeTo")); gatherRuleInfo.SerializeInterval = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "SerializeInterval")); gatherRuleInfo.SerializeIsOrderByDesc = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "SerializeIsOrderByDesc")); gatherRuleInfo.SerializeIsAddZero = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, "SerializeIsAddZero")); gatherRuleInfo.NodeId = _publishmentSystemId; gatherRuleInfo.Charset = ECharsetUtils.GetEnumType(AtomUtility.GetDcElementContent(entry.AdditionalElements, "Charset")); gatherRuleInfo.UrlInclude = AtomUtility.GetDcElementContent(entry.AdditionalElements, "UrlInclude"); gatherRuleInfo.TitleInclude = AtomUtility.GetDcElementContent(entry.AdditionalElements, "TitleInclude"); gatherRuleInfo.ContentExclude = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentExclude")); //解密 gatherRuleInfo.ContentHtmlClearCollection = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentHtmlClearCollection"); gatherRuleInfo.ContentHtmlClearTagCollection = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentHtmlClearTagCollection"); gatherRuleInfo.LastGatherDate = DateUtils.SqlMinValue; gatherRuleInfo.ListAreaStart = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ListAreaStart")); //解密 gatherRuleInfo.ListAreaEnd = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ListAreaEnd")); //解密 gatherRuleInfo.ContentChannelStart = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentChannelStart")); //解密 gatherRuleInfo.ContentChannelEnd = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentChannelEnd")); //解密 gatherRuleInfo.ContentTitleStart = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentTitleStart")); //解密 gatherRuleInfo.ContentTitleEnd = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentTitleEnd")); //解密 gatherRuleInfo.ContentContentStart = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentContentStart")); //解密 gatherRuleInfo.ContentContentEnd = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentContentEnd")); //解密 gatherRuleInfo.ContentNextPageStart = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentNextPageStart")); //解密 gatherRuleInfo.ContentNextPageEnd = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentNextPageEnd")); //解密 gatherRuleInfo.ContentAttributes = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentAttributes")); //解密 gatherRuleInfo.ContentAttributesXml = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ContentAttributesXML")); //解密 gatherRuleInfo.ExtendValues = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "ExtendValues")); //解密 var srcGatherRuleInfo = DataProvider.GatherRuleDao.GetGatherRuleInfo(gatherRuleInfo.GatherRuleName, _publishmentSystemId); if (srcGatherRuleInfo != null) { if (overwrite) { DataProvider.GatherRuleDao.Update(gatherRuleInfo); } else { var importGatherRuleName = DataProvider.GatherRuleDao.GetImportGatherRuleName(_publishmentSystemId, gatherRuleInfo.GatherRuleName); gatherRuleInfo.GatherRuleName = importGatherRuleName; DataProvider.GatherRuleDao.Insert(gatherRuleInfo); } } else { DataProvider.GatherRuleDao.Insert(gatherRuleInfo); } } } }
public void ImportTemplates(bool overwrite, string administratorName) { if (!FileUtils.IsFileExists(_filePath)) { return; } var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(_filePath)); var siteInfo = SiteManager.GetSiteInfo(_siteId); foreach (AtomEntry entry in feed.Entries) { var templateName = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TemplateInfo.TemplateName)); if (string.IsNullOrEmpty(templateName)) { continue; } var templateInfo = new TemplateInfo { SiteId = _siteId, TemplateName = templateName, TemplateType = TemplateTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TemplateInfo.TemplateType))), RelatedFileName = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TemplateInfo.RelatedFileName)), CreatedFileFullName = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TemplateInfo.CreatedFileFullName)), CreatedFileExtName = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TemplateInfo.CreatedFileExtName)), Charset = ECharsetUtils.GetEnumType(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TemplateInfo.Charset))), IsDefault = false }; var templateContent = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, "Content")); var srcTemplateInfo = TemplateManager.GetTemplateInfoByTemplateName(_siteId, templateInfo.TemplateType, templateInfo.TemplateName); int templateId; if (srcTemplateInfo != null) { if (overwrite) { srcTemplateInfo.RelatedFileName = templateInfo.RelatedFileName; srcTemplateInfo.TemplateType = templateInfo.TemplateType; srcTemplateInfo.CreatedFileFullName = templateInfo.CreatedFileFullName; srcTemplateInfo.CreatedFileExtName = templateInfo.CreatedFileExtName; srcTemplateInfo.Charset = templateInfo.Charset; DataProvider.TemplateDao.Update(siteInfo, srcTemplateInfo, templateContent, administratorName); templateId = srcTemplateInfo.Id; } else { templateInfo.TemplateName = DataProvider.TemplateDao.GetImportTemplateName(_siteId, templateInfo.TemplateName); templateId = DataProvider.TemplateDao.Insert(templateInfo, templateContent, administratorName); } } else { templateId = DataProvider.TemplateDao.Insert(templateInfo, templateContent, administratorName); } if (templateInfo.TemplateType == TemplateType.FileTemplate) { CreateManager.CreateFile(_siteId, templateId); } } }
public bool Validate_InsertGatherRule(out string errorMessage) { try { var isNeedAdd = false; if (_isEdit) { if (_theGatherRuleName != GatherRuleName.Text) { isNeedAdd = true; DataProvider.GatherRuleDao.Delete(_theGatherRuleName, PublishmentSystemId); } else { var gatherRuleInfo = DataProvider.GatherRuleDao.GetGatherRuleInfo(_theGatherRuleName, PublishmentSystemId); if (NodeIDDropDownList.SelectedValue != null) { gatherRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherRuleInfo.Charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); gatherRuleInfo.Additional.GatherNum = int.Parse(GatherNum.Text); gatherRuleInfo.Additional.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue); gatherRuleInfo.Additional.IsSetFirstImageAsImageUrl = TranslateUtils.ToBool(IsSetFirstImageAsImageUrl.SelectedValue); gatherRuleInfo.Additional.IsEmptyContentAllowed = TranslateUtils.ToBool(IsEmptyContentAllowed.SelectedValue); gatherRuleInfo.Additional.IsSameTitleAllowed = TranslateUtils.ToBool(IsSameTitleAllowed.SelectedValue); gatherRuleInfo.Additional.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherRuleInfo.Additional.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherRuleInfo.Additional.IsOrderByDesc = TranslateUtils.ToBool(IsOrderByDesc.SelectedValue); 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.TitleInclude = TitleInclude.Text; gatherRuleInfo.ContentExclude = ContentExclude.Text; var htmlClearArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearCollection.Items) { if (item.Selected) { htmlClearArrayList.Add(item.Value); } } gatherRuleInfo.ContentHtmlClearCollection = TranslateUtils.ObjectCollectionToString(htmlClearArrayList); var htmlClearTagArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearTagCollection.Items) { if (item.Selected) { htmlClearTagArrayList.Add(item.Value); } } gatherRuleInfo.ContentHtmlClearTagCollection = TranslateUtils.ObjectCollectionToString(htmlClearTagArrayList); gatherRuleInfo.ListAreaStart = ListAreaStart.Text; gatherRuleInfo.ListAreaEnd = ListAreaEnd.Text; gatherRuleInfo.CookieString = CookieString.Text; gatherRuleInfo.ContentTitleStart = ContentTitleStart.Text; gatherRuleInfo.ContentTitleEnd = ContentTitleEnd.Text; gatherRuleInfo.ContentContentStart = ContentContentStart.Text; gatherRuleInfo.ContentContentEnd = ContentContentEnd.Text; gatherRuleInfo.Additional.ContentContentStart2 = ContentContentStart2.Text; gatherRuleInfo.Additional.ContentContentEnd2 = ContentContentEnd2.Text; gatherRuleInfo.Additional.ContentContentStart3 = ContentContentStart3.Text; gatherRuleInfo.Additional.ContentContentEnd3 = ContentContentEnd3.Text; gatherRuleInfo.Additional.ContentReplaceFrom = ContentReplaceFrom.Text; gatherRuleInfo.Additional.ContentReplaceTo = ContentReplaceTo.Text; gatherRuleInfo.ContentChannelStart = ContentChannelStart.Text; gatherRuleInfo.ContentChannelEnd = ContentChannelEnd.Text; gatherRuleInfo.ContentNextPageStart = ContentNextPageStart.Text; gatherRuleInfo.ContentNextPageEnd = ContentNextPageEnd.Text; var valueArrayList = ControlUtils.GetSelectedListControlValueArrayList(ContentAttributes); gatherRuleInfo.ContentAttributes = TranslateUtils.ObjectCollectionToString(valueArrayList); var attributesXML = new NameValueCollection(); for (var i = 0; i < valueArrayList.Count; i++) { var attributeName = valueArrayList[i] as string; foreach (RepeaterItem item in ContentAttributesRepeater.Items) { if (item.ItemIndex == i) { var contentStart = (TextBox)item.FindControl("ContentStart"); var contentEnd = (TextBox)item.FindControl("ContentEnd"); //采集为空时的默认值 var contentDefault = (TextBox)item.FindControl("ContentDefault"); attributesXML[attributeName + "_ContentStart"] = StringUtils.ValueToUrl(contentStart.Text); attributesXML[attributeName + "_ContentEnd"] = StringUtils.ValueToUrl(contentEnd.Text); //采集为空时的默认值 attributesXML[attributeName + "_ContentDefault"] = StringUtils.ValueToUrl(contentDefault.Text); } } } gatherRuleInfo.ContentAttributesXml = TranslateUtils.NameValueCollectionToString(attributesXML); DataProvider.GatherRuleDao.Update(gatherRuleInfo); } } else { isNeedAdd = true; } if (isNeedAdd) { var gatherRuleInfo = new GatherRuleInfo(); gatherRuleInfo.GatherRuleName = GatherRuleName.Text; gatherRuleInfo.PublishmentSystemId = PublishmentSystemId; if (NodeIDDropDownList.SelectedValue != null) { gatherRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherRuleInfo.Charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); gatherRuleInfo.Additional.GatherNum = int.Parse(GatherNum.Text); gatherRuleInfo.Additional.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue); gatherRuleInfo.Additional.IsSetFirstImageAsImageUrl = TranslateUtils.ToBool(IsSetFirstImageAsImageUrl.SelectedValue); gatherRuleInfo.Additional.IsEmptyContentAllowed = TranslateUtils.ToBool(IsEmptyContentAllowed.SelectedValue); gatherRuleInfo.Additional.IsSameTitleAllowed = TranslateUtils.ToBool(IsSameTitleAllowed.SelectedValue); gatherRuleInfo.Additional.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherRuleInfo.Additional.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherRuleInfo.Additional.IsOrderByDesc = TranslateUtils.ToBool(IsOrderByDesc.SelectedValue); 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.TitleInclude = TitleInclude.Text; gatherRuleInfo.ContentExclude = ContentExclude.Text; var htmlClearArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearCollection.Items) { if (item.Selected) { htmlClearArrayList.Add(item.Value); } } gatherRuleInfo.ContentHtmlClearCollection = TranslateUtils.ObjectCollectionToString(htmlClearArrayList); var htmlClearTagArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearTagCollection.Items) { if (item.Selected) { htmlClearTagArrayList.Add(item.Value); } } gatherRuleInfo.ContentHtmlClearTagCollection = TranslateUtils.ObjectCollectionToString(htmlClearTagArrayList); gatherRuleInfo.ListAreaStart = ListAreaStart.Text; gatherRuleInfo.ListAreaEnd = ListAreaEnd.Text; gatherRuleInfo.CookieString = CookieString.Text; gatherRuleInfo.ContentTitleStart = ContentTitleStart.Text; gatherRuleInfo.ContentTitleEnd = ContentTitleEnd.Text; gatherRuleInfo.ContentContentStart = ContentContentStart.Text; gatherRuleInfo.ContentContentEnd = ContentContentEnd.Text; gatherRuleInfo.Additional.ContentContentStart2 = ContentContentStart2.Text; gatherRuleInfo.Additional.ContentContentEnd2 = ContentContentEnd2.Text; gatherRuleInfo.Additional.ContentContentStart3 = ContentContentStart3.Text; gatherRuleInfo.Additional.ContentContentEnd3 = ContentContentEnd3.Text; gatherRuleInfo.Additional.ContentReplaceFrom = ContentReplaceFrom.Text; gatherRuleInfo.Additional.ContentReplaceTo = ContentReplaceTo.Text; gatherRuleInfo.ContentChannelStart = ContentChannelStart.Text; gatherRuleInfo.ContentChannelEnd = ContentChannelEnd.Text; gatherRuleInfo.ContentNextPageStart = ContentNextPageStart.Text; gatherRuleInfo.ContentNextPageEnd = ContentNextPageEnd.Text; gatherRuleInfo.LastGatherDate = DateUtils.SqlMinValue; var valueArrayList = ControlUtils.GetSelectedListControlValueArrayList(ContentAttributes); gatherRuleInfo.ContentAttributes = TranslateUtils.ObjectCollectionToString(valueArrayList); var attributesXML = new NameValueCollection(); for (var i = 0; i < valueArrayList.Count; i++) { var attributeName = valueArrayList[i] as string; foreach (RepeaterItem item in ContentAttributesRepeater.Items) { if (item.ItemIndex == i) { var contentStart = (TextBox)item.FindControl("ContentStart"); var contentEnd = (TextBox)item.FindControl("ContentEnd"); //采集为空时的默认值 var contentDefault = (TextBox)item.FindControl("ContentDefault"); attributesXML[attributeName + "_ContentStart"] = StringUtils.ValueToUrl(contentStart.Text); attributesXML[attributeName + "_ContentEnd"] = StringUtils.ValueToUrl(contentEnd.Text); //采集为空时的默认值 attributesXML[attributeName + "_ContentDefault"] = StringUtils.ValueToUrl(contentDefault.Text); } } } gatherRuleInfo.ContentAttributesXml = TranslateUtils.NameValueCollectionToString(attributesXML); DataProvider.GatherRuleDao.Insert(gatherRuleInfo); } if (isNeedAdd) { Body.AddSiteLog(PublishmentSystemId, "添加Web页面采集规则", $"采集规则:{GatherRuleName.Text}"); } else { Body.AddSiteLog(PublishmentSystemId, "编辑Web页面采集规则", $"采集规则:{GatherRuleName.Text}"); } errorMessage = string.Empty; return(true); } catch { errorMessage = "操作失败!"; return(false); } }
public bool Validate_InsertGatherRule(out string errorMessage) { try { var isNeedAdd = false; if (_isEdit) { if (_theGatherRuleName != GatherRuleName.Text) { isNeedAdd = true; DataProvider.GatherDatabaseRuleDao.Delete(_theGatherRuleName, PublishmentSystemId); } else { var gatherFileRuleInfo = DataProvider.GatherFileRuleDao.GetGatherFileRuleInfo(_theGatherRuleName, PublishmentSystemId); gatherFileRuleInfo.GatherUrl = GatherUrl.Text; gatherFileRuleInfo.Charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); gatherFileRuleInfo.IsToFile = TranslateUtils.ToBool(IsToFile.SelectedValue); 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; if (NodeIDDropDownList.SelectedValue != null) { gatherFileRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherFileRuleInfo.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue); gatherFileRuleInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherFileRuleInfo.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherFileRuleInfo.ContentExclude = ContentExclude.Text; var htmlClearArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearCollection.Items) { if (item.Selected) { htmlClearArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearCollection = TranslateUtils.ObjectCollectionToString(htmlClearArrayList); var htmlClearTagArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearTagCollection.Items) { if (item.Selected) { htmlClearTagArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearTagCollection = TranslateUtils.ObjectCollectionToString(htmlClearTagArrayList); gatherFileRuleInfo.ContentTitleStart = ContentTitleStart.Text; gatherFileRuleInfo.ContentTitleEnd = ContentTitleEnd.Text; gatherFileRuleInfo.ContentContentStart = ContentContentStart.Text; gatherFileRuleInfo.ContentContentEnd = ContentContentEnd.Text; var valueArrayList = ControlUtils.GetSelectedListControlValueArrayList(ContentAttributes); gatherFileRuleInfo.ContentAttributes = TranslateUtils.ObjectCollectionToString(valueArrayList); var attributesXML = new NameValueCollection(); for (var i = 0; i < valueArrayList.Count; i++) { var attributeName = valueArrayList[i] as string; foreach (RepeaterItem item in ContentAttributesRepeater.Items) { if (item.ItemIndex == i) { var contentStart = (TextBox)item.FindControl("ContentStart"); var contentEnd = (TextBox)item.FindControl("ContentEnd"); attributesXML[attributeName + "_ContentStart"] = StringUtils.ValueToUrl(contentStart.Text); attributesXML[attributeName + "_ContentEnd"] = StringUtils.ValueToUrl(contentEnd.Text); } } } gatherFileRuleInfo.ContentAttributesXml = TranslateUtils.NameValueCollectionToString(attributesXML); DataProvider.GatherFileRuleDao.Update(gatherFileRuleInfo); } } else { isNeedAdd = true; } if (isNeedAdd) { var gatherFileRuleInfo = new GatherFileRuleInfo(); gatherFileRuleInfo.GatherRuleName = GatherRuleName.Text; gatherFileRuleInfo.PublishmentSystemId = PublishmentSystemId; if (NodeIDDropDownList.SelectedValue != null) { gatherFileRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherFileRuleInfo.GatherUrl = GatherUrl.Text; gatherFileRuleInfo.Charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); gatherFileRuleInfo.IsToFile = TranslateUtils.ToBool(IsToFile.SelectedValue); 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; if (NodeIDDropDownList.SelectedValue != null) { gatherFileRuleInfo.NodeId = int.Parse(NodeIDDropDownList.SelectedValue); } gatherFileRuleInfo.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue); gatherFileRuleInfo.IsChecked = TranslateUtils.ToBool(IsChecked.SelectedValue); gatherFileRuleInfo.IsAutoCreate = TranslateUtils.ToBool(IsAutoCreate.SelectedValue); gatherFileRuleInfo.ContentExclude = ContentExclude.Text; var htmlClearArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearCollection.Items) { if (item.Selected) { htmlClearArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearCollection = TranslateUtils.ObjectCollectionToString(htmlClearArrayList); var htmlClearTagArrayList = new ArrayList(); foreach (ListItem item in ContentHtmlClearTagCollection.Items) { if (item.Selected) { htmlClearTagArrayList.Add(item.Value); } } gatherFileRuleInfo.ContentHtmlClearTagCollection = TranslateUtils.ObjectCollectionToString(htmlClearTagArrayList); gatherFileRuleInfo.LastGatherDate = DateUtils.SqlMinValue; gatherFileRuleInfo.ContentTitleStart = ContentTitleStart.Text; gatherFileRuleInfo.ContentTitleEnd = ContentTitleEnd.Text; gatherFileRuleInfo.ContentContentStart = ContentContentStart.Text; gatherFileRuleInfo.ContentContentEnd = ContentContentEnd.Text; var valueArrayList = ControlUtils.GetSelectedListControlValueArrayList(ContentAttributes); gatherFileRuleInfo.ContentAttributes = TranslateUtils.ObjectCollectionToString(valueArrayList); var attributesXML = new NameValueCollection(); for (var i = 0; i < valueArrayList.Count; i++) { var attributeName = valueArrayList[i] as string; foreach (RepeaterItem item in ContentAttributesRepeater.Items) { if (item.ItemIndex == i) { var contentStart = (TextBox)item.FindControl("ContentStart"); var contentEnd = (TextBox)item.FindControl("ContentEnd"); attributesXML[attributeName + "_ContentStart"] = StringUtils.ValueToUrl(contentStart.Text); attributesXML[attributeName + "_ContentEnd"] = StringUtils.ValueToUrl(contentEnd.Text); } } } gatherFileRuleInfo.ContentAttributesXml = TranslateUtils.NameValueCollectionToString(attributesXML); DataProvider.GatherFileRuleDao.Insert(gatherFileRuleInfo); } if (isNeedAdd) { Body.AddSiteLog(PublishmentSystemId, "添加单文件页采集规则", $"采集规则:{GatherRuleName.Text}"); } else { Body.AddSiteLog(PublishmentSystemId, "编辑单文件页采集规则", $"采集规则:{GatherRuleName.Text}"); } errorMessage = string.Empty; return(true); } catch { errorMessage = "操作失败!"; return(false); } }
public IHttpActionResult Main() { try { var body = new RequestBody(); var form = HttpContext.Current.Request.Form; var publishmentSystemId = body.GetPostInt("publishmentSystemId"); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); var ajaxDivId = PageUtils.FilterSqlAndXss(body.GetPostString("ajaxDivId")); var pageNum = body.GetPostInt("pageNum"); var isHighlight = body.GetPostBool("isHighlight"); var isRedirectSingle = body.GetPostBool("isRedirectSingle"); var isDefaultDisplay = body.GetPostBool("isDefaultDisplay"); var dateAttribute = PageUtils.FilterSqlAndXss(body.GetPostString("dateAttribute")); if (string.IsNullOrEmpty(dateAttribute)) { dateAttribute = ContentAttribute.AddDate; } var pageIndex = body.GetPostInt("page", 1) - 1; var template = TranslateUtils.DecryptStringBySecretKey(body.GetPostString("template")); template = StlRequestEntities.ParseRequestEntities(form, template); var word = PageUtils.FilterSql(body.GetPostString("word")); var channelId = body.GetPostString("channelID"); var dateFrom = PageUtils.FilterSqlAndXss(body.GetPostString("dateFrom")); var dateTo = PageUtils.FilterSqlAndXss(body.GetPostString("dateTo")); var date = PageUtils.FilterSqlAndXss(body.GetPostString("date")); var typeCollection = TranslateUtils.StringCollectionToStringCollection(PageUtils.UrlDecode(PageUtils.FilterSqlAndXss(body.GetPostString("type")))); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, TranslateUtils.ToInt(channelId, publishmentSystemId)); if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, publishmentSystemId); } var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var excludeAttributes = "ajaxdivid,pagenum,pageindex,iscrosssite,ishighlight,isredirectsingle,isdefaultdisplay,charset,template,word,click,channelid,datefrom,dateto,date,type,dateattribute"; var templateInfo = new TemplateInfo(0, publishmentSystemId, string.Empty, ETemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharsetUtils.GetEnumType(publishmentSystemInfo.Additional.Charset), false); var pageInfo = new PageInfo(nodeInfo.NodeId, 0, publishmentSystemInfo, templateInfo, body.UserInfo); var contextInfo = new ContextInfo(pageInfo); var contentBuilder = new StringBuilder(template); var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString()); if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList)) { var stlElement = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList); var stlPageContentsElement = stlElement; var stlPageContentsElementReplaceString = stlElement; var whereString = DataProvider.ContentDao.GetWhereStringBySearchOutput(publishmentSystemInfo, nodeInfo.NodeId, tableStyle, word, typeCollection, channelId, dateFrom, dateTo, date, dateAttribute, excludeAttributes, form); //没搜索条件时不显示搜索结果 if (string.IsNullOrEmpty(whereString) && !isDefaultDisplay) { return(Ok(string.Empty)); } var stlPageContents = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, pageNum, whereString); int totalNum; var pageCount = stlPageContents.GetPageCount(out totalNum); if (totalNum == 0) { return(NotFound()); } var isRedirect = false; if (isRedirectSingle && totalNum == 1) { var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, stlPageContents.SqlString); if (contentInfo != null) { isRedirect = true; contentBuilder = new StringBuilder($@" <script> location.href = '{PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo)}'; </script> "); } } if (!isRedirect) { for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { if (currentPageIndex == pageIndex) { var pageHtml = stlPageContents.Parse(totalNum, currentPageIndex, pageCount, false); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentsElementReplaceString, pageHtml)); StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); if (isHighlight && !string.IsNullOrEmpty(word)) { var pagedContents = pagedBuilder.ToString(); pagedBuilder = new StringBuilder(); pagedBuilder.Append(RegexUtils.Replace( $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents, $"<span style='color:#cc0000'>{word}</span>")); } StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false); return(Ok(pagedBuilder.ToString())); } } } } else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList)) { var siteId = TranslateUtils.ToInt(body.GetPostString("siteID"), 0); var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList); var stlPageSqlContentsElement = stlElement; var stlPageSqlContentsElementReplaceString = stlElement; var whereBuilder = new StringBuilder(); if (!string.IsNullOrEmpty(word)) { whereBuilder.Append("("); foreach (var type in typeCollection) { whereBuilder.Append($"[{type}] like '%{word}%' OR "); } whereBuilder.Length = whereBuilder.Length - 3; whereBuilder.Append(")"); } if (!string.IsNullOrEmpty(dateFrom)) { if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append($" AddDate >= '{dateFrom}' "); } if (!string.IsNullOrEmpty(dateTo)) { if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append($" AddDate <= '{dateTo}' "); } if (!string.IsNullOrEmpty(date)) { var days = TranslateUtils.ToInt(date); if (days > 0) { if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append(SqlUtils.GetDateDiffLessThanDays("AddDate", days.ToString())); } } if (siteId > 0) { if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append($"(PublishmentSystemID = {siteId})"); } if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append("(NodeID > 0) "); var tableName = BaiRongDataProvider.TableCollectionDao.GetFirstTableNameByTableType(EAuxiliaryTableType.BackgroundContent); var arraylist = TranslateUtils.StringCollectionToStringList("ajaxdivid,pagenum,pageindex,iscrosssite,ishighlight,isredirectsingle,isdefaultdisplay,charset,successtemplatestring,failuretemplatestring,word,click,channelid,datefrom,dateto,date,type,siteid"); foreach (string key in form.Keys) { if (arraylist.Contains(key.ToLower())) { continue; } if (!string.IsNullOrEmpty(form[key])) { var value = StringUtils.Trim(form[key]); if (!string.IsNullOrEmpty(value)) { if (TableManager.IsAttributeNameExists(tableStyle, tableName, key)) { if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append($"([{key}] like '%{value}%')"); } else { if (whereBuilder.Length > 0) { whereBuilder.Append(" AND "); } whereBuilder.Append($"({ContentAttribute.SettingsXml} like '%{key}={value}%')"); } } } } //没搜索条件时不显示搜索结果 if (whereBuilder.Length == 0 && isDefaultDisplay == false) { return(Ok(string.Empty)); } var stlPageSqlContents = new StlPageSqlContents(stlPageSqlContentsElement, pageInfo, contextInfo, false, false); if (string.IsNullOrEmpty(stlPageSqlContents.DisplayInfo.QueryString)) { stlPageSqlContents.DisplayInfo.QueryString = $"SELECT * FROM {tableName} WHERE {whereBuilder}"; } stlPageSqlContents.LoadData(); int totalNum; var pageCount = stlPageSqlContents.GetPageCount(out totalNum); if (totalNum == 0) { return(NotFound()); } for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++) { if (currentPageIndex == pageIndex) { var pageHtml = stlPageSqlContents.Parse(currentPageIndex, pageCount); var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageSqlContentsElementReplaceString, pageHtml)); StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageNodeId, currentPageIndex, pageCount, totalNum); if (isHighlight && !string.IsNullOrEmpty(word)) { var pagedContents = pagedBuilder.ToString(); pagedBuilder = new StringBuilder(); pagedBuilder.Append(RegexUtils.Replace( $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents, $"<span style='color:#cc0000'>{word}</span>")); } StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, pagedBuilder, string.Empty, false); return(Ok(pagedBuilder.ToString())); } } } StlUtility.ParseStl(publishmentSystemInfo, pageInfo, contextInfo, contentBuilder, string.Empty, false); return(Ok(contentBuilder.ToString())); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "RelatedPath", "FileName", "IsCreate"); _relatedPath = AuthRequest.GetQueryString("RelatedPath").Trim('/'); if (!_relatedPath.StartsWith("@")) { _relatedPath = "@/" + _relatedPath; } _theFileName = AuthRequest.GetQueryString("FileName"); _isCreate = AuthRequest.GetQueryBool("IsCreate"); _fileCharset = ECharset.utf_8; if (SiteInfo != null) { _fileCharset = ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset); } if (_isCreate == false) { var filePath = SiteInfo != null ? PathUtility.MapPath(SiteInfo, PathUtils.Combine(_relatedPath, _theFileName)) : PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName)); if (!FileUtils.IsFileExists(filePath)) { PageUtils.RedirectToErrorPage("此文件不存在!"); return; } } if (IsPostBack) { return; } DdlCharset.Items.Add(new ListItem("默认", string.Empty)); ECharsetUtils.AddListItems(DdlCharset); if (_isCreate == false) { var filePath = SiteInfo != null?PathUtility.MapPath(SiteInfo, PathUtils.Combine(_relatedPath, _theFileName)) : PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName)); TbFileName.Text = _theFileName; TbFileName.Enabled = false; TbFileContent.Text = FileUtils.ReadText(filePath, _fileCharset); } if (_isCreate) { return; } if (SiteInfo != null) { LtlOpen.Text = $@"<a class=""btn btn-default m-l-10"" href=""{PageUtility.ParseNavigationUrl(SiteInfo, PageUtils.Combine(_relatedPath, _theFileName), true)}"" target=""_blank"">浏 览</a>"; } else { LtlOpen.Text = $@"<a class=""btn btn-default m-l-10"" href=""{PageUtils.ParseConfigRootUrl(PageUtils.Combine(_relatedPath, _theFileName))}"" target=""_blank"">浏 览</a>"; } LtlView.Text = $@"<a class=""btn btn-default m-l-10"" href=""{ModalFileView.GetRedirectUrl(SiteId, _relatedPath, _theFileName)}"">查 看</a>"; }
private void Save(bool isClose) { var isSuccess = false; var errorMessage = string.Empty; var content = TranslateUtils.ToBool(DdlIsPureText.SelectedValue) ? TbFileContent.Text : UeFileContent.Text; if (_isCreate == false) { var fileExtName = PathUtils.GetExtension(_theFileName); if (!PathUtility.IsFileExtenstionAllowed(SiteInfo, fileExtName)) { FailMessage("此格式不允许创建,请选择有效的文件名"); return; } var filePath = SiteInfo != null ? PathUtility.MapPath(SiteInfo, PathUtils.Combine(_relatedPath, _theFileName)) : PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName)); try { try { if (!string.IsNullOrEmpty(DdlCharset.SelectedValue)) { _fileCharset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); } FileUtils.WriteText(filePath, _fileCharset, content); } catch { FileUtils.RemoveReadOnlyAndHiddenIfExists(filePath); FileUtils.WriteText(filePath, _fileCharset, content); } AuthRequest.AddSiteLog(SiteId, "新建文件", $"文件名:{_theFileName}"); isSuccess = true; } catch (Exception ex) { errorMessage = ex.Message; } } else { var fileExtName = PathUtils.GetExtension(TbFileName.Text); if (!PathUtility.IsFileExtenstionAllowed(SiteInfo, fileExtName)) { FailMessage("此格式不允许创建,请选择有效的文件名"); return; } var filePath = SiteInfo != null ? PathUtility.MapPath(SiteInfo, PathUtils.Combine(_relatedPath, TbFileName.Text)) : PathUtils.MapPath(PathUtils.Combine(_relatedPath, TbFileName.Text)); if (FileUtils.IsFileExists(filePath)) { errorMessage = "文件名已存在!"; } else { try { try { FileUtils.WriteText(filePath, _fileCharset, content); } catch { FileUtils.RemoveReadOnlyAndHiddenIfExists(filePath); FileUtils.WriteText(filePath, _fileCharset, content); } AuthRequest.AddSiteLog(SiteId, "编辑文件", $"文件名:{_theFileName}"); isSuccess = true; } catch (Exception ex) { errorMessage = ex.Message; } } } if (isSuccess) { if (isClose) { if (_isCreate) { LayerUtils.Close(Page); } else { LayerUtils.CloseWithoutRefresh(Page); } } else { SuccessMessage("文件保存成功!"); } } else { FailMessage(errorMessage); } }
public TemplateInfo GetTemplateByUrlType(int publishmentSystemId, ETemplateType type, string createdFileFullName) { TemplateInfo info = null; var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type)), GetParameter(ParmCreatedFileFullName, EDataType.VarChar, 50, createdFileFullName) }; using (var rdr = ExecuteReader(SqlSelectTemplateByUrlType, parms)) { while (rdr.Read()) { var i = 0; info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ETemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i)); } rdr.Close(); } return(info); }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } if (_fileName != null) { var isChanged = false; if (PathUtils.RemoveExtension(_fileName) != PathUtils.RemoveExtension(TbRelatedFileName.Text))//文件名改变 { var fileNames = DirectoryUtils.GetFileNames(_directoryPath); foreach (var theFileName in fileNames) { var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName); if (fileNameWithoutExtension == TbRelatedFileName.Text.ToLower()) { FailMessage("样式文件修改失败,样式文件已存在!"); return; } } isChanged = true; } var previousFileName = string.Empty; if (isChanged) { previousFileName = _fileName; } var currentFileName = TbRelatedFileName.Text + ".css"; var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text); if (!string.IsNullOrEmpty(previousFileName)) { FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, previousFileName)); } Body.AddSiteLog(SiteId, "修改样式文件", $"样式文件:{currentFileName}"); SuccessMessage("样式文件修改成功!"); AddWaitAndRedirectScript(PageTemplateCss.GetRedirectUrl(SiteId)); } else { var currentFileName = TbRelatedFileName.Text + ".css"; var fileNames = DirectoryUtils.GetFileNames(_directoryPath); foreach (var theFileName in fileNames) { if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName)) { FailMessage("样式文件添加失败,样式文件文件已存在!"); return; } } var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text); Body.AddSiteLog(SiteId, "添加样式文件", $"样式文件:{currentFileName}"); SuccessMessage("样式文件添加成功!"); AddWaitAndRedirectScript(PageTemplateCss.GetRedirectUrl(SiteId)); } }
public string CreateIncludeFile(string virtualUrl, bool isCreateIfExists) { var templateInfo = new TemplateInfo(0, PublishmentSystemId, string.Empty, ETemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharsetUtils.GetEnumType(PublishmentSystemInfo.Additional.Charset), false); var pageInfo = new PageInfo(PublishmentSystemId, 0, PublishmentSystemInfo, templateInfo, null); var contextInfo = new ContextInfo(pageInfo); var parsedVirtualUrl = virtualUrl.Substring(0, virtualUrl.LastIndexOf('.')) + "_parsed" + virtualUrl.Substring(virtualUrl.LastIndexOf('.')); var filePath = PathUtility.MapPath(PublishmentSystemInfo, parsedVirtualUrl); if (!isCreateIfExists && FileUtils.IsFileExists(filePath)) { return(parsedVirtualUrl); } var contentBuilder = new StringBuilder(StlCacheManager.FileContent.GetIncludeContent(PublishmentSystemInfo, virtualUrl, pageInfo.TemplateInfo.Charset)); StlParserManager.ParseTemplateContent(contentBuilder, pageInfo, contextInfo); var pageAfterBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, true); var pageBeforeBodyScripts = StlParserManager.GetPageInfoScript(pageInfo, false); contentBuilder.Insert(0, pageBeforeBodyScripts); contentBuilder.Append(pageAfterBodyScripts); GenerateFile(filePath, pageInfo.TemplateInfo.Charset, contentBuilder); return(parsedVirtualUrl); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (fileName != null) { var isChanged = false; if (PathUtils.RemoveExtension(fileName) != PathUtils.RemoveExtension(RelatedFileName.Text))//文件名改变 { var fileNames = DirectoryUtils.GetFileNames(directoryPath); foreach (var theFileName in fileNames) { var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName); if (fileNameWithoutExtension == RelatedFileName.Text.ToLower()) { FailMessage("脚本文件修改失败,脚本文件已存在!"); return; } } isChanged = true; } if (PathUtils.GetExtension(fileName) != ltlCreatedFileExtName.Text)//文件后缀改变 { isChanged = true; } var previousFileName = string.Empty; if (isChanged) { previousFileName = fileName; } var currentFileName = RelatedFileName.Text + ltlCreatedFileExtName.Text; var charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); try { FileUtils.WriteText(PathUtils.Combine(directoryPath, currentFileName), charset, Content.Text); if (!string.IsNullOrEmpty(previousFileName)) { FileUtils.DeleteFileIfExists(PathUtils.Combine(directoryPath, previousFileName)); } Body.AddSiteLog(PublishmentSystemId, "修改脚本文件", $"脚本文件:{currentFileName}"); SuccessMessage("脚本文件修改成功!"); AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(PublishmentSystemId)); } catch (Exception ex) { FailMessage(ex, "脚本文件修改失败," + ex.Message); } } else { var currentFileName = RelatedFileName.Text + ltlCreatedFileExtName.Text; var fileNames = DirectoryUtils.GetFileNames(directoryPath); foreach (var theFileName in fileNames) { if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName)) { FailMessage("脚本文件添加失败,脚本文件文件已存在!"); return; } } var charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); try { FileUtils.WriteText(PathUtils.Combine(directoryPath, currentFileName), charset, Content.Text); Body.AddSiteLog(PublishmentSystemId, "添加脚本文件", $"脚本文件:{currentFileName}"); SuccessMessage("脚本文件添加成功!"); AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(PublishmentSystemId)); } catch (Exception ex) { FailMessage(ex, "脚本文件添加失败," + ex.Message); } } } }
public GatherFileRuleInfo GetGatherFileRuleInfo(string gatherRuleName, int publishmentSystemId) { GatherFileRuleInfo gatherFileRuleInfo = null; var parms = new IDataParameter[] { GetParameter(ParmGatherFileRuleName, EDataType.NVarChar, 50, gatherRuleName), GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectGatherFileRule, parms)) { if (rdr.Read()) { var i = 0; gatherFileRuleInfo = new GatherFileRuleInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetDateTime(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetBool(rdr, i)); } rdr.Close(); } return(gatherFileRuleInfo); }
public List <TemplateInfo> GetTemplateInfoListBySiteId(int siteId) { var list = new List <TemplateInfo>(); var parms = new IDataParameter[] { GetParameter(ParmSiteId, DataType.Integer, siteId) }; using (var rdr = ExecuteReader(SqlSelectAllTemplateBySiteId, parms)) { while (rdr.Read()) { var i = 0; var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), TemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i)); list.Add(info); } rdr.Close(); } return(list); }
public ArrayList GetGatherFileRuleInfoArrayList(int publishmentSystemId) { var list = new ArrayList(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId) }; using (var rdr = ExecuteReader(SqlSelectAllGatherFileRuleByPsId, parms)) { while (rdr.Read()) { var i = 0; var gatherFileRuleInfo = new GatherFileRuleInfo(GetString(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetDateTime(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i++), GetBool(rdr, i++), GetBool(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetBool(rdr, i)); list.Add(gatherFileRuleInfo); } rdr.Close(); } return(list); }
public Dictionary <int, TemplateInfo> GetTemplateInfoDictionaryBySiteId(int siteId) { var dictionary = new Dictionary <int, TemplateInfo>(); var parms = new IDataParameter[] { GetParameter(ParmSiteId, DataType.Integer, siteId) }; using (var rdr = ExecuteReader(SqlSelectAllTemplateBySiteId, parms)) { while (rdr.Read()) { var i = 0; var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), TemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i)); dictionary.Add(info.Id, info); } rdr.Close(); } return(dictionary); }
public void CreateChannelTemplate_Click(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (Validate(false, false)) { var defaultChannelTemplateId = TemplateManager.GetDefaultTemplateID(PublishmentSystemId, ETemplateType.ChannelTemplate); var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(PublishmentSystemId, ETemplateType.ChannelTemplate); var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(PublishmentSystemId, ETemplateType.ChannelTemplate); foreach (ListItem item in NodeIDCollectionToMatch.Items) { if (item.Selected) { var nodeId = int.Parse(item.Value); var channelTemplateId = -1; var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId); if (nodeInfo.NodeType != ENodeType.BackgroundPublishNode) { channelTemplateId = nodeInfo.ChannelTemplateId; } if (channelTemplateId != -1 && channelTemplateId != 0 && channelTemplateId != defaultChannelTemplateId) { if (TemplateManager.GetTemplateInfo(PublishmentSystemId, channelTemplateId) == null) { channelTemplateId = -1; } } if (channelTemplateId != -1) { var templateInfo = new TemplateInfo(0, PublishmentSystemId, nodeInfo.NodeName, ETemplateType.ChannelTemplate, "T_" + nodeInfo.NodeName + ".html", "index.html", ".html", ECharsetUtils.GetEnumType(PublishmentSystemInfo.Additional.Charset), false); if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower())) { continue; } else if (templateNameList.Contains(templateInfo.TemplateName)) { continue; } var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, Body.AdministratorName); if (nodeInfo.NodeType != ENodeType.BackgroundPublishNode) { TemplateManager.UpdateChannelTemplateID(PublishmentSystemId, nodeId, insertedTemplateId); //DataProvider.BackgroundNodeDAO.UpdateChannelTemplateID(nodeID, insertedTemplateID); } } } } Body.AddSiteLog(PublishmentSystemId, "生成并匹配栏目模版", $"栏目:{GetNodeNames()}"); SuccessMessage("生成栏目模版并匹配成功!"); BindListBox(); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } if (_templateType != TemplateType.ChannelTemplate) { if (!TbCreatedFileFullName.Text.StartsWith("~") && !TbCreatedFileFullName.Text.StartsWith("@")) { TbCreatedFileFullName.Text = PageUtils.Combine("@", TbCreatedFileFullName.Text); } } else { TbCreatedFileFullName.Text = TbCreatedFileFullName.Text.TrimStart('~', '@'); TbCreatedFileFullName.Text = TbCreatedFileFullName.Text.Replace("/", string.Empty); } if (AuthRequest.GetQueryInt("TemplateID") > 0 && _isCopy == false) { var templateId = AuthRequest.GetQueryInt("TemplateID"); var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId); if (templateInfo.TemplateName != TbTemplateName.Text) { var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, templateInfo.TemplateType); if (templateNameList.IndexOf(TbTemplateName.Text) != -1) { FailMessage("模板修改失败,模板名称已存在!"); return; } } TemplateInfo previousTemplateInfo = null; var isChanged = false; if (PathUtils.RemoveExtension(templateInfo.RelatedFileName) != PathUtils.RemoveExtension(TbRelatedFileName.Text)) //文件名改变 { var fileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, templateInfo.TemplateType); foreach (var fileName in fileNameList) { var fileNameWithoutExtension = PathUtils.RemoveExtension(fileName); if (fileNameWithoutExtension == TbRelatedFileName.Text.ToLower()) { FailMessage("模板修改失败,模板文件已存在!"); return; } } isChanged = true; } if (GetTemplateFileExtension(templateInfo) != DdlCreatedFileExtName.SelectedValue) //文件后缀改变 { isChanged = true; } if (isChanged) { previousTemplateInfo = new TemplateInfo(templateInfo.Id, templateInfo.SiteId, templateInfo.TemplateName, templateInfo.TemplateType, templateInfo.RelatedFileName, templateInfo.CreatedFileFullName, templateInfo.CreatedFileExtName, templateInfo.Charset, templateInfo.IsDefault); } templateInfo.TemplateName = TbTemplateName.Text; templateInfo.RelatedFileName = TbRelatedFileName.Text + DdlCreatedFileExtName.SelectedValue; templateInfo.CreatedFileExtName = DdlCreatedFileExtName.SelectedValue; templateInfo.CreatedFileFullName = TbCreatedFileFullName.Text + DdlCreatedFileExtName.SelectedValue; templateInfo.Charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); DataProvider.TemplateDao.Update(SiteInfo, templateInfo, TbContent.Text, AuthRequest.AdminName); if (previousTemplateInfo != null) { FileUtils.DeleteFileIfExists(TemplateManager.GetTemplateFilePath(SiteInfo, previousTemplateInfo)); } CreatePages(templateInfo); AuthRequest.AddSiteLog(SiteId, $"修改{TemplateTypeUtils.GetText(templateInfo.TemplateType)}", $"模板名称:{templateInfo.TemplateName}"); SuccessMessage("模板修改成功!"); } else { var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateTypeUtils.GetEnumType(HihTemplateType.Value)); if (templateNameList.IndexOf(TbTemplateName.Text) != -1) { FailMessage("模板添加失败,模板名称已存在!"); return; } var fileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateTypeUtils.GetEnumType(HihTemplateType.Value)); if (fileNameList.IndexOf(TbRelatedFileName.Text.ToLower()) != -1) { FailMessage("模板添加失败,模板文件已存在!"); return; } var templateInfo = new TemplateInfo { SiteId = SiteId, TemplateName = TbTemplateName.Text, TemplateType = TemplateTypeUtils.GetEnumType(HihTemplateType.Value), RelatedFileName = TbRelatedFileName.Text + DdlCreatedFileExtName.SelectedValue, CreatedFileExtName = DdlCreatedFileExtName.SelectedValue, CreatedFileFullName = TbCreatedFileFullName.Text + DdlCreatedFileExtName.SelectedValue, Charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue), IsDefault = false }; templateInfo.Id = DataProvider.TemplateDao.Insert(templateInfo, TbContent.Text, AuthRequest.AdminName); CreatePages(templateInfo); AuthRequest.AddSiteLog(SiteId, $"添加{TemplateTypeUtils.GetText(templateInfo.TemplateType)}", $"模板名称:{templateInfo.TemplateName}"); SuccessMessage("模板添加成功!"); AddWaitAndRedirectScript(PageTemplate.GetRedirectUrl(SiteId, _templateType)); } }
public void CreateSubContentTemplate_Click(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (Validate(false, false)) { var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(PublishmentSystemId, ETemplateType.ContentTemplate); var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(PublishmentSystemId, ETemplateType.ContentTemplate); foreach (ListItem item in NodeIDCollectionToMatch.Items) { if (item.Selected) { var nodeId = int.Parse(item.Value); var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId); var templateInfo = new TemplateInfo(0, PublishmentSystemId, nodeInfo.NodeName + "_下级", ETemplateType.ContentTemplate, "T_" + nodeInfo.NodeName + "_下级.html", "index.html", ".html", ECharsetUtils.GetEnumType(PublishmentSystemInfo.Additional.Charset), false); if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower())) { continue; } else if (templateNameList.Contains(templateInfo.TemplateName)) { continue; } var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, Body.AdministratorName); var childNodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(nodeId); foreach (var childNodeId in childNodeIdList) { TemplateManager.UpdateContentTemplateID(PublishmentSystemId, childNodeId, insertedTemplateId); //DataProvider.BackgroundNodeDAO.UpdateContentTemplateID(childNodeID, insertedTemplateID); } } } Body.AddSiteLog(PublishmentSystemId, "生成并匹配下级内容模版", $"栏目:{GetNodeNames()}"); SuccessMessage("生成下级内容模版并匹配成功!"); BindListBox(); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } var relatedFileName = TbRelatedFileName.Text; if (!StringUtils.EndsWithIgnoreCase(relatedFileName, _ext)) { relatedFileName += _ext; } if (_fileName != null) { var isChanged = false; if (!StringUtils.EqualsIgnoreCase(_fileName, relatedFileName))//文件名改变 { var fileNames = DirectoryUtils.GetFileNames(_directoryPath); foreach (var theFileName in fileNames) { if (StringUtils.EqualsIgnoreCase(theFileName, relatedFileName)) { FailMessage($"{_name}修改失败,文件已存在!"); return; } } isChanged = true; } var previousFileName = string.Empty; if (isChanged) { previousFileName = _fileName; } var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); FileUtils.WriteText(PathUtils.Combine(_directoryPath, relatedFileName), charset, TbContent.Text); if (!string.IsNullOrEmpty(previousFileName)) { FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, previousFileName)); } AuthRequest.AddSiteLog(SiteId, $"修改{_name}", $"{_name}:{relatedFileName}"); SuccessMessage($"{_name}修改成功!"); AddWaitAndRedirectScript(PageTemplateAssets.GetRedirectUrl(SiteId, _type)); } else { var fileNames = DirectoryUtils.GetFileNames(_directoryPath); foreach (var theFileName in fileNames) { if (StringUtils.EqualsIgnoreCase(theFileName, relatedFileName)) { FailMessage($"{_name}添加失败,文件已存在!"); return; } } var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); FileUtils.WriteText(PathUtils.Combine(_directoryPath, relatedFileName), charset, TbContent.Text); AuthRequest.AddSiteLog(SiteId, $"添加{_name}", $"{_name}:{relatedFileName}"); SuccessMessage($"{_name}添加成功!"); AddWaitAndRedirectScript(PageTemplateAssets.GetRedirectUrl(SiteId, _type)); } }
public List <TemplateInfo> GetTemplateInfoListByType(int publishmentSystemId, ETemplateType type) { var list = new List <TemplateInfo>(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type)) }; using (var rdr = ExecuteReader(SqlSelectAllTemplateByType, parms)) { while (rdr.Read()) { var i = 0; var info = new TemplateInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), ETemplateTypeUtils.GetEnumType(GetString(rdr, i++)), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), ECharsetUtils.GetEnumType(GetString(rdr, i++)), GetBool(rdr, i)); list.Add(info); } rdr.Close(); } return(list); }
public void CreateSubContentTemplate_Click(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) { return; } var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateType.ContentTemplate); var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateType.ContentTemplate); foreach (ListItem item in LbChannelId.Items) { if (!item.Selected) { continue; } var channelId = int.Parse(item.Value); var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId); var templateInfo = new TemplateInfo(0, SiteId, nodeInfo.ChannelName + "_下级", TemplateType.ContentTemplate, "T_" + nodeInfo.ChannelName + "_下级.html", "index.html", ".html", ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false); if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower())) { continue; } if (templateNameList.Contains(templateInfo.TemplateName)) { continue; } var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, AuthRequest.AdminName); var childChannelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(SiteId, channelId), EScopeType.Descendant, string.Empty, string.Empty, string.Empty); foreach (var childChannelId in childChannelIdList) { var childChannelInfo = ChannelManager.GetChannelInfo(SiteId, childChannelId); childChannelInfo.ContentTemplateId = insertedTemplateId; DataProvider.ChannelDao.UpdateContentTemplateId(childChannelInfo); //TemplateManager.UpdateContentTemplateId(SiteId, childChannelId, insertedTemplateId); //DataProvider.BackgroundNodeDAO.UpdateContentTemplateID(childChannelId, insertedTemplateID); } } AuthRequest.AddSiteLog(SiteId, "生成并匹配下级内容模版", $"栏目:{GetNodeNames()}"); SuccessMessage("生成下级内容模版并匹配成功!"); BindListBox(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID", "RelatedPath", "FileName", "IsCreate"); _relatedPath = Body.GetQueryString("RelatedPath").Trim('/'); if (!_relatedPath.StartsWith("@")) { _relatedPath = "@/" + _relatedPath; } _theFileName = Body.GetQueryString("FileName"); _isCreate = Body.GetQueryBool("IsCreate"); _fileCharset = ECharset.utf_8; if (PublishmentSystemInfo != null) { _fileCharset = ECharsetUtils.GetEnumType(PublishmentSystemInfo.Additional.Charset); } if (_isCreate == false) { string filePath; if (PublishmentSystemInfo != null) { filePath = PathUtility.MapPath(PublishmentSystemInfo, PathUtils.Combine(_relatedPath, _theFileName)); } else { filePath = PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName)); } if (!FileUtils.IsFileExists(filePath)) { PageUtils.RedirectToErrorPage("此文件不存在!"); return; } } if (!IsPostBack) { Charset.Items.Add(new ListItem("默认", string.Empty)); ECharsetUtils.AddListItems(Charset); if (_isCreate == false) { var filePath = string.Empty; if (PublishmentSystemInfo != null) { filePath = PathUtility.MapPath(PublishmentSystemInfo, PathUtils.Combine(_relatedPath, _theFileName)); } else { filePath = PathUtils.MapPath(PathUtils.Combine(_relatedPath, _theFileName)); } FileName.Text = _theFileName; FileName.Enabled = false; FileContentTextBox.Text = FileUtils.ReadText(filePath, _fileCharset); } if (!_isCreate) { if (PublishmentSystemInfo != null) { ltlOpen.Text = $@"<a href=""{PageUtility.ParseNavigationUrl(PublishmentSystemInfo, PageUtils.Combine(_relatedPath, _theFileName))}"" target=""_blank"">浏 览</a> "; } else { ltlOpen.Text = $@"<a href=""{PageUtils.ParseConfigRootUrl(PageUtils.Combine(_relatedPath, _theFileName))}"" target=""_blank"">浏 览</a> "; } ltlView.Text = $@"<a href=""{ModalFileView.GetRedirectUrl(PublishmentSystemId, _relatedPath, _theFileName)}"">属 性</a>"; } } }