public Collection<string> getCASNumbers() { Collection<string> ret = new Collection<string>(); CswNbtMetaDataObjectClass RegListCasNoOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListCasNoClass ); CswNbtMetaDataObjectClassProp RegListCasNoCasNoOCP = RegListCasNoOC.getObjectClassProp( CswNbtObjClassRegulatoryListCasNo.PropertyName.CASNo ); CswNbtMetaDataObjectClassProp RegListCasNoRegListOCP = RegListCasNoOC.getObjectClassProp( CswNbtObjClassRegulatoryListCasNo.PropertyName.RegulatoryList ); CswNbtView View = new CswNbtView( _CswNbtResources ); View.ViewName = "Reglist_getCASNumbers"; CswNbtViewRelationship casnoRel = View.AddViewRelationship( RegListCasNoOC, false ); View.AddViewProperty( casnoRel, RegListCasNoCasNoOCP ); View.AddViewPropertyAndFilter( casnoRel, RegListCasNoRegListOCP, SubFieldName: CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID, FilterMode: CswEnumNbtFilterMode.Equals, Value: this.NodeId.PrimaryKey.ToString() ); ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView( View, RequireViewPermissions: false, IncludeSystemNodes: true, IncludeHiddenNodes: true ); for( Int32 i = 0; i < Tree.getChildNodeCount(); i++ ) { Tree.goToNthChild( i ); CswNbtTreeNodeProp casnoTreeProp = Tree.getChildNodePropsOfNode().FirstOrDefault( p => p.ObjectClassPropName == RegListCasNoCasNoOCP.PropName ); if( null != casnoTreeProp ) { ret.Add( casnoTreeProp[( (CswNbtFieldTypeRuleCASNo) RegListCasNoCasNoOCP.getFieldTypeRule() ).TextSubField.Column] ); } Tree.goToParentNode(); } return ret; } // getCASNumbers()
}//_getLocationsView() private void _iterateTree(ICswNbtTree Tree, CswPrimaryKey SelectedNodeId) { CswNbtMetaDataObjectClass LocationOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass); CswNbtMetaDataObjectClassProp LocationNameOCP = LocationOC.getObjectClassProp(CswNbtObjClassLocation.PropertyName.Name); CswNbtMetaDataObjectClassProp LocationFullPathOCP = LocationOC.getObjectClassProp(CswNbtObjClassLocation.PropertyName.FullPath); for (Int32 c = 0; c < Tree.getChildNodeCount(); c += 1) { Tree.goToNthChild(c); Location LocationObj = new Location(); CswNbtTreeNodeProp nameTreeProp = Tree.getChildNodePropsOfNode().FirstOrDefault(p => p.ObjectClassPropName == LocationNameOCP.PropName); CswNbtTreeNodeProp fullPathTreeProp = Tree.getChildNodePropsOfNode().FirstOrDefault(p => p.ObjectClassPropName == LocationFullPathOCP.PropName); LocationObj.Path = fullPathTreeProp.Field1; LocationObj.Name = nameTreeProp.Field1; LocationObj.LocationId = Tree.getNodeIdForCurrentPosition().ToString(); LocationObj.Selected = (Tree.getNodeIdForCurrentPosition() == SelectedNodeId); LocationObj.Disabled = (false == Tree.getNodeIncludedForCurrentPosition()); _LocationCollection.Add(LocationObj); if (Tree.getChildNodeCount() > 0) { _iterateTree(Tree, SelectedNodeId); } Tree.goToParentNode(); } } //_iterateTree()
public static string getAssignedSDSDocumentUrl( CswNbtResources _CswNbtResources, CswPrimaryKey MaterialId ) { string url = ""; if( _CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.SDS ) ) { CswNbtMetaDataObjectClass SDSDocOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.SDSDocumentClass ); CswNbtMetaDataNodeType SDSDocumentNT = SDSDocOC.FirstNodeType; CswNbtView docView = getAssignedSDSDocumentsView( _CswNbtResources, MaterialId ); // We need to re-add these properties because they were removed from the 'Assigned SDS' view in Case 31223 CswNbtMetaDataNodeTypeProp LinkNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.Link ); docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], LinkNTP ); CswNbtMetaDataNodeTypeProp FileNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.File ); docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], FileNTP ); CswNbtMetaDataNodeTypeProp FileTypeNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.FileType ); docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], FileTypeNTP ); // If ChemWatch is enabled, we need to check for this type of file too if( _CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.ChemWatch ) ) { CswNbtMetaDataNodeTypeProp ChemWatchNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( PropertyName.ChemWatch ); docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], ChemWatchNTP ); } CswNbtObjClassUser currentUserNode = _CswNbtResources.Nodes[_CswNbtResources.CurrentNbtUser.UserId]; CswNbtObjClassJurisdiction userJurisdictionNode = _CswNbtResources.Nodes[currentUserNode.JurisdictionProperty.RelatedNodeId]; ICswNbtTree docsTree = _CswNbtResources.Trees.getTreeFromView( docView, false, false, false ); docsTree.goToNthChild( 0 ); //This is a property view, so the data is on the 2nd level int childCount = docsTree.getChildNodeCount(); int lvlMatched = Int32.MinValue; string matchedFileType = ""; CswNbtTreeNodeProp matchedFileProp = null; CswNbtTreeNodeProp matchedLinkProp = null; CswNbtTreeNodeProp matchedChemWatchProp = null; CswPrimaryKey matchedNodeId = null; if( childCount > 0 ) { for( int i = 0; i < childCount; i++ ) { docsTree.goToNthChild( i ); string format = ""; string language = ""; string fileType = ""; CswNbtTreeNodeProp fileProp = null; CswNbtTreeNodeProp linkProp = null; CswNbtTreeNodeProp chemWatchProp = null; CswPrimaryKey nodeId = docsTree.getNodeIdForCurrentPosition(); foreach( CswNbtTreeNodeProp prop in docsTree.getChildNodePropsOfNode() ) { CswNbtMetaDataNodeTypeProp docNTP = _CswNbtResources.MetaData.getNodeTypeProp( prop.NodeTypePropId ); switch( docNTP.getObjectClassPropName() ) { case PropertyName.Format: format = prop.Field1; break; case PropertyName.Language: language = prop.Field1; break; case PropertyName.FileType: fileType = prop.Field1; break; case PropertyName.File: fileProp = prop; break; case PropertyName.Link: linkProp = prop; break; case PropertyName.ChemWatch: chemWatchProp = prop; break; } } if( lvlMatched < 0 ) { matchedFileType = fileType; matchedFileProp = fileProp; matchedLinkProp = linkProp; matchedChemWatchProp = chemWatchProp; matchedNodeId = nodeId; lvlMatched = 0; } if( null != userJurisdictionNode ) { if( lvlMatched < 1 && format.Equals( userJurisdictionNode.Format.Value ) ) { matchedFileType = fileType; matchedFileProp = fileProp; matchedLinkProp = linkProp; matchedChemWatchProp = chemWatchProp; matchedNodeId = nodeId; lvlMatched = 1; } if( lvlMatched < 2 && language.Equals( currentUserNode.Language ) ) { matchedFileType = fileType; matchedFileProp = fileProp; matchedLinkProp = linkProp; matchedChemWatchProp = chemWatchProp; matchedNodeId = nodeId; lvlMatched = 2; } if( lvlMatched < 3 && format.Equals( userJurisdictionNode.Format.Value ) && language.Equals( currentUserNode.Language ) ) { matchedFileType = fileType; matchedFileProp = fileProp; matchedLinkProp = linkProp; matchedChemWatchProp = chemWatchProp; matchedNodeId = nodeId; lvlMatched = 3; } } docsTree.goToParentNode(); } switch( matchedFileType ) { case CswEnumDocumentFileTypes.File: int jctnodepropid = CswConvert.ToInt32( matchedFileProp.JctNodePropId ); url = CswNbtNodePropBlob.getLink( jctnodepropid, matchedNodeId ); break; case CswEnumDocumentFileTypes.Link: CswNbtMetaDataNodeTypeProp linkNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( PropertyName.Link ); //url = CswNbtNodePropLink.GetFullURL( linkNTP.Attribute1, matchedLinkProp.Field1_Big, linkNTP.Attribute2 ); url = CswNbtNodePropLink.GetFullURL( linkNTP.DesignNode.getAttributeValueByColumn( CswEnumNbtPropertyAttributeColumn.Attribute1 ), matchedLinkProp.Field1_Big, linkNTP.DesignNode.getAttributeValueByColumn( CswEnumNbtPropertyAttributeColumn.Attribute2 ) ); break; case CswEnumDocumentFileTypes.ChemWatch: url = "Services/ChemWatch/GetSDSDocument?filename=" + matchedChemWatchProp.Field1; break; } } } return url; }
public ContainerData getContainerStatistics(ContainerData.ReconciliationRequest Request) { for (int i = 0; i < CswEnumNbtContainerLocationStatusOptions._All.Count(); i++) { Data.ContainerStatistics.Add(new ContainerData.ReconciliationStatistics()); Data.ContainerStatistics[i].ContainerCount = 0; Data.ContainerStatistics[i].AmountScanned = 0; Data.ContainerStatistics[i].Status = CswEnumNbtContainerLocationStatusOptions._All.ToArray()[i].ToString(); } _setContainersTree(Request); if (ContainersTree.getChildNodeCount() > 0) { Collection <CswPrimaryKey> AllLocationIds = new Collection <CswPrimaryKey>(); Collection <CswPrimaryKey> ScannedLocationIds = new Collection <CswPrimaryKey>(); for (int i = 0; i < ContainersTree.getChildNodeCount(); i++) //Location Nodes { ContainersTree.goToNthChild(i); AllLocationIds.Add(ContainersTree.getNodeIdForCurrentPosition()); if (ContainersTree.getChildNodeCount() > 0) { for (int j = 0; j < ContainersTree.getChildNodeCount(); j++) //Container Nodes { ContainersTree.goToNthChild(j); CswNbtTreeNodeProp DisposedProp = ContainersTree.getChildNodePropsOfNode().FirstOrDefault(p => p.ObjectClassPropName == CswNbtObjClassContainer.PropertyName.Disposed); if (ContainersTree.getChildNodeCount() > 0) //ContainerLocation Nodes { CswNbtObjClassContainerLocation ContainerLocationNode = _getMostRelevantContainerLocation(); if (null != ContainerLocationNode && _isTypeEnabled(ContainerLocationNode.Type.Value, Request)) { _incrementContainerCount(Data.ContainerStatistics, ContainerLocationNode.Status.Value, ContainerLocationNode.Type.Value); if (ContainerLocationNode.Type.Value == CswEnumNbtContainerLocationTypeOptions.ReconcileScans.ToString()) { ScannedLocationIds.Add(ContainerLocationNode.Location.SelectedNodeId); } } else if (null != DisposedProp && false == CswConvert.ToBoolean(DisposedProp.Field1)) { _incrementContainerCount(Data.ContainerStatistics, CswEnumNbtContainerLocationStatusOptions.NotScanned.ToString()); } } else { _incrementContainerCount(Data.ContainerStatistics, CswEnumNbtContainerLocationStatusOptions.NotScanned.ToString()); } ContainersTree.goToParentNode(); } } ContainersTree.goToParentNode(); } if (_isTypeEnabled(CswEnumNbtContainerLocationTypeOptions.ReconcileScans.ToString(), Request)) { foreach (CswPrimaryKey LocationId in AllLocationIds) { if (false == ScannedLocationIds.Contains(LocationId)) { Data.UnscannedLocations.Add(_makeUnscannedLocation(LocationId)); } } } } foreach (CswNbtObjClassContainerLocation OutOfScopeScan in _getRelevantScansOutsideLocationScope(Request).Values) { _incrementContainerCount(Data.ContainerStatistics, CswEnumNbtContainerLocationStatusOptions.WrongLocation.ToString()); } foreach (ContainerData.ReconciliationStatistics Stat in Data.ContainerStatistics) { if (Stat.ContainerCount > 0) { Stat.PercentScanned = CswConvert.ToDouble(Stat.AmountScanned) / CswConvert.ToDouble(Stat.ContainerCount) * 100.0; } else { Stat.PercentScanned = 0.0; } } return(Data); }
} // getCASNumbers() /// <summary> /// Returns a collection of matching Regulatory List primary keys, based on the provided cas numbers /// </summary> public static Collection<CswPrimaryKey> findMatches( CswNbtResources CswNbtResources, Collection<string> CasNos ) { Collection<CswPrimaryKey> ret = new Collection<CswPrimaryKey>(); if( CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.RegulatoryLists ) ) { CswNbtMetaDataObjectClass RegulatoryListOC = CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListClass ); CswNbtMetaDataObjectClass RegListCasNoOC = CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListCasNoClass ); if( null != RegulatoryListOC && null != RegListCasNoOC ) { CswNbtMetaDataObjectClassProp RegListExclusiveOCP = RegulatoryListOC.getObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.Exclusive ); CswNbtMetaDataObjectClassProp RegListCasNoCasNoOCP = RegListCasNoOC.getObjectClassProp( CswNbtObjClassRegulatoryListCasNo.PropertyName.CASNo ); Collection<CswPrimaryKey> ExclusiveMatches = new Collection<CswPrimaryKey>(); // find matches if( CasNos.Count > 0 ) { #region Manually Managed Reg Lists CswNbtView View = new CswNbtView( CswNbtResources ); View.ViewName = "Reglist_findMatches"; CswNbtViewRelationship casnoRel = View.AddViewRelationship( RegListCasNoOC, false ); CswNbtViewProperty casnoVP = View.AddViewProperty( casnoRel, RegListCasNoCasNoOCP ); foreach( string cas in CasNos ) { View.AddViewPropertyFilter( casnoVP, Conjunction: CswEnumNbtFilterConjunction.Or, FilterMode: CswEnumNbtFilterMode.Equals, Value: cas ); } CswNbtViewRelationship regListRel = View.AddViewRelationship( casnoRel, CswEnumNbtViewPropOwnerType.First, RegListCasNoOC.getObjectClassProp( CswNbtObjClassRegulatoryListCasNo.PropertyName.RegulatoryList ), false ); View.AddViewProperty( regListRel, RegListExclusiveOCP ); ICswNbtTree Tree = CswNbtResources.Trees.getTreeFromView( View, RequireViewPermissions: false, IncludeSystemNodes: true, IncludeHiddenNodes: true ); for( Int32 i = 0; i < Tree.getChildNodeCount(); i++ ) // RegListCasNo { Tree.goToNthChild( i ); for( Int32 j = 0; j < Tree.getChildNodeCount(); j++ ) // RegList { Tree.goToNthChild( j ); CswPrimaryKey thisRegListId = Tree.getNodeIdForCurrentPosition(); CswNbtTreeNodeProp exclusiveTreeProp = Tree.getChildNodePropsOfNode().FirstOrDefault( p => p.ObjectClassPropName == RegListExclusiveOCP.PropName ); if( null != exclusiveTreeProp ) { CswEnumTristate thisExclusive = CswConvert.ToTristate( exclusiveTreeProp[( (CswNbtFieldTypeRuleLogical) RegListExclusiveOCP.getFieldTypeRule() ).CheckedSubField.Column] ); if( CswEnumTristate.True == thisExclusive ) { ExclusiveMatches.Add( thisRegListId ); } else { ret.Add( thisRegListId ); } } Tree.goToParentNode(); } // for( Int32 j = 0; j < Tree.getChildNodeCount(); j++ ) // RegList Tree.goToParentNode(); } // for( Int32 i = 0; i < Tree.getChildNodeCount(); i++ ) // RegListCasNo #endregion Manually Managed Reg Lists #region Regulation Database Managed Reg Lists string SyncModule = string.Empty; if( CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.LOLISync ) ) { SyncModule = CswEnumRegulatoryListListModes.LOLIManaged; } else if( CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.ArielSync ) ) { SyncModule = CswEnumRegulatoryListListModes.ArielManaged; } if( false == string.IsNullOrEmpty( SyncModule ) ) //at least one of LOLISync or ArielSync is enabled { CswNbtMetaDataObjectClass RegListListCodeOC = CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListListCodeClass ); if( null != RegListListCodeOC ) { CswNbtMetaDataObjectClassProp RegListListCodeListCodeOCP = RegListListCodeOC.getObjectClassProp( CswNbtObjClassRegulatoryListListCode.PropertyName.ListCode ); CswNbtMetaDataObjectClassProp RegListListCodeRegulatoryListOCP = RegListListCodeOC.getObjectClassProp( CswNbtObjClassRegulatoryListListCode.PropertyName.RegulatoryList ); CswNbtMetaDataObjectClassProp RegListListModeOCP = RegulatoryListOC.getObjectClassProp( PropertyName.ListMode ); // Get all regulation db managed regulatory lists CswNbtView View1 = new CswNbtView( CswNbtResources ); View1.ViewName = "RegLists_RegDbManaged"; CswNbtViewRelationship ParentRelationship = View1.AddViewRelationship( RegulatoryListOC, false ); View1.AddViewPropertyAndFilter( ParentViewRelationship: ParentRelationship, MetaDataProp: RegListListModeOCP, Value: SyncModule, //sync module that is enabled SubFieldName: CswNbtFieldTypeRuleList.SubFieldName.Value, FilterMode: CswEnumNbtFilterMode.Equals ); CswNbtViewRelationship SecondaryRelationship = View1.AddViewRelationship( ParentRelationship, CswEnumNbtViewPropOwnerType.Second, RegListListCodeRegulatoryListOCP, false ); View1.AddViewProperty( SecondaryRelationship, RegListListCodeListCodeOCP ); // Dictionary that stores the Regions and List Codes for each Regulatory List Dictionary<CswPrimaryKey, Tuple<string, List<string>>> RegListListCodes = new Dictionary<CswPrimaryKey, Tuple<string, List<string>>>(); // Get and iterate the Tree ICswNbtTree Tree1 = CswNbtResources.Trees.getTreeFromView( View1, false, true, true ); for( Int32 i = 0; i < Tree1.getChildNodeCount(); i++ ) // Regulatory List Nodes { Tree1.goToNthChild( i ); List<string> CurrentListCodes = new List<string>(); CswNbtObjClassRegulatoryList CurrentRegListNode = Tree1.getCurrentNode(); CswPrimaryKey CurrentRegListPk = CurrentRegListNode.NodeId; string CurrentRegListRegions = ""; if( string.IsNullOrEmpty( CswConvert.ToString( CurrentRegListNode.Regions.Value ) ) ) { if( SyncModule.Equals( CswEnumRegulatoryListListModes.ArielManaged ) ) { CurrentRegListRegions = CswNbtResources.ConfigVbls.getConfigVariableValue( CswConvert.ToString( CswEnumNbtConfigurationVariables.arielmodules ) ); } } else { CurrentRegListRegions = CswConvert.ToString( CurrentRegListNode.Regions.Value ); } for( int j = 0; j < Tree1.getChildNodeCount(); j++ ) // Regulatory List List Code Nodes { Tree1.goToNthChild( j ); CswNbtTreeNodeProp ListCodeTreeProp = null; foreach( CswNbtTreeNodeProp currentTnp in Tree1.getChildNodePropsOfNode() ) { if( currentTnp.ObjectClassPropName == RegListListCodeListCodeOCP.PropName ) { ListCodeTreeProp = currentTnp; break; } } if( null != ListCodeTreeProp ) { CurrentListCodes.Add( CswConvert.ToString( ListCodeTreeProp.Field1 ) ); } Tree1.goToParentNode(); } // Add to the dictionary RegListListCodes.Add( CurrentRegListPk, new Tuple<string, List<string>>( CurrentRegListRegions, CurrentListCodes ) ); Tree1.goToParentNode(); } // Search the regulation database foreach( string CurrentCasNo in CasNos ) { foreach( KeyValuePair<CswPrimaryKey, Tuple<string, List<string>>> Pair in RegListListCodes ) { CswC3SearchParams CswC3SearchParams = new CswC3SearchParams(); CswNbtC3ClientManager CswNbtC3ClientManager = new CswNbtC3ClientManager( CswNbtResources, CswC3SearchParams ); SearchClient C3SearchClient = CswNbtC3ClientManager.initializeC3Client(); if( null != C3SearchClient ) { string ListCodes = string.Join( ",", Pair.Value.Item2.ToArray() ); string Regions = Pair.Value.Item1; CswC3SearchParams.Query = CurrentCasNo; // Query takes the Cas Number CswC3SearchParams.ListCodes = ListCodes; // ListCodes should be a comma delimited string of all list codes CswC3SearchParams.Regions = Regions; // String list of all regions (for Ariel) CswC3SearchParams.RegulationDatabase = CswNbtC3ClientManager.RegulationDatabase; // Which Regulation Database to search CswRetObjSearchResults SearchResults = C3SearchClient.getListCodesByCasNo( CswC3SearchParams ); if( null != SearchResults.RegulationDbDataResults ) { if( SearchResults.RegulationDbDataResults.Length > 0 ) { // If at least one list code was returned, add this regulatory list id to the list of matching reg lists ret.Add( Pair.Key ); } } } } //foreach( KeyValuePair<CswPrimaryKey, List<string>> Pair in RegListListCodes ) } //foreach( string CurrentCasNo in CasNos ) }//if (null != RegListListCodeOC) }//if (CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.LOLISync)) #endregion Regulation Database Managed Reg Lists } // if( CasNos.Count > 0 ) // find exclusive lists that didn't match { CswNbtView exclusiveView = new CswNbtView( CswNbtResources ); CswNbtViewRelationship regListRel = exclusiveView.AddViewRelationship( RegulatoryListOC, false ); regListRel.NodeIdsToFilterOut = ExclusiveMatches; exclusiveView.AddViewPropertyAndFilter( regListRel, RegListExclusiveOCP, Value: CswEnumTristate.True.ToString() ); ICswNbtTree Tree = CswNbtResources.Trees.getTreeFromView( exclusiveView, RequireViewPermissions: false, IncludeSystemNodes: true, IncludeHiddenNodes: true ); for( Int32 i = 0; i < Tree.getChildNodeCount(); i++ ) { Tree.goToNthChild( i ); ret.Add( Tree.getNodeIdForCurrentPosition() ); Tree.goToParentNode(); } } // exclusive } // if( null != RegulatoryListOC && null != RegListCasNoOC ) } // if( CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.RegulatoryLists ) ) return ret; } // findMatches()
/// <summary> /// Create a dictionary of the unique key values of related nodes /// As a side effect, also populate MergeInfoData.NodePair.NodeReferences /// </summary> private Dictionary <CswDelimitedString, CswPrimaryKey> _getUniqueKeysDict(MergeInfoData.MergeInfoNodePair NodePair, CswNbtNode Node, CswNbtMetaDataNodeTypeProp NodeReferenceProp) { Dictionary <CswDelimitedString, CswPrimaryKey> ret = new Dictionary <CswDelimitedString, CswPrimaryKey>(); char delimiter = '|'; // Find unique properties for this reference's nodetype IEnumerable <CswNbtMetaDataNodeTypeProp> UniqueProps = NodeReferenceProp.getNodeType().getUniqueProps(); // Create a view of nodes that point to the target node via this reference CswNbtView view = new CswNbtView(_CswNbtResources); CswNbtViewRelationship rel1 = view.AddViewRelationship(Node.getNodeType(), false); rel1.NodeIdsToFilterIn.Add(Node.NodeId); CswNbtViewRelationship rel2 = view.AddViewRelationship(rel1, CswEnumNbtViewPropOwnerType.Second, NodeReferenceProp, false); foreach (CswNbtMetaDataNodeTypeProp uniqueProp in UniqueProps) { view.AddViewProperty(rel2, uniqueProp); } // Iterate children and store unique property values in a dictionary key ICswNbtTree tree = _CswNbtResources.Trees.getTreeFromView(view, RequireViewPermissions: false, IncludeHiddenNodes: true, IncludeSystemNodes: true); if (tree.getChildNodeCount() > 0) { tree.goToNthChild(0); for (Int32 c = 0; c < tree.getChildNodeCount(); c++) { tree.goToNthChild(c); CswPrimaryKey thisNodeId = tree.getNodeIdForCurrentPosition(); // Populate MergeInfoData.NodePair.NodeReferences while we're here NodePair.NodeReferences.Add(new MergeInfoData.MergeInfoNodeReference() { NodeId = thisNodeId.ToString(), NodeTypePropId = NodeReferenceProp.PropId }); CswDelimitedString key; if (_AllUniqueKeys.ContainsKey(thisNodeId)) { // If we've seen this node before, use the existing key but override the merge property // (this will allow us to merge correctly if a nodetype has // multiple compound unique references that are all involved in the merge) key = _AllUniqueKeys[thisNodeId]; for (Int32 u = 0; u < UniqueProps.Count(); u++) { if (UniqueProps.ElementAt(u).PropId == NodeReferenceProp.PropId) { // This value will be equal after the merge key[u] = "[mergeresult]"; } } // foreach( CswNbtMetaDataNodeTypeProp uniqueProp in UniqueProps ) } // if( _AllUniqueKeys.ContainsKey( thisNodeId ) ) else { // generate a new key key = new CswDelimitedString(delimiter); foreach (CswNbtMetaDataNodeTypeProp uniqueProp in UniqueProps) { CswNbtTreeNodeProp prop = tree.getChildNodePropsOfNode().FirstOrDefault(p => p.NodeTypePropId == uniqueProp.PropId); if (null != prop) { if (prop.NodeTypePropId == NodeReferenceProp.PropId) { // This value will be equal after the merge key.Add("[mergeresult]"); } else { key.Add(prop.Gestalt); } } else { key.Add(""); } } // foreach( CswNbtMetaDataNodeTypeProp uniqueProp in UniqueProps ) } // if-else( _AllUniqueKeys.ContainsKey( thisNodeId ) ) if (key.Count > 0) { ret.Add(key, thisNodeId); _AllUniqueKeys[thisNodeId] = key; } tree.goToParentNode(); } // for( Int32 c = 0; c < tree.getChildNodeCount(); c++ ) } // if( tree.getChildNodeCount() > 0 ) return(ret); } // _getUniqueKeysDict()