Beispiel #1
0
        public override void update()
        {
            CswNbtMetaDataObjectClass InventoryLevelOc = _CswNbtSchemaModTrnsctn.createObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.InventoryLevelClass, "docs.gif", true, false );
            CswNbtMetaDataObjectClass MaterialOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.MaterialClass );
            CswNbtMetaDataObjectClassProp IlMaterialOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.Material,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.Relationship,
                IsFk = true,
                FkType = NbtViewRelatedIdType.ObjectClassId.ToString(),
                FkValue = MaterialOc.ObjectClassId,
                IsRequired = true,
                IsCompoundUnique = true
            } );

            CswNbtMetaDataObjectClassProp IlLocationOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.Location,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.Location,
                IsRequired = true,
                IsCompoundUnique = true
            } );

            CswNbtMetaDataObjectClassProp IlTypeOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.Type,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.List,
                ListOptions = CswNbtObjClassInventoryLevel.Types.Options.ToString(),
                IsRequired = true,
                IsCompoundUnique = true
            } );

            CswNbtMetaDataObjectClassProp IlLevelOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.Level,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.Quantity,
                IsRequired = true
            } );

            _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.Subscribe,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.UserSelect,
                SetValOnAdd = true
            } );

            _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.LastNotified,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.DateTime,
                ServerManaged = true
            } );

            CswNbtMetaDataObjectClassProp IlStatusOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( InventoryLevelOc, new CswNbtWcfMetaDataModel.ObjectClassProp
            {
                PropName = CswNbtObjClassInventoryLevel.PropertyName.Status,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.List,
                ListOptions = CswNbtObjClassInventoryLevel.Statuses.Options.ToString(),
                ServerManaged = true
            } );
            _CswNbtSchemaModTrnsctn.MetaData.SetObjectClassPropDefaultValue( IlStatusOcp, IlStatusOcp.getFieldTypeRule().SubFields.Default.Name, CswNbtObjClassInventoryLevel.Statuses.Ok );

            _CswNbtSchemaModTrnsctn.createModuleObjectClassJunction( CswNbtResources.CswNbtModule.CISPro, InventoryLevelOc.ObjectClassId );

            CswNbtMetaDataNodeType InventoryLevelNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Inventory Level" );
            if( null != InventoryLevelNt && InventoryLevelNt.ObjectClassId != InventoryLevelOc.ObjectClassId )
            {
                InventoryLevelNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "CISPro Inventory Level" );
            }
            if( null != InventoryLevelNt && InventoryLevelNt.ObjectClassId != InventoryLevelOc.ObjectClassId )
            {
                CswStatusMessage Msg = new CswStatusMessage
                                            {
                                                AppType = AppType.SchemUpdt,
                                                ContentType = ContentType.Error
                                            };
                Msg.Attributes.Add( ChemSW.Log.LegalAttribute.exoteric_message, "Nodetypes 'Inventory Level' and 'CISPro Inventory Level' already exist and are not of the InventoryLevel Object Class." );
                _CswNbtSchemaModTrnsctn.CswLogger.send( Msg );
            }
            if( null == InventoryLevelNt )
            {
                InventoryLevelNt = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( new CswNbtWcfMetaDataModel.NodeType( InventoryLevelOc )
                                                                         {
                                                                             NodeTypeName = "Inventory Level",
                                                                             Category = "Materials",
                                                                         } );
                CswNbtMetaDataNodeTypeProp Material = InventoryLevelNt.getNodeTypePropByObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Material );
                CswNbtMetaDataNodeTypeProp Level = InventoryLevelNt.getNodeTypePropByObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Level );
                CswNbtMetaDataNodeTypeProp Type = InventoryLevelNt.getNodeTypePropByObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Type );
                InventoryLevelNt.addNameTemplateText( Material.PropName );
                InventoryLevelNt.addNameTemplateText( Type.PropName );
                InventoryLevelNt.addNameTemplateText( Level.PropName );
            }

            foreach( CswNbtMetaDataNodeType MaterialNt in MaterialOc.getLatestVersionNodeTypes() )
            {
                CswNbtMetaDataNodeTypeTab PhysicalTab = MaterialNt.getNodeTypeTab( "Physical Tab" );
                if( null != PhysicalTab )
                {
                    PhysicalTab.TabName = "Physical";
                }
                else
                {
                    PhysicalTab = MaterialNt.getNodeTypeTab( "Physical" );
                    if( null == PhysicalTab )
                    {
                        PhysicalTab = _CswNbtSchemaModTrnsctn.MetaData.makeNewTab( MaterialNt, "Physical", MaterialNt.getNodeTypeTabIds().Count );
                    }
                }
                CswNbtMetaDataNodeTypeProp LevelsNtp = _CswNbtSchemaModTrnsctn.MetaData.makeNewProp( new CswNbtWcfMetaDataModel.NodeTypeProp( MaterialNt, _CswNbtSchemaModTrnsctn.MetaData.getFieldType( CswNbtMetaDataFieldType.NbtFieldType.Grid ), "Inventory Levels" )
                {
                    TabId = PhysicalTab.TabId
                } );
                LevelsNtp.Extended = CswNbtNodePropGrid.GridPropMode.Link.ToString();

                CswNbtView LevelsView = _CswNbtSchemaModTrnsctn.restoreView( LevelsNtp.ViewId );
                if( null == LevelsView )
                {
                    LevelsView = _CswNbtSchemaModTrnsctn.makeView();
                    LevelsNtp.ViewId = LevelsView.ViewId;
                }

                LevelsView.Root.ChildRelationships.Clear();
                LevelsView.ViewMode = NbtViewRenderingMode.Grid;
                LevelsView.Visibility = NbtViewVisibility.Property;

                CswNbtViewRelationship RootRel = LevelsView.AddViewRelationship( MaterialNt, true );
                CswNbtViewRelationship LevelRel = LevelsView.AddViewRelationship( RootRel, NbtViewPropOwnerType.Second, IlMaterialOcp, true );
                LevelsView.AddViewProperty( LevelRel, IlTypeOcp );
                LevelsView.AddViewProperty( LevelRel, IlLevelOcp );
                LevelsView.AddViewProperty( LevelRel, IlLocationOcp );
                LevelsView.AddViewProperty( LevelRel, IlStatusOcp );
                LevelsView.save();
            }

        }//Update()
        public override void update()
        {

            #region NodeTypes

            CswNbtMetaDataObjectClass RequestOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.RequestClass );
            string RequestNodeTypeName = "Request";
            CswNbtMetaDataNodeType RequestNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( RequestNodeTypeName );

            if( null != RequestNt && RequestNt.ObjectClassId != RequestOc.ObjectClassId )
            {
                RequestNodeTypeName = "CISPro Request";
                RequestNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( RequestNodeTypeName );
            }
            if( null != RequestNt && RequestNt.ObjectClassId != RequestOc.ObjectClassId )
            {
                throw new CswDniException( ErrorType.Error, "Could not create a unique Request NodeType", "Request nodetypes named 'Request' and 'CISPro Request' already exist." );
            }
            if( null == RequestNt )
            {
                RequestNt = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( new CswNbtWcfMetaDataModel.NodeType( RequestOc )
                                                                     {
                                                                         Category = "Requests",
                                                                         NodeTypeName = RequestNodeTypeName
                                                                     } );

            }
            CswNbtMetaDataNodeTypeProp NameNtp = RequestNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequest.PropertyName.Name.ToString() );
            CswNbtMetaDataNodeTypeProp UserNtp = RequestNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequest.PropertyName.Requestor.ToString() );
            CswNbtMetaDataNodeTypeProp DateNtp = RequestNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequest.PropertyName.SubmittedDate.ToString() );
            RequestNt.NameTemplateValue = "";
            RequestNt.addNameTemplateText( NameNtp.PropName );
            RequestNt.addNameTemplateText( UserNtp.PropName );
            RequestNt.addNameTemplateText( DateNtp.PropName );

            CswNbtMetaDataObjectClass RequestItemOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.RequestItemClass );
            string RequestItemNodeTypeName = "Request Item";
            CswNbtMetaDataNodeType RequestItemNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( RequestItemNodeTypeName );

            if( null != RequestItemNt && RequestItemNt.ObjectClassId != RequestItemOc.ObjectClassId )
            {
                RequestItemNodeTypeName = "CISPro Request Item";
                RequestNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( RequestItemNodeTypeName );
            }
            if( null != RequestItemNt && RequestItemNt.ObjectClassId != RequestItemOc.ObjectClassId )
            {
                throw new CswDniException( ErrorType.Error, "Could not create a unique Request Item NodeType", "Request nodetypes named 'Request Item' and 'CISPro Request Item' already exist." );
            }
            if( null == RequestItemNt )
            {
                RequestItemNt = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType(new CswNbtWcfMetaDataModel.NodeType(RequestItemOc)
                    {
                        Category = "Requests",
                        NodeTypeName = RequestItemNodeTypeName
                    });
            }
            CswNbtMetaDataNodeTypeProp RequestItemRequestNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Request );
            RequestItemRequestNtp.SetFK( NbtViewRelatedIdType.NodeTypeId.ToString(), RequestNt.NodeTypeId );

            CswNbtMetaDataNodeTypeProp TypeNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Type );
            CswNbtMetaDataNodeTypeProp StatusNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Status );
            CswNbtMetaDataNodeTypeProp ExternalOrderNoNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.ExternalOrderNumber );
            CswNbtMetaDataNodeTypeProp QuantityNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Quantity );
            CswNbtMetaDataNodeTypeProp CountNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Count );
            CswNbtMetaDataNodeTypeProp SizeNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Size );
            CswNbtMetaDataNodeTypeProp MaterialNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Material );
            CswNbtMetaDataNodeTypeProp ContainerNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Container );
            CswNbtMetaDataNodeTypeProp LocationNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Location );
            CswNbtMetaDataNodeTypeProp NumberNtp = RequestItemNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Number );

            Int32 SequenceId = _CswNbtSchemaModTrnsctn.makeSequence( new CswSequenceName( "Request Items" ), "R", "", 6, 1 );
            NumberNtp.setSequence( SequenceId );

            RequestItemNt.addNameTemplateText( RequestItemRequestNtp.PropName );
            RequestItemNt.addNameTemplateText( NumberNtp.PropName );
            RequestItemNt.addNameTemplateText( TypeNtp.PropName );

            #endregion NodeTypes

            #region Tabs

            CswNbtMetaDataNodeTypeTab RequestItemsNtt = RequestNt.getNodeTypeTab( "Request Items" );
            if( null == RequestItemsNtt )
            {
                RequestItemsNtt = _CswNbtSchemaModTrnsctn.MetaData.makeNewTab( RequestNt, "Request Items",
                                                                              RequestNt.getNodeTypeTabIds().Count );
            }
            CswNbtMetaDataFieldType GridFt =
                _CswNbtSchemaModTrnsctn.MetaData.getFieldType( CswNbtMetaDataFieldType.NbtFieldType.Grid );
            CswNbtMetaDataNodeTypeProp RequestItemsGridNtp =
                _CswNbtSchemaModTrnsctn.MetaData.makeNewProp( new CswNbtWcfMetaDataModel.NodeTypeProp( RequestNt,
                                                                                                     GridFt,
                                                                                                     "Request Items" )
                                                                 {
                                                                     TabId = RequestItemsNtt.TabId
                                                                 } );
            CswNbtView GridView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( RequestItemsGridNtp.ViewId );
            GridView.ViewName = "Requested Items";
            GridView.Visibility = NbtViewVisibility.Property;
            GridView.ViewMode = NbtViewRenderingMode.Grid;
            GridView.Category = "Requests";
            GridView.Root.ChildRelationships.Clear();
            CswNbtViewRelationship RequestRel = GridView.AddViewRelationship( RequestNt, false );
            CswNbtViewRelationship RequestItemRel = GridView.AddViewRelationship( RequestRel,
                                                                                 NbtViewPropOwnerType.Second,
                                                                                 RequestItemRequestNtp, false );
            GridView.AddViewProperty( RequestItemRel, NumberNtp );
            GridView.AddViewProperty( RequestItemRel, TypeNtp );
            GridView.AddViewProperty( RequestItemRel, ExternalOrderNoNtp );
            GridView.AddViewProperty( RequestItemRel, StatusNtp );
            GridView.AddViewProperty( RequestItemRel, QuantityNtp );
            GridView.AddViewProperty( RequestItemRel, CountNtp );
            GridView.AddViewProperty( RequestItemRel, SizeNtp );
            GridView.AddViewProperty( RequestItemRel, MaterialNtp );
            GridView.AddViewProperty( RequestItemRel, ContainerNtp );
            GridView.AddViewProperty( RequestItemRel, LocationNtp );
            GridView.save();


            #endregion Tabs

            #region Views

            string MyRequestViewName = "My Request History";
            bool UniqueView = _CswNbtSchemaModTrnsctn.restoreViews( MyRequestViewName ).Count == 0;
            if( false == UniqueView )
            {
                MyRequestViewName = "My CISPro Request History";
                UniqueView = _CswNbtSchemaModTrnsctn.restoreViews( MyRequestViewName ).Count == 0;
            }
            if( UniqueView )
            {
                CswNbtView MyRequestsView = _CswNbtSchemaModTrnsctn.makeView();
                MyRequestsView.makeNew( MyRequestViewName, NbtViewVisibility.Global );
                MyRequestsView.Category = "Requests";
                MyRequestsView.ViewMode = NbtViewRenderingMode.Tree;
                CswNbtViewRelationship RequestVr = MyRequestsView.AddViewRelationship( RequestNt, true );
                MyRequestsView.AddViewPropertyAndFilter( RequestVr, RequestNt.getNodeTypePropByObjectClassProp( CswNbtObjClassRequest.PropertyName.SubmittedDate.ToString() ), FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotNull );
                MyRequestsView.save();
            }
            #endregion Views

        }//Update()
