public static string GetChannelPageFilePath(PublishmentSystemInfo publishmentSystemInfo, int nodeId, int currentPageIndex) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); if (nodeInfo.NodeType == ENodeType.BackgroundPublishNode) { var templateInfo = TemplateManager.GetDefaultTemplateInfo(publishmentSystemInfo.PublishmentSystemId, ETemplateType.IndexPageTemplate); return(GetIndexPageFilePath(publishmentSystemInfo, templateInfo.CreatedFileFullName, publishmentSystemInfo.IsHeadquarters, currentPageIndex)); } var filePath = nodeInfo.FilePath; if (string.IsNullOrEmpty(filePath)) { filePath = ChannelFilePathRules.Parse(publishmentSystemInfo, nodeId); } filePath = MapPath(publishmentSystemInfo, filePath);// PathUtils.Combine(publishmentSystemPath, filePath); if (PathUtils.IsDirectoryPath(filePath)) { filePath = PathUtils.Combine(filePath, nodeId + ".html"); } DirectoryUtils.CreateDirectoryIfNotExists(filePath); if (currentPageIndex != 0) { string appendix = $"_{(currentPageIndex + 1)}"; var fileName = PathUtils.GetFileNameWithoutExtension(filePath) + appendix + PathUtils.GetExtension(filePath); filePath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), fileName); } return(filePath); }
private static string GetChannelUrlNotComputed(PublishmentSystemInfo publishmentSystemInfo, int nodeId, ENodeType nodeType, bool isFromBackground) { if (nodeType == ENodeType.BackgroundPublishNode) { return(GetIndexPageUrl(publishmentSystemInfo, isFromBackground)); } var linkUrl = string.Empty; var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); if (nodeInfo != null) { linkUrl = nodeInfo.LinkUrl; } if (string.IsNullOrEmpty(linkUrl)) { if (nodeInfo != null) { var filePath = nodeInfo.FilePath; if (string.IsNullOrEmpty(filePath)) { var channelUrl = PathUtility.ChannelFilePathRules.Parse(publishmentSystemInfo, nodeId); return(GetPublishmentSystemUrl(publishmentSystemInfo, channelUrl, isFromBackground)); } return(ParseNavigationUrl(publishmentSystemInfo, PathUtility.AddVirtualToPath(filePath), isFromBackground)); } } return(ParseNavigationUrl(publishmentSystemInfo, linkUrl, isFromBackground)); }
public static string GetDescription(int publishmentSystemID, NodeInfo nodeInfo) { var results = string.Empty; if (nodeInfo != null) { results = ECrossSiteTransTypeUtils.GetText(nodeInfo.Additional.TransType); if (nodeInfo.Additional.TransType == ECrossSiteTransType.AllParentSite || nodeInfo.Additional.TransType == ECrossSiteTransType.AllSite) { if (!string.IsNullOrEmpty(nodeInfo.Additional.TransNodeNames)) { results += $"({nodeInfo.Additional.TransNodeNames})"; } } else if (nodeInfo.Additional.TransType == ECrossSiteTransType.SelfSite || nodeInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite || nodeInfo.Additional.TransType == ECrossSiteTransType.ParentSite) { PublishmentSystemInfo publishmentSystemInfo = null; if (nodeInfo.Additional.TransType == ECrossSiteTransType.SelfSite) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemID); } else if (nodeInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(nodeInfo.Additional.TransPublishmentSystemID); } else { var parentPublishmentSystemID = PublishmentSystemManager.GetParentPublishmentSystemId(publishmentSystemID); if (parentPublishmentSystemID != 0) { publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(parentPublishmentSystemID); } } if (publishmentSystemInfo != null && !string.IsNullOrEmpty(nodeInfo.Additional.TransNodeIDs)) { var nodeNameBuilder = new StringBuilder(); var nodeIDArrayList = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.TransNodeIDs); foreach (int nodeID in nodeIDArrayList) { var theNodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); if (theNodeInfo != null) { nodeNameBuilder.Append(theNodeInfo.NodeName).Append(","); } } if (nodeNameBuilder.Length > 0) { nodeNameBuilder.Length--; results += $"({publishmentSystemInfo.PublishmentSystemName}:{nodeNameBuilder})"; } } } } return(results); }
public static void LoadNodeIDListBox(ListBox nodeIDListBox, PublishmentSystemInfo publishmentSystemInfo, int psID, NodeInfo nodeInfo, string administratorName) { nodeIDListBox.Items.Clear(); var isUseNodeNames = false; if (nodeInfo.Additional.TransType == ECrossSiteTransType.AllParentSite || nodeInfo.Additional.TransType == ECrossSiteTransType.AllSite) { isUseNodeNames = true; } if (!isUseNodeNames) { var nodeIDArrayList = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.TransNodeIDs); foreach (int theNodeID in nodeIDArrayList) { var theNodeInfo = NodeManager.GetNodeInfo(psID, theNodeID); if (theNodeInfo != null) { var listitem = new ListItem(theNodeInfo.NodeName, theNodeInfo.NodeId.ToString()); nodeIDListBox.Items.Add(listitem); } } } else { if (!string.IsNullOrEmpty(nodeInfo.Additional.TransNodeNames)) { var nodeNameArrayList = TranslateUtils.StringCollectionToStringList(nodeInfo.Additional.TransNodeNames); var dic = NodeManager.GetNodeInfoHashtableByPublishmentSystemId(psID); if (dic != null) { foreach (string nodeName in nodeNameArrayList) { foreach (var theNodeId in dic.Keys) { var theNodeInfo = NodeManager.GetNodeInfo(psID, (int)theNodeId); if (theNodeInfo.NodeName == nodeName) { var listitem = new ListItem(theNodeInfo.NodeName, theNodeInfo.NodeId.ToString()); nodeIDListBox.Items.Add(listitem); break; } } } } } else { NodeManager.AddListItemsForAddContent(nodeIDListBox.Items, PublishmentSystemManager.GetPublishmentSystemInfo(psID), false, administratorName); } } }
/// <summary> /// 对GetContentUrlByID的优化 /// 通过传入参数contentInfoCurrent,避免对ContentInfo查询太多 /// </summary> private static string GetContentUrlById(PublishmentSystemInfo publishmentSystemInfo, ContentInfo contentInfoCurrent, int sourceId, int referenceId, string linkUrl, bool isFromBackground) { var nodeId = contentInfoCurrent.NodeId; if (referenceId > 0 && contentInfoCurrent.GetExtendedAttribute(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) { if (sourceId > 0 && (NodeManager.IsExists(publishmentSystemInfo.PublishmentSystemId, sourceId) || NodeManager.IsExists(sourceId))) { var targetNodeId = sourceId; var targetPublishmentSystemId = DataProvider.NodeDao.GetPublishmentSystemId(targetNodeId); var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemId); var targetNodeInfo = NodeManager.GetNodeInfo(targetPublishmentSystemId, targetNodeId); var tableStyle = NodeManager.GetTableStyle(targetPublishmentSystemInfo, targetNodeInfo); var tableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeInfo); var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, referenceId); if (contentInfo == null || contentInfo.NodeId <= 0) { return(PageUtils.UnclickedUrl); } if (contentInfo.PublishmentSystemId == targetPublishmentSystemInfo.PublishmentSystemId) { return(GetContentUrlById(targetPublishmentSystemInfo, contentInfo, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.LinkUrl), isFromBackground)); } var publishmentSystemInfoTmp = PublishmentSystemManager.GetPublishmentSystemInfo(contentInfo.PublishmentSystemId); return(GetContentUrlById(publishmentSystemInfoTmp, contentInfo, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.LinkUrl), isFromBackground)); } else { var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeId); nodeId = BaiRongDataProvider.ContentDao.GetNodeId(tableName, referenceId); linkUrl = BaiRongDataProvider.ContentDao.GetValue(tableName, referenceId, BackgroundContentAttribute.LinkUrl); if (NodeManager.IsExists(publishmentSystemInfo.PublishmentSystemId, nodeId)) { return(GetContentUrlById(publishmentSystemInfo, nodeId, referenceId, 0, 0, linkUrl, isFromBackground)); } var targetPublishmentSystemId = DataProvider.NodeDao.GetPublishmentSystemId(nodeId); var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemId); return(GetContentUrlById(targetPublishmentSystemInfo, nodeId, referenceId, 0, 0, linkUrl, isFromBackground)); } } if (!string.IsNullOrEmpty(linkUrl)) { return(ParseNavigationUrl(publishmentSystemInfo, linkUrl, isFromBackground)); } var contentUrl = PathUtility.ContentFilePathRules.Parse(publishmentSystemInfo, nodeId, contentInfoCurrent); return(GetPublishmentSystemUrl(publishmentSystemInfo, contentUrl, isFromBackground)); }
public static TemplateInfo GetTemplateInfo(int publishmentSystemID, int nodeID, ETemplateType templateType) { var templateID = 0; if (templateType == ETemplateType.IndexPageTemplate) { templateID = GetDefaultTemplateID(publishmentSystemID, ETemplateType.IndexPageTemplate); } else if (templateType == ETemplateType.ChannelTemplate) { var nodeType = NodeManager.GetNodeType(publishmentSystemID, nodeID); if (nodeType == ENodeType.BackgroundPublishNode) { templateID = GetDefaultTemplateID(publishmentSystemID, ETemplateType.IndexPageTemplate); } else { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemID, nodeID); if (nodeInfo != null) { templateID = nodeInfo.ChannelTemplateId; } } } else if (templateType == ETemplateType.ContentTemplate) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemID, nodeID); if (nodeInfo != null) { templateID = nodeInfo.ContentTemplateId; } } TemplateInfo templateInfo = null; if (templateID != 0) { templateInfo = GetTemplateInfo(publishmentSystemID, templateID); } if (templateInfo == null) { templateInfo = GetDefaultTemplateInfo(publishmentSystemID, templateType); } return(templateInfo); }
public static int GetContentTempalteID(int publishmentSystemID, int nodeID) { var templateID = 0; var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemID, nodeID); if (nodeInfo != null) { templateID = nodeInfo.ContentTemplateId; } if (templateID == 0) { templateID = GetDefaultTemplateID(publishmentSystemID, ETemplateType.ContentTemplate); } return(templateID); }
public static bool IsAncestorOrSelf(int publishmentSystemID, int parentID, int childID) { if (parentID == childID) { return(true); } var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemID, childID); if (nodeInfo == null) { return(false); } if (CompareUtils.Contains(nodeInfo.ParentsPath, parentID.ToString())) { return(true); } return(false); }
public static List <NodeInfo> GetWritingNodeInfoList(string adminUserName, int publishmentSystemId) { var nodeInfoList = new List <NodeInfo>(); if (!string.IsNullOrEmpty(adminUserName)) { if (AdminManager.HasChannelPermissionIsConsoleAdministrator(adminUserName) || AdminManager.HasChannelPermissionIsSystemAdministrator(adminUserName))//如果是超级管理员或站点管理员 { var nodeList = DataProvider.NodeDao.GetNodeInfoListByPublishmentSystemId(publishmentSystemId, string.Empty); foreach (var nodeInfo in nodeList) { if (nodeInfo != null && EContentModelTypeUtils.Equals(nodeInfo.ContentModelId, EContentModelType.Content)) { nodeInfoList.Add(nodeInfo); } } } else { var ps = new ProductAdministratorWithPermissions(adminUserName); ICollection nodeIdCollection = ps.ChannelPermissionDict.Keys; foreach (int nodeId in nodeIdCollection) { var nodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(nodeId); nodeIdList.Insert(0, nodeId); foreach (int ownNodeId in nodeIdList) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, ownNodeId); if (nodeInfo != null && EContentModelTypeUtils.Equals(nodeInfo.ContentModelId, EContentModelType.Content)) { nodeInfoList.Add(nodeInfo); } } } } } return(nodeInfoList); }
private static string GetContentFilePathRule(int publishmentSystemId, int nodeId) { if (nodeId == 0) { return(string.Empty); } var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, nodeId); if (nodeInfo == null) { return(string.Empty); } var filePathRule = nodeInfo.ContentFilePathRule; if (string.IsNullOrEmpty(filePathRule) && nodeInfo.ParentId != 0) { filePathRule = GetContentFilePathRule(publishmentSystemId, nodeInfo.ParentId); } return(filePathRule); }
public static List <int> GetChannelRelatedIdentities(int publishmentSystemId, int nodeId) { var arraylist = new List <int>(); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, nodeId); if (nodeInfo != null) { var nodeIdCollection = "0," + nodeInfo.NodeId; if (nodeInfo.ParentsCount > 0) { nodeIdCollection = "0," + nodeInfo.ParentsPath + "," + nodeInfo.NodeId; } arraylist = TranslateUtils.StringCollectionToIntList(nodeIdCollection); arraylist.Reverse(); } else { arraylist.Add(0); } return(arraylist); }
public static void CreateSiteMapBaidu(PublishmentSystemInfo publishmentSystemInfo) { var publishmentSystemUrl = PageUtils.AddProtocolToUrl(publishmentSystemInfo.PublishmentSystemUrl.ToLower()); var siteMapBuilder = new StringBuilder(); siteMapBuilder.Append($@"<?xml version=""1.0"" encoding=""GB2312"" ?> <document> <webSite>{publishmentSystemUrl}</webSite> <webMaster>{publishmentSystemInfo.Additional.SiteMapBaiduWebMaster}</webMaster> <updatePeri>{publishmentSystemInfo.Additional.SiteMapBaiduUpdatePeri}</updatePeri> "); var urlArrayList = new ArrayList(); //内容页 var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId); if (nodeIdList != null && nodeIdList.Count > 0) { foreach (int nodeID in nodeIdList) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var contentIdList = DataProvider.ContentDao.GetContentIdListChecked(tableName, nodeID, string.Empty); if (contentIdList != null && contentIdList.Count > 0) { foreach (var contentId in contentIdList) { var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId); var contentUrl = PageUtils.AddProtocolToUrl(PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo)); if (!string.IsNullOrEmpty(contentUrl)) { if (urlArrayList.Contains(contentUrl.ToLower())) { continue; } else { urlArrayList.Add(contentUrl.ToLower()); } if (contentUrl.ToLower().StartsWith(publishmentSystemUrl)) { siteMapBuilder.Append($@" <item> <link><![CDATA[{contentUrl}]]></link> <title><![CDATA[{contentInfo.Title}]]></title> <text><![CDATA[{StringUtils.StripTags(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.Content))}]]></text> <image><![CDATA[{PageUtility.ParseNavigationUrl(publishmentSystemInfo, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl))}]]></image> <category><![CDATA[{NodeManager.GetNodeName(publishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId)}]]></category> <pubDate>{DateUtils.GetDateAndTimeString(contentInfo.AddDate)}</pubDate> </item> "); } } } } } } siteMapBuilder.Append(@" </document>"); var siteMapPath = PathUtility.MapPath(publishmentSystemInfo, publishmentSystemInfo.Additional.SiteMapBaiduPath); FileUtils.WriteText(siteMapPath, ECharset.gb2312, siteMapBuilder.ToString()); }
public static void LoadPublishmentSystemIDDropDownList(DropDownList publishmentSystemIDDropDownList, PublishmentSystemInfo publishmentSystemInfo, int nodeID) { publishmentSystemIDDropDownList.Items.Clear(); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); if (nodeInfo.Additional.TransType == ECrossSiteTransType.SelfSite || nodeInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite || nodeInfo.Additional.TransType == ECrossSiteTransType.ParentSite) { int thePublishmentSystemID; if (nodeInfo.Additional.TransType == ECrossSiteTransType.SelfSite) { thePublishmentSystemID = publishmentSystemInfo.PublishmentSystemId; } else if (nodeInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite) { thePublishmentSystemID = nodeInfo.Additional.TransPublishmentSystemID; } else { thePublishmentSystemID = PublishmentSystemManager.GetParentPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId); } if (thePublishmentSystemID > 0) { var thePublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(thePublishmentSystemID); if (thePublishmentSystemInfo != null) { var listitem = new ListItem(thePublishmentSystemInfo.PublishmentSystemName, thePublishmentSystemInfo.PublishmentSystemId.ToString()); publishmentSystemIDDropDownList.Items.Add(listitem); } } } else if (nodeInfo.Additional.TransType == ECrossSiteTransType.AllParentSite || nodeInfo.Additional.TransType == ECrossSiteTransType.AllSite) { var publishmentSystemIdList = PublishmentSystemManager.GetPublishmentSystemIdList(); var allParentPublishmentSystemIdList = new List <int>(); if (nodeInfo.Additional.TransType == ECrossSiteTransType.AllParentSite) { PublishmentSystemManager.GetAllParentPublishmentSystemIdList(allParentPublishmentSystemIdList, publishmentSystemIdList, publishmentSystemInfo.PublishmentSystemId); } foreach (int psId in publishmentSystemIdList) { if (psId == publishmentSystemInfo.PublishmentSystemId) { continue; } var psInfo = PublishmentSystemManager.GetPublishmentSystemInfo(psId); var show = false; if (nodeInfo.Additional.TransType == ECrossSiteTransType.AllSite) { show = true; } else if (nodeInfo.Additional.TransType == ECrossSiteTransType.AllParentSite) { if (psInfo.IsHeadquarters || allParentPublishmentSystemIdList.Contains(psInfo.PublishmentSystemId)) { show = true; } } if (show) { var listitem = new ListItem(psInfo.PublishmentSystemName, psId.ToString()); if (psInfo.IsHeadquarters) { listitem.Selected = true; } publishmentSystemIDDropDownList.Items.Add(listitem); } } } }
public static void CreateSiteMapGoogle(PublishmentSystemInfo publishmentSystemInfo) { var totalNum = DataProvider.NodeDao.GetContentNumByPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId); if (totalNum == 0 || totalNum <= publishmentSystemInfo.Additional.SiteMapGooglePageCount) { var siteMapBuilder = new StringBuilder(); siteMapBuilder.Append(siteMapGoogleHead); var urlFormat = publishmentSystemInfo.Additional.SiteMapGoogleIsShowLastModified ? siteMapGoogleUrlWithLastModifiedFotmat : siteMapGoogleUrlFotmat; var lastmode = DateUtils.GetDateString(DateTime.Now); var urlArrayList = new ArrayList(); //首页 var publishmentSystemUrl = PageUtils.AddProtocolToUrl(publishmentSystemInfo.PublishmentSystemUrl.ToLower()); siteMapBuilder.AppendFormat(urlFormat, publishmentSystemUrl, "1.0", publishmentSystemInfo.Additional.SiteMapGoogleChangeFrequency, lastmode); //栏目页 var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId); if (nodeIdList != null && nodeIdList.Count > 0) { foreach (int nodeID in nodeIdList) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); var channelUrl = PageUtils.AddProtocolToUrl(PageUtility.GetChannelUrl(publishmentSystemInfo, nodeInfo)); if (!string.IsNullOrEmpty(channelUrl)) { if (urlArrayList.Contains(channelUrl.ToLower())) { continue; } else { urlArrayList.Add(channelUrl.ToLower()); } if (channelUrl.ToLower().StartsWith(publishmentSystemUrl)) { siteMapBuilder.AppendFormat(urlFormat, channelUrl, "0.8", publishmentSystemInfo.Additional.SiteMapGoogleChangeFrequency, lastmode); } } } } if (nodeIdList != null && nodeIdList.Count > 0) { foreach (int nodeID in nodeIdList) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var contentIdList = DataProvider.ContentDao.GetContentIdListChecked(tableName, nodeID, string.Empty); //内容页 if (contentIdList != null && contentIdList.Count > 0) { foreach (var contentId in contentIdList) { var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId); var contentUrl = PageUtils.AddProtocolToUrl(PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo)); if (!string.IsNullOrEmpty(contentUrl)) { if (urlArrayList.Contains(contentUrl.ToLower())) { continue; } else { urlArrayList.Add(contentUrl.ToLower()); } if (contentUrl.ToLower().StartsWith(publishmentSystemUrl)) { siteMapBuilder.AppendFormat(urlFormat, contentUrl, "0.5", publishmentSystemInfo.Additional.SiteMapGoogleChangeFrequency, lastmode); } } } } } } siteMapBuilder.Append(siteMapGoogleFoot); var siteMapPath = PathUtility.MapPath(publishmentSystemInfo, publishmentSystemInfo.Additional.SiteMapGooglePath); FileUtils.WriteText(siteMapPath, ECharset.utf_8, siteMapBuilder.ToString()); } else { var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId); var nodeIDWithContentIDArrayList = new ArrayList(); if (nodeIdList != null && nodeIdList.Count > 0) { foreach (int nodeID in nodeIdList) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var idList = DataProvider.ContentDao.GetContentIdListChecked(tableName, nodeID, string.Empty); foreach (var contentId in idList) { nodeIDWithContentIDArrayList.Add($"{nodeID}_{contentId}"); } } } var deci = (double)nodeIDWithContentIDArrayList.Count / publishmentSystemInfo.Additional.SiteMapGooglePageCount; var count = Convert.ToInt32(Math.Ceiling(deci)); var siteMapIndexBuilder = new StringBuilder(); var siteMapGooglePath = publishmentSystemInfo.Additional.SiteMapGooglePath.ToLower(); var ext = PageUtils.GetExtensionFromUrl(siteMapGooglePath); var urlFormat = publishmentSystemInfo.Additional.SiteMapGoogleIsShowLastModified ? siteMapGoogleUrlWithLastModifiedFotmat : siteMapGoogleUrlFotmat; var lastmode = DateUtils.GetDateString(DateTime.Now); var publishmentSystemUrl = PageUtils.AddProtocolToUrl(publishmentSystemInfo.PublishmentSystemUrl.ToLower()); for (var i = 1; i <= count; i++) { var virtualPath = StringUtils.InsertBefore(ext, siteMapGooglePath, i.ToString()); siteMapIndexBuilder.Append($@" <sitemap> <loc>{PageUtility.ParseNavigationUrl(publishmentSystemInfo, virtualPath)}</loc> <lastmod>{DateUtils.GetDateString(DateTime.Now)}</lastmod> </sitemap> "); var siteMapBuilder = new StringBuilder(); siteMapBuilder.Append(siteMapGoogleHead); var urlArrayList = new ArrayList(); if (i == 1) { //首页 siteMapBuilder.AppendFormat(urlFormat, publishmentSystemUrl, "1.0", publishmentSystemInfo.Additional.SiteMapGoogleChangeFrequency, lastmode); //栏目页 if (nodeIdList != null && nodeIdList.Count > 0) { foreach (int nodeID in nodeIdList) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); var channelUrl = PageUtils.AddProtocolToUrl(PageUtility.GetChannelUrl(publishmentSystemInfo, nodeInfo)); if (!string.IsNullOrEmpty(channelUrl)) { if (urlArrayList.Contains(channelUrl.ToLower())) { continue; } else { urlArrayList.Add(channelUrl.ToLower()); } if (channelUrl.ToLower().StartsWith(publishmentSystemUrl)) { siteMapBuilder.AppendFormat(urlFormat, channelUrl, "0.8", publishmentSystemInfo.Additional.SiteMapGoogleChangeFrequency, lastmode); } } } } } var pageCount = publishmentSystemInfo.Additional.SiteMapGooglePageCount; if (i == count) { pageCount = nodeIDWithContentIDArrayList.Count - (count - 1) * publishmentSystemInfo.Additional.SiteMapGooglePageCount; } var pageNodeIDWithContentIDArrayList = nodeIDWithContentIDArrayList.GetRange((i - 1) * publishmentSystemInfo.Additional.SiteMapGooglePageCount, pageCount); //内容页 foreach (string nodeIDWithContentID in pageNodeIDWithContentIDArrayList) { var nodeID = TranslateUtils.ToInt(nodeIDWithContentID.Split('_')[0]); var contentID = TranslateUtils.ToInt(nodeIDWithContentID.Split('_')[1]); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeID); var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentID); var contentUrl = PageUtils.AddProtocolToUrl(PageUtility.GetContentUrl(publishmentSystemInfo, contentInfo)); if (!string.IsNullOrEmpty(contentUrl)) { if (urlArrayList.Contains(contentUrl.ToLower())) { continue; } else { urlArrayList.Add(contentUrl.ToLower()); } if (contentUrl.ToLower().StartsWith(publishmentSystemUrl)) { siteMapBuilder.AppendFormat(urlFormat, contentUrl, "0.5", publishmentSystemInfo.Additional.SiteMapGoogleChangeFrequency, lastmode); } } } siteMapBuilder.Append(siteMapGoogleFoot); var siteMapPagePath = PathUtility.MapPath(publishmentSystemInfo, virtualPath); FileUtils.WriteText(siteMapPagePath, ECharset.utf_8, siteMapBuilder.ToString()); } string sitemapIndexString = $@" <?xml version=""1.0"" encoding=""UTF-8""?> <sitemapindex xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd""> {siteMapIndexBuilder.ToString()} </sitemapindex> "; var siteMapPath = PathUtility.MapPath(publishmentSystemInfo, publishmentSystemInfo.Additional.SiteMapGooglePath); FileUtils.WriteText(siteMapPath, ECharset.utf_8, sitemapIndexString); } }
//递归处理 private static string ParseChannelPath(PublishmentSystemInfo publishmentSystemInfo, int nodeId, string channelFilePathRule) { var filePath = channelFilePathRule.Trim(); const string regex = "(?<element>{@[^}]+})"; var elements = RegexUtils.GetContents("element", regex, filePath); NodeInfo nodeInfo = null; foreach (var element in elements) { var value = string.Empty; if (StringUtils.EqualsIgnoreCase(element, ChannelId)) { value = nodeId.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, ChannelIndex)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.NodeIndexName; } else if (StringUtils.EqualsIgnoreCase(element, Year)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.AddDate.Year.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Month)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.AddDate.Month.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Day)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.AddDate.Day.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Hour)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.AddDate.Hour.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Minute)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.AddDate.Minute.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Second)) { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.AddDate.Second.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Sequence)) { value = DataProvider.NodeDao.GetSequence(publishmentSystemInfo.PublishmentSystemId, nodeId).ToString(); } else if (StringUtils.EqualsIgnoreCase(element, ParentRule))//继承父级设置 20151113 sessionliang { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } var parentInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeInfo.ParentId); if (parentInfo != null) { var parentRule = GetChannelFilePathRule(publishmentSystemInfo, parentInfo.NodeId); value = DirectoryUtils.GetDirectoryPath(ParseChannelPath(publishmentSystemInfo, parentInfo.NodeId, parentRule)).Replace("\\", "/"); } } else if (StringUtils.EqualsIgnoreCase(element, ChannelName))//栏目名称 20151113 sessionliang { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } value = nodeInfo.NodeName; } else { if (nodeInfo == null) { nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); } var attributeName = element.Replace("{@", string.Empty).Replace("}", string.Empty); value = nodeInfo.Additional.GetExtendedAttribute(attributeName); } filePath = filePath.Replace(element, value); } if (!filePath.Contains("//")) { return(filePath); } filePath = Regex.Replace(filePath, @"(/)\1{2,}", "/"); filePath = Regex.Replace(filePath, @"//", "/"); return(filePath); }
private static string ParseContentPath(PublishmentSystemInfo publishmentSystemInfo, int nodeId, ContentInfo contentInfo, string contentFilePathRule) { var filePath = contentFilePathRule.Trim(); var regex = "(?<element>{@[^}]+})"; var elements = RegexUtils.GetContents("element", regex, filePath); var addDate = DateTime.MinValue; var contentId = contentInfo.Id; foreach (var element in elements) { var value = string.Empty; if (StringUtils.EqualsIgnoreCase(element, ChannelId)) { value = nodeId.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, ChannelIndex)) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); if (nodeInfo != null) { value = nodeInfo.NodeIndexName; } } else if (StringUtils.EqualsIgnoreCase(element, ContentId)) { value = contentId.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Sequence)) { var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeId); value = BaiRongDataProvider.ContentDao.GetSequence(tableName, nodeId, contentId).ToString(); } else if (StringUtils.EqualsIgnoreCase(element, ParentRule))//继承父级设置 20151113 sessionliang { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); var parentInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeInfo.ParentId); if (parentInfo != null) { var parentRule = GetContentFilePathRule(publishmentSystemInfo, parentInfo.NodeId); value = DirectoryUtils.GetDirectoryPath(ParseContentPath(publishmentSystemInfo, parentInfo.NodeId, contentInfo, parentRule)).Replace("\\", "/"); } } else if (StringUtils.EqualsIgnoreCase(element, ChannelName))//栏目名称 20151113 sessionliang { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); value = nodeInfo.NodeName; } else if (StringUtils.EqualsIgnoreCase(element, Year) || StringUtils.EqualsIgnoreCase(element, Month) || StringUtils.EqualsIgnoreCase(element, Day) || StringUtils.EqualsIgnoreCase(element, Hour) || StringUtils.EqualsIgnoreCase(element, Minute) || StringUtils.EqualsIgnoreCase(element, Second)) { if (addDate == DateTime.MinValue) { var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeId); addDate = BaiRongDataProvider.ContentDao.GetAddDate(tableName, contentId); } if (StringUtils.EqualsIgnoreCase(element, Year)) { value = addDate.Year.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Month)) { value = addDate.Month.ToString("D2"); //value = addDate.ToString("MM"); } else if (StringUtils.EqualsIgnoreCase(element, Day)) { value = addDate.Day.ToString("D2"); //value = addDate.ToString("dd"); } else if (StringUtils.EqualsIgnoreCase(element, Hour)) { value = addDate.Hour.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Minute)) { value = addDate.Minute.ToString(); } else if (StringUtils.EqualsIgnoreCase(element, Second)) { value = addDate.Second.ToString(); } } else { var attributeName = element.Replace("{@", string.Empty).Replace("}", string.Empty); value = contentInfo.GetExtendedAttribute(attributeName); } value = StringUtils.HtmlDecode(value); filePath = filePath.Replace(element, value); } if (filePath.Contains("//")) { filePath = Regex.Replace(filePath, @"(/)\1{2,}", "/"); filePath = filePath.Replace("//", "/"); } if (filePath.Contains("(")) { regex = @"(?<element>\([^\)]+\))"; elements = RegexUtils.GetContents("element", regex, filePath); foreach (var element in elements) { if (!element.Contains("|")) { continue; } var value = element.Replace("(", string.Empty).Replace(")", string.Empty); var value1 = value.Split('|')[0]; var value2 = value.Split('|')[1]; value = value1 + value2; if (!string.IsNullOrEmpty(value1) && !string.IsNullOrEmpty(value1)) { value = value1; } filePath = filePath.Replace(element, value); } } return(filePath); }
public static NodeInfo GetNodeInfo(int siteID, int channelID) { return(NodeManager.GetNodeInfo(siteID, channelID)); }
public static List <int> GetChannelIDList(int siteID, int channelID) { var nodeInfo = NodeManager.GetNodeInfo(siteID, channelID); return(DataProvider.NodeDao.GetNodeIdListByScopeType(nodeInfo, EScopeType.All, string.Empty, string.Empty)); }
public static void Translate(string administratorName, PublishmentSystemInfo publishmentSystemInfo, int nodeId, int contentId, int targetPublishmentSystemId, int targetNodeId, ETranslateContentType translateType) { if (publishmentSystemInfo == null || nodeId <= 0 || contentId <= 0 || targetPublishmentSystemId <= 0 || targetNodeId <= 0) { return; } var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemId); var targetTableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeId); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId); if (contentInfo == null) { return; } if (translateType == ETranslateContentType.Copy) { FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Copy.ToString(); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString()); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId)) { var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentId); if (photoInfoList.Count > 0) { foreach (var photoInfo in photoInfoList) { photoInfo.PublishmentSystemID = targetPublishmentSystemId; photoInfo.ContentID = theContentId; FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl); DataProvider.PhotoDao.Insert(photoInfo); } } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentId); } } else if (translateType == ETranslateContentType.Cut) { FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Cut.ToString(); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString()); if (StringUtils.EqualsIgnoreCase(tableName, targetTableName)) { contentInfo.Taxis = DataProvider.ContentDao.GetTaxisToInsert(targetTableName, targetNodeId, contentInfo.IsTop); DataProvider.ContentDao.Update(targetTableName, targetPublishmentSystemInfo, contentInfo); } else { DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); DataProvider.ContentDao.DeleteContents(publishmentSystemInfo.PublishmentSystemId, tableName, TranslateUtils.ToIntList(contentId), nodeId); } DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo, nodeId, true); DataProvider.NodeDao.UpdateContentNum(targetPublishmentSystemInfo, targetNodeId, true); if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId)) { var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentId); if (photoInfoList.Count > 0) { foreach (var photoInfo in photoInfoList) { photoInfo.PublishmentSystemID = targetPublishmentSystemId; FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl); DataProvider.PhotoDao.Update(photoInfo); } } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, contentInfo.Id); } } else if (translateType == ETranslateContentType.Reference) { if (contentInfo.ReferenceId != 0) { return; } contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.ReferenceId = contentId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Reference.ToString(); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString()); DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); } else if (translateType == ETranslateContentType.ReferenceContent) { if (contentInfo.ReferenceId != 0) { return; } FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.ReferenceId = contentId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.ReferenceContent.ToString(); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId)) { var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentId); if (photoInfoList.Count > 0) { foreach (var photoInfo in photoInfoList) { photoInfo.PublishmentSystemID = targetPublishmentSystemId; photoInfo.ContentID = theContentId; FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl); DataProvider.PhotoDao.Insert(photoInfo); } } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentId); } } }