Пример #1
0
        public static string GetChannelPageFilePath(SiteInfo siteInfo, int channelId, int currentPageIndex)
        {
            var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);

            if (nodeInfo.ParentId == 0)
            {
                var templateInfo = TemplateManager.GetDefaultTemplateInfo(siteInfo.Id, TemplateType.IndexPageTemplate);
                return(GetIndexPageFilePath(siteInfo, templateInfo.CreatedFileFullName, siteInfo.IsRoot, currentPageIndex));
            }
            var filePath = nodeInfo.FilePath;

            if (string.IsNullOrEmpty(filePath))
            {
                filePath = ChannelFilePathRules.Parse(siteInfo, channelId);
            }

            filePath = MapPath(siteInfo, filePath);// PathUtils.Combine(sitePath, filePath);
            if (PathUtils.IsDirectoryPath(filePath))
            {
                filePath = PathUtils.Combine(filePath, channelId + ".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);
        }
Пример #2
0
        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);
        }
        public async Task <ActionResult <ObjectResult <List <KeyValuePair <string, string> > > > > Get([FromQuery] GetRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.SettingsCreateRule))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(this.Error("无法确定内容对应的站点"));
            }

            Dictionary <string, string> dict;

            if (request.IsChannel)
            {
                var rules = new ChannelFilePathRules(_pathManager, _databaseManager);
                dict = await rules.GetDictionaryAsync(request.ChannelId);
            }
            else
            {
                var rules = new ContentFilePathRules(_pathManager, _databaseManager);
                dict = await rules.GetDictionaryAsync(site, request.ChannelId);
            }
            var list = new List <KeyValuePair <string, string> >();

            foreach (var rule in dict)
            {
                list.Add(new KeyValuePair <string, string>(rule.Key, rule.Value));
            }

            return(new ObjectResult <List <KeyValuePair <string, string> > >
            {
                Value = list
            });
        }