Пример #1
0
        public static string GetSiteDir(string path)
        {
            var siteDir         = string.Empty;
            var directoryPath   = DirectoryUtils.GetDirectoryPath(path).ToLower().Trim(' ', '/', '\\');
            var applicationPath = WebConfigUtils.PhysicalApplicationPath.ToLower().Trim(' ', '/', '\\');
            var directoryDir    = StringUtils.ReplaceStartsWith(directoryPath, applicationPath, string.Empty).Trim(' ', '/', '\\');

            if (directoryDir == string.Empty)
            {
                return(string.Empty);
            }

            var pairList = PublishmentSystemManager.GetPublishmentSystemInfoKeyValuePairList();

            foreach (var pair in pairList)
            {
                var publishmentSystemInfo = pair.Value;
                if (publishmentSystemInfo?.IsHeadquarters != false)
                {
                    continue;
                }

                if (StringUtils.Contains(directoryDir, publishmentSystemInfo.PublishmentSystemDir.ToLower()))
                {
                    siteDir = publishmentSystemInfo.PublishmentSystemDir;
                }
            }

            return(PathUtils.GetDirectoryName(siteDir));
        }
Пример #2
0
        public static string GetPublishmentSystemVirtualUrlByAbsoluteUrl(PublishmentSystemInfo publishmentSystemInfo, string absoluteUrl)
        {
            if (publishmentSystemInfo == null)
            {
                var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            }
            if (!string.IsNullOrEmpty(absoluteUrl))
            {
                if (PageUtils.IsProtocolUrl(absoluteUrl) || absoluteUrl.StartsWith("/"))
                {
                    absoluteUrl = absoluteUrl.ToLower();
                    var publishmentSystemUrl = GetPublishmentSystemUrl(publishmentSystemInfo, string.Empty).ToLower();

                    if (PageUtils.IsProtocolUrl(absoluteUrl))
                    {
                        publishmentSystemUrl = PageUtils.AddProtocolToUrl(publishmentSystemUrl);
                    }

                    absoluteUrl = StringUtils.ReplaceFirst(publishmentSystemUrl, absoluteUrl, string.Empty);
                }
                else if (absoluteUrl.StartsWith("."))
                {
                    absoluteUrl = absoluteUrl.Replace("../", string.Empty);
                    absoluteUrl = absoluteUrl.Replace("./", string.Empty);
                }
                return(PageUtils.Combine("@", absoluteUrl));
            }
            else
            {
                return(string.Empty);
            }
        }
Пример #3
0
 //level=0代表站点根目录,1代表下一级目标。。。返回代码类似../images/pic.jpg
 public static string GetPublishmentSystemUrlOfRelatedByPhysicalPath(PublishmentSystemInfo publishmentSystemInfo, string physicalPath, int level)
 {
     if (publishmentSystemInfo == null)
     {
         var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
         publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
     }
     if (!string.IsNullOrEmpty(physicalPath))
     {
         var publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
         var requestPath           = physicalPath.ToLower().Replace(publishmentSystemPath.ToLower(), string.Empty);
         requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
         requestPath = requestPath.Trim(PageUtils.SeparatorChar);
         if (level > 0)
         {
             for (var i = 0; i < level; i++)
             {
                 requestPath = "../" + requestPath;
             }
         }
         return(requestPath);
     }
     else
     {
         return(string.Empty);
     }
 }
Пример #4
0
        /// <summary>
        /// 从设置信息中的RootUrl中取得地址,并结合发布系统和相对地址,得到能够运行动态文件的地址。
        /// </summary>
        public static string GetRootUrlByPublishmentSystemId(PublishmentSystemInfo psInfo, string requestPath)
        {
            if (psInfo == null)
            {
                var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
                psInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            }
            //string url = ConfigUtils.Instance.ApplicationPath;
            var url = PageUtils.GetRootUrl(string.Empty);

            if (url.EndsWith("/"))
            {
                url = url.Substring(0, url.Length - 1);
            }
            url += "/" + psInfo.PublishmentSystemDir;

            if (requestPath != null && requestPath.Trim().Length > 0)
            {
                if (requestPath.StartsWith("/"))
                {
                    requestPath = requestPath.Substring(1);
                }
                if (requestPath.EndsWith("/"))
                {
                    requestPath = requestPath.Substring(0, requestPath.Length - 1);
                }
                url = url + "/" + requestPath;
            }
            return(url);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
                }
            }
        }
Пример #7
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));
        }
