Ejemplo n.º 1
0
        public override async Task InstallingAsync(IFeatureEventContext context)
        {
            //var schemaBuilder = context.ServiceProvider.GetRequiredService<ISchemaBuilder>();
            using (var builder = _schemaBuilder)
            {
                // Configure
                Configure(builder);

                // EntityMentions schema
                EntityMentions(builder);

                // Log statements to execute
                if (context.Logger.IsEnabled(LogLevel.Information))
                {
                    context.Logger.LogInformation($"The following SQL statements will be executed...");
                    foreach (var statement in builder.Statements)
                    {
                        context.Logger.LogInformation(statement);
                    }
                }

                // Execute statements
                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    context.Errors.Add(error, $"InstallingAsync within {this.GetType().FullName}");
                }
            }
        }
Ejemplo n.º 2
0
        public override async Task InstallingAsync(IFeatureEventContext context)
        {
            if (context.Logger.IsEnabled(LogLevel.Information))
            {
                context.Logger.LogInformation($"InstallingAsync called within {ModuleId}");
            }

            using (var builder = _schemaBuilder)
            {
                // configure
                Configure(builder);

                // Ratings schema
                Ratings(builder);

                // Log statements to execute
                if (context.Logger.IsEnabled(LogLevel.Information))
                {
                    context.Logger.LogInformation($"The following SQL statements will be executed...");
                    foreach (var statement in builder.Statements)
                    {
                        context.Logger.LogInformation(statement);
                    }
                }

                // Execute statements
                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    context.Errors.Add(error, $"InstallingAsync within {this.GetType().FullName}");
                }
            }
        }
Ejemplo n.º 3
0
        public override async Task SetUp(SetUpContext context, Action <string, string> reportError)
        {
            // Build schemas
            using (var builder = _schemaBuilder)
            {
                // configure
                Configure(builder);

                // user schema
                Users(builder);

                // photo schema
                UserPhoto(builder);

                // banner schema
                UserBanner(builder);

                // meta data schema
                UserData(builder);

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    reportError(error, $"SetUp within {this.GetType().FullName} - {error}");
                }
            }

            // Configure default users
            await ConfigureDefaultUsers(context, reportError);

            // Configure administrator
            await ConfigureSuperUser(context, reportError);
        }
Ejemplo n.º 4
0
        public async Task <ICommandResult <SchemaFullTextIndex> > CreateAsync(SchemaFullTextIndex model)
        {
            // Create result
            var result = new CommandResult <SchemaFullTextIndex>();

            // Drop index
            using (var builder = _schemaBuilder)
            {
                builder.FullTextBuilder.CreateIndex(model);

                var errors = (ICollection <string>) await _schemaManager.ExecuteAsync(builder.Statements);

                if (errors.Any())
                {
                    return(result.Failed(errors.Select(s => new CommandError(s)).ToArray()));
                }
            }

            // Expire store
            _cacheManager.CancelTokens(typeof(FullTextIndexStore));

            // Return result
            return(result.Success(model));
        }
Ejemplo n.º 5
0
        public override async Task SetUp(SetUpContext context, Action <string, string> reportError)
        {
            using (var builder = _schemaBuilder)
            {
                // configure
                Configure(builder);

                // User reputations
                UserReputations(builder);

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    reportError(error, $"SetUp within {this.GetType().FullName} - {error}");
                }
            }
        }
Ejemplo n.º 6
0
        public override async Task SetUp(SetUpContext context, Action <string, string> reportError)
        {
            //var schemaBuilder = context.ServiceProvider.GetRequiredService<ISchemaBuilder>();
            using (var builder = _schemaBuilder)
            {
                // configure
                Configure(builder);

                // Emails schema
                Emails(builder);

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    reportError(error, $"SetUp within {this.GetType().FullName} - {error}");
                }
            }
        }
Ejemplo n.º 7
0
        public override async Task InstallingAsync(IFeatureEventContext context)
        {
            var demo = new SchemaTable()
            {
                Name    = "Demo",
                Columns = new List <SchemaColumn>()
                {
                    new SchemaColumn()
                    {
                        PrimaryKey = true,
                        Name       = "Id",
                        DbType     = DbType.Int32
                    }
                }
            };

            //var schemaBuilder = context.ServiceProvider.GetRequiredService<ISchemaBuilder>();
            using (var builder = _schemaBuilder)
            {
                // create tables and default procedures
                builder
                .Configure(options =>
                {
                    options.ModuleName                 = base.ModuleId;
                    options.Version                    = "1.0.0";
                    options.DropTablesBeforeCreate     = true;
                    options.DropProceduresBeforeCreate = true;
                });

                builder.TableBuilder.CreateTable(demo);
                builder.ProcedureBuilder.CreateDefaultProcedures(demo);

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    context.Errors.Add(error, $"InstallingAsync within {this.GetType().FullName}");
                }
            }
        }
Ejemplo n.º 8
0
        public override async Task SetUp(SetUpContext context, Action <string, string> reportError)
        {
            using (var builder = _schemaBuilder)
            {
                // configure
                Configure(builder);

                // roles
                Roles(builder);

                // user roles
                UserRoles(builder);

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    reportError(error, $"SetUp within {this.GetType().FullName} - {error}");
                }
            }

            // Install default roles & permissions on first set-up
            await _defaultRolesManager.InstallDefaultRolesAsync();
        }
