private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string inputName, bool isLoadValues, string inputTemplateString, string successTemplateString, string failureTemplateString, string siteName) { var parsedContent = string.Empty; var prePublishmentSystemInfo = pageInfo.PublishmentSystemInfo; var prePageNodeId = pageInfo.PageNodeId; var prePageContentId = pageInfo.PageContentId; var publishmentSystemId = pageInfo.PublishmentSystemId; PublishmentSystemInfo publishmentSystemInfo = null; if (!string.IsNullOrEmpty(siteName)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoBySiteName(siteName); } if (publishmentSystemInfo != null) { pageInfo.ChangeSite(publishmentSystemInfo, publishmentSystemInfo.PublishmentSystemId, 0, contextInfo); publishmentSystemId = publishmentSystemInfo.PublishmentSystemId; } var inputId = DataProvider.InputDao.GetInputIdAsPossible(inputName, publishmentSystemId); if (inputId > 0) { var inputInfo = DataProvider.InputDao.GetInputInfo(inputId); var inputTemplate = new InputTemplate(pageInfo.PublishmentSystemInfo, inputInfo); parsedContent = inputTemplate.GetTemplate(isLoadValues, inputTemplateString, successTemplateString, failureTemplateString); var innerBuilder = new StringBuilder(parsedContent); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); parsedContent = innerBuilder.ToString(); if (isLoadValues) { pageInfo.AddPageScriptsIfNotExists(ElementName, $@" <script language=""vbscript""> Function str2asc(strstr) str2asc = hex(asc(strstr)) End Function Function asc2str(ascasc) asc2str = chr(ascasc) End Function </script> <script type=""text/javascript"" src=""{SiteFilesAssets.Input.GetScriptUrl(pageInfo.ApiUrl)}""></script>"); } } pageInfo.ChangeSite(prePublishmentSystemInfo, prePageNodeId, prePageContentId, contextInfo); return(parsedContent); }
public IEnumerable GetStlDataSource(string siteName, string siteDir, int startNum, int totalNum, string whereString, EScopeType scopeType, string orderByString, string since) { IEnumerable ie = null; var sqlWhereString = string.Empty; PublishmentSystemInfo publishmentSystemInfo = null; if (!string.IsNullOrEmpty(siteName)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoBySiteName(siteName); } else if (!string.IsNullOrEmpty(siteDir)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoByDirectory(siteDir); } if (publishmentSystemInfo != null) { sqlWhereString = $"WHERE (ParentPublishmentSystemID = {publishmentSystemInfo.PublishmentSystemId})"; } else { if (scopeType == EScopeType.Children) { sqlWhereString = "WHERE (ParentPublishmentSystemID = 0 AND IsHeadquarters = 'False')"; } else if (scopeType == EScopeType.Descendant) { sqlWhereString = "WHERE (IsHeadquarters = 'False')"; } } if (!string.IsNullOrEmpty(whereString)) { sqlWhereString = string.IsNullOrEmpty(sqlWhereString) ? $"WHERE ({whereString})" : $"{sqlWhereString} AND ({whereString})"; } if (string.IsNullOrEmpty(orderByString) || StringUtils.EqualsIgnoreCase(orderByString, "default")) { orderByString = "ORDER BY IsHeadquarters DESC, ParentPublishmentSystemID, Taxis DESC, PublishmentSystemID"; var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TableName, startNum, totalNum, SqlUtils.Asterisk, sqlWhereString, orderByString); ie = (IEnumerable)ExecuteReader(sqlSelect); } return(ie); }
private static string ParseImpl(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, string siteName, string siteDir) { PublishmentSystemInfo publishmentSystemInfo = null; if (!string.IsNullOrEmpty(siteName)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoBySiteName(siteName); } else if (!string.IsNullOrEmpty(siteDir)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoByDirectory(siteDir); } else { var siteId = DataProvider.PublishmentSystemDao.GetPublishmentSystemIdByIsHeadquarters(); if (siteId > 0) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId); } } if (publishmentSystemInfo == null) { return(string.Empty); } var prePublishmentSystemInfo = pageInfo.PublishmentSystemInfo; var prePageNodeId = pageInfo.PageNodeId; var prePageContentId = pageInfo.PageContentId; pageInfo.ChangeSite(publishmentSystemInfo, publishmentSystemInfo.PublishmentSystemId, 0, contextInfo); var innerBuilder = new StringBuilder(node.InnerXml); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); var parsedContent = innerBuilder.ToString(); pageInfo.ChangeSite(prePublishmentSystemInfo, prePageNodeId, prePageContentId, contextInfo); return(parsedContent); }
public string GetWhereStringByStlSearch(bool isAllSites, string siteName, string siteDir, string siteIds, string channelIndex, string channelName, string channelIds, string type, string word, string dateAttribute, string dateFrom, string dateTo, string since, int publishmentSystemId, List <string> excludeAttributes, NameValueCollection form, out bool isDefaultCondition) { isDefaultCondition = true; var whereBuilder = new StringBuilder(); PublishmentSystemInfo publishmentSystemInfo = null; if (!string.IsNullOrEmpty(siteName)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoBySiteName(siteName); } else if (!string.IsNullOrEmpty(siteDir)) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoByDirectory(siteDir); } if (publishmentSystemInfo == null) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); } var channelId = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(publishmentSystemId, publishmentSystemId, channelIndex, channelName); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, channelId); if (isAllSites) { whereBuilder.Append("(PublishmentSystemID > 0) "); } else if (!string.IsNullOrEmpty(siteIds)) { whereBuilder.Append($"(PublishmentSystemID IN ({TranslateUtils.ToSqlInStringWithoutQuote(TranslateUtils.StringCollectionToIntList(siteIds))})) "); } else { whereBuilder.Append($"(PublishmentSystemID = {publishmentSystemInfo.PublishmentSystemId}) "); } if (!string.IsNullOrEmpty(channelIds)) { whereBuilder.Append(" AND "); var nodeIdList = new List <int>(); foreach (var nodeId in TranslateUtils.StringCollectionToIntList(channelIds)) { nodeIdList.Add(nodeId); nodeIdList.AddRange(DataProvider.NodeDao.GetNodeIdListForDescendant(nodeId)); } whereBuilder.Append(nodeIdList.Count == 1 ? $"(NodeID = {nodeIdList[0]}) " : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) "); } else if (channelId != publishmentSystemId) { whereBuilder.Append(" AND "); var nodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(channelId); nodeIdList.Add(channelId); whereBuilder.Append(nodeIdList.Count == 1 ? $"(NodeID = {nodeIdList[0]}) " : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) "); } var typeList = new List <string>(); if (string.IsNullOrEmpty(type)) { typeList.Add(ContentAttribute.Title); } else { typeList = TranslateUtils.StringCollectionToStringList(type); } if (!string.IsNullOrEmpty(word)) { whereBuilder.Append(" AND ("); foreach (var attributeName in typeList) { whereBuilder.Append($"[{attributeName}] LIKE '%{PageUtils.FilterSql(word)}%' OR "); } whereBuilder.Length = whereBuilder.Length - 3; whereBuilder.Append(")"); } if (string.IsNullOrEmpty(dateAttribute)) { dateAttribute = ContentAttribute.AddDate; } if (!string.IsNullOrEmpty(dateFrom)) { whereBuilder.Append(" AND "); whereBuilder.Append($" {dateAttribute} >= '{dateFrom}' "); } if (!string.IsNullOrEmpty(dateTo)) { whereBuilder.Append(" AND "); whereBuilder.Append($" {dateAttribute} <= '{dateTo}' "); } if (!string.IsNullOrEmpty(since)) { var sinceDate = DateTime.Now.AddHours(-DateUtils.GetSinceHours(since)); whereBuilder.Append($" AND {dateAttribute} BETWEEN '{DateUtils.GetDateAndTimeString(sinceDate)}' AND {SqlUtils.GetDefaultDateString()} "); } var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var styleInfoList = RelatedIdentities.GetTableStyleInfoList(publishmentSystemInfo, tableStyle, nodeInfo.NodeId); foreach (string key in form.Keys) { if (excludeAttributes.Contains(key.ToLower())) { continue; } if (string.IsNullOrEmpty(form[key])) { continue; } var value = StringUtils.Trim(form[key]); if (string.IsNullOrEmpty(value)) { continue; } if (TableManager.IsAttributeNameExists(tableStyle, tableName, key)) { whereBuilder.Append(" AND "); whereBuilder.Append($"({key} LIKE '%{value}%')"); } else { foreach (var tableStyleInfo in styleInfoList) { if (StringUtils.EqualsIgnoreCase(tableStyleInfo.AttributeName, key)) { whereBuilder.Append(" AND "); whereBuilder.Append($"({ContentAttribute.SettingsXml} LIKE '%{key}={value}%')"); break; } } } if (tableStyle == ETableStyle.GovPublicContent) { if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.DepartmentId)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category1Id)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category2Id)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category3Id)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category4Id)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category5Id)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category6Id)) { whereBuilder.Append(" AND "); whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})"); } } } if (whereBuilder.ToString().Contains(" AND ")) { isDefaultCondition = false; } return(whereBuilder.ToString()); }