mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18585: Preventing some expected errors from being logged during setup
Work Item: 18585 --HG-- branch : 1.x
This commit is contained in:
@@ -108,21 +108,17 @@ namespace Orchard.Setup.Services {
|
|||||||
var shellBlueprint = _compositionStrategy.Compose(shellSettings, shellDescriptor);
|
var shellBlueprint = _compositionStrategy.Compose(shellSettings, shellDescriptor);
|
||||||
|
|
||||||
// initialize database explicitly, and store shell descriptor
|
// initialize database explicitly, and store shell descriptor
|
||||||
using (var bootstrapLifetimeScope = _shellContainerFactory.CreateContainer(shellSettings, shellBlueprint))
|
using (var bootstrapLifetimeScope = _shellContainerFactory.CreateContainer(shellSettings, shellBlueprint)) {
|
||||||
{
|
|
||||||
|
|
||||||
using (var environment = bootstrapLifetimeScope.CreateWorkContextScope())
|
using (var environment = bootstrapLifetimeScope.CreateWorkContextScope()) {
|
||||||
{
|
|
||||||
|
|
||||||
// check if the database is already created (in case an exception occured in the second phase)
|
// check if the database is already created (in case an exception occured in the second phase)
|
||||||
var shellDescriptorRepository = environment.Resolve<IRepository<ShellDescriptorRecord>>();
|
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>());
|
||||||
try
|
try {
|
||||||
{
|
var tablePrefix = String.IsNullOrEmpty(_shellSettings.DataTablePrefix) ? "" : _shellSettings.DataTablePrefix + "_";
|
||||||
shellDescriptorRepository.Get(x => true);
|
schemaBuilder.ExecuteSql("SELECT * FROM " + tablePrefix + "Settings_ShellDescriptorRecord");
|
||||||
}
|
}
|
||||||
catch
|
catch {
|
||||||
{
|
|
||||||
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>());
|
|
||||||
var reportsCoordinator = environment.Resolve<IReportsCoordinator>();
|
var reportsCoordinator = environment.Resolve<IReportsCoordinator>();
|
||||||
|
|
||||||
reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
|
reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
|
||||||
@@ -136,8 +132,7 @@ namespace Orchard.Setup.Services {
|
|||||||
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
|
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
|
||||||
dataMigrationManager.Update("Settings");
|
dataMigrationManager.Update("Settings");
|
||||||
|
|
||||||
foreach (var feature in context.EnabledFeatures)
|
foreach (var feature in context.EnabledFeatures) {
|
||||||
{
|
|
||||||
dataMigrationManager.Update(feature);
|
dataMigrationManager.Update(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -339,17 +339,20 @@ namespace Orchard.Data.Migration.Interpreters {
|
|||||||
var session = _sessionLocator.For(typeof(ContentItemRecord));
|
var session = _sessionLocator.For(typeof(ContentItemRecord));
|
||||||
var connection = session.Connection;
|
var connection = session.Connection;
|
||||||
|
|
||||||
foreach (var sqlStatement in _sqlStatements) {
|
try {
|
||||||
Logger.Debug(sqlStatement);
|
foreach (var sqlStatement in _sqlStatements) {
|
||||||
using (var command = connection.CreateCommand()) {
|
Logger.Debug(sqlStatement);
|
||||||
command.CommandText = sqlStatement;
|
using (var command = connection.CreateCommand()) {
|
||||||
command.ExecuteNonQuery();
|
command.CommandText = sqlStatement;
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
_reportsCoordinator.Information("Data Migration", String.Format("Executing SQL Query: {0}", sqlStatement));
|
||||||
}
|
}
|
||||||
|
|
||||||
_reportsCoordinator.Information("Data Migration", String.Format("Executing SQL Query: {0}", sqlStatement));
|
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
_sqlStatements.Clear();
|
_sqlStatements.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ExecuteCustomInterpreter<T>(T command) where T : ISchemaBuilderCommand {
|
private bool ExecuteCustomInterpreter<T>(T command) where T : ISchemaBuilderCommand {
|
||||||
|
@@ -96,7 +96,7 @@ namespace Orchard.Environment.ShellBuilders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ShellContext CreateSetupContext(ShellSettings settings) {
|
public ShellContext CreateSetupContext(ShellSettings settings) {
|
||||||
Logger.Warning("No shell settings available. Creating shell context for setup");
|
Logger.Debug("No shell settings available. Creating shell context for setup");
|
||||||
|
|
||||||
var descriptor = new ShellDescriptor {
|
var descriptor = new ShellDescriptor {
|
||||||
SerialNumber = -1,
|
SerialNumber = -1,
|
||||||
|
Reference in New Issue
Block a user