Beispiel #1
0
        private bool _userHasTabPermission(CswEnumNbtNodeTypePermission PermissionType, CswNbtMetaDataNodeType NodeType, CswNbtMetaDataNodeTypeTab Tab)
        {
            bool hasPermission = true;

            hasPermission = _CswNbtResources.Permit.canTab(PermissionType, NodeType, Tab);
            return(hasPermission);
        }
Beispiel #2
0
        public override void update()
        {
            // Add nodetypes for new object classes
            CswNbtMetaDataObjectClass RegListMemberOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListMemberClass );
            CswNbtMetaDataObjectClassProp RegListMemberChemicalOCP = RegListMemberOC.getObjectClassProp( CswNbtObjClassRegulatoryListMember.PropertyName.Chemical );
            CswNbtMetaDataNodeType RegListMemberNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeTypeDeprecated( new CswNbtWcfMetaDataModel.NodeType( RegListMemberOC )
                {
                    NodeTypeName = "Regulatory List Member",
                    Category = "Materials",
                    SearchDeferObjectClassPropId = RegListMemberChemicalOCP.ObjectClassPropId
                } );
            RegListMemberNT.setNameTemplateText( CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassRegulatoryListMember.PropertyName.Chemical ) + "-" + CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassRegulatoryListMember.PropertyName.RegulatoryList ) );
            
            RegListMemberNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryListMember.PropertyName.ByUser ).removeFromLayout( CswEnumNbtLayoutType.Add );

            CswNbtMetaDataObjectClass RegListCasNoOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListCasNoClass );
            CswNbtMetaDataObjectClassProp RegListCasNoRegListOCP = RegListCasNoOC.getObjectClassProp( CswNbtObjClassRegulatoryListCasNo.PropertyName.RegulatoryList );
            CswNbtMetaDataNodeType RegListCasNoNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeTypeDeprecated( new CswNbtWcfMetaDataModel.NodeType( RegListCasNoOC )
                {
                    NodeTypeName = "Regulatory List CAS",
                    Category = "Materials",
                    SearchDeferObjectClassPropId = RegListCasNoRegListOCP.ObjectClassPropId
                } );
            RegListCasNoNT.setNameTemplateText( CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassRegulatoryListCasNo.PropertyName.RegulatoryList ) + "-" + CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassRegulatoryListCasNo.PropertyName.CASNo ) );

            // Grant permissions to cispro_admin
            CswNbtObjClassRole CISProAdminRole = _CswNbtSchemaModTrnsctn.Nodes.makeRoleNodeFromRoleName( "CISPro_Admin" );
            CswEnumNbtNodeTypePermission[] AllPerms = new CswEnumNbtNodeTypePermission[]
                {
                    CswEnumNbtNodeTypePermission.Create, CswEnumNbtNodeTypePermission.Delete, CswEnumNbtNodeTypePermission.Edit, CswEnumNbtNodeTypePermission.View
                };
            _CswNbtSchemaModTrnsctn.Permit.set( AllPerms, RegListMemberNT, CISProAdminRole, true );
            _CswNbtSchemaModTrnsctn.Permit.set( AllPerms, RegListCasNoNT, CISProAdminRole, true );

        } // update()
Beispiel #3
0
        private bool _userHasPermission(CswEnumNbtNodeTypePermission PermissionType, CswNbtMetaDataNodeType RetNodeType)
        {
            bool hasPermission = true;

            if (PermissionType == CswEnumNbtNodeTypePermission.Create)
            {
                hasPermission = hasPermission && RetNodeType.getObjectClass().CanAdd;
            }
            hasPermission = hasPermission && _CswNbtResources.Permit.canNodeType(PermissionType, RetNodeType);

            return(hasPermission);
        }
