}//getBalanceInformation( ICswResources CswResources, CswNbtBalanceReturn Return, string Request ) private static CswNbtObjClassUnitOfMeasure _mapUnitToNode( CswNbtResources NbtResources, string UnitName ) { CswNbtObjClassUnitOfMeasure Unit = null; CswNbtMetaDataObjectClass UnitsOfMeasureOC = NbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.UnitOfMeasureClass ); CswNbtView MatchingUOMsView = new CswNbtView( NbtResources ); CswNbtViewRelationship ParentRelationship = MatchingUOMsView.AddViewRelationship( UnitsOfMeasureOC, false ); CswNbtMetaDataObjectClassProp NameOCP = UnitsOfMeasureOC.getObjectClassProp( CswNbtObjClassUnitOfMeasure.PropertyName.Name ); MatchingUOMsView.AddViewPropertyAndFilter( ParentRelationship, MetaDataProp: NameOCP, Value: UnitName, SubFieldName: CswEnumNbtSubFieldName.Text, FilterMode: CswEnumNbtFilterMode.Equals ); CswNbtMetaDataObjectClassProp AliasesOCP = UnitsOfMeasureOC.getObjectClassProp( CswNbtObjClassUnitOfMeasure.PropertyName.Aliases ); MatchingUOMsView.AddViewPropertyAndFilter( ParentRelationship, MetaDataProp: AliasesOCP, Value: "," + UnitName + ",", SubFieldName: CswEnumNbtSubFieldName.Text, FilterMode: CswEnumNbtFilterMode.Contains, Conjunction: CswEnumNbtFilterConjunction.Or ); MatchingUOMsView.AddViewPropertyAndFilter( ParentRelationship, MetaDataProp : AliasesOCP, Value : UnitName + ",", SubFieldName : CswEnumNbtSubFieldName.Text, FilterMode : CswEnumNbtFilterMode.Begins, Conjunction : CswEnumNbtFilterConjunction.Or ); MatchingUOMsView.AddViewPropertyAndFilter( ParentRelationship, MetaDataProp : AliasesOCP, Value : "," + UnitName, SubFieldName : CswEnumNbtSubFieldName.Text, FilterMode : CswEnumNbtFilterMode.Ends, Conjunction : CswEnumNbtFilterConjunction.Or ); MatchingUOMsView.AddViewPropertyAndFilter( ParentRelationship, MetaDataProp : AliasesOCP, Value : UnitName, SubFieldName : CswEnumNbtSubFieldName.Text, FilterMode : CswEnumNbtFilterMode.Equals, Conjunction : CswEnumNbtFilterConjunction.Or ); // Get and iterate the Tree ICswNbtTree MatchingUOMsTree = NbtResources.Trees.getTreeFromView( MatchingUOMsView, false, false, true ); int Count = MatchingUOMsTree.getChildNodeCount(); for( int i = 0; i < Count; i++ ) { MatchingUOMsTree.goToNthChild( i ); Unit = MatchingUOMsTree.getNodeForCurrentPosition(); MatchingUOMsTree.goToParentNode(); } return Unit; }//_mapUnitToNode( CswNbtResources NbtResources, string UnitName )
/// <summary> /// Get a landing page for a Material /// </summary> public static JObject getLandingPageData(CswNbtResources NbtResources, CswNbtNode MaterialNode, bool UseBatchOp, Collection <CswPrimaryKey> ContainerIds, CswNbtView MaterialNodeView = null) { JObject Ret = new JObject(); if (null != MaterialNode) { MaterialNodeView = MaterialNodeView ?? CswNbtPropertySetMaterial.getMaterialNodeView(NbtResources, MaterialNode, "Received: "); MaterialNodeView.SaveToCache(IncludeInQuickLaunch: false); Ret["ActionId"] = NbtResources.Actions[CswEnumNbtActionName.Receiving].ActionId.ToString(); //Used for Tab and Button items Ret["NodeId"] = MaterialNode.NodeId.ToString(); Ret["NodeViewId"] = MaterialNodeView.SessionViewId.ToString(); //Used for node-specific Add items Ret["RelatedNodeId"] = MaterialNode.NodeId.ToString(); Ret["RelatedNodeName"] = MaterialNode.NodeName; //If (and when) action landing pages are slated to be roleId-specific, remove this line Ret["isConfigurable"] = NbtResources.CurrentNbtUser.IsAdministrator(); //Used for viewing new material Ret["ActionLinks"] = new JObject(); string ActionLinkName = MaterialNode.NodeId.ToString(); Ret["ActionLinks"][ActionLinkName] = new JObject(); Ret["ActionLinks"][ActionLinkName]["Text"] = MaterialNode.NodeName; Ret["ActionLinks"][ActionLinkName]["ViewId"] = MaterialNodeView.SessionViewId.ToString(); if (UseBatchOp) { Ret["Title"] = "The containers for this material have been scheduled for creation, but may not be available immediately. Click 'View Batch Operations' to check their progress."; Ret["ActionLinks"]["BatchOps"] = new JObject(); Ret["ActionLinks"]["BatchOps"]["ActionName"] = "These containers will be created in a batch operation and may not be immediately available. You can check the progress of their creation below:"; Ret["ActionLinks"]["BatchOps"]["Text"] = "View Batch Operations"; Ret["ActionLinks"]["BatchOps"]["ViewId"] = NbtResources.ViewSelect.getViewIdByName("My Batch Operations", CswEnumNbtViewVisibility.Global, null, null).ToString(); } else { CswNbtMetaDataNodeType ContainerNT = NbtResources.MetaData.getNodeType("Container"); if (null != ContainerNT) { CswNbtView NewContainersView = new CswNbtView(NbtResources); NewContainersView.ViewName = "New Containers"; CswNbtViewRelationship ContainerVr = NewContainersView.AddViewRelationship(ContainerNT, true); ContainerVr.NodeIdsToFilterIn = ContainerIds; NewContainersView.SaveToCache(false); Ret["ActionLinks"]["NewContainers"] = new JObject(); Ret["ActionLinks"]["NewContainers"]["Text"] = "View Received Containers"; Ret["ActionLinks"]["NewContainers"]["ViewId"] = NewContainersView.SessionViewId.ToString();; } } } return(Ret); }
public override void update() { HashSet<CswNbtViewId> SeenViewIds = new HashSet<CswNbtViewId>(); CswNbtMetaDataObjectClass ChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass ); CswNbtMetaDataObjectClass MaterialComponentOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.MaterialComponentClass ); CswNbtMetaDataObjectClassProp ConstituentOCP = MaterialComponentOC.getObjectClassProp( CswNbtObjClassMaterialComponent.PropertyName.Constituent ); CswNbtMetaDataObjectClassProp MixtureOCP = MaterialComponentOC.getObjectClassProp( CswNbtObjClassMaterialComponent.PropertyName.Mixture ); CswNbtMetaDataObjectClassProp PercentageOCP = MaterialComponentOC.getObjectClassProp( CswNbtObjClassMaterialComponent.PropertyName.Percentage ); CswNbtMetaDataNodeType ConstituentNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Constituent" ); if( null != ConstituentNT ) { CswNbtMetaDataNodeTypeProp ConstituentCASNoNTP = ConstituentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassChemical.PropertyName.CasNo ); foreach( CswNbtMetaDataNodeType ChemicalNT in ChemicalOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp ConstituentNTP = ChemicalNT.getNodeTypeProp( "Components" ); if( null != ConstituentNTP ) { if( false == SeenViewIds.Contains( ConstituentNTP.ViewId ) ) { CswNbtView ConstituentsPropView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( ConstituentNTP.ViewId ); ConstituentsPropView.Root.ChildRelationships.Clear(); CswNbtViewRelationship ChemicalParent = ConstituentsPropView.AddViewRelationship( ChemicalOC, false ); CswNbtViewRelationship MaterialComponentRelationship = ConstituentsPropView.AddViewRelationship( ChemicalParent, CswEnumNbtViewPropOwnerType.Second, MixtureOCP, true ); ConstituentsPropView.AddViewProperty( MaterialComponentRelationship, ConstituentOCP, 1 ); CswNbtViewRelationship ConstituentRelationship = ConstituentsPropView.AddViewRelationship( MaterialComponentRelationship, CswEnumNbtViewPropOwnerType.First, ConstituentOCP, false ); ConstituentsPropView.AddViewProperty( ConstituentRelationship, ConstituentCASNoNTP, 2 ); ConstituentsPropView.AddViewProperty( MaterialComponentRelationship, PercentageOCP, 3 ); ConstituentsPropView.save(); SeenViewIds.Add( ConstituentNTP.ViewId ); } } } } } // update()
public CswNbtView CreateDefaultView(bool IncludeDefaultFilters = true) { CswNbtView DefaultView = new CswNbtView(_CswNbtMetaDataResources.CswNbtResources); DefaultView.ViewName = this.Name; CswNbtViewRelationship RelationshipToMe = DefaultView.AddViewRelationship(this, IncludeDefaultFilters); return(DefaultView); }
public override void update() { //Remove ability to add Inv Levels on Location Views Inventory Levels prop CswNbtMetaDataObjectClass locationOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.LocationClass ); CswNbtMetaDataObjectClass invLvlOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.InventoryLevelClass ); CswNbtMetaDataObjectClassProp locationOCP = invLvlOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Location ); CswNbtMetaDataObjectClassProp currentQuantOCP = invLvlOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.CurrentQuantity ); CswNbtMetaDataObjectClassProp levelOCP = invLvlOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Level ); CswNbtMetaDataObjectClassProp materialOCP = invLvlOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Material ); CswNbtMetaDataObjectClassProp statusOCP = invLvlOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Status ); CswNbtMetaDataObjectClassProp typeOCP = invLvlOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Type ); foreach( CswNbtMetaDataNodeType locationNT in locationOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp invLevelsNTP = locationNT.getNodeTypeProp( "Inventory Levels" ); if( null != invLevelsNTP ) { CswNbtView invLevelsView = _CswNbtSchemaModTrnsctn.restoreView( invLevelsNTP.ViewId ); invLevelsView.Root.ChildRelationships.Clear(); CswNbtViewRelationship locationParent = invLevelsView.AddViewRelationship( locationNT, true ); CswNbtViewRelationship invLvlParent = invLevelsView.AddViewRelationship( locationParent, NbtViewPropOwnerType.Second, locationOCP, true ); invLvlParent.AddChildren = NbtViewAddChildrenSetting.None; //cannot add Inv Levels int order = 1; _addProp( invLevelsView, invLvlParent, currentQuantOCP, order ); order++; _addProp( invLevelsView, invLvlParent, levelOCP, order ); order++; _addProp( invLevelsView, invLvlParent, materialOCP, order ); order++; _addProp( invLevelsView, invLvlParent, statusOCP, order ); order++; _addProp( invLevelsView, invLvlParent, typeOCP, order ); invLevelsView.save(); } } } //Update()
public override void update() { CswNbtMetaDataNodeType SDSDocumentNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "SDS Document" ); if( null != SDSDocumentNT ) { CswNbtMetaDataObjectClass MaterialOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass ); foreach( CswNbtMetaDataNodeType MaterialNT in MaterialOC.getNodeTypes() ) { if( MaterialNT.NodeTypeName == "Chemical" ) { CswNbtMetaDataNodeTypeProp AssignedSDSNTP = MaterialNT.getNodeTypeProp( "Assigned SDS" ); if( null != AssignedSDSNTP ) { CswNbtMetaDataNodeTypeProp OwnerOCP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Owner ); CswNbtMetaDataNodeTypeProp RevisionDateNTP = SDSDocumentNT.getNodeTypeProp( "Revision Date" ); CswNbtMetaDataNodeTypeProp ArchivedNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Archived ); CswNbtMetaDataNodeTypeProp FileNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.File ); CswNbtMetaDataNodeTypeProp LinkNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Link ); CswNbtMetaDataNodeTypeProp LanguageNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Language ); CswNbtMetaDataNodeTypeProp FormatNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Format ); CswNbtView AssignedSDSView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( AssignedSDSNTP.ViewId ); AssignedSDSView.Root.ChildRelationships.Clear(); CswNbtViewRelationship RootRel = AssignedSDSView.AddViewRelationship( MaterialNT, false ); CswNbtViewRelationship DocRel = AssignedSDSView.AddViewRelationship( RootRel, CswEnumNbtViewPropOwnerType.Second, OwnerOCP, true ); AssignedSDSView.AddViewPropertyAndFilter( DocRel, ArchivedNTP, CswEnumTristate.False.ToString(), FilterMode: CswEnumNbtFilterMode.Equals, ShowAtRuntime: true, ShowInGrid: false ); if( null != RevisionDateNTP ) { AssignedSDSView.AddViewProperty( DocRel, RevisionDateNTP, 1 ); } AssignedSDSView.AddViewProperty( DocRel, FileNTP, 2 ); AssignedSDSView.AddViewProperty( DocRel, LinkNTP, 3 ); AssignedSDSView.AddViewProperty( DocRel, LanguageNTP, 4 ); AssignedSDSView.AddViewProperty( DocRel, FormatNTP, 5 ); AssignedSDSView.save(); } } } } } // update()
public override void update() { CswNbtMetaDataObjectClass mepOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.ManufacturerEquivalentPartClass ); //create the MEP NT CswNbtMetaDataNodeType mepNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Manufacturing Equivalent Part" ); if( null == mepNT ) { mepNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( mepOC.ObjectClassId, "Manufacturing Equivalent Part", "MLM" ); string mepNameTemplate = CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassManufacturerEquivalentPart.PropertyName.Manufacturer ); mepNameTemplate += CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassManufacturerEquivalentPart.PropertyName.EnterprisePart ); mepNameTemplate += CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassManufacturerEquivalentPart.PropertyName.Material ); mepNT.setNameTemplateText( mepNameTemplate ); CswNbtMetaDataNodeTypeProp materialNTP = mepNT.getNodeTypePropByObjectClassProp( CswNbtObjClassManufacturerEquivalentPart.PropertyName.Material ); _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add, mepNT.NodeTypeId, materialNTP.PropId, true ); CswNbtMetaDataNodeTypeProp epNTP = mepNT.getNodeTypePropByObjectClassProp( CswNbtObjClassManufacturerEquivalentPart.PropertyName.EnterprisePart ); _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add, mepNT.NodeTypeId, epNTP.PropId, true ); CswNbtMetaDataNodeTypeProp manufactufacturerNTP = mepNT.getNodeTypePropByObjectClassProp( CswNbtObjClassManufacturerEquivalentPart.PropertyName.Manufacturer ); _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add, mepNT.NodeTypeId, manufactufacturerNTP.PropId, true ); //create demo MEP node CswNbtObjClassManufacturerEquivalentPart mepNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( mepNT.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode ); //get the default EP node and set it o the demo MEP nodes EP prop CswNbtMetaDataNodeType epNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Enterprise Part" ); if( null != epNT ) { foreach( CswNbtObjClassEnterprisePart epNode in epNT.getNodes( false, false ) ) { if( epNode.GCAS.Text.Equals( "EP123" ) ) //the default EP node had its GCAS set to this in CswUpdateSchema_01T_Case27865_part1 { mepNode.EnterprisePart.RelatedNodeId = epNode.NodeId; } } } mepNode.IsDemo = true; mepNode.postChanges( false ); } //create the MEPs view CswNbtView mepsView = _CswNbtSchemaModTrnsctn.restoreView( "Manufacturing Equivalent Parts" ); if( null == mepsView ) { mepsView = _CswNbtSchemaModTrnsctn.makeNewView( "Manufacturing Equivalent Parts", NbtViewVisibility.Global ); mepsView.Category = "MLM (demo)"; mepsView.ViewMode = NbtViewRenderingMode.Tree; mepsView.AddViewRelationship( mepOC, true ); mepsView.IsDemo = true; mepsView.save(); } }
private void _getViewProps(CswNbtView TempView, CswNbtViewEditorData Return) { foreach (CswNbtMetaDataNodeType NodeType in _CswNbtResources.MetaData.getNodeTypes() .Where(nt => _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, nt))) { CswNbtViewRelationship Relationship = TempView.AddViewRelationship(NodeType, true); //CswNbtViewNode foundNode = CurrentView.FindViewNodeByArbitraryId( Relationship.ArbitraryId ); Return.Step2.Relationships.Add(Relationship); _addNameTemplateProps(TempView, Relationship, NodeType); } foreach (CswNbtMetaDataObjectClass ObjClass in _CswNbtResources.MetaData.getObjectClasses() .Where(oc => false == oc.IsDesign() || _CswNbtResources.Permit.can(CswEnumNbtActionName.Design)) // case 31533 .OrderBy(ObjClass => ObjClass.ObjectClass.Value)) { CswNbtViewRelationship Relationship = TempView.AddViewRelationship(ObjClass, true); //CswNbtViewNode foundNode = CurrentView.FindViewNodeByArbitraryId( Relationship.ArbitraryId ); Return.Step2.Relationships.Add(Relationship); foreach (CswNbtMetaDataNodeType NodeType in ObjClass.getNodeTypes() .Where(nt => _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, nt))) { _addNameTemplateProps(TempView, Relationship, NodeType); } } foreach (CswNbtMetaDataPropertySet PropSet in _CswNbtResources.MetaData.getPropertySets() .OrderBy(PropSet => PropSet.Name)) { CswNbtViewRelationship Relationship = TempView.AddViewRelationship(PropSet, true); //CswNbtViewNode foundNode = CurrentView.FindViewNodeByArbitraryId( Relationship.ArbitraryId ); Return.Step2.Relationships.Add(Relationship); foreach (CswNbtMetaDataObjectClass ObjClass in PropSet.getObjectClasses() .Where(oc => false == oc.IsDesign() || _CswNbtResources.Permit.can(CswEnumNbtActionName.Design))) // case 31533 { foreach (CswNbtMetaDataNodeType NodeType in ObjClass.getNodeTypes() .Where(nt => _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, nt))) { _addNameTemplateProps(TempView, Relationship, NodeType); } } } }
public override void update() { //Fetch the data we need CswNbtMetaDataObjectClass SDSDocOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.SDSDocumentClass ); CswNbtMetaDataObjectClassProp fileTypeOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.FileType ); CswNbtMetaDataObjectClassProp archivedOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Archived ); CswNbtMetaDataObjectClassProp formatOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Format ); CswNbtMetaDataObjectClassProp languageOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Language ); CswNbtMetaDataObjectClassProp fileOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.File ); CswNbtMetaDataObjectClassProp linkOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Link ); CswNbtMetaDataObjectClassProp ownerOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.Owner ); CswNbtMetaDataObjectClassProp revisionDateOCP = SDSDocOC.getObjectClassProp( CswNbtObjClassSDSDocument.PropertyName.RevisionDate ); CswNbtMetaDataObjectClass ChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass ); CswNbtMetaDataObjectClassProp AssignedSDS_OCP = ChemicalOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.AssignedSDS ); //Find the relationship to add the prop to CswNbtView AssignedSDSView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( AssignedSDS_OCP.ViewXml ); AssignedSDSView.Clear(); AssignedSDSView.SetVisibility( CswEnumNbtViewVisibility.Property, null, null ); CswNbtViewRelationship chemLvl = AssignedSDSView.AddViewRelationship( ChemicalOC, false ); CswNbtViewRelationship sdsLvl = AssignedSDSView.AddViewRelationship( chemLvl, CswEnumNbtViewPropOwnerType.Second, ownerOCP, true ); AssignedSDSView.AddViewPropertyAndFilter( sdsLvl, MetaDataProp : archivedOCP, SubFieldName : CswEnumNbtSubFieldName.Checked, Value : false.ToString(), FilterMode : CswEnumNbtFilterMode.Equals, ShowInGrid : false ); AssignedSDSView.AddViewProperty( sdsLvl, revisionDateOCP, 1 ); AssignedSDSView.AddViewProperty( sdsLvl, formatOCP, 5 ); AssignedSDSView.AddViewProperty( sdsLvl, languageOCP, 4 ); AssignedSDSView.AddViewProperty( sdsLvl, fileOCP, 2 ); AssignedSDSView.AddViewProperty( sdsLvl, linkOCP, 3 ); CswNbtViewProperty fileTypeVP = AssignedSDSView.AddViewProperty( sdsLvl, fileTypeOCP ); fileTypeVP.ShowInGrid = false; _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( AssignedSDS_OCP, CswEnumNbtObjectClassPropAttributes.viewxml, AssignedSDSView.ToString() ); } // update()
} // update() private void _updateAliasesValue( CswNbtMetaDataObjectClass UoMOC, CswNbtObjClassUnitOfMeasure UoMNode, string NewAliases ) { // The new aliases we want to add CswCommaDelimitedString NewAliasesCommaDelimited = new CswCommaDelimitedString( NewAliases ); CswCommaDelimitedString UpdatedAliases = UoMNode.AliasesAsDelimitedString; // Create a view of all UoM nodes and their Aliases property CswNbtView UoMView = _CswNbtSchemaModTrnsctn.makeView(); CswNbtViewRelationship ParentRelationship = UoMView.AddViewRelationship( UoMOC, false ); CswNbtMetaDataObjectClassProp AliasesOCP = UoMOC.getObjectClassProp( CswNbtObjClassUnitOfMeasure.PropertyName.Aliases ); UoMView.AddViewProperty( ParentRelationship, AliasesOCP ); CswCommaDelimitedString AliasesToRemove = new CswCommaDelimitedString(); ICswNbtTree UoMNodesTree = _CswNbtSchemaModTrnsctn.getTreeFromView( UoMView, false ); for( int i = 0; i < UoMNodesTree.getChildNodeCount(); i++ ) { UoMNodesTree.goToNthChild( i ); string CurrentNodeName = UoMNodesTree.getNodeNameForCurrentPosition(); CswPrimaryKey CurrentNodeId = UoMNodesTree.getNodeIdForCurrentPosition(); if( CurrentNodeId != UoMNode.NodeId ) { foreach( CswNbtTreeNodeProp TreeNodeProp in UoMNodesTree.getChildNodePropsOfNode() ) { CswCommaDelimitedString CurrentUoMNodeAliases = new CswCommaDelimitedString(); CurrentUoMNodeAliases.FromString( TreeNodeProp.Gestalt, false, true ); foreach( string alias1 in NewAliasesCommaDelimited ) { // If alias1 matches the NodeName or any of the Aliases on the Node, we don't want it if( alias1.Equals( CurrentNodeName ) || CurrentUoMNodeAliases.Any( alias2 => alias1.Equals( alias2 ) ) ) { AliasesToRemove.Add( alias1 ); } } } } UoMNodesTree.goToParentNode(); } // Make the updated aliases for the node foreach( string alias1 in NewAliasesCommaDelimited ) { if( false == AliasesToRemove.Contains( alias1 ) && false == UoMNode.AliasesAsDelimitedString.Contains( alias1 ) ) { UpdatedAliases.Add( alias1 ); } } // Update the property value UoMNode.Aliases.Text = CswConvert.ToString( UpdatedAliases ); UoMNode.postChanges( false ); }//_updateAliasesValue()
public void afterCreateNodeTypeProp(CswNbtMetaDataNodeTypeProp NodeTypeProp) { //Case 53001 - grid properties need to have the the current NT set as the root CswNbtView propView = _CswNbtFieldResources.CswNbtResources.ViewSelect.restoreView(NodeTypeProp.ViewId); propView.SetViewMode(CswEnumNbtViewRenderingMode.Grid); propView.AddViewRelationship(NodeTypeProp.getNodeType(), true); propView.save(); _CswNbtFieldTypeRuleDefault.afterCreateNodeTypeProp(NodeTypeProp); }
private void _makeSampleSizeView(string ViewName, string FilterVal) { CswNbtMetaDataObjectClass UnitOfMeasureOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass(CswEnumNbtObjectClass.UnitOfMeasureClass); CswNbtMetaDataObjectClassProp NameOCP = UnitOfMeasureOC.getObjectClassProp(CswNbtObjClassUnitOfMeasure.PropertyName.Name); CswNbtView SampleSizeUnitsView = _CswNbtSchemaModTrnsctn.makeSafeView(ViewName, CswEnumNbtViewVisibility.Hidden); CswNbtViewRelationship parent = SampleSizeUnitsView.AddViewRelationship(UnitOfMeasureOC, true); SampleSizeUnitsView.AddViewPropertyAndFilter(parent, NameOCP, FilterVal); SampleSizeUnitsView.save(); }
public override void update() { CswNbtMetaDataNodeType ContainerDocumentNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Container Document" ); CswNbtMetaDataObjectClass ContainerOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ContainerClass ); foreach( CswNbtMetaDataNodeType ContainerNT in ContainerOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp DocumentsNTP = ContainerNT.getNodeTypeProp( "Documents" ); if( null != DocumentsNTP && null != ContainerDocumentNT ) { CswNbtView ContainerDocsView = _CswNbtSchemaModTrnsctn.restoreView( DocumentsNTP.ViewId ); if( null == ContainerDocsView ) { ContainerDocsView = _CswNbtSchemaModTrnsctn.makeSafeView( "Documents", CswEnumNbtViewVisibility.Property ); ContainerDocsView.ViewMode = CswEnumNbtViewRenderingMode.Grid; } ContainerDocsView.Root.ChildRelationships.Clear(); CswNbtMetaDataNodeTypeProp OwnerNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Owner ); CswNbtMetaDataNodeTypeProp ArchivedNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Archived ); CswNbtMetaDataNodeTypeProp FileNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.File ); CswNbtMetaDataNodeTypeProp LinkNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Link ); CswNbtMetaDataNodeTypeProp TitleNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Title ); CswNbtMetaDataNodeTypeProp AcquiredDateNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.AcquiredDate ); CswNbtMetaDataNodeTypeProp ExpirationDateNTP = ContainerDocumentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.ExpirationDate ); CswNbtViewRelationship RootRel = ContainerDocsView.AddViewRelationship( ContainerNT, false ); CswNbtViewRelationship DocRel = ContainerDocsView.AddViewRelationship( RootRel, CswEnumNbtViewPropOwnerType.Second, OwnerNTP, true ); ContainerDocsView.AddViewPropertyAndFilter( DocRel, ArchivedNTP, CswEnumTristate.False.ToString(), FilterMode: CswEnumNbtFilterMode.Equals, ShowAtRuntime: true, ShowInGrid: false ); ContainerDocsView.AddViewProperty( DocRel, FileNTP, 1 ); ContainerDocsView.AddViewProperty( DocRel, LinkNTP, 2 ); ContainerDocsView.AddViewProperty( DocRel, TitleNTP, 3 ); ContainerDocsView.AddViewProperty( DocRel, AcquiredDateNTP, 4 ); ContainerDocsView.AddViewProperty( DocRel, ExpirationDateNTP, 5 ); ContainerDocsView.save(); DocumentsNTP.ViewId = ContainerDocsView.ViewId; } } } // update()
public override void update() { CswNbtView RequestView = _CswNbtSchemaModTrnsctn.restoreView("My Request History", CswEnumNbtViewVisibility.Global); if (null != RequestView) { CswNbtMetaDataObjectClass RequestOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestClass); RequestView.Root.ChildRelationships.Clear(); RequestView.AddViewRelationship(RequestOC, true); RequestView.save(); } }
private void _updateSizesView( CswNbtMetaDataNodeType MaterialNT ) { CswNbtMetaDataNodeTypeProp SizesNTP = MaterialNT.getNodeTypeProp( MaterialNT.NodeTypeName + " Sizes" ); if( null != SizesNTP ) { CswNbtMetaDataObjectClass SizeOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.SizeClass ); CswNbtMetaDataObjectClassProp MatOCP = SizeOC.getObjectClassProp( CswNbtObjClassSize.PropertyName.Material ); CswNbtMetaDataObjectClassProp InitQtyOCP = SizeOC.getObjectClassProp( CswNbtObjClassSize.PropertyName.InitialQuantity ); CswNbtMetaDataObjectClassProp CatalogNoOCP = SizeOC.getObjectClassProp( CswNbtObjClassSize.PropertyName.CatalogNo ); CswNbtMetaDataObjectClassProp QtyEditOCP = SizeOC.getObjectClassProp( CswNbtObjClassSize.PropertyName.QuantityEditable ); CswNbtView SizesView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( SizesNTP.ViewId ); SizesView.Root.ChildRelationships.Clear(); CswNbtViewRelationship RootRel = SizesView.AddViewRelationship( MaterialPS, false ); CswNbtViewRelationship MatRel = SizesView.AddViewRelationship( RootRel, CswEnumNbtViewPropOwnerType.Second, MatOCP, true ); SizesView.AddViewProperty( MatRel, InitQtyOCP, 1 ); SizesView.AddViewProperty( MatRel, CatalogNoOCP, 2 ); SizesView.AddViewProperty( MatRel, QtyEditOCP, 3 ); SizesView.save(); } }
} // getBarcodeProperty() public CswNbtView CreateDefaultView(bool includeDefaultFilters = true) { CswNbtView DefaultView = new CswNbtView(_CswNbtMetaDataResources.CswNbtResources); DefaultView.ViewName = this.NodeTypeName; CswNbtViewRelationship RelationshipToMe = DefaultView.AddViewRelationship(this, includeDefaultFilters); //RelationshipToMe.ArbitraryId = RelationshipToMe.SecondId.ToString(); return(DefaultView); }
} // CalculateMTBF() private Int32 _countProblems(DateTime StartDate, DateTime EndDate) { Int32 ret = 0; if (this.NodeId != null) { // BZ 6779 CswNbtMetaDataObjectClass ProblemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ProblemClass); CswNbtMetaDataObjectClassProp OwnerOCP = ProblemOC.getObjectClassProp(CswNbtObjClassProblem.PropertyName.Owner); CswNbtMetaDataObjectClassProp FailureOCP = ProblemOC.getObjectClassProp(CswNbtObjClassProblem.PropertyName.Failure); CswNbtMetaDataObjectClassProp DateOpenedOCP = ProblemOC.getObjectClassProp(CswNbtObjClassProblem.PropertyName.DateOpened); CswNbtView ProblemFailuresView = new CswNbtView(_CswNbtResources); ProblemFailuresView.ViewName = "Problem Failures"; CswNbtViewRelationship ParentRelationship = ProblemFailuresView.AddViewRelationship(this.NodeTypeProp.getNodeType(), true); ParentRelationship.NodeIdsToFilterIn.Add(this.NodeId); CswNbtViewRelationship ChildRelationship = ProblemFailuresView.AddViewRelationship(ParentRelationship, CswEnumNbtViewPropOwnerType.Second, OwnerOCP, true); // BZ 10277 - Only Problems flagged Failure CswNbtViewProperty FailureVP = ProblemFailuresView.AddViewProperty(ChildRelationship, FailureOCP); CswNbtViewPropertyFilter FailureFilter = ProblemFailuresView.AddViewPropertyFilter(FailureVP, CswNbtFieldTypeRuleLogical.SubFieldName.Checked, CswEnumNbtFilterMode.Equals, CswEnumTristate.True.ToString(), false); // BZ 10259...within the calculation date scope CswNbtViewProperty DateOpenedVP = ProblemFailuresView.AddViewProperty(ChildRelationship, DateOpenedOCP); CswNbtViewPropertyFilter DateOpenedStartFilter = ProblemFailuresView.AddViewPropertyFilter(DateOpenedVP, CswNbtFieldTypeRuleDateTime.SubFieldName.Value, CswEnumNbtFilterMode.GreaterThanOrEquals, StartDate.ToString(), false); CswNbtViewPropertyFilter DateOpenedEndFilter = ProblemFailuresView.AddViewPropertyFilter(DateOpenedVP, CswNbtFieldTypeRuleDateTime.SubFieldName.Value, CswEnumNbtFilterMode.LessThanOrEquals, EndDate.ToString(), false); ICswNbtTree ProblemNodesTree = _CswNbtResources.Trees.getTreeFromView(_CswNbtResources.CurrentNbtUser, ProblemFailuresView, true, false, false); if (ProblemNodesTree.getChildNodeCount() > 0) { ProblemNodesTree.goToNthChild(0); ret = ProblemNodesTree.getChildNodeCount(); } } return(ret); } // _countProblems()
public override void update() { _CswNbtSchemaModTrnsctn.createAction( CswEnumNbtActionName.Material_Approval, false, String.Empty, "Materials" ); _CswNbtSchemaModTrnsctn.createModuleActionJunction( CswEnumNbtModuleName.Containers, CswEnumNbtActionName.Material_Approval ); CswNbtMetaDataObjectClass RoleOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RoleClass ); foreach( CswNbtNode RoleNode in RoleOC.getNodes( false, true ) ) { bool CanApprove = ( RoleNode.NodeName == "Administrator" || RoleNode.NodeName == "chemsw_admin_role" || RoleNode.NodeName == "CISPro_Receiver" || RoleNode.NodeName == "CISPro_Admin" ); _CswNbtSchemaModTrnsctn.Permit.set( CswEnumNbtActionName.Material_Approval, RoleNode, CanApprove ); } CswNbtMetaDataObjectClass MaterialOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass ); CswNbtMetaDataObjectClassProp MaterialIdProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.MaterialId ); CswNbtMetaDataObjectClassProp TradeNameProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.TradeName ); CswNbtMetaDataObjectClassProp SupplierProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.Supplier ); CswNbtMetaDataObjectClassProp PartNoProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.PartNumber ); CswNbtMetaDataObjectClassProp CASNoProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.CasNo ); CswNbtMetaDataObjectClassProp PhysicalStateProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.PhysicalState ); CswNbtMetaDataObjectClassProp ApprovedForReceivingProp = MaterialOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.ApprovedForReceiving ); CswNbtView UnapprovedMaterialsView = _CswNbtSchemaModTrnsctn.restoreView( "Unapproved Materials", CswEnumNbtViewVisibility.Global ); if( null == UnapprovedMaterialsView ) { UnapprovedMaterialsView = _CswNbtSchemaModTrnsctn.makeNewView( "Unapproved Materials", CswEnumNbtViewVisibility.Global ); } else { UnapprovedMaterialsView.Root.ChildRelationships.Clear(); } UnapprovedMaterialsView.ViewMode = CswEnumNbtViewRenderingMode.Grid; UnapprovedMaterialsView.Category = "Materials"; CswNbtViewRelationship MatRel = UnapprovedMaterialsView.AddViewRelationship( MaterialOC, true ); CswNbtViewProperty MaterialIdVP = UnapprovedMaterialsView.AddViewProperty( MatRel, MaterialIdProp ); MaterialIdVP.Order = 1; CswNbtViewProperty TradeNameVP = UnapprovedMaterialsView.AddViewProperty( MatRel, TradeNameProp ); TradeNameVP.Order = 2; CswNbtViewProperty SupplierVP = UnapprovedMaterialsView.AddViewProperty( MatRel, SupplierProp ); SupplierVP.Order = 3; CswNbtViewProperty PartNoVP = UnapprovedMaterialsView.AddViewProperty( MatRel, PartNoProp ); PartNoVP.Order = 4; CswNbtViewProperty CASNoVP = UnapprovedMaterialsView.AddViewProperty( MatRel, CASNoProp ); CASNoVP.Order = 5; CswNbtViewProperty PhysicalStateVP = UnapprovedMaterialsView.AddViewProperty( MatRel, PhysicalStateProp ); PhysicalStateVP.Order = 6; UnapprovedMaterialsView.AddViewPropertyAndFilter( MatRel, ApprovedForReceivingProp, CswEnumTristate.False.ToString(), FilterMode: CswEnumNbtFilterMode.Equals, ShowInGrid: false ); UnapprovedMaterialsView.save(); } // update()
private CswCommaDelimitedString _getMaterialPKsForEP(CswPrimaryKey EPId) { CswCommaDelimitedString EPMaterialPks = new CswCommaDelimitedString(); CswNbtMetaDataObjectClass ManufacturerEquivalentPartOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ManufacturerEquivalentPartClass); CswNbtMetaDataObjectClassProp EPOCP = ManufacturerEquivalentPartOC.getObjectClassProp(CswNbtObjClassManufacturerEquivalentPart.PropertyName.EnterprisePart); CswNbtMetaDataObjectClassProp ManufacturerOCP = ManufacturerEquivalentPartOC.getObjectClassProp(CswNbtObjClassManufacturerEquivalentPart.PropertyName.Manufacturer); CswNbtMetaDataObjectClass ManufacturerOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ManufacturerClass); CswNbtMetaDataObjectClassProp MaterialOCP = ManufacturerOC.getObjectClassProp(CswNbtObjClassManufacturer.PropertyName.Material); CswNbtView EPMatsView = new CswNbtView(_CswNbtResources); EPMatsView.ViewName = "Materials under " + EPId; CswNbtViewRelationship MEPVR = EPMatsView.AddViewRelationship(ManufacturerEquivalentPartOC, false); EPMatsView.AddViewPropertyAndFilter(MEPVR, EPOCP, SubFieldName: CswEnumNbtSubFieldName.NodeID, Value: EPId.PrimaryKey.ToString()); CswNbtViewRelationship ManufacturerVR = EPMatsView.AddViewRelationship(MEPVR, CswEnumNbtViewPropOwnerType.First, ManufacturerOCP, false); CswNbtViewRelationship MatVR = EPMatsView.AddViewRelationship(ManufacturerVR, CswEnumNbtViewPropOwnerType.First, MaterialOCP, false); ICswNbtTree EPMatsTree = _CswNbtResources.Trees.getTreeFromView(EPMatsView, false, true, true); for (int i = 0; i < EPMatsTree.getChildNodeCount(); i++) { EPMatsTree.goToNthChild(i); //EP's MEPs if (EPMatsTree.getChildNodeCount() > 0) { EPMatsTree.goToNthChild(0); //MEP's Manufacturer if (EPMatsTree.getChildNodeCount() > 0) { EPMatsTree.goToNthChild(0); //Manufacturer's Material EPMaterialPks.Add(EPMatsTree.getNodeIdForCurrentPosition().PrimaryKey.ToString()); EPMatsTree.goToParentNode(); } EPMatsTree.goToParentNode(); } EPMatsTree.goToParentNode(); } return(EPMaterialPks); }
private ICswNbtTree _getReportTree( string ReportName ) { CswNbtMetaDataObjectClass ReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ReportClass ); CswNbtMetaDataObjectClassProp ReportNameOCP = ReportOC.getObjectClassProp( CswNbtObjClassReport.PropertyName.ReportName ); CswNbtView ReportNodeView = _CswNbtSchemaModTrnsctn.makeView(); CswNbtViewRelationship root = ReportNodeView.AddViewRelationship( ReportOC, false ); ReportNodeView.AddViewPropertyAndFilter( root, ReportNameOCP, Value : ReportName, FilterMode : CswEnumNbtFilterMode.Equals ); return _CswNbtSchemaModTrnsctn.getTreeFromView( ReportNodeView, true ); }
public static void GetRelating(ICswResources CswResources, CswNbtExplorerRelatingReturn RelatingNodes, CswNbtExplorerRequest Req) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswNbtView view = new CswNbtView(NbtResources); if (Req.RelatingId.StartsWith("OC_")) { int ObjClassId = CswConvert.ToInt32(Req.RelatingId.Substring(Req.RelatingId.LastIndexOf('_') + 1)); CswNbtMetaDataObjectClass ObjClass = NbtResources.MetaData.getObjectClass(ObjClassId); CswNbtMetaDataObjectClassProp objectClassProp = ObjClass.getObjectClassProp(Req.RelatingPropId); CswNbtViewRelationship parent = view.AddViewRelationship(ObjClass, true); CswPrimaryKey pk = CswConvert.ToPrimaryKey(Req.NodeId); view.AddViewPropertyAndFilter(parent, objectClassProp, Value: pk.PrimaryKey.ToString(), SubFieldName: CswEnumNbtSubFieldName.NodeID); } else { int NtId = CswConvert.ToInt32(Req.RelatingId.Substring(Req.RelatingId.LastIndexOf('_') + 1)); CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType(NtId); CswNbtMetaDataNodeTypeProp ntp = NodeType.getNodeTypeProp(Req.RelatingPropId); CswNbtViewRelationship parent = view.AddViewRelationship(NodeType, true); CswPrimaryKey pk = CswConvert.ToPrimaryKey(Req.NodeId); view.AddViewPropertyAndFilter(parent, ntp, Value: pk.PrimaryKey.ToString(), SubFieldName: CswEnumNbtSubFieldName.NodeID); } ICswNbtTree tree = NbtResources.Trees.getTreeFromView(view, false, false, false); for (int i = 0; i < tree.getChildNodeCount(); i++) { tree.goToNthChild(i); CswNbtNodeKey nodeKey = tree.getNodeKeyForCurrentPosition(); string nodeName = tree.getNodeNameForCurrentPosition(); CswNbtMetaDataNodeType nodetype = NbtResources.MetaData.getNodeType(nodeKey.NodeTypeId); RelatingNodes.Data.Add(nodeName, nodeKey.NodeId, nodetype.NodeTypeName, string.Empty, string.Empty, string.Empty); tree.goToParentNode(); } }
public override void update() { // Create a demo mail report (notification) CswNbtMetaDataObjectClass UserOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.UserClass ); CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MailReportClass ); CswNbtMetaDataNodeType MailReportNT = MailReportOC.FirstNodeType; CswNbtMetaDataNodeTypeProp MailReportNameNTP = MailReportNT.getNodeTypeProp( "Name" ); CswNbtMetaDataNodeType UserNT = UserOC.FirstNodeType; CswNbtMetaDataNodeTypeProp UserLockedNTP = UserNT.getNodeTypePropByObjectClassProp( CswNbtObjClassUser.PropertyName.AccountLocked ); if( null != MailReportNT && null != UserNT ) { CswNbtObjClassMailReport MailReportNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( MailReportNT.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode ); if( null != MailReportNameNTP ) { MailReportNode.Node.Properties[MailReportNameNTP].AsText.Text = "Locked Users Notification"; } MailReportNode.OutputFormat.Value = "link"; MailReportNode.Type.Value = CswNbtObjClassMailReport.TypeOptionView; MailReportNode.Event.Value = CswNbtObjClassMailReport.EventOption.Edit.ToString(); MailReportNode.TargetType.SelectedNodeTypeIds.Add( UserNT.NodeTypeId.ToString() ); MailReportNode.Message.Text = "The following user accounts have been locked:"; MailReportNode.Enabled.Checked = Tristate.False; MailReportNode.IsDemo = true; CswRateInterval HourlyRate = _CswNbtSchemaModTrnsctn.makeRateInterval(); HourlyRate.setHourly( 1, DateTime.Now ); MailReportNode.DueDateInterval.RateInterval = HourlyRate; CswNbtObjClassUser AdminUser = _CswNbtSchemaModTrnsctn.Nodes.makeUserNodeFromUsername( "admin" ); if( null != AdminUser ) { MailReportNode.Recipients.AddUser( AdminUser.UserId ); } MailReportNode.postChanges( true ); CswNbtView ReportView = _CswNbtSchemaModTrnsctn.restoreView( MailReportNode.ReportView.ViewId ); ReportView.Root.ChildRelationships.Clear(); CswNbtViewRelationship UserRel = ReportView.AddViewRelationship( UserNT, false ); ReportView.AddViewPropertyAndFilter( UserRel, UserLockedNTP, Tristate.True.ToString() ); ReportView.save(); } // if( null != MailReportNT ) }//Update()
private void _updateInventoryLevelsView( CswNbtMetaDataNodeType MaterialNT ) { CswNbtMetaDataNodeTypeProp InventoryLevelsNTP = MaterialNT.getNodeTypeProp( "Inventory Levels" ); if( null != InventoryLevelsNTP ) { CswNbtMetaDataObjectClass InventoryLevelOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.InventoryLevelClass ); CswNbtMetaDataObjectClassProp MatOCP = InventoryLevelOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Material ); CswNbtMetaDataObjectClassProp TypeOCP = InventoryLevelOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Type ); CswNbtMetaDataObjectClassProp LevelOCP = InventoryLevelOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Level ); CswNbtMetaDataObjectClassProp LocationOCP = InventoryLevelOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Location ); CswNbtMetaDataObjectClassProp StatusOCP = InventoryLevelOC.getObjectClassProp( CswNbtObjClassInventoryLevel.PropertyName.Status ); CswNbtView InventoryLevelsView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( InventoryLevelsNTP.ViewId ); InventoryLevelsView.Root.ChildRelationships.Clear(); CswNbtViewRelationship RootRel = InventoryLevelsView.AddViewRelationship( MaterialPS, false ); CswNbtViewRelationship MatRel = InventoryLevelsView.AddViewRelationship( RootRel, CswEnumNbtViewPropOwnerType.Second, MatOCP, true ); InventoryLevelsView.AddViewProperty( MatRel, TypeOCP, 1 ); InventoryLevelsView.AddViewProperty( MatRel, LevelOCP, 2 ); InventoryLevelsView.AddViewProperty( MatRel, LocationOCP, 3 ); InventoryLevelsView.AddViewProperty( MatRel, StatusOCP, 4 ); InventoryLevelsView.save(); } }
public static void RunStructureSearch(ICswResources CswResources, StructureSearchDataReturn Return, StructureSearchViewData StructureSearchData) { CswNbtResources NbtResources = (CswNbtResources)CswResources; string molData = StructureSearchData.molString; bool exact = StructureSearchData.exact; Collection <CswPrimaryKey> results = new Collection <CswPrimaryKey>(); //If the DirectStructureSearch module is enabled, use AcclDirect to run a search. Otherwise use the legacy code if (NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch)) { DataTable resultsTbl = NbtResources.AcclDirect.RunStructureSearch(molData, exact); foreach (DataRow row in resultsTbl.Rows) { results.Add(new CswPrimaryKey("nodes", CswConvert.ToInt32(row["nodeid"]))); } } else { Dictionary <int, string> resultsDict = NbtResources.StructureSearchManager.RunSearch(molData, exact); foreach (int nodeidPk in resultsDict.Keys) { results.Add(new CswPrimaryKey("nodes", nodeidPk)); } } CswNbtView searchView = new CswNbtView(NbtResources); searchView.SetViewMode(CswEnumNbtViewRenderingMode.Table); searchView.Category = "Recent"; searchView.ViewName = "Structure Search Results"; if (results.Count > 0) { CswNbtMetaDataObjectClass materialOC = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass); CswNbtMetaDataObjectClassProp molCOP = materialOC.getObjectClassProp(CswNbtObjClassChemical.PropertyName.Structure); CswNbtViewRelationship parent = searchView.AddViewRelationship(materialOC, false); searchView.AddViewProperty(parent, molCOP); foreach (CswPrimaryKey nodeId in results) { parent.NodeIdsToFilterIn.Add(nodeId); } } searchView.SaveToCache(false); StructureSearchData.viewId = searchView.SessionViewId.ToString(); StructureSearchData.viewMode = searchView.ViewMode.ToString(); Return.Data = StructureSearchData; }
public void TogglePrintLabels(bool Hidden, CswEnumNbtModuleName Module) { CswNbtMetaDataObjectClass printLabelOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.PrintLabelClass); CswNbtMetaDataObjectClassProp nodetypesOCP = printLabelOC.getObjectClassProp(CswNbtObjClassPrintLabel.PropertyName.NodeTypes); CswNbtView printLabelsView = new CswNbtView(_CswNbtResources); CswNbtViewRelationship parent = printLabelsView.AddViewRelationship(printLabelOC, false); CswTableSelect childObjectClasses_TS = _CswNbtResources.makeCswTableSelect("getModuleChildren", "jct_modules_objectclass"); int moduleId = _CswNbtResources.Modules.GetModuleId(Module); DataTable childObjClasses_DT = childObjectClasses_TS.getTable("where moduleid = " + moduleId); bool first = true; foreach (DataRow Row in childObjClasses_DT.Rows) { int ObjClassId = CswConvert.ToInt32(Row["objectclassid"]); foreach (CswNbtMetaDataNodeType NodeType in _CswNbtResources.MetaData.getNodeTypes(ObjClassId)) { if (first) { printLabelsView.AddViewPropertyAndFilter(parent, nodetypesOCP, Value: NodeType.NodeTypeName, FilterMode: CswEnumNbtFilterMode.Contains); first = false; } else { printLabelsView.AddViewPropertyAndFilter(parent, nodetypesOCP, Value: NodeType.NodeTypeName, FilterMode: CswEnumNbtFilterMode.Contains, Conjunction: CswEnumNbtFilterConjunction.Or); } } } ICswNbtTree printLabelsTree = _CswNbtResources.Trees.getTreeFromView(printLabelsView, false, true, true); int childCount = printLabelsTree.getChildNodeCount(); for (int i = 0; i < childCount; i++) { printLabelsTree.goToNthChild(i); CswNbtNode printLabelNode = printLabelsTree.getNodeForCurrentPosition(); printLabelNode.Hidden = Hidden; printLabelNode.postChanges(false); printLabelsTree.goToParentNode(); } }
}//makeNodeFromNodeTypeId() /// <summary> /// Fetches a User Node from the Username, using a View and a TreeLoader. /// </summary> /// <remarks> /// not sure if this belongs here in CswNbtNodeCollection /// </remarks> /// <param name="Username">Username of User</param> /// <param name="RequireViewPermissions"></param> public CswNbtNode makeUserNodeFromUsername(string Username, bool RequireViewPermissions = true) { CswTimer Timer = new CswTimer(); CswNbtNode UserNode = null; CswNbtMetaDataObjectClass User_ObjectClass = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.UserClass); CswNbtMetaDataObjectClassProp UserName_ObjectClassProp = User_ObjectClass.getObjectClassProp(CswNbtObjClassUser.PropertyName.Username); _CswNbtResources.logTimerResult("makeUserNodeFromUsername 1", Timer); // generate the view CswNbtView View = new CswNbtView(_CswNbtResources); View.ViewName = "CswNbtNodes.makeUserNodeFromUsername(" + Username + ")"; CswNbtViewRelationship UserRelationship = View.AddViewRelationship(User_ObjectClass, false); CswNbtViewProperty Prop = View.AddViewProperty(UserRelationship, UserName_ObjectClassProp); CswNbtViewPropertyFilter Filter = View.AddViewPropertyFilter(Prop, CswNbtFieldTypeRuleText.SubFieldName.Text, CswEnumNbtFilterMode.Equals, Username, false); _CswNbtResources.logTimerResult("makeUserNodeFromUsername 2", Timer); // generate the tree ICswNbtTree UserTree = _CswNbtResources.Trees.getTreeFromView(View, RequireViewPermissions, true, IncludeHiddenNodes: true); _CswNbtResources.logTimerResult("makeUserNodeFromUsername 3", Timer); // get user node UserTree.goToRoot(); if (UserTree.getChildNodeCount() > 0) { UserTree.goToNthChild(0); _CswNbtResources.logTimerResult("makeUserNodeFromUsername 4", Timer); UserNode = UserTree.getNodeForCurrentPosition(); } //else //{ // foreach( CswNbtMetaDataNodeType UserNodeTypes in User_ObjectClass.NodeTypes ) // { // foreach( CswNbtNode user in UserNodeTypes.getNodes( true, false ) ) // { // if( user.Properties[UserName_ObjectClassProp.PropName].AsText.Text == Username ) // { // UserNode = user; // break; // } // } // } _CswNbtResources.logTimerResult("makeUserNodeFromUsername 5", Timer); return(UserNode); }
public override void update() { CswNbtMetaDataObjectClass VendorOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.VendorClass ); CswNbtMetaDataPropertySet MaterialPS = _CswNbtSchemaModTrnsctn.MetaData.getPropertySet( CswEnumNbtPropertySetName.MaterialSet ); CswNbtMetaDataObjectClass ManufacturerOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ManufacturerClass ); if( null == ManufacturerOC ) { ManufacturerOC = _CswNbtSchemaModTrnsctn.createObjectClass( CswEnumNbtObjectClass.ManufacturerClass, "box.png", true ); _CswNbtSchemaModTrnsctn.createModuleObjectClassJunction( CswEnumNbtModuleName.MLM, ManufacturerOC.ObjectClassId ); _CswNbtSchemaModTrnsctn.createObjectClassProp( ManufacturerOC, new CswNbtWcfMetaDataModel.ObjectClassProp( ManufacturerOC ) { PropName = CswNbtObjClassManufacturer.PropertyName.Material, FieldType = CswEnumNbtFieldType.Relationship, IsFk = true, FkType = CswEnumNbtViewRelatedIdType.PropertySetId.ToString(), FkValue = MaterialPS.PropertySetId, IsRequired = true } ); CswNbtView ManufacturingSiteView = _CswNbtSchemaModTrnsctn.makeView(); CswNbtViewRelationship parent = ManufacturingSiteView.AddViewRelationship( VendorOC, true ); CswNbtMetaDataObjectClassProp VendorTypeOCP = VendorOC.getObjectClassProp( CswNbtObjClassVendor.PropertyName.VendorTypeName ); ManufacturingSiteView.AddViewPropertyAndFilter( parent, MetaDataProp : VendorTypeOCP, Value : CswNbtObjClassVendor.VendorTypes.Manufacturing, FilterMode : CswEnumNbtFilterMode.Equals ); ManufacturingSiteView.Visibility = CswEnumNbtViewVisibility.Property; ManufacturingSiteView.ViewName = "Manufacturing Site"; _CswNbtSchemaModTrnsctn.createObjectClassProp( ManufacturerOC, new CswNbtWcfMetaDataModel.ObjectClassProp( ManufacturerOC ) { PropName = CswNbtObjClassManufacturer.PropertyName.ManufacturingSite, FieldType = CswEnumNbtFieldType.Relationship, IsFk = true, FkType = CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), FkValue = VendorOC.ObjectClassId, IsRequired = true, ViewXml = ManufacturingSiteView.ToString() } ); _CswNbtSchemaModTrnsctn.createObjectClassProp( ManufacturerOC, new CswNbtWcfMetaDataModel.ObjectClassProp( ManufacturerOC ) { PropName = CswNbtObjClassManufacturer.PropertyName.Qualified, FieldType = CswEnumNbtFieldType.Logical } ); } CswNbtMetaDataNodeType ManufacturerNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( new CswNbtWcfMetaDataModel.NodeType( ManufacturerOC ) { NodeTypeName = "Manufacturer", Category = "MLM" } ); } // update()
public override void update() { CswNbtMetaDataObjectClass VendorOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.VendorClass ); // For the existing vendor nodetype(s), set the default value of Internal to false. foreach( CswNbtMetaDataNodeType VendorNT in VendorOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp VendorInternalNTP = VendorNT.getNodeTypePropByObjectClassProp( CswNbtObjClassVendor.PropertyName.Internal ); VendorInternalNTP.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.DefaultValue].AsLogical.Checked = CswEnumTristate.False; VendorInternalNTP.DesignNode.postChanges( false ); // For all existing vendor nodes, set Internal to false. foreach( CswNbtObjClassVendor VendorNode in VendorNT.getNodes( false, true ) ) { VendorNode.Internal.Checked = CswEnumTristate.False; VendorNode.postChanges( false ); } } // Duplicate the existing Vendor nodetype, and name the new Vendor nodetype "Internal Vendor" CswNbtMetaDataNodeType FirstVendorNT = VendorOC.getNodeTypes().FirstOrDefault(); if( null != FirstVendorNT ) { CswNbtObjClassDesignNodeType NewVendorNTNode = FirstVendorNT.DesignNode.CopyNode( OnCopy: delegate( CswNbtNode CopiedNode ) { ( (CswNbtObjClassDesignNodeType) CopiedNode ).NodeTypeName.Text = "Internal Vendor"; } ); NewVendorNTNode.postChanges( false ); // For the new vendor nodetype, set the default value of Internal to true. CswNbtMetaDataNodeTypeProp VendorInternalNTP = NewVendorNTNode.RelationalNodeType.getNodeTypePropByObjectClassProp( CswNbtObjClassVendor.PropertyName.Internal ); VendorInternalNTP.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.DefaultValue].AsLogical.Checked = CswEnumTristate.True; VendorInternalNTP.DesignNode.postChanges( false ); } // Fix the default 'Vendors' view to use the Vendor object class instead of the nodetype. if( _CswNbtSchemaModTrnsctn.isMaster() ) { CswNbtView View = _CswNbtSchemaModTrnsctn.restoreView( "Vendors", CswEnumNbtViewVisibility.Global ); if( null != View ) { View.Root.ChildRelationships.Clear(); CswNbtViewRelationship rel1 = View.AddViewRelationship( VendorOC, true ); View.save(); } } } // update()
private CswNbtView _getReconciliationView(ContainerData.ReconciliationRequest Request) { Collection <CswPrimaryKey> LocationIds = _getLocationIds(Request); CswNbtMetaDataObjectClass LocationOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass); CswNbtMetaDataObjectClass ContainerOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerClass); CswNbtMetaDataObjectClassProp LocationOCP = ContainerOC.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Location); CswNbtMetaDataObjectClassProp DateCreatedOCP = ContainerOC.getObjectClassProp(CswNbtObjClassContainer.PropertyName.DateCreated); CswNbtMetaDataObjectClassProp DisposedOCP = ContainerOC.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Disposed); CswNbtMetaDataObjectClass ContainerLocationOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerLocationClass); CswNbtMetaDataObjectClassProp ContainerOCP = ContainerLocationOC.getObjectClassProp(CswNbtObjClassContainerLocation.PropertyName.Container); CswNbtMetaDataObjectClassProp ScanDateOCP = ContainerLocationOC.getObjectClassProp(CswNbtObjClassContainerLocation.PropertyName.ScanDate); CswNbtView ContainersView = new CswNbtView(_CswNbtResources); CswNbtViewRelationship LocationVR = ContainersView.AddViewRelationship(LocationOC, false); LocationVR.NodeIdsToFilterIn = LocationIds; CswNbtViewRelationship ContainerVR = ContainersView.AddViewRelationship(LocationVR, CswEnumNbtViewPropOwnerType.Second, LocationOCP, false); CswNbtViewProperty DateCreatedVP = ContainersView.AddViewProperty(ContainerVR, DateCreatedOCP); ContainersView.AddViewPropertyFilter(DateCreatedVP, FilterMode: CswEnumNbtFilterMode.LessThanOrEquals, Value: Request.EndDate); CswNbtViewProperty DisposedVP = ContainersView.AddViewProperty(ContainerVR, DisposedOCP); CswNbtViewRelationship ContainerLocationVR = ContainersView.AddViewRelationship(ContainerVR, CswEnumNbtViewPropOwnerType.Second, ContainerOCP, false); CswNbtViewProperty ScanDateVP = ContainersView.AddViewProperty(ContainerLocationVR, ScanDateOCP); if (CswConvert.ToDateTime(Request.StartDate) > CswConvert.ToDateTime(Request.EndDate)) { Request.StartDate = Request.EndDate; } ContainersView.AddViewPropertyFilter(ScanDateVP, FilterMode: CswEnumNbtFilterMode.GreaterThanOrEquals, Value: Request.StartDate); ContainersView.AddViewPropertyFilter(ScanDateVP, FilterMode: CswEnumNbtFilterMode.LessThanOrEquals, Value: Request.EndDate); ContainersView.setSortProperty(ScanDateVP, CswEnumNbtViewPropertySortMethod.Descending); return(ContainersView); }
private ICswNbtTree _getRelatedRequestItemsTree(string FilterByStatus = null) { CswNbtView RequestItemView = new CswNbtView(_CswNbtResources); CswNbtMetaDataObjectClass RequestOc = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestClass); CswNbtViewRelationship RootVr = RequestItemView.AddViewRelationship(RequestOc, IncludeDefaultFilters: false); RootVr.NodeIdsToFilterIn.Add(this.NodeId); CswNbtMetaDataObjectClass RequestItemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass); CswNbtMetaDataObjectClassProp RequestOCP = RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.Request); CswNbtViewRelationship RequestItemVR = RequestItemView.AddViewRelationship(RootVr, CswEnumNbtViewPropOwnerType.Second, RequestOCP, IncludeDefaultFilters: false); if (false == string.IsNullOrEmpty(FilterByStatus)) { RequestItemView.AddViewPropertyAndFilter(RequestItemVR, RequestItemOC.getObjectClassProp(CswNbtObjClassRequestItem.PropertyName.Status), FilterByStatus.ToString(), FilterMode: CswEnumNbtFilterMode.Equals); } ICswNbtTree RequestItemTree = _CswNbtResources.Trees.getTreeFromView(RequestItemView, IncludeSystemNodes: false, RequireViewPermissions: false, IncludeHiddenNodes: false); return(RequestItemTree); }