Esempio n. 1
0
        /// <summary>
        /// Instance a new EnterprisePart Request Item
        /// </summary>
        public CswNbtObjClassRequestItem makeEnterprisePartRequestItem(CswNbtObjClassEnterprisePart EnterprisePart, CswNbtObjClass.NbtButtonData ButtonData)
        {
            checkForCentralInventoryGroups(_CswNbtResources);
            CswNbtObjClassRequestItem RequestItem   = null;
            CswNbtMetaDataObjectClass RequestItemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass);
            CswNbtMetaDataNodeType    RequestItemNT = RequestItemOC.getNodeTypes().FirstOrDefault();
            CswNbtSdTabsAndProps      PropsAction   = new CswNbtSdTabsAndProps(_CswNbtResources);

            if (null != RequestItemNT)
            {
                RequestItem = PropsAction.getAddNodeAndPostChanges(RequestItemNT, delegate(CswNbtNode NewNode)
                {
                    CswNbtObjClassRequestItem RequestItemNode    = NewNode;
                    RequestItemNode.EnterprisePart.RelatedNodeId = EnterprisePart.NodeId;
                    RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.EnterprisePart;
                    if (null != _ThisUser.DefaultLocationId)
                    {
                        CswNbtObjClassLocation DefaultAsLocation = _CswNbtResources.Nodes.GetNode(_ThisUser.DefaultLocationId);
                        if (null != DefaultAsLocation)
                        {
                            RequestItemNode.Location.SelectedNodeId = DefaultAsLocation.NodeId;
                            RequestItemNode.Location.CachedNodeName = DefaultAsLocation.Location.CachedNodeName;
                            RequestItemNode.Location.CachedPath     = DefaultAsLocation.Location.CachedPath;
                        }
                    }
                });
            }
            return(RequestItem);
        }
        public override void update()
        {
            CswNbtMetaDataObjectClass enterprisePartOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.EnterprisePartClass );


            //create the EP nodetype
            CswNbtMetaDataNodeType enterprisePartNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Enterprise Part" );
            if( null == enterprisePartNT )
            {
                enterprisePartNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( enterprisePartOC.ObjectClassId, "Enterprise Part", "MLM" );

                string epnameTemplate = CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassEnterprisePart.PropertyName.GCAS );
                enterprisePartNT.setNameTemplateText( epnameTemplate );

                CswNbtMetaDataNodeTypeProp gcasNTP = enterprisePartNT.getNodeTypePropByObjectClassProp( CswNbtObjClassEnterprisePart.PropertyName.GCAS );
                _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add, enterprisePartNT.NodeTypeId, gcasNTP.PropId, true );

                //create the demo EP node
                CswNbtObjClassEnterprisePart epNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( enterprisePartNT.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode );
                epNode.GCAS.Text = "EP123";
                epNode.IsDemo = true;
                epNode.postChanges( false );
            }

            //create the EPs view
            CswNbtView enterprisePartsView = _CswNbtSchemaModTrnsctn.restoreView( "Enterprise Parts" );
            if( null == enterprisePartsView )
            {
                enterprisePartsView = _CswNbtSchemaModTrnsctn.makeNewView( "Enterprise Parts", NbtViewVisibility.Global );
                enterprisePartsView.Category = "MLM (demo)";
                enterprisePartsView.ViewMode = NbtViewRenderingMode.Tree;
                enterprisePartsView.AddViewRelationship( enterprisePartOC, true );
                enterprisePartsView.IsDemo = true;
                enterprisePartsView.save();
            }

        }