Beispiel #4
0
        /// <summary>
        /// Based on the input, verifies if the user has permission to continue
        /// </summary>
        public bool hasPermission(CswNbtResources NbtResources, CswEnumNbtNodeTypePermission Permission, CswNbtAPIGenericRequest GenericRequest, CswNbtAPIReturn Return)
        {
            bool ret = false;
            CswNbtMetaDataNodeType NodeType = NbtResources.MetaData.getNodeType(GenericRequest.MetaDataName);

            if (null != NodeType)
            {
                if (NbtResources.Permit.canAnyTab(Permission, NodeType, User: NbtResources.CurrentNbtUser))
                {
                    ret = true;
                }
                else
                {
                    Return.Status = Return.Status = HttpStatusCode.Forbidden; //Permission denied
                }
            }
            else
            {
                Return.Status = Return.Status = HttpStatusCode.NotFound;
            }
            return(ret);
        }
        private CswNbtResources _testInit(string RoleName, string UserName, CswEnumTristate IsAdmin, CswEnumNbtNodeTypePermission Permission, bool PermissionValue)
        {
            CswNbtSdResourcesMgr ResourcesMgr = new CswNbtSdResourcesMgr(_TestData.CswNbtResources);
            CswNbtObjClassRole   Role         = _TestData.CswNbtResources.Nodes[ResourcesMgr.makeNewRole(RoleName)];
            CswNbtResources      Ret          = null;

            if (null != Role)
            {
                Role.Administrator.Checked = IsAdmin;
                _TestData.CswNbtResources.Permit.set(Permission, _SprocketNt, Role, PermissionValue);
                Role.postChanges(ForceUpdate: false);
                _TestData.CswNbtResources.finalize();

                Ret = ResourcesMgr.makeNewUserResources(UserName, Role.NodeId);
            }
            return(Ret);
        }