Пример #8
0
        public static bool IsTranslatable(PublishmentSystemInfo publishmentSystemInfo, NodeInfo nodeInfo)
        {
            var isTranslatable = false;

            if (nodeInfo != null && nodeInfo.Additional.TransType != ECrossSiteTransType.None)
            {
                var transType = nodeInfo.Additional.TransType;
                if (transType != ECrossSiteTransType.None)
                {
                    if (transType == ECrossSiteTransType.AllParentSite)
                    {
                        var parentPublishmentSystemID = PublishmentSystemManager.GetParentPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId);
                        if (parentPublishmentSystemID != 0)
                        {
                            isTranslatable = true;
                        }
                    }
                    else if (transType == ECrossSiteTransType.SelfSite)
                    {
                        isTranslatable = true;
                    }
                    else if (transType == ECrossSiteTransType.AllSite)
                    {
                        isTranslatable = true;
                    }
                    else if (transType == ECrossSiteTransType.SpecifiedSite)
                    {
                        if (nodeInfo.Additional.TransPublishmentSystemID > 0)
                        {
                            var thePublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(nodeInfo.Additional.TransPublishmentSystemID);
                            if (thePublishmentSystemInfo != null)
                            {
                                isTranslatable = true;
                            }
                        }
                    }
                    else if (transType == ECrossSiteTransType.ParentSite)
                    {
                        var parentPublishmentSystemID = PublishmentSystemManager.GetParentPublishmentSystemId(publishmentSystemInfo.PublishmentSystemId);
                        if (parentPublishmentSystemID != 0)
                        {
                            isTranslatable = true;
                        }
                    }
                }
            }

            return(isTranslatable);
        }
Пример #9
0
        public static bool IsExists(int nodeId)
        {
            var list = PublishmentSystemManager.GetPublishmentSystemIdList();

            foreach (var publishmentSystemId in list)
            {
                var nodeInfo = GetNodeInfo(publishmentSystemId, nodeId);
                if (nodeInfo != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #10
0
        public static void ChangeParentPublishmentSystem(int oldParentPublishmentSystemId, int newParentPublishmentSystemId, int publishmentSystemId, string publishmentSystemDir)
        {
            if (oldParentPublishmentSystemId == newParentPublishmentSystemId)
            {
                return;
            }

            string oldPsPath;

            if (oldParentPublishmentSystemId != 0)
            {
                var oldPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(oldParentPublishmentSystemId);

                oldPsPath = PathUtils.Combine(PathUtility.GetPublishmentSystemPath(oldPublishmentSystemInfo), publishmentSystemDir);
            }
            else
            {
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                oldPsPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
            }

            string newPsPath;

            if (newParentPublishmentSystemId != 0)
            {
                var newPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(newParentPublishmentSystemId);

                newPsPath = PathUtils.Combine(PathUtility.GetPublishmentSystemPath(newPublishmentSystemInfo), publishmentSystemDir);
            }
            else
            {
                newPsPath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, publishmentSystemDir);
            }

            if (DirectoryUtils.IsDirectoryExists(newPsPath))
            {
                throw new ArgumentException("发布系统修改失败,发布路径文件夹已存在!");
            }
            if (DirectoryUtils.IsDirectoryExists(oldPsPath))
            {
                DirectoryUtils.MoveDirectory(oldPsPath, newPsPath, false);
            }
            else
            {
                DirectoryUtils.CreateDirectoryIfNotExists(newPsPath);
            }
        }
Пример #11
0
 public static string GetPublishmentSystemVirtualUrlByPhysicalPath(PublishmentSystemInfo publishmentSystemInfo, string physicalPath)
 {
     if (publishmentSystemInfo == null)
     {
         var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
         publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
     }
     if (!string.IsNullOrEmpty(physicalPath))
     {
         var publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
         var requestPath           = physicalPath.ToLower().Replace(publishmentSystemPath.ToLower(), string.Empty);
         requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
         return(PageUtils.Combine("@", requestPath));
     }
     else
     {
         return(string.Empty);
     }
 }
Пример #12
0
        public static int GetCurrentPublishmentSystemId()
        {
            int publishmentSystemId;
            var publishmentSystemIdList = PublishmentSystemManager.GetPublishmentSystemIdList();

            if (publishmentSystemIdList.Count == 1)
            {
                publishmentSystemId = publishmentSystemIdList[0];
            }
            else
            {
                var publishmentSystemDir = GetCurrentSiteDir();
                publishmentSystemId = !string.IsNullOrEmpty(publishmentSystemDir) ? DataProvider.PublishmentSystemDao.GetPublishmentSystemIdByPublishmentSystemDir(publishmentSystemDir) : DataProvider.PublishmentSystemDao.GetPublishmentSystemIdByIsHeadquarters();

                if (publishmentSystemId == 0)
                {
                    publishmentSystemId = DataProvider.PublishmentSystemDao.GetPublishmentSystemIdByIsHeadquarters();
                }
            }
            return(publishmentSystemId);
        }
Пример #13
0
 //返回代码类似/dev/site/images/pic.jpg
 public static string GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo publishmentSystemInfo, string physicalPath)
 {
     if (publishmentSystemInfo == null)
     {
         var publishmentSystemId = PathUtility.GetCurrentPublishmentSystemId();
         publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
     }
     if (!string.IsNullOrEmpty(physicalPath))
     {
         var    publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo);
         string requestPath;
         if (physicalPath.StartsWith(publishmentSystemPath))
         {
             requestPath = StringUtils.ReplaceStartsWith(physicalPath, publishmentSystemPath, string.Empty);
         }
         else
         {
             requestPath = physicalPath.ToLower().Replace(publishmentSystemPath.ToLower(), string.Empty);
         }
         requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
         return(GetPublishmentSystemUrl(publishmentSystemInfo, requestPath));
     }
     return(publishmentSystemInfo.PublishmentSystemUrl);
 }
