Ejemplo n.º 1
0
        protected override void SetValue(ModelRole role, MetadataPermission permission)
        {
            var tp = role.TablePermissions.FindByName(Column.Table.Name);
            var cp = tp != null?tp.MetadataObject.ColumnPermissions.Find(Column.Name) : null;

            // Permission removed:
            if (permission == MetadataPermission.Default)
            {
                // Do nothing if same value or no CP defined
                if (cp == null)
                {
                    return;
                }

                // Otherwise, remove CP:
                Column.Handler.UndoManager.Add(new UndoPropertyChangedAction(Column, "ObjectLevelSecurity", cp.MetadataPermission, permission, role.Name));
                tp.MetadataObject.ColumnPermissions.Remove(cp);
            }
            else // Non-default permission assigned:
            {
                Handler.BeginUpdate("object level security");

                // Create TP if not exists:
                if (tp == null)
                {
                    tp = TablePermission.CreateFromMetadata(role, new TOM.TablePermission {
                        Table = Column.Table.MetadataObject
                    });
                }

                // Create CP if not exists:
                if (cp == null)
                {
                    cp = new TOM.ColumnPermission {
                        Column = Column.MetadataObject
                    };
                    tp.MetadataObject.ColumnPermissions.Add(cp);
                }

                // Do nothing if same value
                if ((MetadataPermission)cp.MetadataPermission == permission)
                {
                    return;
                }

                // Otherwise, assign the new permission to CP:
                Column.Handler.UndoManager.Add(new UndoPropertyChangedAction(Column, "ObjectLevelSecurity", cp.MetadataPermission, permission, role.Name));
                cp.MetadataPermission = (TOM.MetadataPermission)permission;

                Handler.EndUpdate();
            }
        }
Ejemplo n.º 2
0
        protected override void SetValue(Table table, MetadataPermission permission)
        {
            var tp = Role.TablePermissions.FindByName(table.Name);

            if (tp == null && permission == MetadataPermission.Default)
            {
                return;
            }

            if (tp == null)
            {
                tp = TablePermission.CreateFromMetadata(Role, new TOM.TablePermission {
                    Table = table.MetadataObject
                });
            }

            tp.MetadataPermission = permission;
        }
Ejemplo n.º 3
0
        protected override void SetValue(Table table, string filterExpression)
        {
            var tp = Role.TablePermissions.FindByName(table.Name);

            // Filter expression removed:
            if (string.IsNullOrWhiteSpace(filterExpression))
            {
                // Don't do anything if there is no TablePermission for this table anyway:
                if (tp == null)
                {
                    return;
                }

                // Otherwise, remove the filter expression:
                if (Handler.CompatibilityLevel >= 1400 && (tp.MetadataObject.MetadataPermission != TOM.MetadataPermission.Default ||
                                                           tp.MetadataObject.ColumnPermissions.Any(cp => cp.MetadataPermission != TOM.MetadataPermission.Default)))
                {
                    tp.FilterExpression = string.Empty;
                }
                else
                {
                    tp.Delete();
                }
            }
            else // Filter expression assigned:
            {
                // Create a new TablePermission if we don't already have one for this table:
                if (tp == null)
                {
                    tp = TablePermission.CreateFromMetadata(Role, new TOM.TablePermission {
                        Table = table.MetadataObject
                    });
                }

                tp.FilterExpression = filterExpression;
            }
        }
Ejemplo n.º 4
0
 internal RoleColumnOLSIndexer(TablePermission tps) : base(tps)
 {
     TablePermission = tps;
 }