public override void ReadJSON(JObject JObject, Dictionary <Int32, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap) { if (null != JObject[_CheckedSubField.ToXmlNodeName(true)]) { Checked = CswConvert.ToTristate(JObject[_CheckedSubField.ToXmlNodeName(true)].ToString(), Required); } }
public void ToggleProp(CswNbtMetaDataNodeTypeProp NodeTypeProp, bool Hidden) { if (null != NodeTypeProp) { NodeTypeProp.DesignNode.Hidden.Checked = CswConvert.ToTristate(Hidden); } }
public static JObject getSizeNodeProps(CswNbtResources CswNbtResources, Int32 SizeNodeTypeId, JObject SizeObj, bool WriteNode, out CswNbtNode SizeNode, CswPrimaryKey MaterialId = null) { JObject Ret = new JObject(); SizeNode = CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNodeTypeId, OverrideUniqueValidation: true); string UoMId = SizeObj["uom"]["id"].ToString(); // CIS-53182: Preventative measure against the uomid being empty from client if (null != MaterialId && string.IsNullOrEmpty(UoMId) && false == string.IsNullOrEmpty(SizeObj["uom"]["value"].ToString())) { // Try to find the id for the unit of measure CswNbtUnitViewBuilder UnitViewBuilder = new CswNbtUnitViewBuilder(CswNbtResources); CswNbtView UnitsView = UnitViewBuilder.getQuantityUnitOfMeasureView(MaterialId); ICswNbtTree UnitTree = CswNbtResources.Trees.getTreeFromView(UnitsView, false, false, false); for (int i = 0; i < UnitTree.getChildNodeCount(); i++) { UnitTree.goToNthChild(i); if (UnitTree.getNodeNameForCurrentPosition().Equals(SizeObj["uom"]["value"].ToString())) { UoMId = UnitTree.getNodeIdForCurrentPosition().ToString(); } } } CswPrimaryKey UnitIdPK = CswConvert.ToPrimaryKey(UoMId); if (null != UnitIdPK) { SizeNode = CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNodeTypeId, delegate(CswNbtNode NewNode) { CswNbtObjClassSize NodeAsSize = (CswNbtObjClassSize)NewNode; NodeAsSize.InitialQuantity.Quantity = CswConvert.ToDouble(SizeObj["quantity"]["value"]); NodeAsSize.InitialQuantity.UnitId = UnitIdPK; NodeAsSize.CatalogNo.Text = SizeObj["catalogNo"]["value"].ToString(); NodeAsSize.QuantityEditable.Checked = CswConvert.ToTristate(SizeObj["quantityEditable"]["value"]); NodeAsSize.Dispensable.Checked = CswConvert.ToTristate(SizeObj["dispensible"]["value"]); NodeAsSize.UnitCount.Value = CswConvert.ToDouble(SizeObj["unitCount"]["value"]); NodeAsSize.Material.RelatedNodeId = MaterialId; }); } else { SizeNode = null; } return(Ret); }
public override void update() { CswNbtMetaDataObjectClass DesignNtpOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignNodeTypePropClass ); foreach( CswNbtMetaDataNodeType DesignNtpNT in DesignNtpOC.getNodeTypes() ) { // Set existing values of hidden foreach( CswNbtObjClassDesignNodeTypeProp DesignNtpNode in DesignNtpNT.getNodes( false, true ) ) { DesignNtpNode.Hidden.Checked = CswConvert.ToTristate( DesignNtpNode.RelationalNodeTypeProp.Hidden ); DesignNtpNode.postChanges( false ); } // Fix layout CswNbtMetaDataNodeTypeProp HiddenNTP = DesignNtpNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignNodeTypeProp.PropertyName.Hidden ); CswNbtMetaDataNodeTypeProp ReadOnlyNTP = DesignNtpNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignNodeTypeProp.PropertyName.ReadOnly ); _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswEnumNbtLayoutType.Edit, HiddenNTP, ReadOnlyNTP, true ); } // Synchronize property with nodetype_props.hidden CswTableUpdate jctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "51775_jctddntp_update", "jct_dd_ntp" ); DataTable jctTable = jctUpdate.getEmptyTable(); foreach( CswNbtMetaDataNodeType DesignNtpNT in DesignNtpOC.getNodeTypes() ) { _CswNbtSchemaModTrnsctn.CswDataDictionary.setCurrentColumn( "nodetype_props", "hidden" ); CswNbtMetaDataNodeTypeProp HiddenNTP = DesignNtpNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignNodeTypeProp.PropertyName.Hidden ); DataRow NodeTypeNameRow = jctTable.NewRow(); NodeTypeNameRow["nodetypepropid"] = HiddenNTP.PropId; NodeTypeNameRow["datadictionaryid"] = _CswNbtSchemaModTrnsctn.CswDataDictionary.TableColId; if( null != HiddenNTP.getFieldTypeRule().SubFields.Default ) { NodeTypeNameRow["subfieldname"] = HiddenNTP.getFieldTypeRule().SubFields.Default.Name; } jctTable.Rows.Add( NodeTypeNameRow ); } jctUpdate.update( jctTable ); // make Request module require the Multi-Inventory-Group module _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql( @"update modules set prereq = (select moduleid from modules where name = '" + CswEnumNbtModuleName.MultiInventoryGroup + @"') where name = '" + CswEnumNbtModuleName.Requesting + @"'" ); } // update()
private void _createInventoryGroupPermission( CswNbtObjClassRole Role, Tristate Request, Tristate Receive ) { CswNbtMetaDataNodeType InventoryGroupPermissionNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Inventory Group Permission" ); if( InventoryGroupPermissionNT != null && InventoryGroupNode != null ) { CswNbtObjClassInventoryGroupPermission InvGrpPermNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( InventoryGroupPermissionNT.NodeTypeId, CswNbtNodeCollection.MakeNodeOperation.WriteNode ); InvGrpPermNode.InventoryGroup.RelatedNodeId = InventoryGroupNode.NodeId; InvGrpPermNode.Role.RelatedNodeId = Role.NodeId; //WorkUnit? InvGrpPermNode.View.Checked = Tristate.True; InvGrpPermNode.Edit.Checked = CswConvert.ToTristate( Role.Name.Text != "CISPro_View_Only" ); InvGrpPermNode.Dispense.Checked = CswConvert.ToTristate( Role.Name.Text != "CISPro_View_Only" ); InvGrpPermNode.Request.Checked = Request; InvGrpPermNode.Dispose.Checked = CswConvert.ToTristate( Role.Name.Text != "CISPro_View_Only" ); InvGrpPermNode.Undispose.Checked = CswConvert.ToTristate( Role.Name.Text == "CISPro_Admin" ); //InvGrpPermNode.Receive.Checked = Receive; InvGrpPermNode.postChanges( false ); } }
internal CswNbtNode createUserNode(string Username = "******", string Password = "******", CswEnumTristate isLocked = null, CswEnumTristate isArchived = null) { isLocked = isLocked ?? CswEnumTristate.False; isArchived = isArchived ?? CswEnumTristate.False; CswNbtMetaDataObjectClass RoleOc = CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RoleClass); CswPrimaryKey RoleId = RoleOc.getNodeIdAndNames(false, false).Select(RoleIds => RoleIds.Key).FirstOrDefault(); CswNbtNode ret = CswNbtResources.Nodes.makeNodeFromNodeTypeId(_getNodeTypeId("User"), OverrideUniqueValidation : true, OnAfterMakeNode : delegate(CswNbtNode NewNode) { CswNbtObjClassUser NewUser = NewNode; NewUser.UsernameProperty.Text = Username; NewUser.Role.RelatedNodeId = RoleId; NewUser.PasswordProperty.Password = Password; NewUser.AccountLocked.Checked = CswConvert.ToTristate(isLocked); NewUser.Archived.Checked = CswConvert.ToTristate(isArchived); //NewUser.postChanges( ForceUpdate: false ); }); _finalize(); return(ret); }
} // 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()
public static void UpdateBalanceData( ICswResources CswResources, SerialBalance Return, SerialBalance Request ) { CswNbtResources NbtResources = (CswNbtResources) CswResources; CswNbtMetaDataObjectClass BalanceOC = NbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.BalanceClass ); if( null != BalanceOC ) { CswNbtMetaDataObjectClassProp BalanceNameOCP = BalanceOC.getObjectClassProp( CswNbtObjClassBalance.PropertyName.Name ); CswNbtObjClassBalance Balance; Action<CswNbtNode> UpdateBalance = delegate( CswNbtNode NewNode ) { CswNbtObjClassBalance thisBalance = NewNode; thisBalance.Name.Text = Request.NbtName; thisBalance.Quantity.Quantity = Request.CurrentWeight; thisBalance.LastActive.DateTimeValue = DateTime.Now; thisBalance.Device.Text = Request.DeviceDescription; thisBalance.Manufacturer.Text = Request.Manufacturer; thisBalance.Operational.Checked = CswConvert.ToTristate( Request.Operational ); thisBalance.BalanceConfiguration.RelatedNodeId = _findConfigurationWithName( NbtResources, Request.Configuration ).NodeId; CswNbtObjClassUnitOfMeasure Unit = _mapUnitToNode( NbtResources, Request.UnitOfMeasurement ); if( null != Unit ) { thisBalance.Quantity.UnitId = Unit.NodeId; } }; if( string.IsNullOrEmpty(Request.NodeId) ) { CswNbtView ExistingBalancesView = new CswNbtView( NbtResources ); ExistingBalancesView.ViewName = "Existing Balances"; CswNbtViewRelationship BalanceRel = ExistingBalancesView.AddViewRelationship( BalanceOC, false ); ExistingBalancesView.AddViewPropertyAndFilter( BalanceRel, BalanceNameOCP, Value: Request.NbtName, FilterMode: CswEnumNbtFilterMode.Equals ); ICswNbtTree ExistingBalancesTree = NbtResources.Trees.getTreeFromView( ExistingBalancesView, false, true, true ); if( ExistingBalancesTree.getChildNodeCount() == 0 ) { //there is no balance with this name yet. Make a new one. CswNbtMetaDataNodeType BalanceNT = BalanceOC.FirstNodeType; Balance = NbtResources.Nodes.makeNodeFromNodeTypeId( BalanceNT.NodeTypeId, UpdateBalance ); } else { //this balance already exists, grab a reference to it. ExistingBalancesTree.goToNthChild( 0 ); Balance = ExistingBalancesTree.getCurrentNode(); UpdateBalance( Balance.Node ); Balance.postChanges( false ); } }//if null == request.nodeid else { Balance = NbtResources.Nodes[new CswPrimaryKey( "nodes", Convert.ToInt32( Request.NodeId ) )]; UpdateBalance( Balance.Node ); Balance.postChanges( false ); } //return the requested balance back, plus what nodeId it was assigned Return = Request; Return.NodeId = Balance.NodeId.PrimaryKey.ToString(); }//if ( null != BalanceOC ) }//UpdateBalanceData()
} // TreeToJson() private void _TreeNodeToGrid(CswNbtView View, ICswNbtTree Tree, CswExtJsGrid grid, CswExtJsGridRow gridrow) { string gridUniquePrefix = _getUniquePrefix(View); Collection <CswNbtTreeNodeProp> ChildProps = Tree.getChildNodePropsOfNode(); foreach (CswNbtTreeNodeProp Prop in ChildProps) { // Potential bug here! // If the view defines the property by objectclass propname, but the nodetype propname differs, this might break CswExtJsGridDataIndex dataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, Prop.PropName); bool IsHidden = Prop.Hidden; bool IsLocked = Tree.getNodeLockedForCurrentPosition(); string newValue = string.Empty; if (false == IsHidden) { CswPrimaryKey NodeId = Tree.getNodeIdForCurrentPosition(); CswNbtMetaDataNodeTypeProp MetaDataProp = _CswNbtResources.MetaData.getNodeTypeProp(Prop.NodeTypePropId); string oldValue = Prop.Gestalt; if (string.IsNullOrEmpty(oldValue)) { oldValue = null; } switch (Prop.FieldType) { case CswEnumNbtFieldType.Button: if (false == IsLocked) { CswNbtFieldTypeRuleButton buttonFTR = (CswNbtFieldTypeRuleButton)MetaDataProp.getFieldTypeRule(); grid.rowData.btns.Add(new CswExtJsGridButton { DataIndex = dataIndex.ToString(), RowNo = gridrow.RowNo, MenuOptions = Prop[buttonFTR.MenuOptionsSubField.Column], SelectedText = oldValue ?? Prop.PropName, PropAttr = new CswPropIdAttr(NodeId, Prop.NodeTypePropId).ToString(), Mode = String.IsNullOrEmpty(MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Extended)) ? "button" : MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Extended) }); } break; case CswEnumNbtFieldType.File: string LinkUrl = CswNbtNodePropBlob.getLink(Prop.JctNodePropId, NodeId); if (false == string.IsNullOrEmpty(LinkUrl) && false == string.IsNullOrEmpty(oldValue)) { newValue = "<a target=\"blank\" href=\"" + LinkUrl + "\">" + (oldValue) + "</a>"; } break; case CswEnumNbtFieldType.Image: string ImageUrl = CswNbtNodePropImage.getLink(Prop.JctNodePropId, NodeId); if (false == string.IsNullOrEmpty(ImageUrl)) { newValue = "<a target=\"blank\" href=\"" + ImageUrl + "\">" + (oldValue ?? "Image") + "</a>"; } break; case CswEnumNbtFieldType.Link: //string Href = CswNbtNodePropLink.GetFullURL( MetaDataProp.Attribute1, Prop.Field1_Big, MetaDataProp.Attribute2 ); string Href = CswNbtNodePropLink.GetFullURL(MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Attribute1), Prop.Field1_Big, MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Attribute2)); if (false == string.IsNullOrEmpty(Href)) { newValue = "<a target=\"blank\" href=\"" + Href + "\">" + (oldValue ?? "Link") + "</a>"; } break; case CswEnumNbtFieldType.Logical: newValue = CswConvert.ToDisplayString(CswConvert.ToTristate(oldValue)); break; case CswEnumNbtFieldType.MOL: string molUrl = CswNbtNodePropMol.getLink(Prop.JctNodePropId, NodeId); if (false == string.IsNullOrEmpty(molUrl)) { newValue = "<a target=\"blank\" href=\"" + molUrl + "\">" + "Structure.jpg" + "</a>"; } break; default: newValue = oldValue; break; } } gridrow.data[dataIndex] = newValue; } // foreach( JObject Prop in ChildProps ) // Recurse, but add properties of child nodes to the same gridrow for (Int32 c = 0; c < Tree.getChildNodeCount(); c++) { Tree.goToNthChild(c); _TreeNodeToGrid(View, Tree, grid, gridrow); Tree.goToParentNode(); } } // _TreeNodeToGrid()
protected override void beforeWriteNodeLogic( bool Creating, bool OverrideUniqueValidation ) { // The user cannot change his or her own Administrator privileges. if( Administrator.wasAnySubFieldModified() && Administrator.Checked != CswConvert.ToTristate( Administrator.GetOriginalPropRowValue() ) && _CswNbtResources.CurrentUser.RoleId == _CswNbtNode.NodeId ) { _CswNbtNode.Properties.clearModifiedFlag(); // prevents multiple error messages from appearing if we attempt to write() again throw new CswDniException( CswEnumErrorType.Warning, "You may not change your own administrator status", "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to edit the Administrator property of their own Role" ); } // case 22512 // also case 22557 - use the original name, not the new one CswNbtNodePropWrapper NamePropWrapper = Node.Properties[PropertyName.Name]; if( NamePropWrapper.GetOriginalPropRowValue( _CswNbtResources.MetaData.getFieldTypeRule( NamePropWrapper.getFieldTypeValue() ).SubFields.Default.Column ) == ChemSWAdminRoleName && _CswNbtResources.CurrentNbtUser.Username != CswNbtObjClassUser.ChemSWAdminUsername && false == ( _CswNbtResources.CurrentNbtUser is CswNbtSystemUser ) ) { throw new CswDniException( CswEnumErrorType.Warning, "The " + ChemSWAdminRoleName + " role cannot be edited", "Current user (" + _CswNbtResources.CurrentUser.Username + ") attempted to edit the '" + ChemSWAdminRoleName + "' role." ); } if( NodeTypePermissions.wasAnySubFieldModified( false ) ) { // case 25444 - was it *really* modified? CswNbtNodePropWrapper NodeTypePermissionsPropWrapper = Node.Properties[PropertyName.NodeTypePermissions]; string NodeTypePermissionsOriginalValueStr = NodeTypePermissionsPropWrapper.GetOriginalPropRowValue( CswEnumNbtPropColumn.ClobData ); CswCommaDelimitedString NodeTypePermissionsOriginalValue = new CswCommaDelimitedString(); NodeTypePermissionsOriginalValue.FromString( NodeTypePermissionsOriginalValueStr ); if( NodeTypePermissions.Value != NodeTypePermissionsOriginalValue ) { // Prevent granting permission to Design nodetypes without Design Action permission if( NodeTypePermissions.Gestalt.Contains( "Design" ) && // shortcut false == _CswNbtResources.Permit.can( CswEnumNbtActionName.Design, this ) ) { throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to Design NodeTypes without the Design Action Permission", "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to grant access to Design NodeTypes on role: " + _CswNbtNode.NodeName ); } } } // case 22437 if( ActionPermissions.wasAnySubFieldModified() ) { // case 25444 - was it *really* modified? CswNbtNodePropWrapper ActionPermissionsPropWrapper = Node.Properties[PropertyName.ActionPermissions]; string ActionPermissionsOriginalValueStr = ActionPermissionsPropWrapper.GetOriginalPropRowValue( ( (CswNbtFieldTypeRuleMultiList) _CswNbtResources.MetaData.getFieldTypeRule( ActionPermissionsPropWrapper.getFieldTypeValue() ) ).ValueSubField.Column ); CswCommaDelimitedString ActionPermissionsOriginalValue = new CswCommaDelimitedString(); ActionPermissionsOriginalValue.FromString( ActionPermissionsOriginalValueStr ); if( ActionPermissions.Value != ActionPermissionsOriginalValue ) { // You can never grant your own action permissions if( _CswNbtResources.CurrentUser.RoleId == _CswNbtNode.NodeId && this.Name.Text != ChemSWAdminRoleName ) { // case 26346 - we might be trimming invalid actions out automatically, // so just throw if an action permissions is being ADDED, not removed bool ActionAdded = false; foreach( string ActionStr in ActionPermissions.Value ) { if( false == ActionPermissionsOriginalValue.Contains( ActionStr ) ) { ActionAdded = true; } } if( ActionAdded ) { throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to actions for which you have no permissions", "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to edit their own action permissions on role: " + _CswNbtNode.NodeName ); } } // You can only grant action permissions on other roles to which you have access foreach( CswNbtAction Action in _CswNbtResources.Actions ) { if( true == _CswNbtResources.Permit.can( Action, this ) ) // permission is being granted { if( ( Action.Name == CswEnumNbtActionName.Design || Action.Name == CswEnumNbtActionName.Create_Inspection || //Case 24288 Action.Name == CswEnumNbtActionName.View_Scheduled_Rules ) && //Case 28564 _CswNbtResources.CurrentNbtUser.Rolename != ChemSWAdminRoleName && //Case 28433: chemsw_admin can grant Design to anyone. false == _CswNbtResources.IsSystemUser ) { // case 23677 throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to " + Action.DisplayName + " to this role", "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to grant access to action " + Action.DisplayName + " to role " + _CswNbtNode.NodeName ); } //Case 29338 - If the Role has no Material NT create permissions, remove the Create Material action permission if( Action.Name == CswEnumNbtActionName.Create_Material ) { CswNbtMetaDataPropertySet MaterialPS = _CswNbtResources.MetaData.getPropertySet( CswEnumNbtPropertySetName.MaterialSet ); bool HasOneMaterialCreate = false; foreach( CswNbtMetaDataObjectClass MaterialOc in MaterialPS.getObjectClasses() ) { foreach( CswNbtMetaDataNodeType MaterialNt in MaterialOc.getNodeTypes() ) { string NodeTypePermission = MakeNodeTypePermissionValue( MaterialNt.FirstVersionNodeTypeId, CswEnumNbtNodeTypePermission.Create ); HasOneMaterialCreate = HasOneMaterialCreate || NodeTypePermissions.CheckValue( NodeTypePermission ); } } if( false == HasOneMaterialCreate ) { ActionPermissions.RemoveValue( MakeActionPermissionValue( Action ) ); } } if( false == _CswNbtResources.Permit.can( Action, _CswNbtResources.CurrentNbtUser ) ) { throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to actions for which you have no permissions", "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to grant access to action " + Action.DisplayName + " to role " + _CswNbtNode.NodeName ); } } // if( true == _CswNbtResources.Permit.can( Action, this ) ) } // foreach( string ActionNameString in ActionPermissions.YValues ) } // if( ActionPermissions.Value != ActionPermissionsOriginalValue ) } // if( ActionPermissions.getAnySubFieldModified() ) }//beforeWriteNode()
public override void ReadDataRow(DataRow PropRow, Dictionary <string, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap) { Checked = CswConvert.ToTristate(PropRow[_CheckedSubField.ToXmlNodeName()], Required); }
public CswNbtNodePropLogical(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node) : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node) { _CheckedSubField = ((CswNbtFieldTypeRuleLogical)_FieldTypeRule).CheckedSubField; // Associate subfields with methods on this object, for SetSubFieldValue() _SubFieldMethods.Add(_CheckedSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Checked, x => Checked = CswConvert.ToTristate(x))); }
public void assignPropsToLocations( string LocationNodeKeys, bool UpdateInventoryGroup, string SelectedInventoryGroupNodeId, bool UpdateAllowInventory, string AllowInventory, bool UpdateControlZone, string SelectedControlZoneNodeId, bool UpdateStorageCompatability, string SelectedImages ) { if( false == string.IsNullOrEmpty( LocationNodeKeys ) ) { ///we don't pre-load he allowinventory value because there's no extra expense ///to doing so repeatedly in the loop CswNbtNode InventoryGroupNode = null; if( ( true == UpdateInventoryGroup ) && ( false == string.IsNullOrEmpty( SelectedInventoryGroupNodeId ) ) ) { CswPrimaryKey IGKey = new CswPrimaryKey(); IGKey.FromString( SelectedInventoryGroupNodeId ); InventoryGroupNode = _CswNbtResources.Nodes[IGKey]; } CswNbtNode ControlZoneNode = null; if( ( true == UpdateControlZone ) && ( false == string.IsNullOrEmpty( SelectedControlZoneNodeId ) ) ) { CswPrimaryKey IGKey = new CswPrimaryKey(); IGKey.FromString( SelectedControlZoneNodeId ); ControlZoneNode = _CswNbtResources.Nodes[IGKey]; } CswDelimitedString Images = new CswDelimitedString( ',' ); if( true == UpdateStorageCompatability ) { if( false == string.IsNullOrEmpty( SelectedImages ) ) { Images.FromString( SelectedImages ); } } foreach( string CurrentLocationKey in LocationNodeKeys.Split( ',' ) ) { if( false == string.IsNullOrEmpty( CurrentLocationKey ) ) { CswNbtNodeKey LKey = new CswNbtNodeKey( CurrentLocationKey ); CswNbtObjClassLocation CurrentLocationNode = _CswNbtResources.Nodes[LKey]; if( null != CurrentLocationNode ) { if( true == UpdateInventoryGroup ) { if( null != InventoryGroupNode ) { CurrentLocationNode.InventoryGroup.RelatedNodeId = InventoryGroupNode.NodeId; } else { CurrentLocationNode.InventoryGroup.RelatedNodeId = null; } } if( true == UpdateControlZone ) { if( null != ControlZoneNode ) { CurrentLocationNode.ControlZone.RelatedNodeId = ControlZoneNode.NodeId; } else { CurrentLocationNode.ControlZone.RelatedNodeId = null; } } if( UpdateAllowInventory ) { CurrentLocationNode.AllowInventory.Checked = CswConvert.ToTristate( AllowInventory ); } if( UpdateStorageCompatability ) { CurrentLocationNode.StorageCompatibility.Value = Images; } CurrentLocationNode.postChanges( true ); }//if current key yielded a node } //if there is a location keye } //iterate locations }//if we have location keys }//assignInventoryGroupToLocations()
}//ctor public void update(Int32 NodeTypeId, CswPrimaryKey RelationalId, DataTable PropsTable) { if (CswTools.IsPrimaryKey(RelationalId)) { CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeId); string TableName = NodeType.TableName; if (TableName != "nodes") { string PkColumnName = _CswNbtResources.getPrimeKeyColName(TableName); CswTableUpdate CswTableUpdate = null; DataTable DataTable = null; DataRow DataRow = null; // horrible special case for Design // We need to use CswNbtMetaDataResources objects, or else we have dirty-write problems if (NodeType.TableName.StartsWith("nodetype")) { switch (NodeType.TableName) { case "nodetypes": CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTableUpdate; CswNbtMetaDataNodeType relatedNT = _CswNbtResources.MetaData.getNodeType(RelationalId.PrimaryKey, null, true); DataTable = relatedNT._DataRow.Table; DataRow = relatedNT._DataRow; break; case "nodetype_tabset": CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTabTableUpdate; CswNbtMetaDataNodeTypeTab relatedNTT = _CswNbtResources.MetaData.getNodeTypeTab(RelationalId.PrimaryKey, true); DataTable = relatedNTT._DataRow.Table; DataRow = relatedNTT._DataRow; break; case "nodetype_props": CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypePropTableUpdate; CswNbtMetaDataNodeTypeProp relatedNTP = _CswNbtResources.MetaData.getNodeTypeProp(RelationalId.PrimaryKey, null, true); DataTable = relatedNTP._DataRow.Table; DataRow = relatedNTP._DataRow; break; } } // if( NodeType.TableName.StartsWith( "nodetype" ) ) if (null == DataTable || null == CswTableUpdate) { CswTableUpdate = _CswNbtResources.makeCswTableUpdate("CswNbtNodePropCollDataRelational_update", TableName); DataTable = CswTableUpdate.getTable(null, PkColumnName, RelationalId.PrimaryKey, string.Empty, false); DataRow = DataTable.Rows[0]; } if (null != DataRow) { CswTableSelect MappingSelect = _CswNbtResources.makeCswTableSelect("PropCollDataRelational_mapping", "jct_dd_ntp"); DataTable MappingTable = MappingSelect.getTable("where nodetypepropid in (select nodetypepropid from nodetype_props where nodetypeid =" + NodeTypeId.ToString() + ")"); foreach (DataRow CurrentRow in PropsTable.Rows) { CswNbtMetaDataNodeTypeProp thisNTP = NodeType.getNodeTypeProp(CswConvert.ToInt32(CurrentRow["nodetypepropid"])); if (null != thisNTP) { foreach (CswNbtSubField CurrentSubField in thisNTP.getFieldTypeRule().SubFields) { DataRow MappingRow = MappingTable.Rows.Cast <DataRow>() .FirstOrDefault(r => CswConvert.ToInt32(r["nodetypepropid"]) == thisNTP.PropId && r["subfieldname"].ToString() == CurrentSubField.Name.ToString()); if (null != MappingRow) { _CswNbtResources.DataDictionary.setCurrentColumn(CswConvert.ToInt32(MappingRow["datadictionaryid"])); if (_CswNbtResources.DataDictionary.ColumnName != string.Empty) { if (CurrentRow[CurrentSubField.Column.ToString()].ToString() == string.Empty) { DataRow[_CswNbtResources.DataDictionary.ColumnName] = DBNull.Value; } else if (_CswNbtResources.DataDictionary.ColumnName == CswEnumNbtPropertyAttributeColumn.Defaultvalueid) { // Special case for Default Value: we need to sync the jctnodepropid row, not the value DataRow[_CswNbtResources.DataDictionary.ColumnName] = CurrentRow["jctnodepropid"]; } else { object value = CurrentRow[CurrentSubField.Column.ToString()]; // Special case for Multi: translate "Single" and "Multiple" to 0 and 1 resp. if (_CswNbtResources.DataDictionary.ColumnName == CswEnumNbtPropertyAttributeColumn.Multi) { if (value.ToString() == CswEnumNbtPropertySelectMode.Single.ToString()) { value = 1; } else { value = 0; } } // Special case for booleans and tristates else if (thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Logical) { value = CswConvert.TristateToDbVal(CswConvert.ToTristate(CurrentRow[CurrentSubField.Column.ToString()])); } // Special case for relationships and locations, if the related entity is also relational else if (CurrentSubField.Name == CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID && (thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Relationship || thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Location)) { CswNbtNode RelatedNode = _CswNbtResources.Nodes[new CswPrimaryKey("nodes", CswConvert.ToInt32(value))]; if (null != RelatedNode && RelatedNode.getNodeType().DoRelationalSync) { // Remap the foreign key reference to the relational primary key value = RelatedNode.RelationalId.PrimaryKey; } } DataRow[_CswNbtResources.DataDictionary.ColumnName] = value; //CurrentRow[CurrentSubField.Column.ToString()]; } } // if( _CswNbtResources.DataDictionary.ColumnName != string.Empty ) } // if( null != MappingRow ) } // foreach( CswNbtSubField CurrentSubField in thisNTP.getFieldTypeRule().SubFields ) } // if( null != thisNTP ) } // foreach( DataRow CurrentRow in PropsTable.Rows ) CswTableUpdate.update(DataTable); } // if( null != DataRow ) } // if( TableName != "nodes" ) } // if( CswTools.IsPrimaryKey( RelationalId ) ) } //update()