public override void update() { // Fix existing barcode values CswNbtMetaDataObjectClass LocationOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.LocationClass ); foreach( CswNbtMetaDataNodeType LocationNT in LocationOC.getNodeTypes() ) { foreach( CswNbtObjClassLocation LocationNode in LocationNT.getNodes( false, false ) ) { if( false == LocationNode.Barcode.Barcode.StartsWith( "LS" ) ) { LocationNode.Barcode.setBarcodeValue( OverrideExisting: true ); } if( LocationNode.Barcode.SequenceNumber == Int32.MinValue ) { LocationNode.Barcode.resetSequenceNumber(); } if( LocationNode.Barcode.Barcode.Length < 8 ) { string NewBarcodeValue = "LS" + CswTools.PadInt( CswConvert.ToInt32( LocationNode.Barcode.SequenceNumber ), 6 ); LocationNode.Barcode.setBarcodeValueOverride( NewBarcodeValue, false ); } LocationNode.postChanges( false ); } // foreach( CswNbtObjClassLocation LocationNode in LocationNT.getNodes( false, false ) ) } // foreach( CswNbtMetaDataNodeType LocationNT in LocationOC.getNodeTypes() ) } //Update()
public override void update() { // Set 'Allow Inventory' on Room location and below CswNbtMetaDataObjectClass LocationOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.LocationClass ); CswNbtMetaDataObjectClassProp LocationAllowInvOCP = LocationOC.getObjectClassProp( CswNbtObjClassLocation.AllowInventoryPropertyName); // Make it required _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( LocationAllowInvOCP, CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.isrequired, true ); // Default values on nodetypes foreach( CswNbtMetaDataNodeType LocationNT in LocationOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp LocationAllowInvNTP = LocationNT.getNodeTypePropByObjectClassProp( CswNbtObjClassLocation.AllowInventoryPropertyName ); if( LocationNT.NodeTypeName == "Room" || LocationNT.NodeTypeName == "Cabinet" || LocationNT.NodeTypeName == "Shelf" || LocationNT.NodeTypeName == "Box" ) { LocationAllowInvNTP.DefaultValue.AsLogical.Checked = Tristate.True; } else { LocationAllowInvNTP.DefaultValue.AsLogical.Checked = Tristate.False; } } // Values for existing nodes foreach(CswNbtObjClassLocation LocationNode in LocationOC.getNodes(false, true)) { if( LocationNode.NodeType.NodeTypeName == "Room" || LocationNode.NodeType.NodeTypeName == "Cabinet" || LocationNode.NodeType.NodeTypeName == "Shelf" || LocationNode.NodeType.NodeTypeName == "Box" ) { LocationNode.AllowInventory.Checked = Tristate.True; } else { LocationNode.AllowInventory.Checked = Tristate.False; } LocationNode.postChanges(false); } // foreach(CswNbtObjClassLocation in LocationOC.getNodes(false, true)) }//Update()
public override void update() { // Fix bugs introduced in Othello's CswUpdateSchemaCase25981.cs // Remove erroneous extra value string Sql = @"delete from jct_nodes_props where jctnodepropid in (select j.jctnodepropid from jct_nodes_props j join nodetype_props p on j.nodetypepropid = p.nodetypepropid join nodes n on j.nodeid = n.nodeid join nodetypes t1 on p.nodetypeid = t1.nodetypeid join nodetypes t2 on n.nodetypeid = t2.nodetypeid where t1.nodetypeid <> t2.nodetypeid)"; _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql( Sql ); // Set up Lab 2 correctly CswNbtMetaDataObjectClass LocationOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.LocationClass ); Collection<CswNbtNode> LocationNodes = LocationOC.getNodes( false, true ); CswNbtObjClassLocation LocationNRL = null; foreach( CswNbtObjClassLocation LocationNode in LocationNodes ) { if( LocationNode.Name.Text == "North Research Lab" ) { LocationNRL = LocationNode; } } // foreach( CswNbtObjClassLocation LocationNode in LocationNodes ) if( LocationNRL != null ) { foreach( CswNbtObjClassLocation LocationNode in LocationNodes ) { if( LocationNode.Name.Text == string.Empty && LocationNode.IsDemo ) { LocationNode.Name.Text = "Lab 2"; LocationNode.Location.SelectedNodeId = LocationNRL.NodeId; LocationNode.postChanges( true ); } } // foreach( CswNbtObjClassLocation LocationNode in LocationNodes ) } // if( LocationNRL != null ) }//Update()
public override void update() { bool MakeAdminNode = true; bool MakeChemSWAdminNode = true; CswNbtObjClassWorkUnit DefaultWorkUnit = _getDefaultWorkUnit(); CswNbtObjClassInventoryGroup CISProInventoryGroup = _getInventoryGroup( "CISPro" ); CswNbtObjClassInventoryGroup DefaultInventoryGroup = _getInventoryGroup( "Default Inventory Group" ); CswNbtObjClassRole AdminRole = _CswNbtSchemaModTrnsctn.Nodes.makeRoleNodeFromRoleName( "Administrator" ); CswNbtObjClassRole ChemSWAdminRole = _CswNbtSchemaModTrnsctn.Nodes.makeRoleNodeFromRoleName( "chemsw_admin_role" ); CswNbtMetaDataObjectClass InvGrpPermOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.InventoryGroupPermissionClass ); CswNbtMetaDataNodeType InvGrpPermNt = InvGrpPermOc.FirstNodeType; if( null != DefaultInventoryGroup ) { if( null != InvGrpPermNt && null != DefaultWorkUnit ) { foreach( CswNbtObjClassInventoryGroupPermission InvGrpPermNode in InvGrpPermOc.getNodes( false, false, IncludeHiddenNodes: true ) ) { if( ( null != CISProInventoryGroup && InvGrpPermNode.InventoryGroup.RelatedNodeId == CISProInventoryGroup.NodeId ) || InvGrpPermNode.InventoryGroup.Gestalt == "CISPro" ) { InvGrpPermNode.InventoryGroup.RelatedNodeId = DefaultInventoryGroup.NodeId; InvGrpPermNode.WorkUnit.RelatedNodeId = DefaultWorkUnit.NodeId; InvGrpPermNode.postChanges( true ); } if( null != AdminRole && InvGrpPermNode.Role.RelatedNodeId == AdminRole.NodeId ) { MakeAdminNode = false; } else if( null != ChemSWAdminRole && InvGrpPermNode.Role.RelatedNodeId == ChemSWAdminRole.NodeId ) { MakeChemSWAdminNode = false; } } if( MakeAdminNode && null != AdminRole ) { _createInventoryGroupPermission( InvGrpPermNt.NodeTypeId, AdminRole.NodeId, DefaultInventoryGroup.NodeId, DefaultWorkUnit.NodeId ); } if( MakeChemSWAdminNode && null != ChemSWAdminRole ) { _createInventoryGroupPermission( InvGrpPermNt.NodeTypeId, ChemSWAdminRole.NodeId, DefaultInventoryGroup.NodeId, DefaultWorkUnit.NodeId ); } } CswNbtMetaDataObjectClass LocationOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.LocationClass ); CswNbtMetaDataNodeType LocationNt = LocationOc.FirstNodeType; if( null != CISProInventoryGroup && null != LocationNt ) { foreach( CswNbtObjClassLocation LocationNode in LocationOc.getNodes( false, false, IncludeHiddenNodes: true ) ) { if( LocationNode.InventoryGroup.RelatedNodeId == CISProInventoryGroup.NodeId ) { LocationNode.InventoryGroup.RelatedNodeId = DefaultInventoryGroup.NodeId; LocationNode.postChanges( false ); } } CISProInventoryGroup.Node.delete(); } } }//Update()