Ejemplo n.º 9
0
        public override async Task SetUp(SetUpContext context, Action <string, string> reportError)
        {
            // --------------------------
            // Build core schemas
            // --------------------------

            using (var builder = _schemaBuilder)
            {
                // configure
                Configure(builder);

                // features schema
                Features(builder);

                // Did any errors occur?

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    reportError(error, $"SetUp within {this.GetType().FullName} - {error}");
                }
            }
        }
Ejemplo n.º 10
0
        public override async Task SetUp(
            SetUpContext context,
            Action <string, string> reportError)
        {
            // --------------------------
            // Build core schemas
            // --------------------------

            var dictionaryTable = new SchemaTable()
            {
                Name    = "DictionaryEntries",
                Columns = new List <SchemaColumn>()
                {
                    new SchemaColumn()
                    {
                        PrimaryKey = true,
                        Name       = "Id",
                        DbType     = DbType.Int32
                    },
                    new SchemaColumn()
                    {
                        Name   = "[Key]",
                        Length = "255",
                        DbType = DbType.String
                    },
                    new SchemaColumn()
                    {
                        Name   = "[Value]",
                        Length = "max",
                        DbType = DbType.String
                    },
                    new SchemaColumn()
                    {
                        Name   = "CreatedUserId",
                        DbType = DbType.Int32
                    },
                    new SchemaColumn()
                    {
                        Name   = "CreatedDate",
                        DbType = DbType.DateTimeOffset
                    },
                    new SchemaColumn()
                    {
                        Name   = "ModifiedUserId",
                        DbType = DbType.Int32
                    },
                    new SchemaColumn()
                    {
                        Name     = "ModifiedDate",
                        DbType   = DbType.DateTimeOffset,
                        Nullable = true
                    }
                }
            };

            var documentTable = new SchemaTable()
            {
                Name    = "DocumentEntries",
                Columns = new List <SchemaColumn>()
                {
                    new SchemaColumn()
                    {
                        PrimaryKey = true,
                        Name       = "Id",
                        DbType     = DbType.Int32
                    },
                    new SchemaColumn()
                    {
                        Name   = "[Type]",
                        Length = "500",
                        DbType = DbType.String
                    },
                    new SchemaColumn()
                    {
                        Name   = "[Value]",
                        Length = "max",
                        DbType = DbType.String
                    },
                    new SchemaColumn()
                    {
                        Name   = "CreatedDate",
                        DbType = DbType.DateTimeOffset
                    },
                    new SchemaColumn()
                    {
                        Name   = "CreatedUserId",
                        DbType = DbType.Int32
                    },
                    new SchemaColumn()
                    {
                        Name   = "ModifiedDate",
                        DbType = DbType.DateTimeOffset
                    },
                    new SchemaColumn()
                    {
                        Name     = "ModifiedUserId",
                        DbType   = DbType.Int32,
                        Nullable = true
                    }
                }
            };

            using (var builder = _schemaBuilder)
            {
                // Build dictionary store
                // --------------------------

                builder
                .Configure(options =>
                {
                    options.ModuleName = "Plato.Core";
                    options.Version    = "1.0.0";
                });
                builder.TableBuilder.CreateTable(dictionaryTable);

                builder.ProcedureBuilder.CreateDefaultProcedures(dictionaryTable)
                .CreateProcedure(
                    new SchemaProcedure("SelectDictionaryEntryByKey", StoredProcedureType.SelectByKey)
                    .ForTable(dictionaryTable).WithParameter(new SchemaColumn()
                {
                    Name   = "[Key]",
                    Length = "255",
                    DbType = DbType.String
                }));

                builder.ProcedureBuilder.CreateDefaultProcedures(dictionaryTable)
                .CreateProcedure(
                    new SchemaProcedure("DeleteDictionaryEntryByKey", StoredProcedureType.DeleteByKey)
                    .ForTable(dictionaryTable).WithParameter(new SchemaColumn()
                {
                    Name   = "[Key]",
                    Length = "255",
                    DbType = DbType.String
                }));

                // Build document store
                // --------------------------

                builder
                .Configure(options =>
                {
                    options.ModuleName = "Plato.Core";
                    options.Version    = "1.0.0";
                });

                builder.TableBuilder.CreateTable(documentTable);

                builder.ProcedureBuilder
                .CreateDefaultProcedures(documentTable)
                .CreateProcedure(
                    new SchemaProcedure("SelectDocumentEntryByType", StoredProcedureType.SelectByKey)
                    .ForTable(documentTable)
                    .WithParameter(new SchemaColumn()
                {
                    Name   = "[Type]",
                    Length = "500",
                    DbType = DbType.String
                }));

                // Did any errors occur?

                var errors = await _schemaManager.ExecuteAsync(builder.Statements);

                foreach (var error in errors)
                {
                    reportError(error, $"SetUp within {this.GetType().FullName} - {error}");
                }
            }
        }