public void Update(PublishmentSystemInfo publishmentSystemInfo, TemplateInfo templateInfo, string templateContent, string administratorName) { if (templateInfo.IsDefault) { SetAllTemplateDefaultToFalse(publishmentSystemInfo.PublishmentSystemId, templateInfo.TemplateType); } var updateParms = new IDataParameter[] { GetParameter(ParmTemplateName, EDataType.NVarChar, 50, templateInfo.TemplateName), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateInfo.TemplateType)), GetParameter(ParmRelatedFileName, EDataType.NVarChar, 50, templateInfo.RelatedFileName), GetParameter(ParmCreatedFileFullName, EDataType.NVarChar, 50, templateInfo.CreatedFileFullName), GetParameter(ParmCreatedFileExtName, EDataType.VarChar, 50, templateInfo.CreatedFileExtName), GetParameter(ParmCharset, EDataType.VarChar, 50, ECharsetUtils.GetValue(templateInfo.Charset)), GetParameter(ParmIsDefault, EDataType.VarChar, 18, templateInfo.IsDefault.ToString()), GetParameter(ParmTemplateId, EDataType.Integer, templateInfo.TemplateId) }; ExecuteNonQuery(SqlUpdateTemplate, updateParms); TemplateManager.WriteContentToTemplateFile(publishmentSystemInfo, templateInfo, templateContent, administratorName); TemplateManager.RemoveCache(templateInfo.PublishmentSystemId); }
private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, bool isGetUrlFromAttribute, string channelIndex, string channelName, string type, string scope, bool isAverage, string style, int addNum, string since) { var channelId = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(pageInfo.PublishmentSystemId, contextInfo.ChannelID, channelIndex, channelName); var contentId = 0; //判断是否链接地址由标签属性获得 if (isGetUrlFromAttribute == false) { contentId = contextInfo.ContentID; } var templateType = pageInfo.TemplateInfo.TemplateType; if (contextInfo.ChannelID != 0) { templateType = ETemplateType.ChannelTemplate; if (contentId != 0) { templateType = ETemplateType.ContentTemplate; } } return(GetAnalysisValue(pageInfo, channelId, contentId, ETemplateTypeUtils.GetValue(templateType), type, scope, isAverage, style, addNum, since, string.Empty)); }
public static string GetRedirectUrl(int publishmentSystemId, int templateId, ETemplateType templateType) { return(PageUtils.GetCmsUrl(nameof(PageTemplateAdd), new NameValueCollection { { "PublishmentSystemID", publishmentSystemId.ToString() }, { "TemplateID", templateId.ToString() }, { "TemplateType", ETemplateTypeUtils.GetValue(templateType) } })); }
public static string GetDeleteAllPageUrl(int publishmentSystemId, ETemplateType templateType) { return(PageUtils.GetCmsUrl(nameof(PageProgressBar), new NameValueCollection { { "PublishmentSystemID", publishmentSystemId.ToString() }, { "TemplateType", ETemplateTypeUtils.GetValue(templateType) }, { "DeleteAllPage", true.ToString() } })); }
/// <summary> /// 初始化首页模板 /// </summary> /// <param name="appId"></param> public void InitDefaultContentTemplate(long appId) { this.Title = ContentDefaultTitle; this.Name = ContentDefaultName; this.Type = ETemplateTypeUtils.GetValue(ETemplateType.ContentTemplate); this.AppId = appId; this.Extension = DefaultExtension; this.IsDefault = true; }
public static string GetUrl(string apiUrl, int publishmentSystemId, int uniqueId, string area, int channelId, int fileTemplateId, ETemplateType templateType) { apiUrl = PageUtils.Combine(apiUrl, Route); apiUrl = apiUrl.Replace("{publishmentSystemId}", publishmentSystemId.ToString()); apiUrl = apiUrl.Replace("{uniqueId}", uniqueId.ToString()); apiUrl = apiUrl.Replace("{area}", area); apiUrl = apiUrl.Replace("{channelId}", channelId.ToString()); apiUrl = apiUrl.Replace("{fileTemplateId}", fileTemplateId.ToString()); apiUrl = apiUrl.Replace("{templateType}", ETemplateTypeUtils.GetValue(templateType)); return(apiUrl); }
public IEnumerable GetDataSourceByType(int publishmentSystemId, ETemplateType type) { var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type)) }; var enumerable = (IEnumerable)ExecuteReader(SqlSelectAllTemplateByType, parms); return(enumerable); }
private void SetAllTemplateDefaultToFalse(int publishmentSystemId, ETemplateType templateType) { var sqlString = "UPDATE siteserver_Template SET IsDefault = @IsDefault WHERE PublishmentSystemID = @PublishmentSystemID AND TemplateType = @TemplateType"; var updateParms = new IDataParameter[] { GetParameter(ParmIsDefault, EDataType.VarChar, 18, false.ToString()), GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateType)) }; ExecuteNonQuery(sqlString, updateParms); }
public int Insert(TemplateInfo templateInfo, string templateContent, string administratorName) { int templateId; if (templateInfo.IsDefault) { SetAllTemplateDefaultToFalse(templateInfo.PublishmentSystemId, templateInfo.TemplateType); } var sqlInsertTemplate = "INSERT INTO siteserver_Template (PublishmentSystemID, TemplateName, TemplateType, RelatedFileName, CreatedFileFullName, CreatedFileExtName, Charset, IsDefault) VALUES (@PublishmentSystemID, @TemplateName, @TemplateType, @RelatedFileName, @CreatedFileFullName, @CreatedFileExtName, @Charset, @IsDefault)"; var insertParms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, templateInfo.PublishmentSystemId), GetParameter(ParmTemplateName, EDataType.NVarChar, 50, templateInfo.TemplateName), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateInfo.TemplateType)), GetParameter(ParmRelatedFileName, EDataType.NVarChar, 50, templateInfo.RelatedFileName), GetParameter(ParmCreatedFileFullName, EDataType.NVarChar, 50, templateInfo.CreatedFileFullName), GetParameter(ParmCreatedFileExtName, EDataType.VarChar, 50, templateInfo.CreatedFileExtName), GetParameter(ParmCharset, EDataType.VarChar, 50, ECharsetUtils.GetValue(templateInfo.Charset)), GetParameter(ParmIsDefault, EDataType.VarChar, 18, templateInfo.IsDefault.ToString()) }; using (var conn = GetConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { templateId = ExecuteNonQueryAndReturnId(trans, sqlInsertTemplate, insertParms); trans.Commit(); } catch { trans.Rollback(); throw; } } } var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(templateInfo.PublishmentSystemId); TemplateManager.WriteContentToTemplateFile(publishmentSystemInfo, templateInfo, templateContent, administratorName); TemplateManager.RemoveCache(templateInfo.PublishmentSystemId); return(templateId); }
public async Task Should_Create() { //default app var deraultApp = await _appManager.FindDefaultAsync(); //Act var t = new Templates.Template(deraultApp.Id, "test", "T_test", ETemplateTypeUtils.GetValue(ETemplateType.FileTemplate), Templates.Template.DefaultExtension, false); t.TemplateContent = "123123"; await _templateManager.CreateAsync(t); //Assert var root1 = GetTemplateOrNull("test"); root1.ShouldNotBeNull(); }
/// <summary> /// 获取模板文件路径 /// </summary> /// <param name="template"></param> /// <returns></returns> public string GetTemplateFilePath(Template template) { if (template.Type == ETemplateTypeUtils.GetValue(ETemplateType.IndexTemplate)) { return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.IndexTemplateDirName, template.Name + template.Extension)); } else if (template.Type == ETemplateTypeUtils.GetValue(ETemplateType.ChannelTemplate)) { return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.ChannelTemplateDirName, template.Name + template.Extension)); } else if (template.Type == ETemplateTypeUtils.GetValue(ETemplateType.ContentTemplate)) { return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.ContentTemplateDirName, template.Name + template.Extension)); } else { return(PathUtils.Combine(DirectoryUtils.Instance.PhysicalApplicationPath, template.App.AppDir, DirectoryUtils.Template.TemplateDirName, DirectoryUtils.Template.FileTemplateDirName, template.Name + template.Extension)); } }
public List <int> GetTemplateIdListByType(int publishmentSystemId, ETemplateType type) { var list = new List <int>(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type)) }; using (var rdr = ExecuteReader(SqlSelectAllTemplateIdByType, parms)) { while (rdr.Read()) { var templateId = GetInt(rdr, 0); list.Add(templateId); } rdr.Close(); } return(list); }
public ArrayList GetTemplateNameArrayList(int publishmentSystemId, ETemplateType templateType) { var list = new ArrayList(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateType)) }; using (var rdr = ExecuteReader(SqlSelectTemplateNames, parms)) { while (rdr.Read()) { list.Add(GetString(rdr, 0)); } rdr.Close(); } return(list); }
public TemplateInfo GetTemplateByTemplateId(int publishmentSystemId, ETemplateType type, string tId) { TemplateInfo info = null; var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(type)), GetParameter(ParmTemplateId, EDataType.Integer, tId) }; using (var rdr = ExecuteReader(SqlSelectTemplateByTemplateid, parms)) { if (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 List <string> GetLowerRelatedFileNameList(int publishmentSystemId, ETemplateType templateType) { var list = new List <string>(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmTemplateType, EDataType.VarChar, 50, ETemplateTypeUtils.GetValue(templateType)) }; using (var rdr = ExecuteReader(SqlSelectRelatedFileNameByTemplateType, parms)) { while (rdr.Read()) { list.Add(GetString(rdr, 0).ToLower()); } rdr.Close(); } return(list); }
private AtomEntry ExportTemplateInfo(TemplateInfo templateInfo) { var entry = AtomUtility.GetEmptyEntry(); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(_publishmentSystemId); AtomUtility.AddDcElement(entry.AdditionalElements, "TemplateID", templateInfo.TemplateId.ToString()); AtomUtility.AddDcElement(entry.AdditionalElements, "PublishmentSystemID", templateInfo.PublishmentSystemId.ToString()); AtomUtility.AddDcElement(entry.AdditionalElements, "TemplateName", templateInfo.TemplateName); AtomUtility.AddDcElement(entry.AdditionalElements, "TemplateType", ETemplateTypeUtils.GetValue(templateInfo.TemplateType)); AtomUtility.AddDcElement(entry.AdditionalElements, "RelatedFileName", templateInfo.RelatedFileName); AtomUtility.AddDcElement(entry.AdditionalElements, "CreatedFileFullName", templateInfo.CreatedFileFullName); AtomUtility.AddDcElement(entry.AdditionalElements, "CreatedFileExtName", templateInfo.CreatedFileExtName); AtomUtility.AddDcElement(entry.AdditionalElements, "Charset", ECharsetUtils.GetValue(templateInfo.Charset)); AtomUtility.AddDcElement(entry.AdditionalElements, "IsDefault", templateInfo.IsDefault.ToString()); var templateContent = StlCacheManager.FileContent.GetTemplateContent(publishmentSystemInfo, templateInfo); AtomUtility.AddDcElement(entry.AdditionalElements, "Content", AtomUtility.Encrypt(templateContent)); return(entry); }
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); }
private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, string testType, string testOperate, string testValue) { string successTemplateString; string failureTemplateString; StlParserUtility.GetYesOrNoTemplateString(node, pageInfo, out successTemplateString, out failureTemplateString); if (StringUtils.EqualsIgnoreCase(testType, TypeIsUserLoggin) || StringUtils.EqualsIgnoreCase(testType, TypeIsAdministratorLoggin) || StringUtils.EqualsIgnoreCase(testType, TypeIsUserOrAdministratorLoggin) || StringUtils.EqualsIgnoreCase(testType, TypeUserGroup)) { return(TestTypeDynamic(pageInfo, contextInfo, testType, testValue, testOperate, successTemplateString, failureTemplateString)); } var isSuccess = false; if (StringUtils.EqualsIgnoreCase(testType, TypeChannelName)) { var channelName = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId).NodeName; isSuccess = TestTypeValue(testOperate, testValue, channelName); } else if (StringUtils.EqualsIgnoreCase(testType, TypeChannelIndex)) { var channelIndex = NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId).NodeIndexName; isSuccess = TestTypeValue(testOperate, testValue, channelIndex); } else if (StringUtils.EqualsIgnoreCase(testType, TypeTemplateName)) { isSuccess = TestTypeValue(testOperate, testValue, pageInfo.TemplateInfo.TemplateName); } else if (StringUtils.EqualsIgnoreCase(testType, TypeTemplateType)) { isSuccess = TestTypeValue(testOperate, testValue, ETemplateTypeUtils.GetValue(pageInfo.TemplateInfo.TemplateType)); } else if (StringUtils.EqualsIgnoreCase(testType, TypeTopLevel)) { var topLevel = NodeManager.GetTopLevel(pageInfo.PublishmentSystemId, contextInfo.ChannelId); isSuccess = IsNumber(topLevel, testOperate, testValue); } else if (StringUtils.EqualsIgnoreCase(testType, TypeUpChannel)) { isSuccess = TestTypeUpChannel(pageInfo, contextInfo, testOperate, testValue); } else if (StringUtils.EqualsIgnoreCase(testType, TypeUpChannelOrSelf)) { isSuccess = TestTypeUpChannelOrSelf(pageInfo, contextInfo, testOperate, testValue); } else if (StringUtils.EqualsIgnoreCase(testType, TypeSelfChannel)) { isSuccess = pageInfo.PageNodeId == contextInfo.ChannelId; } else if (StringUtils.EqualsIgnoreCase(testType, TypeGroupChannel)) { var groupChannels = TranslateUtils.StringCollectionToStringList( NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId).NodeGroupNameCollection); isSuccess = TestTypeValues(testOperate, testValue, groupChannels); } else if (StringUtils.EqualsIgnoreCase(testType, TypeGroupContent)) { if (contextInfo.ContextType == EContextType.Content) { var tableName = NodeManager.GetTableName(pageInfo.PublishmentSystemInfo, contextInfo.ChannelId); var groupContents = TranslateUtils.StringCollectionToStringList(BaiRongDataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.ContentGroupNameCollection)); isSuccess = TestTypeValues(testOperate, testValue, groupContents); } } else if (StringUtils.EqualsIgnoreCase(testType, TypeAddDate)) { var addDate = GetAddDateByContext(pageInfo, contextInfo); isSuccess = IsDateTime(addDate, testOperate, testValue); } else if (StringUtils.EqualsIgnoreCase(testType, TypeLastEditDate)) { var lastEditDate = GetLastEditDateByContext(pageInfo, contextInfo); isSuccess = IsDateTime(lastEditDate, testOperate, testValue); } else if (StringUtils.EqualsIgnoreCase(testType, TypeItemIndex)) { var itemIndex = StlParserUtility.GetItemIndex(contextInfo); isSuccess = IsNumber(itemIndex, testOperate, testValue); } else if (StringUtils.EqualsIgnoreCase(testType, TypeOddItem)) { var itemIndex = StlParserUtility.GetItemIndex(contextInfo); isSuccess = itemIndex % 2 == 1; } else { isSuccess = TestTypeDefault(pageInfo, contextInfo, testType, testOperate, testValue); } var parsedContent = isSuccess ? successTemplateString : failureTemplateString; if (string.IsNullOrEmpty(parsedContent)) { return(string.Empty); } var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); return(parsedContent); }
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"); } } }
public List <TemplateInfo> GetTemplateInfoListOfFile(int publishmentSystemId) { var list = new List <TemplateInfo>(); string sqlString = $"SELECT TemplateID, PublishmentSystemID, TemplateName, TemplateType, RelatedFileName, CreatedFileFullName, CreatedFileExtName, Charset, IsDefault FROM siteserver_Template WHERE PublishmentSystemID = {publishmentSystemId} AND TemplateType = '{ETemplateTypeUtils.GetValue(ETemplateType.FileTemplate)}' 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++), 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); }