コード例 #1
0
        private void ImportNodeInfo(NodeInfo nodeInfo, ScopedElementCollection additionalElements, int parentId, IList nodeIndexNameArrayList)
        {
            nodeInfo.NodeName            = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeName);
            nodeInfo.NodeType            = ENodeTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeType));
            nodeInfo.PublishmentSystemId = _publishmentSystemInfo.PublishmentSystemId;
            var contentModelId = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ContentModelId);

            if (!string.IsNullOrEmpty(contentModelId))
            {
                nodeInfo.ContentModelId = contentModelId;
            }
            nodeInfo.ParentId = parentId;
            var nodeIndexName = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeIndexName);

            if (!string.IsNullOrEmpty(nodeIndexName) && nodeIndexNameArrayList.IndexOf(nodeIndexName) == -1)
            {
                nodeInfo.NodeIndexName = nodeIndexName;
                nodeIndexNameArrayList.Add(nodeIndexName);
            }
            nodeInfo.NodeGroupNameCollection = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.NodeGroupNameCollection);
            nodeInfo.AddDate             = DateTime.Now;
            nodeInfo.ImageUrl            = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ImageUrl);
            nodeInfo.Content             = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.Content));
            nodeInfo.FilePath            = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.FilePath);
            nodeInfo.ChannelFilePathRule = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ChannelFilePathRule);
            nodeInfo.ContentFilePathRule = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ContentFilePathRule);

            nodeInfo.LinkUrl  = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.LinkUrl);
            nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.LinkType));

            var channelTemplateName = AtomUtility.GetDcElementContent(additionalElements, ChannelTemplateName);

            if (!string.IsNullOrEmpty(channelTemplateName))
            {
                nodeInfo.ChannelTemplateId = TemplateManager.GetTemplateIDByTemplateName(_publishmentSystemInfo.PublishmentSystemId, ETemplateType.ChannelTemplate, channelTemplateName);
            }
            var contentTemplateName = AtomUtility.GetDcElementContent(additionalElements, ContentTemplateName);

            if (!string.IsNullOrEmpty(contentTemplateName))
            {
                nodeInfo.ContentTemplateId = TemplateManager.GetTemplateIDByTemplateName(_publishmentSystemInfo.PublishmentSystemId, ETemplateType.ContentTemplate, contentTemplateName);
            }

            nodeInfo.Keywords    = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.Keywords);
            nodeInfo.Description = AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.Description);

            nodeInfo.SetExtendValues(AtomUtility.GetDcElementContent(additionalElements, NodeAttribute.ExtendValues));
        }
コード例 #2
0
        public int ImportChannelsAndContents(string filePath, bool isImportContents, bool isOverride, int theParentId)
        {
            var psChildCount      = DataProvider.NodeDao.GetNodeCount(_publishmentSystemInfo.PublishmentSystemId);
            var nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(_publishmentSystemInfo.PublishmentSystemId);

            if (!FileUtils.IsFileExists(filePath))
            {
                return(0);
            }
            var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

            var firstIndex  = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1;
            var lastIndex   = filePath.LastIndexOf(".", StringComparison.Ordinal);
            var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex);

            var idx = orderString.IndexOf("_", StringComparison.Ordinal);

            if (idx != -1)
            {
                var secondOrder = TranslateUtils.ToInt(orderString.Split('_')[1]);
                secondOrder = secondOrder + psChildCount;
                orderString = orderString.Substring(idx + 1);
                idx         = orderString.IndexOf("_", StringComparison.Ordinal);
                if (idx != -1)
                {
                    orderString = orderString.Substring(idx);
                    orderString = "1_" + secondOrder + orderString;
                }
                else
                {
                    orderString = "1_" + secondOrder;
                }

                orderString = orderString.Substring(0, orderString.LastIndexOf("_", StringComparison.Ordinal));
            }

            var parentId = DataProvider.NodeDao.GetNodeId(_publishmentSystemInfo.PublishmentSystemId, orderString);

            if (theParentId != 0)
            {
                parentId = theParentId;
            }

            var nodeType = ENodeTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(feed.AdditionalElements, NodeAttribute.NodeType));
            int nodeId;

            if (nodeType == ENodeType.BackgroundPublishNode)
            {
                nodeId = _publishmentSystemInfo.PublishmentSystemId;
                var nodeInfo = NodeManager.GetNodeInfo(_publishmentSystemInfo.PublishmentSystemId, _publishmentSystemInfo.PublishmentSystemId);
                ImportNodeInfo(nodeInfo, feed.AdditionalElements, parentId, nodeIndexNameList);

                DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);

                if (isImportContents)
                {
                    ImportContents(feed.Entries, nodeInfo, 0, isOverride);
                }
            }
            else
            {
                var nodeInfo = new NodeInfo();
                ImportNodeInfo(nodeInfo, feed.AdditionalElements, parentId, nodeIndexNameList);
                if (string.IsNullOrEmpty(nodeInfo.NodeName))
                {
                    return(0);
                }

                var isUpdate          = false;
                var theSameNameNodeId = 0;
                if (isOverride)
                {
                    theSameNameNodeId = DataProvider.NodeDao.GetNodeIdByParentIdAndNodeName(_publishmentSystemInfo.PublishmentSystemId, parentId, nodeInfo.NodeName, false);
                    if (theSameNameNodeId != 0)
                    {
                        isUpdate = true;
                    }
                }
                if (!isUpdate)
                {
                    //BackgroundNodeInfo backgroundNodeInfo = new BackgroundNodeInfo();
                    //this.ImportBackgroundNodeInfo(backgroundNodeInfo, feed.AdditionalElements);

                    nodeId = DataProvider.NodeDao.InsertNodeInfo(nodeInfo);
                }
                else
                {
                    nodeId   = theSameNameNodeId;
                    nodeInfo = NodeManager.GetNodeInfo(_publishmentSystemInfo.PublishmentSystemId, theSameNameNodeId);
                    var tableName = NodeManager.GetTableName(_publishmentSystemInfo, nodeInfo);
                    ImportNodeInfo(nodeInfo, feed.AdditionalElements, parentId, nodeIndexNameList);

                    DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);

                    DataProvider.ContentDao.DeleteContentsByNodeId(_publishmentSystemInfo.PublishmentSystemId, tableName, theSameNameNodeId);
                }

                if (isImportContents)
                {
                    ImportContents(feed.Entries, nodeInfo, 0, isOverride);
                }
            }

            //this.FSO.CreateRedirectChannel(nodeID);
            //this.FSO.AddChannelToWaitingCreate(nodeID);
            return(nodeId);
        }