Beispiel #6
0
        protected override void afterPromoteNodeLogic()
        {
            // ------------------------------------------------------------
            // This logic from makeNewNodeType in CswNbtMetaData.cs
            // ------------------------------------------------------------

            if (CswTools.IsPrimaryKey(RelationalId))
            {
                Int32 NodeTypeId = RelationalId.PrimaryKey;

                //CswTableUpdate NodeTypesUpdate = _CswNbtResources.makeCswTableUpdate( "DesignNodeType_afterCreateNode_NodeTypesUpdate", "nodetypes" );
                //DataTable NodeTypesTable = NodeTypesUpdate.getTable( "nodetypeid", NodeTypeId );
                //if( NodeTypesTable.Rows.Count > 0 )
                //{
                // Set values not controlled by the node
                //DataRow NodeTypesRow = NodeTypesTable.Rows[0];
                if (null != RelationalNodeType)
                {
                    DataRow NodeTypesRow = RelationalNodeType._DataRow;

                    NodeTypesRow["versionno"]      = "1";
                    NodeTypesRow["tablename"]      = "nodes";
                    NodeTypesRow["nodecount"]      = 0;
                    NodeTypesRow["firstversionid"] = NodeTypeId.ToString();
                    _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTableUpdate.update(NodeTypesRow.Table);

                    //CswNbtMetaDataNodeType NewNodeType = RelationalNodeType;

                    if (false == InternalCreate)
                    {
                        // Now can create nodetype_props and tabset records
                        //CswTableUpdate NodeTypePropTableUpdate = _CswNbtResources.makeCswTableUpdate( "DesignNodeType_afterCreateNode_NodeTypePropUpdate", "nodetypes" );
                        //DataTable NodeTypeProps = NodeTypePropTableUpdate.getTable( "nodetypeid", NodeTypeId );

                        // Make an initial tab
                        //CswNbtMetaDataObjectClass DesignNodeTypeOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignNodeTypeClass );
                        CswNbtMetaDataObjectClass DesignNodeTypeTabOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.DesignNodeTypeTabClass);
                        //CswNbtMetaDataObjectClass DesignNodeTypePropOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignNodeTypePropClass );

                        //CswNbtMetaDataNodeType DesignNodeTypeNT = DesignNodeTypeOC.FirstNodeType;
                        CswNbtMetaDataNodeType DesignNodeTypeTabNT = DesignNodeTypeTabOC.FirstNodeType;
                        //CswNbtMetaDataNodeType DesignNodeTypePropNT = DesignNodeTypePropOC.FirstNodeType;

                        if (null != DesignNodeTypeTabNT)
                        {
                            _CswNbtResources.Nodes.makeNodeFromNodeTypeId(DesignNodeTypeTabNT.NodeTypeId, delegate(CswNbtNode NewNode)
                            {
                                CswNbtObjClassDesignNodeTypeTab IdentityTab = NewNode;
                                IdentityTab.NodeTypeValue.RelatedNodeId     = this.NodeId;
                                IdentityTab.TabName.Text = CswNbtMetaData.IdentityTabName;
                                IdentityTab.Order.Value  = 0;
                                //IdentityTab.ServerManaged.Checked = CswEnumTristate.True;
                                //IdentityTab.postChanges( false );
                            });

                            _CswNbtResources.Nodes.makeNodeFromNodeTypeId(DesignNodeTypeTabNT.NodeTypeId, delegate(CswNbtNode NewNode)
                            {
                                CswNbtObjClassDesignNodeTypeTab FirstTab = NewNode;
                                FirstTab.NodeTypeValue.RelatedNodeId     = this.NodeId;
                                FirstTab.TabName.Text = NodeTypeName.Text;
                                FirstTab.Order.Value  = 1;
                                // FirstTab.postChanges( false );
                            });
                        } // if( null != DesignNodeTypeTabNT )


                        // Make initial props
                        _setPropertyValuesFromObjectClass();
                        _requiresSync = false;
                    } // if( false == InternalCreate )

                    //if( OnMakeNewNodeType != null )
                    //    OnMakeNewNodeType( NewNodeType, false );

                    //refreshAll();

                    //will need to refresh auto-views
                    //_RefreshViewForNodetypeId.Add( NodeTypeId );
                } // if( null != RelationalNodeType )


                // Give the current user's role full permissions to the new nodetype
                CswEnumNbtNodeTypePermission[] AllPerms = new CswEnumNbtNodeTypePermission[]
                {
                    CswEnumNbtNodeTypePermission.Delete,
                    CswEnumNbtNodeTypePermission.Create,
                    CswEnumNbtNodeTypePermission.Edit,
                    CswEnumNbtNodeTypePermission.View
                };

                if (null != _CswNbtResources.CurrentNbtUser.RoleId)
                {
                    CswNbtNode         RoleNode       = _CswNbtResources.Nodes[_CswNbtResources.CurrentNbtUser.RoleId];
                    CswNbtObjClassRole RoleNodeAsRole = (CswNbtObjClassRole)RoleNode;

                    // case 23185 - reset permission options
                    RoleNodeAsRole.triggerAfterPopulateProps();

                    _CswNbtResources.Permit.set(AllPerms, RelationalId.PrimaryKey, RoleNodeAsRole, true);
                }//if we have a current user
                else if (_CswNbtResources.CurrentNbtUser is CswNbtSystemUser)
                {
                    // Grant permission to Administrator, unless it's a Design nodetype
                    if (RelationalNodeType.getObjectClass().ObjectClass != CswEnumNbtObjectClass.DesignNodeTypeClass &&
                        RelationalNodeType.getObjectClass().ObjectClass != CswEnumNbtObjectClass.DesignNodeTypeTabClass &&
                        RelationalNodeType.getObjectClass().ObjectClass != CswEnumNbtObjectClass.DesignNodeTypePropClass &&
                        RelationalNodeType.getObjectClass().ObjectClass != CswEnumNbtObjectClass.DesignSequenceClass)
                    {
                        CswNbtObjClassRole RoleNode = _CswNbtResources.Nodes.makeRoleNodeFromRoleName("Administrator");
                        if (RoleNode != null)
                        {
                            _CswNbtResources.Permit.set(AllPerms, RelationalNodeType, RoleNode, true);
                        }
                    }
                    // Grant permission to chemsw_admin
                    CswNbtObjClassRole RoleNode2 = _CswNbtResources.Nodes.makeRoleNodeFromRoleName(CswNbtObjClassRole.ChemSWAdminRoleName);
                    if (RoleNode2 != null)
                    {
                        _CswNbtResources.Permit.set(AllPerms, RelationalNodeType, RoleNode2, true);
                    }
                }

                if (ObjectClassPropertyValue.ObjectClass == CswEnumNbtObjectClass.InspectionDesignClass)
                {
                    _OnMakeNewInspectionDesignNodeType(RelationalNodeType);
                }
            } // if( CswTools.IsPrimaryKey( RelationalId ) )
        }     // afterPromoteNode()
 public static string MakeNodeTypePermissionText( string LatestVersionNodeTypeName, CswEnumNbtNodeTypePermission Permission )
 {
     return LatestVersionNodeTypeName + ": " + Permission.ToString();
 }
        }//beforeDeleteNode()     

        public static string MakeNodeTypePermissionValue( Int32 FirstVersionNodeTypeId, CswEnumNbtNodeTypePermission Permission )
        {
            return "nt_" + FirstVersionNodeTypeId.ToString() + "_" + Permission.ToString();
        }
        public override void update()
        {
            // New 'IsConstituent' property
            CswNbtMetaDataPropertySet MaterialPS = _CswNbtSchemaModTrnsctn.MetaData.getPropertySet( CswEnumNbtPropertySetName.MaterialSet );
            foreach( CswNbtMetaDataObjectClass MaterialOC in _CswNbtSchemaModTrnsctn.MetaData.getObjectClassesByPropertySetId( MaterialPS.PropertySetId ) )
            {
                foreach( CswNbtMetaDataNodeType MaterialNT in MaterialOC.getNodeTypes() )
                {
                    CswNbtMetaDataNodeTypeProp IsConstituentNTP = MaterialNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetMaterial.PropertyName.IsConstituent );
                    IsConstituentNTP.DefaultValue.AsLogical.Checked = CswEnumTristate.False;
                    IsConstituentNTP.removeFromAllLayouts();

                    foreach( CswNbtPropertySetMaterial MaterialNode in MaterialNT.getNodes( false, true ) )
                    {
                        MaterialNode.IsConstituent.Checked = CswEnumTristate.False;
                        MaterialNode.postChanges( false );
                    }
                }
            }

            CswNbtMetaDataObjectClass ChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass );
            if( null != ChemicalOC.FirstNodeType )
            {
                //1. Create a new NodeType (of ObjClassChemical) called "Constituent"
                CswNbtMetaDataNodeType ConstituentNT = _CswNbtSchemaModTrnsctn.MetaData.CopyNodeType( ChemicalOC.FirstNodeType, "Constituent" );

                CswNbtMetaDataNodeTypeProp TradeNameNTP = ConstituentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassChemical.PropertyName.TradeName );
                ConstituentNT.setNameTemplateText( CswNbtMetaData.MakeTemplateEntry( TradeNameNTP.PropName ) );

                // IsConstituent is true here
                CswNbtMetaDataNodeTypeProp IsConstituentNTP = ConstituentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassChemical.PropertyName.IsConstituent );
                IsConstituentNTP.DefaultValue.AsLogical.Checked = CswEnumTristate.True;

                //2. Set Allow Receiving prop to "false" by default
                CswNbtMetaDataNodeTypeProp ApprovedReceivingNTP = ConstituentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassChemical.PropertyName.ApprovedForReceiving );
                ApprovedReceivingNTP.DefaultValue.AsLogical.Checked = CswEnumTristate.False;
                ApprovedReceivingNTP.ServerManaged = true;

                Collection<CswNbtMetaDataNodeTypeProp> PropertiesToDelete = new Collection<CswNbtMetaDataNodeTypeProp>();
                PropertiesToDelete.Add( ConstituentNT.getNodeTypeProp( "Chemical Sizes" ) );
                PropertiesToDelete.Add( ConstituentNT.getNodeTypeProp( "Inventory Levels" ) );
                PropertiesToDelete.Add( ConstituentNT.getNodeTypeProp( "Chemical Containers" ) );
                PropertiesToDelete.Add( ConstituentNT.getNodeTypeProp( "Components" ) );

                foreach( CswNbtMetaDataNodeTypeProp DoomedProp in PropertiesToDelete )
                {
                    if( null != DoomedProp )
                    {
                        _CswNbtSchemaModTrnsctn.MetaData.DeleteNodeTypeProp( DoomedProp );
                    }
                }

                CswNbtMetaDataNodeTypeProp SupplierNTP = ConstituentNT.getNodeTypePropByObjectClassProp( CswNbtObjClassChemical.PropertyName.Supplier );
                SupplierNTP.removeFromAllLayouts();


                // Grant permissions to cispro_admin
                CswNbtObjClassRole CISProAdminRole = _CswNbtSchemaModTrnsctn.Nodes.makeRoleNodeFromRoleName( "CISPro_Admin" );
                CswEnumNbtNodeTypePermission[] AllPerms = new CswEnumNbtNodeTypePermission[]
                {
                    CswEnumNbtNodeTypePermission.Create, CswEnumNbtNodeTypePermission.Delete, CswEnumNbtNodeTypePermission.Edit, CswEnumNbtNodeTypePermission.View
                };
                _CswNbtSchemaModTrnsctn.Permit.set( AllPerms, ConstituentNT, CISProAdminRole, true );

            } // if( null != ChemicalOC.FirstNodeType )
        } // update()