#18585: Preventing some expected errors from being logged during setup

Work Item: 18585

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-06-25 14:42:15 -07:00
parent fb8f839c89
commit 85927959cd
3 changed files with 21 additions and 23 deletions

View File

@@ -108,21 +108,17 @@ namespace Orchard.Setup.Services {
var shellBlueprint = _compositionStrategy.Compose(shellSettings, shellDescriptor);
// 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)
var shellDescriptorRepository = environment.Resolve<IRepository<ShellDescriptorRecord>>();
try
{
shellDescriptorRepository.Get(x => true);
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>());
try {
var tablePrefix = String.IsNullOrEmpty(_shellSettings.DataTablePrefix) ? "" : _shellSettings.DataTablePrefix + "_";
schemaBuilder.ExecuteSql("SELECT * FROM " + tablePrefix + "Settings_ShellDescriptorRecord");
}
catch
{
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>());
catch {
var reportsCoordinator = environment.Resolve<IReportsCoordinator>();
reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
@@ -136,8 +132,7 @@ namespace Orchard.Setup.Services {
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
dataMigrationManager.Update("Settings");
foreach (var feature in context.EnabledFeatures)
{
foreach (var feature in context.EnabledFeatures) {
dataMigrationManager.Update(feature);
}

View File

@@ -339,17 +339,20 @@ namespace Orchard.Data.Migration.Interpreters {
var session = _sessionLocator.For(typeof(ContentItemRecord));
var connection = session.Connection;
foreach (var sqlStatement in _sqlStatements) {
Logger.Debug(sqlStatement);
using (var command = connection.CreateCommand()) {
command.CommandText = sqlStatement;
command.ExecuteNonQuery();
try {
foreach (var sqlStatement in _sqlStatements) {
Logger.Debug(sqlStatement);
using (var command = connection.CreateCommand()) {
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));
}
_sqlStatements.Clear();
finally {
_sqlStatements.Clear();
}
}
private bool ExecuteCustomInterpreter<T>(T command) where T : ISchemaBuilderCommand {

View File

@@ -96,7 +96,7 @@ namespace Orchard.Environment.ShellBuilders {
}
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 {
SerialNumber = -1,