public override void update()
        {

            CswNbtMetaDataNodeType SiteNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Site" );
            if( null != SiteNT )
            {
                CswNbtMetaDataNodeTypeProp LocationNTP = SiteNT.getNodeTypePropByObjectClassProp( CswNbtObjClassLocation.PropertyName.Location );

                LocationNTP.ReadOnly = true;
                LocationNTP.removeFromAllLayouts();
                LocationNTP.Hidden = true;

                CswNbtView SitesView = _CswNbtSchemaModTrnsctn.makeNewView( "Sites Location Not Null", CswEnumNbtViewVisibility.Hidden );

                CswNbtViewRelationship parent = SitesView.AddViewRelationship( SiteNT, false );
                SitesView.AddViewPropertyAndFilter( parent, LocationNTP,
                                                    SubFieldName: CswEnumNbtSubFieldName.NodeID,
                                                    FilterMode: CswEnumNbtFilterMode.NotNull );

                ICswNbtTree tree = _CswNbtSchemaModTrnsctn.getTreeFromView( SitesView, true );
                for( int i = 0; i < tree.getChildNodeCount(); i++ )
                {
                    tree.goToNthChild( i );

                    CswNbtObjClassLocation SiteNode = tree.getNodeForCurrentPosition();
                    SiteNode.Location.SelectedNodeId = null;
                    SiteNode.Location.RefreshNodeName();
                    SiteNode.Location.SyncGestalt();
                    SiteNode.postChanges( false );

                    tree.goToParentNode();
                }

                SitesView.Delete();
            }

        } // update()
