Beispiel #1
0
        public void CreateTable(IList <ColumnDetails> columns, SecurityPermissions permissions)
        {
            this.Table = new Table(this.Configuration.ArribaTable, this.Configuration.ItemCountLimit);

            // Try to load the table if it already exists
            if (BinarySerializable.EnumerateUnder(Path.Combine("Tables", this.Configuration.ArribaTable)).Count() > 0)
            {
                Trace.WriteLine(string.Format("Loading Arriba Table '{0}'...", this.Configuration.ArribaTable));
                this.Table.Load(this.Configuration.ArribaTable);
            }

            // Columns are added dynamically by Append

            // Set the table security
            SecureDatabase sdb = new SecureDatabase();

            sdb.SetSecurity(this.Configuration.ArribaTable, permissions);
            sdb.SaveSecurity(this.Configuration.ArribaTable);

            // Debug Only: Verify consistency just after load
            if (this.DiagnosticsEnabled)
            {
                Trace.WriteLine("Verifying Arriba Table consistency [on load]...");

                ExecutionDetails d = new ExecutionDetails();
                this.Table.VerifyConsistency(this.DiagnosticsLevel, d);

                if (!d.Succeeded)
                {
                    Debugger.Break();
                    Trace.TraceError(String.Format("Consistency Errors Detected: {0}", String.Join("\r\n", d.Errors)));
                }
            }
        }
Beispiel #2
0
        private static void SetSettings(Table table, CombinedSettings settings)
        {
            // Set and write security
            SecureDatabase db = new SecureDatabase();

            db.SetSecurity(table.Name, settings.Security);
            db.SaveSecurity(table.Name);

            // Create/Modify columns
            foreach (ColumnDetails cd in settings.Schema)
            {
                table.AddColumn(cd);
            }
        }
Beispiel #3
0
        private static void SetTableCreators(string creators)
        {
            Console.WriteLine("Setting table creators...");

            SecurityPermissions createPermissions = new SecurityPermissions();

            foreach (string creator in creators.Split(';'))
            {
                string[]      parts = creator.Split(':');
                IdentityScope scope = parts[0].Equals("u", StringComparison.OrdinalIgnoreCase) ? IdentityScope.User : IdentityScope.Group;
                createPermissions.Grant(new SecurityIdentity(scope, parts[1]), PermissionScope.Owner);

                Console.WriteLine($" - {scope} {parts[1]}");
            }

            // Create table, if required
            SecureDatabase db = new SecureDatabase();

            db.SetSecurity("", createPermissions);
            db.SaveSecurity("");
        }