Пример #14
0
 public static string GetPublishmentSystemPath(int publishmentSystemId, params string[] paths)
 {
     return(GetPublishmentSystemPath(PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId), paths));
 }
Пример #15
0
        public static VisualInfo GetInstance()
        {
            var visualInfo = new VisualInfo();

            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["s"]))
            {
                visualInfo.publishmentSystemID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["s"]);
            }
            if (visualInfo.publishmentSystemID == 0)
            {
                visualInfo.publishmentSystemID = PathUtility.GetCurrentPublishmentSystemId();
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["n"]))
            {
                visualInfo.channelID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["n"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["c"]))
            {
                visualInfo.contentID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["c"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["f"]))
            {
                visualInfo.fileTemplateID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["f"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["p"]))
            {
                visualInfo.pageIndex = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["p"]);
            }
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["isPreview"]))
            {
                visualInfo.isPreview = TranslateUtils.ToBool(HttpContext.Current.Request.QueryString["isPreview"]);
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["previewID"]))
                {
                    visualInfo.contentID = TranslateUtils.ToInt(HttpContext.Current.Request.QueryString["previewID"]);//编辑界面预览
                }
            }

            if (visualInfo.channelID > 0)
            {
                visualInfo.templateType = ETemplateType.ChannelTemplate;
            }
            if (visualInfo.contentID > 0 || visualInfo.isPreview)
            {
                visualInfo.templateType = ETemplateType.ContentTemplate;
            }
            if (visualInfo.fileTemplateID > 0)
            {
                visualInfo.templateType = ETemplateType.FileTemplate;
            }

            if (visualInfo.channelID == 0)
            {
                visualInfo.channelID = visualInfo.publishmentSystemID;
            }

            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(visualInfo.publishmentSystemID);

            if (visualInfo.templateType == ETemplateType.IndexPageTemplate)
            {
                var templateInfo   = TemplateManager.GetTemplateInfo(visualInfo.publishmentSystemID, 0, ETemplateType.IndexPageTemplate);
                var isHeadquarters = publishmentSystemInfo.IsHeadquarters;
                visualInfo.filePath = PathUtility.GetIndexPageFilePath(publishmentSystemInfo, templateInfo.CreatedFileFullName, isHeadquarters, visualInfo.pageIndex);
            }
            else if (visualInfo.templateType == ETemplateType.ChannelTemplate)
            {
                visualInfo.filePath = PathUtility.GetChannelPageFilePath(publishmentSystemInfo, visualInfo.channelID, visualInfo.pageIndex);
            }
            else if (visualInfo.templateType == ETemplateType.ContentTemplate)
            {
                visualInfo.filePath = PathUtility.GetContentPageFilePath(publishmentSystemInfo, visualInfo.channelID, visualInfo.contentID, visualInfo.pageIndex);
            }
            else if (visualInfo.templateType == ETemplateType.FileTemplate)
            {
                var templateInfo = TemplateManager.GetTemplateInfo(visualInfo.publishmentSystemID, visualInfo.fileTemplateID);
                visualInfo.filePath = PathUtility.MapPath(publishmentSystemInfo, templateInfo.CreatedFileFullName);
            }

            return(visualInfo);
        }
Пример #16
0
        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);
                    }
                }
            }
        }
Пример #17
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
            }
        }
Пример #18
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);
                }
            }
        }
Пример #19
0
        public static string ParseNavigationUrl(int publishmentSystemId, string url)
        {
            var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);

            return(ParseNavigationUrl(publishmentSystemInfo, url, false));
        }