Пример #2
0
        public override void update()
        {
            //Create action
            _CswNbtSchemaModTrnsctn.createAction( CswEnumNbtActionName.Manage_Locations, true, "", "System" );
            _CswNbtSchemaModTrnsctn.createModuleActionJunction( CswEnumNbtModuleName.CISPro.ToString(), CswEnumNbtActionName.Manage_Locations );

            //Make inventory group property required
            CswNbtMetaDataObjectClass LocationOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.LocationClass );
            if( null != LocationOC )
            {

                CswNbtMetaDataObjectClass InventoryGroupOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.InventoryGroupClass );
                if( null != InventoryGroupOC )
                {
                    CswNbtMetaDataObjectClassProp InventoryGroupOCP = LocationOC.getObjectClassProp( CswNbtObjClassLocation.PropertyName.InventoryGroup );
                    if( null != InventoryGroupOCP )
                    {

                        CswNbtSearch InventoryGroupNodeSearch = _CswNbtSchemaModTrnsctn.CswNbtSearch;
                        InventoryGroupNodeSearch.SearchTerm = "Default Inventory Group";
                        InventoryGroupNodeSearch.addFilter( InventoryGroupOC, false );

                        ICswNbtTree TreeOfArbitraryNodes = InventoryGroupNodeSearch.Results();
                        if( TreeOfArbitraryNodes.getRootTreeNode().ChildNodes.Count > 0 )
                        {

                            CswNbtTreeNode IGTreeNode = TreeOfArbitraryNodes.getRootTreeNode().ChildNodes[0];
                            CswNbtNode DefaultInventoryGroupNode = _CswNbtSchemaModTrnsctn.Nodes[IGTreeNode.NodeKey];
                            if( null != DefaultInventoryGroupNode )
                            {
                                //*** get tree of locations that don't have an inventory group
                                CswNbtView ViewOfLocationsWithNullIG = _CswNbtSchemaModTrnsctn.makeView();
                                //                            ViewOfLocationsWithNullIG.makeNew( "Null IVG Locations", NbtViewVisibility.Global, null, null );
                                ViewOfLocationsWithNullIG.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                                ViewOfLocationsWithNullIG.Category = "System";
                                ViewOfLocationsWithNullIG.Width = 100;
                                CswNbtViewRelationship ViewRelLocationsOC = ViewOfLocationsWithNullIG.AddViewRelationship( LocationOC, true );


                                CswNbtViewProperty ViewPropIGOCP = ViewOfLocationsWithNullIG.AddViewProperty( ViewRelLocationsOC, InventoryGroupOCP );

                                ViewOfLocationsWithNullIG.AddViewPropertyFilter( ViewPropIGOCP, CswEnumNbtSubFieldName.NodeID, CswEnumNbtFilterMode.Null );

                                ICswNbtTree TreeOfLocations = _CswNbtSchemaModTrnsctn.getTreeFromView( ViewOfLocationsWithNullIG, true );


                                TreeOfLocations.goToRoot();
                                int TotalLocationNodes = TreeOfLocations.getChildNodeCount();
                                for( int idx = 0; idx < TotalLocationNodes; idx++ )
                                {
                                    TreeOfLocations.goToNthChild( idx );
                                    CswNbtObjClassLocation CurrentLocationNode = TreeOfLocations.getNodeForCurrentPosition();
                                    CurrentLocationNode.InventoryGroup.RelatedNodeId = DefaultInventoryGroupNode.NodeId;
                                    CurrentLocationNode.postChanges( true );
                                    TreeOfLocations.goToParentNode(); 

                                } // for( int idx = 0; idx < TotalTargetNodes; idx++ )


                            }//if there are any matching inventory group nodes




                            //foreach( CswNbtNode CurrentLocationNode in LocationOC.getNodes( false, true ) )
                            //{
                            //    if( null == CurrentLocationNode.Properties[InventoryGroupOCP.PropName].AsRelationship.RelatedNodeId )
                            //    {
                            //        CurrentLocationNode.Properties[InventoryGroupOCP.PropName].AsRelationship.RelatedNodeId = DefaultInventoryGroupNode.NodeId;
                            //        CurrentLocationNode.postChanges( true );

                            //    }//if the location doesn't have an inventory group

                            //}//iterate location nodes

                        }//if we found a default inventory group


                        _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( InventoryGroupOCP, CswEnumNbtObjectClassPropAttributes.isrequired, true );

                    }//if we found the inventory group OCP

                }//if we found the inventory group OC

            }//if we found the location OC

        } // update()
        public void assignPropsToLocations( string LocationNodeKeys, bool UpdateInventoryGroup, string SelectedInventoryGroupNodeId, bool UpdateAllowInventory, string AllowInventory, bool UpdateControlZone, string SelectedControlZoneNodeId, bool UpdateStorageCompatability, string SelectedImages )
        {

            if( false == string.IsNullOrEmpty( LocationNodeKeys ) )
            {


                ///we don't pre-load he allowinventory value because there's no extra expense
                ///to doing so repeatedly in the loop

                CswNbtNode InventoryGroupNode = null;
                if( ( true == UpdateInventoryGroup ) && ( false == string.IsNullOrEmpty( SelectedInventoryGroupNodeId ) ) )
                {
                    CswPrimaryKey IGKey = new CswPrimaryKey();
                    IGKey.FromString( SelectedInventoryGroupNodeId );
                    InventoryGroupNode = _CswNbtResources.Nodes[IGKey];
                }

                CswNbtNode ControlZoneNode = null;
                if( ( true == UpdateControlZone ) && ( false == string.IsNullOrEmpty( SelectedControlZoneNodeId ) ) )
                {
                    CswPrimaryKey IGKey = new CswPrimaryKey();
                    IGKey.FromString( SelectedControlZoneNodeId );
                    ControlZoneNode = _CswNbtResources.Nodes[IGKey];
                }



                CswDelimitedString Images = new CswDelimitedString( ',' );
                if( true == UpdateStorageCompatability )
                {
                    if( false == string.IsNullOrEmpty( SelectedImages ) )
                    {
                        Images.FromString( SelectedImages );
                    }
                }



                foreach( string CurrentLocationKey in LocationNodeKeys.Split( ',' ) )
                {
                    if( false == string.IsNullOrEmpty( CurrentLocationKey ) )
                    {
                        CswNbtNodeKey LKey = new CswNbtNodeKey( CurrentLocationKey );
                        CswNbtObjClassLocation CurrentLocationNode = _CswNbtResources.Nodes[LKey];
                        if( null != CurrentLocationNode )
                        {

                            if( true == UpdateInventoryGroup )
                            {
                                if( null != InventoryGroupNode )
                                {
                                    CurrentLocationNode.InventoryGroup.RelatedNodeId = InventoryGroupNode.NodeId;
                                }
                                else
                                {
                                    CurrentLocationNode.InventoryGroup.RelatedNodeId = null;
                                }
                            }

                            if( true == UpdateControlZone )
                            {
                                if( null != ControlZoneNode )
                                {
                                    CurrentLocationNode.ControlZone.RelatedNodeId = ControlZoneNode.NodeId;
                                }
                                else
                                {
                                    CurrentLocationNode.ControlZone.RelatedNodeId = null;
                                }
                            }
                            

                            if( UpdateAllowInventory )
                            {
                                CurrentLocationNode.AllowInventory.Checked = CswConvert.ToTristate( AllowInventory );
                            }

                            if( UpdateStorageCompatability )
                            {
                                CurrentLocationNode.StorageCompatibility.Value = Images;
                            }

                            CurrentLocationNode.postChanges( true );

                        }//if current key yielded a node

                    } //if there is a location keye

                } //iterate locations


            }//if we have location keys

        }//assignInventoryGroupToLocations()