Beispiel #3
0
        public override void update()
        {
            CswNbtMetaDataObjectClass InventoryGroupOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.InventoryGroupClass );

            CswNbtObjClassInventoryGroup DefaultNodeAsInventoryGroup = null;
            foreach( CswNbtNode Group in InventoryGroupOc.getNodes( true, false ) )
            {
                CswNbtObjClassInventoryGroup NodeAsInventoryGroup = Group;
                if( null != NodeAsInventoryGroup )
                {
                    if( NodeAsInventoryGroup.Name.Text.ToLower() == "cispro" )
                    {
                        DefaultNodeAsInventoryGroup = NodeAsInventoryGroup;
                        DefaultNodeAsInventoryGroup.Name.Text = "Default Inventory Group";
                        DefaultNodeAsInventoryGroup.IsDemo = true;
                        DefaultNodeAsInventoryGroup.postChanges( ForceUpdate: false );
                    }
                }
            }
            if( null == DefaultNodeAsInventoryGroup )
            {
                CswNbtMetaDataNodeType InventoryGroupNt = InventoryGroupOc.getLatestVersionNodeTypes().FirstOrDefault();
                if( null != InventoryGroupNt )
                {
                    DefaultNodeAsInventoryGroup = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( InventoryGroupNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                    DefaultNodeAsInventoryGroup.Name.Text = "Default Inventory Group";
                    DefaultNodeAsInventoryGroup.postChanges( ForceUpdate: false );
                }
            }
            CswNbtMetaDataObjectClass LocationOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.LocationClass );
            CswNbtObjClassLocation DefaultLocation = null;
            if( null != DefaultNodeAsInventoryGroup )
            {
                foreach( CswNbtObjClassLocation Location in LocationOc.getNodes( true, false ) )
                {
                    if( null != Location )
                    {
                        if( Location.Name.Text.ToLower() == "center hall" )
                        {
                            DefaultLocation = Location;
                        }
                        if( null == Location.InventoryGroup.RelatedNodeId || Int32.MinValue == Location.InventoryGroup.RelatedNodeId.PrimaryKey )
                        {
                            Location.InventoryGroup.RelatedNodeId = DefaultNodeAsInventoryGroup.NodeId;
                            Location.postChanges( ForceUpdate: false );
                        }
                    }
                }
            }

            CswNbtMetaDataObjectClass WorkUnitOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.WorkUnitClass );
            CswNbtMetaDataNodeType WorkUnitNt = WorkUnitOc.getLatestVersionNodeTypes().FirstOrDefault();
            if( null != WorkUnitNt )
            {
                WorkUnitNt.NameTemplateValue = "";
                WorkUnitNt.addNameTemplateText( CswNbtObjClassWorkUnit.NamePropertyName );
                CswNbtObjClassWorkUnit DefaultWorkUnit = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( WorkUnitNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                DefaultWorkUnit.Name.Text = "Default Work Unit";
                DefaultWorkUnit.IsDemo = true;
                DefaultWorkUnit.postChanges( ForceUpdate: false );

                CswNbtMetaDataObjectClass UserOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.UserClass );
                Collection<Int32> RoleIdsWithUsers = new Collection<Int32>();
                CswNbtMetaDataNodeType UserNt = null;
                foreach( CswNbtObjClassUser User in UserOc.getNodes( true, false ) )
                {
                    if( null != User )
                    {
                        UserNt = UserNt ?? User.NodeType;
                        RoleIdsWithUsers.Add( User.RoleId.PrimaryKey );
                        if( null == User.WorkUnitProperty.RelatedNodeId || Int32.MinValue == User.WorkUnitProperty.RelatedNodeId.PrimaryKey )
                        {
                            User.WorkUnitProperty.RelatedNodeId = DefaultWorkUnit.NodeId;
                        }
                        if( null != DefaultLocation && ( null == User.DefaultLocationProperty.SelectedNodeId || Int32.MinValue == User.DefaultLocationProperty.SelectedNodeId.PrimaryKey ) )
                        {
                            User.DefaultLocationProperty.SelectedNodeId = DefaultLocation.NodeId;
                        }
                        User.postChanges( ForceUpdate: false );
                    }
                }

                CswNbtMetaDataObjectClass RoleOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.RoleClass );
                if( null == UserNt )
                {
                    UserNt = UserOc.getLatestVersionNodeTypes().FirstOrDefault();
                }
                if( null != UserNt )
                {
                    foreach( CswNbtObjClassRole Role in RoleOc.getNodes( true, false ) )
                    {
                        if( null != Role && false == RoleIdsWithUsers.Contains( Role.NodeId.PrimaryKey ) )
                        {
                            string ValidUserName = CswNbtObjClassUser.getValidUserName( Role.Name.Text.ToLower() );
                            if( ValidUserName != CswNbtObjClassUser.ChemSWAdminUsername )
                            {
                                if( CswNbtObjClassUser.IsUserNameUnique( _CswNbtSchemaModTrnsctn.MetaData._CswNbtMetaDataResources.CswNbtResources, ValidUserName ) )
                                {
                                    CswNbtObjClassUser NewUser = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( UserNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                                    NewUser.IsDemo = false;
                                    NewUser.Role.RelatedNodeId = Role.NodeId;
                                    NewUser.UsernameProperty.Text = ValidUserName;
                                    NewUser.WorkUnitProperty.RelatedNodeId = DefaultWorkUnit.NodeId;
                                    if( null != DefaultLocation )
                                    {
                                        NewUser.DefaultLocationProperty.SelectedNodeId = DefaultLocation.NodeId;
                                    }
                                    NewUser.PasswordProperty.Password = Role.Name.Text.ToLower();
                                    NewUser.postChanges( ForceUpdate: false );
                                }
                            }
                        }
                    }
                }
                CswNbtMetaDataObjectClass IgPermissionOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.InventoryGroupPermissionClass );
                foreach( CswNbtObjClassInventoryGroupPermission Permission in IgPermissionOc.getNodes( true, false ) )
                {
                    if( null != Permission )
                    {
                        if( null != DefaultNodeAsInventoryGroup && ( null == Permission.InventoryGroup.RelatedNodeId || Int32.MinValue == Permission.InventoryGroup.RelatedNodeId.PrimaryKey ) )
                        {
                            Permission.InventoryGroup.RelatedNodeId = DefaultNodeAsInventoryGroup.NodeId;
                        }
                        if( null == Permission.WorkUnit.RelatedNodeId || Int32.MinValue == Permission.WorkUnit.RelatedNodeId.PrimaryKey )
                        {
                            Permission.WorkUnit.RelatedNodeId = DefaultWorkUnit.NodeId;
                        }
                        Permission.postChanges( ForceUpdate: false );
                    }
                }
            }

            CswNbtMetaDataObjectClass MaterialOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.MaterialClass );
            CswNbtMetaDataObjectClass SynonymOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.MaterialSynonymClass );
            CswNbtMetaDataObjectClass SizeOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.SizeClass );
            CswNbtMetaDataObjectClass VendorOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.VendorClass );
            CswNbtMetaDataObjectClass UnitOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.UnitOfMeasureClass );

            CswNbtObjClassVendor DefaultVendor = null;
            CswNbtMetaDataNodeType VendorNt = VendorOc.getLatestVersionNodeTypes().FirstOrDefault();
            if( null != VendorNt )
            {
                DefaultVendor = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( VendorNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                DefaultVendor.VendorName.Text = "Default Vendor";
                DefaultVendor.IsDemo = true;
                DefaultVendor.postChanges( ForceUpdate: false );
            }
            CswNbtMetaDataNodeType SizeNt = SizeOc.getLatestVersionNodeTypes().FirstOrDefault();
            CswNbtMetaDataNodeType SynonymNt = SynonymOc.getLatestVersionNodeTypes().FirstOrDefault();
            CswNbtObjClassUnitOfMeasure DefaultSizeUnit = null;
            CswNbtObjClassUnitOfMeasure DefaultTimeUnit = null;
            foreach( CswNbtObjClassUnitOfMeasure Unit in UnitOc.getNodes( true, false ) )
            {
                if( null != Unit )
                {
                    if( Unit.Name.Text.ToLower() == "g" )
                    {
                        DefaultSizeUnit = Unit;
                    }
                    else if( Unit.Name.Text.ToLower() == "years" )
                    {
                        DefaultTimeUnit = Unit;
                    }
                }
            }

            foreach( CswNbtMetaDataNodeType MaterialNt in MaterialOc.getLatestVersionNodeTypes() )
            {
                CswNbtObjClassMaterial Material = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( MaterialNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                Material.IsDemo = true;
                Material.TradeName.Text = "Default " + MaterialNt.NodeTypeName;
                if( null != DefaultVendor )
                {
                    Material.Supplier.RelatedNodeId = DefaultVendor.NodeId;
                }
                Material.PartNumber.Text = "658-35AB";
                Material.PhysicalState.Value = CswNbtObjClassMaterial.PhysicalStates.Solid;
                Material.ExpirationInterval.Quantity = 1;
                if( null != DefaultTimeUnit )
                {
                    Material.ExpirationInterval.UnitId = DefaultTimeUnit.NodeId;
                }
                Material.postChanges( ForceUpdate: false );

                if( null != SizeNt )
                {
                    CswNbtObjClassSize Size = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( SizeNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                    Size.IsDemo = true;
                    Size.Material.RelatedNodeId = Material.NodeId;
                    Size.CatalogNo.Text = "NE-H5/3";
                    Size.InitialQuantity.Quantity = 1;
                    if( null != DefaultSizeUnit )
                    {
                        Size.InitialQuantity.UnitId = DefaultSizeUnit.NodeId;
                    }
                    Size.postChanges( ForceUpdate: false );
                }

                if( null != SynonymNt )
                {
                    CswNbtObjClassMaterialSynonym Synonym = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( SynonymNt.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode, OverrideUniqueValidation: false );
                    Synonym.IsDemo = true;
                    Synonym.Material.RelatedNodeId = Material.NodeId;
                    Synonym.Name.Text = Material.TradeName.Text + " Synonym";
                    Synonym.postChanges( ForceUpdate: false );
                }
            }


        }//Update()
        public override void update()
        {
            CswNbtMetaDataObjectClass GhsOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.GHSClass );
            CswNbtMetaDataObjectClass GHSClassOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.GHSClassificationClass );

            // Fix layout of Ghs NodeType
            foreach( CswNbtMetaDataNodeType GhsNT in GhsOC.getNodeTypes() )
            {
                CswNbtMetaDataNodeTypeProp AddLabelCodesNTP = GhsNT.getNodeTypePropByObjectClassProp( CswNbtObjClassGHS.PropertyName.AddLabelCodes );

                Int32 AddDisplayRow = 8;
                if( null != AddLabelCodesNTP.AddLayout && AddLabelCodesNTP.AddLayout.DisplayRow != Int32.MinValue )
                {
                    AddDisplayRow = AddLabelCodesNTP.AddLayout.DisplayRow + 1;
                }
                Int32 EditDisplayRow = 8;
                if( null != AddLabelCodesNTP.FirstEditLayout && AddLabelCodesNTP.FirstEditLayout.DisplayRow != Int32.MinValue )
                {
                    EditDisplayRow = AddLabelCodesNTP.FirstEditLayout.DisplayRow + 1;
                }

                CswNbtMetaDataNodeTypeProp ClassNTP = GhsNT.getNodeTypePropByObjectClassProp( CswNbtObjClassGHS.PropertyName.Classifications );
                ClassNTP.updateLayout( CswEnumNbtLayoutType.Add, true, Int32.MinValue, AddDisplayRow, 1, "Classification" );
                ClassNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, GhsNT.getFirstNodeTypeTab().TabId, EditDisplayRow, 1, "Classification" );
                EditDisplayRow++;

                CswNbtMetaDataNodeTypeProp ClassGridNTP = GhsNT.getNodeTypePropByObjectClassProp( CswNbtObjClassGHS.PropertyName.ClassificationsGrid );
                ClassGridNTP.removeFromLayout( CswEnumNbtLayoutType.Add );
                ClassGridNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, GhsNT.getFirstNodeTypeTab().TabId, EditDisplayRow, 1, "Classification" );
            }

            // Add new 'GHS Classification' nodetype
            GHSClassNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( new CswNbtWcfMetaDataModel.NodeType( GHSClassOC )
                {
                    NodeTypeName = "GHS Classification",
                    Category = "System"
                } );

            GHSClassNT.addNameTemplateText( CswNbtObjClassGHSClassification.PropertyName.English );

            CswNbtMetaDataNodeTypeProp GHSClassCategoryNTP = GHSClassNT.getNodeTypePropByObjectClassProp( CswNbtObjClassGHSClassification.PropertyName.Category );
            GHSClassCategoryNTP.updateLayout( CswEnumNbtLayoutType.Add, true, Int32.MinValue, 1, 1 );
            GHSClassCategoryNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, GHSClassNT.getFirstNodeTypeTab().TabId, 1, 1 );


            // Populate 'GHS Classification' nodes
            _addGhsClassNode( "Health", "Acute Toxicity: Oral (Category 1)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Oral (Category 2)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Oral (Category 3)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Oral (Category 4)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Oral (Category 5)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dermal (Category 1)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dermal (Category 2)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dermal (Category 3)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dermal (Category 4)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dermal (Category 5)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Gases (Category 1)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Gases (Category 2)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Gases (Category 3)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Gases (Category 4)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Gases (Category 5)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Vapors (Category 1)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Vapors (Category 2)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Vapors (Category 3)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Vapors (Category 4)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Vapors (Category 5)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dusts & mists (Category 1)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dusts & mists (Category 2)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dusts & mists (Category 3)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dusts & mists (Category 4)" );
            _addGhsClassNode( "Health", "Acute Toxicity: Dusts & mists (Category 5)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Acute) (Category I)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Acute) (Category II)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Acute) (Category III)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Chronic) (Category I)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Chronic) (Category II)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Chronic) (Category III)" );
            _addGhsClassNode( "Environmental", "Aquatic Toxicity (Chronic) (Category IV)" );
            _addGhsClassNode( "Health", "Aspiration Toxicity (Category 1)" );
            _addGhsClassNode( "Health", "Aspiration Toxicity (Category 2)" );
            _addGhsClassNode( "Health", "Carcinogenicity (Category 1A)" );
            _addGhsClassNode( "Health", "Carcinogenicity (Category 1B)" );
            _addGhsClassNode( "Health", "Carcinogenicity (Category 2)" );
            _addGhsClassNode( "Physical", "Corrosive to Metal" );
            _addGhsClassNode( "Physical", "Explosives (Division 1.1)" );
            _addGhsClassNode( "Physical", "Explosives (Division 1.2)" );
            _addGhsClassNode( "Physical", "Explosives (Division 1.3)" );
            _addGhsClassNode( "Physical", "Explosives (Division 1.4)" );
            _addGhsClassNode( "Physical", "Explosives (Division 1.5)" );
            _addGhsClassNode( "Physical", "Explosives (Division 1.6" );
            _addGhsClassNode( "Physical", "Explosives (Unstable Explosives)" );
            _addGhsClassNode( "Physical", "Flammable Aerosols (Category 1)" );
            _addGhsClassNode( "Physical", "Flammable Aerosols (Category 2)" );
            _addGhsClassNode( "Physical", "Flammable Gas (Category 1)" );
            _addGhsClassNode( "Physical", "Flammable Gas (Category 2)" );
            _addGhsClassNode( "Physical", "Flammable Liquids (Category 1)" );
            _addGhsClassNode( "Physical", "Flammable Liquids (Category 2)" );
            _addGhsClassNode( "Physical", "Flammable Liquids (Category 3)" );
            _addGhsClassNode( "Physical", "Flammable Liquids (Category 4)" );
            _addGhsClassNode( "Physical", "Flammable Solids (Category 1)" );
            _addGhsClassNode( "Physical", "Flammable Solids (Category 2)" );
            _addGhsClassNode( "Physical", "Gases Under Pressure (Compressed gas)" );
            _addGhsClassNode( "Physical", "Gases Under Pressure (Dissolved gas)" );
            _addGhsClassNode( "Physical", "Gases Under Pressure (Liquefied gas)" );
            _addGhsClassNode( "Physical", "Gases Under Pressure (Refrigerated liquefied gas)" );
            _addGhsClassNode( "Health", "Germ Cell Mutagenicity (Category 1A)" );
            _addGhsClassNode( "Health", "Germ Cell Mutagenicity (Category 1B)" );
            _addGhsClassNode( "Health", "Germ Cell Mutagenicity (Category 2)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type A)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type B)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type C)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type D)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type E)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type F)" );
            _addGhsClassNode( "Physical", "Organic Peroxides (Type G)" );
            _addGhsClassNode( "Physical", "Oxidizing Gases" );
            _addGhsClassNode( "Physical", "Oxidizing Liquids (Category 1)" );
            _addGhsClassNode( "Physical", "Oxidizing Liquids (Category 2)" );
            _addGhsClassNode( "Physical", "Oxidizing Liquids (Category 3)" );
            _addGhsClassNode( "Physical", "Oxidizing Solids (Category 1)" );
            _addGhsClassNode( "Physical", "Oxidizing Solids (Category 2)" );
            _addGhsClassNode( "Physical", "Oxidizing Solids (Category 3)" );
            _addGhsClassNode( "Physical", "Pyrophoric Liquids" );
            _addGhsClassNode( "Physical", "Pyrophoric Solids" );
            _addGhsClassNode( "Physical", "Self-Heating Substances and Mixtures (Category 1)" );
            _addGhsClassNode( "Physical", "Self-Heating Substances and Mixtures (Category 2)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type A)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type B)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type C)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type D)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type E)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type F)" );
            _addGhsClassNode( "Physical", "Self-Reactive Substances and Mixtures (Type G)" );
            _addGhsClassNode( "Health", "Serious Eye Damage/Eye Irritation (Category 1)" );
            _addGhsClassNode( "Health", "Serious Eye Damage/Eye Irritation (Category 2A)" );
            _addGhsClassNode( "Health", "Serious Eye Damage/Eye Irritation (Category 2B)" );
            _addGhsClassNode( "Health", "Skin Corrosion/Irritation (Category 1A)" );
            _addGhsClassNode( "Health", "Skin Corrosion/Irritation (Category 1B)" );
            _addGhsClassNode( "Health", "Skin Corrosion/Irritation (Category 1C)" );
            _addGhsClassNode( "Health", "Skin Corrosion/Irritation (Category 2)" );
            _addGhsClassNode( "Health", "Skin Corrosion/Irritation (Category 3)" );
            _addGhsClassNode( "Health", "Skin Sensitization" );
            _addGhsClassNode( "Health", "Respiratory Sensitization" );
            _addGhsClassNode( "Health", "Specific Target Organ Toxicity (Repeated Exposure) (Category 1)" );
            _addGhsClassNode( "Health", "Specific Target Organ Toxicity (Repeated Exposure) (Category 2)" );
            _addGhsClassNode( "Health", "Specific Target Organ Toxicity (Single Exposure) (Category 1)" );
            _addGhsClassNode( "Health", "Specific Target Organ Toxicity (Single Exposure) (Category 2)" );
            _addGhsClassNode( "Health", "Specific Target Organ Toxicity (Single Exposure) (Category 3)" );
            _addGhsClassNode( "Physical", "Substances and Mixtures, which on Contact with Water, Emit Flammable Gases (Category 1)" );
            _addGhsClassNode( "Physical", "Substances and Mixtures, which on Contact with Water, Emit Flammable Gases (Category 2)" );
            _addGhsClassNode( "Physical", "Substances and Mixtures, which on Contact with Water, Emit Flammable Gases (Category 3)" );
            _addGhsClassNode( "Health", "Reproductive Toxicity (Category 1A)" );
            _addGhsClassNode( "Health", "Reproductive Toxicity (Category 1B)" );
            _addGhsClassNode( "Health", "Reproductive Toxicity (Category 2)" );
            _addGhsClassNode( "Health", "Reproductive Toxicity (Lactation Effects)" );
        } // update()