示例#1
0
        } // _applyPropJson

        /// <summary>
        /// Creates a temporary node of the given NodeTypeId and returns a view containing the temp node
        /// </summary>
        /// <param name="_CswResources">Resources</param>
        /// <param name="Response">Repsonse Object containing the ViewId</param>
        /// <param name="NodeTypeId">NodeTypeId of which to create a temp node</param>
        public static void createTempNode(ICswResources _CswResources, CswNbtViewIdReturn Response, string NodeTypeId)
        {
            CswNbtResources        _CswNbtResources = (CswNbtResources)_CswResources;
            CswNbtMetaDataNodeType NT       = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(NodeTypeId));
            CswNbtNode             TempNode = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(NT.NodeTypeId, null, true);
            CswNbtView             TempView = TempNode.getViewOfNode(false);

            TempView.Root.ChildRelationships[0].AllowAdd = true;
            TempView.IncludeTempNodes = true;
            TempView.SaveToCache(false);
            Response.Data.ViewId = TempView.SessionViewId.ToString();
        }
示例#2
0
        }         // _applyMergeChoicesToNode()

        public CswNbtView finishMerge(MergeInfoData Choices)
        {
            CswNbtView view            = new CswNbtView(_CswNbtResources);
            CswNbtNode firstMergedNode = null;

            foreach (MergeInfoData.MergeInfoNodePair nodePair in Choices.NodePairs)
            {
                // Remove the temp node
                CswNbtNode NodeTemp = _CswNbtResources.Nodes[nodePair.NodeTempId];
                if (null != NodeTemp)
                {
                    NodeTemp.delete(DeleteAllRequiredRelatedNodes: false, OverridePermissions: true, ValidateRequiredRelationships: false);
                }

                // Merge Node1 into Node2, and delete Node1
                CswNbtNode Node1 = _CswNbtResources.Nodes[nodePair.Node1Id];
                CswNbtNode Node2 = _CswNbtResources.Nodes[nodePair.Node2Id];
                if (null != Node1 && null != Node2)
                {
                    // Store the first node merged to return
                    if (null == firstMergedNode)
                    {
                        firstMergedNode = Node2;
                    }

                    // Apply the merge to Node2
                    _applyMergeChoicesToNode(Choices, nodePair, Node2);
                    Node2.postChanges(ForceUpdate: false, IsCopy: false, OverrideUniqueValidation: true);

                    // Update any references to point to node2
                    foreach (MergeInfoData.MergeInfoNodeReference Ref in nodePair.NodeReferences)
                    {
                        CswNbtNode refNode = _CswNbtResources.Nodes[Ref.NodeId];
                        if (refNode.Properties[Ref.NodeTypePropId].getFieldTypeValue() == CswEnumNbtFieldType.UserSelect)
                        {
                            // Special case: UserSelect
                            refNode.Properties[Ref.NodeTypePropId].AsUserSelect.RemoveUser(Node1.NodeId);
                            refNode.Properties[Ref.NodeTypePropId].AsUserSelect.AddUser(Node2.NodeId);
                            refNode.Properties[Ref.NodeTypePropId].AsUserSelect.SyncGestalt();
                        }
                        else
                        {
                            // Node Reference
                            refNode.Properties[Ref.NodeTypePropId].AsNodeReference.ReferencedNodeId = Node2.NodeId;
                            refNode.Properties[Ref.NodeTypePropId].AsNodeReference.RefreshNodeName();
                        }
                        refNode.postChanges(ForceUpdate: false, IsCopy: false, OverrideUniqueValidation: true);
                    }

                    // Delete merged node 1
                    Node1.delete(DeleteAllRequiredRelatedNodes: false, OverridePermissions: true, ValidateRequiredRelationships: false);
                } // if( null != Node1 && null != Node2 )
            }     // foreach( MergeInfoData.MergeInfoNodePair nodePair in Choices.NodePairs )

            // Return a view of the first merged node
            if (null != firstMergedNode)
            {
                view = firstMergedNode.getViewOfNode(includeDefaultFilters: false);
            }
            return(view);
        } // finishMerge()