Exemple #1
0
        public static string GetContentUrl(PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo, int contentId, bool isFromBackground)
        {
            var tableStyle  = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var tableName   = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
            var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);

            return(GetContentUrlById(publishmentSystemInfo, contentInfo, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.LinkUrl), isFromBackground));
        }
Exemple #2
0
        public static string GetContentPageFilePath(PublishmentSystemInfo publishmentSystemInfo, int nodeId, int contentId, int currentPageIndex)
        {
            var tableStyle  = NodeManager.GetTableStyle(publishmentSystemInfo, nodeId);
            var tableName   = NodeManager.GetTableName(publishmentSystemInfo, nodeId);
            var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);

            return(GetContentPageFilePath(publishmentSystemInfo, nodeId, contentInfo, currentPageIndex));
        }
Exemple #3
0
            public static string Parse(PublishmentSystemInfo publishmentSystemInfo, int nodeId, int contentId)
            {
                var contentFilePathRule = GetContentFilePathRule(publishmentSystemInfo, nodeId);
                var tableStyle          = NodeManager.GetTableStyle(publishmentSystemInfo, nodeId);
                var tableName           = NodeManager.GetTableName(publishmentSystemInfo, nodeId);
                var contentInfo         = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);
                var filePath            = ParseContentPath(publishmentSystemInfo, nodeId, contentInfo, contentFilePathRule);

                return(filePath);
            }
Exemple #4
0
        /// <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));
        }
Exemple #5
0
            public static IDictionary GetDictionary(PublishmentSystemInfo publishmentSystemInfo, int nodeId)
            {
                var dictionary = new ListDictionary
                {
                    { ChannelId, "栏目ID" },
                    { ChannelIndex, "栏目索引" },
                    { ContentId, "内容ID" },
                    { Year, "年份" },
                    { Month, "月份" },
                    { Day, "日期" },
                    { Hour, "小时" },
                    { Minute, "分钟" },
                    { Second, "秒钟" },
                    { Sequence, "顺序数" },
                    { ParentRule, "父级命名规则" },
                    { ChannelName, "栏目名称" }
                };

                //继承父级设置 20151113 sessionliang

                var tableStyle        = NodeManager.GetTableStyle(publishmentSystemInfo, nodeId);
                var tableName         = NodeManager.GetTableName(publishmentSystemInfo, nodeId);
                var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemInfo.PublishmentSystemId, nodeId);

                var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);

                foreach (var styleInfo in styleInfoList)
                {
                    if (EInputTypeUtils.Equals(styleInfo.InputType, EInputType.Text))
                    {
                        dictionary.Add($@"{{@{styleInfo.AttributeName}}}", styleInfo.DisplayName);
                    }
                }

                return(dictionary);
            }
Exemple #6
0
        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());
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        public static void TransContentInfo(PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo, int contentID, PublishmentSystemInfo targetPublishmentSystemInfo, int targetNodeID)
        {
            var targetTableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeID);

            var tableStyle  = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var tableName   = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
            var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentID);

            FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo);
            contentInfo.PublishmentSystemId = targetPublishmentSystemInfo.PublishmentSystemId;
            contentInfo.SourceId            = nodeInfo.NodeId;
            contentInfo.NodeId = targetNodeID;
            if (targetPublishmentSystemInfo.Additional.IsCrossSiteTransChecked)
            {
                contentInfo.IsChecked = true;
            }
            else
            {
                contentInfo.IsChecked = false;
            }
            contentInfo.CheckedLevel = 0;

            //复制
            if (Equals(nodeInfo.Additional.TransDoneType, ETranslateContentType.Copy))
            {
                contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
            }
            //引用地址
            else if (Equals(nodeInfo.Additional.TransDoneType, ETranslateContentType.Reference))
            {
                contentInfo.PublishmentSystemId = targetPublishmentSystemInfo.PublishmentSystemId;
                contentInfo.SourceId            = nodeInfo.NodeId;
                contentInfo.NodeId      = targetNodeID;
                contentInfo.ReferenceId = contentID;
                contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
            }
            //引用内容
            else if (Equals(nodeInfo.Additional.TransDoneType, ETranslateContentType.ReferenceContent))
            {
                contentInfo.PublishmentSystemId = targetPublishmentSystemInfo.PublishmentSystemId;
                contentInfo.SourceId            = nodeInfo.NodeId;
                contentInfo.NodeId      = targetNodeID;
                contentInfo.ReferenceId = contentID;
                contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.ReferenceContent.ToString());
            }


            if (!string.IsNullOrEmpty(targetTableName))
            {
                var theContentID = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo);

                #region  制资源
                var targetPulishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemInfo.PublishmentSystemId);
                var targetTableStyle           = NodeManager.GetTableStyle(targetPulishmentSystemInfo, targetNodeID);
                var targetContentInfo          = DataProvider.ContentDao.GetContentInfo(targetTableStyle, targetTableName, theContentID);
                //资源:图片,文件,视频
                if (!string.IsNullOrEmpty(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl)))
                {
                    //修改图片
                    var sourceImageUrl = PathUtility.MapPath(publishmentSystemInfo, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.ImageUrl));
                    CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl, publishmentSystemInfo);
                }
                else if (!string.IsNullOrEmpty(contentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))))
                {
                    var sourceImageUrls = TranslateUtils.StringCollectionToStringList(contentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));

                    foreach (string imageUrl in sourceImageUrls)
                    {
                        var sourceImageUrl = PathUtility.MapPath(publishmentSystemInfo, imageUrl);
                        CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl, publishmentSystemInfo);
                    }
                }
                if (!string.IsNullOrEmpty(contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl)))
                {
                    //修改附件
                    var sourceFileUrl = PathUtility.MapPath(publishmentSystemInfo, contentInfo.GetExtendedAttribute(BackgroundContentAttribute.FileUrl));
                    CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl, publishmentSystemInfo);
                }
                else if (!string.IsNullOrEmpty(contentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))))
                {
                    var sourceFileUrls = TranslateUtils.StringCollectionToStringList(contentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));

                    foreach (string FileUrl in sourceFileUrls)
                    {
                        var sourceFileUrl = PathUtility.MapPath(publishmentSystemInfo, FileUrl);
                        CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl, publishmentSystemInfo);
                    }
                }
                #endregion
            }
        }
Exemple #9
0
        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);
                }
            }
        }