/// <summary>
        /// WCF method to fulfill a Move Containers request
        /// </summary>
        public static void fulfillContainerMoveRequest(ICswResources CswResources, CswNbtRequestDataModel.CswRequestReturn Ret, CswNbtRequestDataModel.RequestFulfill Request)
        {
            CswNbtResources           NbtResources = _validate(CswResources);
            CswNbtObjClassRequestItem RequestItem  = NbtResources.Nodes[Request.RequestItemId];

            if (null != RequestItem)
            {
                Int32 ContainersMoved = moveContainers(NbtResources, RequestItem, Request);
                Ret.Data.Succeeded = ContainersMoved > 0;
                if (Ret.Data.Succeeded)
                {
                    if (CswTools.IsDouble(RequestItem.TotalMoved.Value))
                    {
                        RequestItem.TotalMoved.Value += ContainersMoved;
                    }
                    else
                    {
                        RequestItem.TotalMoved.Value = ContainersMoved;
                    }
                    RequestItem.Status.Value = CswNbtObjClassRequestItem.Statuses.Moved;
                    RequestItem.FulfillmentHistory.AddComment("Moved " + ContainersMoved + " containers to " +
                                                              CswNbtNode.getNodeLink(RequestItem.Location.SelectedNodeId, RequestItem.Location.CachedFullPath));
                    RequestItem.postChanges(ForceUpdate: false);
                }
            }
        }
            public JObject ToJson()
            {
                JObject NodeObj = new JObject();
                NodeObj["nodename"] = NodeName;
                if( null == NodeId )
                {
                    NodeObj["nodeid"] = "";
                }
                else
                {
                    NodeObj["nodeid"] = NodeId.ToString();
                }
                if( null == NodeKey )
                {
                    NodeObj["nodekey"] = "";
                }
                else
                {
                    NodeObj["nodekey"] = NodeKey.ToString();
                }
                NodeObj["nodelink"] = CswNbtNode.getNodeLink( NodeId, NodeName );
                NodeObj["c3productid"] = C3ProductId.ToString();
                NodeObj["acdcdbregno"] = ACDCdbregno.ToString();
                NodeObj["locked"] = Locked.ToString().ToLower();
                NodeObj["disabled"] = Disabled.ToString().ToLower();
                NodeObj["isFavorite"] = IsFavorite.ToString().ToLower();
                NodeObj["nodetypeid"] = NodeType.NodeTypeId;
                NodeObj["nodetypename"] = NodeType.NodeTypeName;
                NodeObj["thumbnailurl"] = ThumbnailUrl;
                NodeObj["thumbnailbase64str"] = ThumbnailBase64Str;
                NodeObj["allowview"] = AllowView;
                NodeObj["allowedit"] = AllowEdit;
                NodeObj["allowdelete"] = AllowDelete;

                NodeObj["allowimport"] = AllowImport;
                NodeObj["allowrequest"] = AllowRequest;

                // Props in the View
                JArray PropsArray = new JArray();
                NodeObj["props"] = PropsArray;
                foreach( TableProp thisProp in Props.Values )
                {
                    PropsArray.Add( thisProp.ToJson() );
                }
                return NodeObj;
            } // ToJson()
        public override void ToJSON( JObject ParentObject )
        {
            CswNbtNode RelatedNode = null;
            if( CswTools.IsPrimaryKey( RelatedNodeId ) )
            {
                //ParentObject[_NodeIDSubField.ToXmlNodeName( true ).ToLower()] = RelatedNodeId.ToString();
                RelatedNode = _CswNbtResources.Nodes[RelatedNodeId];
            }

            if( IsEditModeEditable )
            {
                JArray JOptions = (JArray) ( ParentObject["options"] = new JArray() );
                bool AllowEdit = _CswNbtResources.Permit.isPropWritable( CswEnumNbtNodeTypePermission.Create, NodeTypeProp, null );
                Int32 OptionCount = 0;
                if( AllowEdit )
                {
                    CswPrimaryKey pk = null;
                    if( null != RelatedNode )
                    {
                        pk = RelatedNode.NodeId;
                    }
                    //Dictionary<CswPrimaryKey, string> Options = _OptionsOverride ?? _getOptions( _CswNbtResources, _CswNbtMetaDataNodeTypeProp.IsRequired, _CswNbtMetaDataNodeTypeProp.FKValue, pk, View );
                    Dictionary<CswPrimaryKey, string> Options = _OptionsOverride ?? _getOptions( _CswNbtResources,
                                                                                                 CswConvert.ToBoolean( _CswNbtNodePropData[CswNbtFieldTypeRuleRelationship.AttributeName.Required] ),
                                                                                                 CswConvert.ToInt32( _CswNbtNodePropData[CswNbtFieldTypeRuleRelationship.AttributeName.Target, CswNbtFieldTypeRuleMetaDataList.SubFieldName.Id] ),
                                                                                                 pk, View );
                    if( Options.Count > _SearchThreshold )
                    {
                        ParentObject["usesearch"] = true;
                    }
                    else
                    {
                        ParentObject["usesearch"] = false;
                        CswPrimaryKey FirstPk = null;
                        foreach( CswPrimaryKey NodePk in Options.Keys )
                        {
                            if( CswTools.IsPrimaryKey( NodePk ) )
                            {
                                OptionCount += 1;
                                JObject JOption = new JObject();
                                FirstPk = FirstPk ?? NodePk;
                                JOption["id"] = NodePk.ToString();
                                JOption["value"] = Options[NodePk];
                                JOption["link"] = CswNbtNode.getNodeLink( NodePk, Options[NodePk] );
                                JOptions.Add( JOption );
                            }
                        }

                        //If Required, show empty when no value is selected and if there is more than one option to select from
                        bool ShowEmptyOption = Required && false == CswTools.IsPrimaryKey( RelatedNodeId ) && 1 < OptionCount;
                        //If not Required, always show the empty value
                        ShowEmptyOption = ShowEmptyOption || false == Required;

                        if( ShowEmptyOption )
                        {
                            JObject JOption = new JObject();
                            JOption["id"] = "";
                            JOption["value"] = "";
                            JOptions.AddFirst( JOption );
                        }
                        else
                        {
                            //Case 30030
                            if( null == RelatedNode &&
                                Required &&
                                Options.Count == 1 &&
                                CswTools.IsPrimaryKey( FirstPk ) )
                            {
                                RelatedNode = _CswNbtResources.Nodes[FirstPk];
                            }
                        }
                    }
                }

                ParentObject["nodetypeid"] = 0;
                ParentObject["objectclassid"] = 0;
                ParentObject["propertysetid"] = 0;
                bool AllowAdd = false;
                bool AllowView = true;
                if( null != RelatedNodeId )
                {
                    CswNbtMetaDataNodeType TargetNodeType = _CswNbtResources.MetaData.getNodeTypeFromNodeId( RelatedNodeId );
                    AllowAdd = ( null != TargetNodeType && _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.Create, TargetNodeType ) );
                    AllowView = ( null != TargetNodeType && _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.View, TargetNodeType ) );
                }
                else if( TargetType == CswEnumNbtViewRelatedIdType.NodeTypeId )
                {
                    ParentObject["nodetypeid"] = TargetId;
                    CswNbtMetaDataNodeType TargetNodeType = _CswNbtResources.MetaData.getNodeType( TargetId );
                    AllowAdd = ( null != TargetNodeType && _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.Create, TargetNodeType ) );
                    AllowView = ( null != TargetNodeType && _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.View, TargetNodeType ) );
                }
                else if( TargetType == CswEnumNbtViewRelatedIdType.ObjectClassId )
                {
                    ParentObject["objectclassid"] = TargetId;
                    CswNbtMetaDataObjectClass TargetObjectClass = _CswNbtResources.MetaData.getObjectClass( TargetId );
                    AllowAdd = ( null != TargetObjectClass &&
                                 TargetObjectClass.CanAdd &&
                                 TargetObjectClass.getNodeTypes().Any( nt => _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.Create, nt ) ) );
                    if( false == AllowAdd )
                    {
                        AllowView = ( null != TargetObjectClass &&
                                      TargetObjectClass.getNodeTypes().Any( nt => _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.View, nt ) ) );
                    }
                }
                else if( TargetType == CswEnumNbtViewRelatedIdType.PropertySetId )
                {
                    ParentObject["propertysetid"] = TargetId;
                    CswNbtMetaDataPropertySet TargetPropSet = _CswNbtResources.MetaData.getPropertySet( TargetId );
                    AllowAdd = TargetPropSet.getObjectClasses().Any( oc => null != oc &&
                                                                           oc.CanAdd &&
                                                                           oc.getNodeTypes().Any( nt => _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.Create, nt ) ) );
                    if( false == AllowAdd )
                    {
                        AllowView = TargetPropSet.getObjectClasses().Any( oc => null != oc &&
                                                                                oc.getNodeTypes().Any( nt => _CswNbtResources.Permit.canNodeType( CswEnumNbtNodeTypePermission.View, nt ) ) );
                    }
                }
                ParentObject["allowadd"] = AllowAdd;
                ParentObject["allowview"] = AllowView;

                if( null != View )
                {
                    ParentObject["viewid"] = View.ViewId.ToString();
                    if( AllowEdit && OptionCount == 0 )
                    {
                        ParentObject["doGetNodes"] = true;
                    }
                }
            } // if( ForEdit )

            ParentObject[_NodeIDSubField.ToXmlNodeName( true ).ToLower()] = string.Empty;
            ParentObject[_NameSubField.ToXmlNodeName( true ).ToLower()] = CachedNodeName;
            ParentObject["relatednodeid"] = string.Empty;
            ParentObject["relatednodelink"] = string.Empty;
            if( null != RelatedNode )
            {
                ParentObject[_NodeIDSubField.ToXmlNodeName( true ).ToLower()] = RelatedNode.NodeId.ToString();
                ParentObject[_NameSubField.ToXmlNodeName( true ).ToLower()] = RelatedNode.NodeName;
                ParentObject["relatednodeid"] = RelatedNode.NodeId.ToString();
                ParentObject["relatednodelink"] = RelatedNode.NodeLink;
            }
        } // ToJSON()