/// <summary>
        /// Ensures the Merchello database has been installed.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        internal bool EnsureDatabase()
        {
            var databaseSchemaCreation = new DatabaseSchemaCreation(_database, _logger, new DatabaseSchemaHelper(_database, _logger, _sqlSyntaxProvider), _sqlSyntaxProvider);
            var schemaResult           = databaseSchemaCreation.ValidateSchema();
            var databaseVersion        = schemaResult.DetermineInstalledVersion();

            if (databaseVersion != new Version("0.0.0"))
            {
                return(true);
            }

            // install the database
            var schemaHelper = new MerchelloDatabaseSchemaHelper(this._database, this._logger, this._sqlSyntaxProvider);

            schemaHelper.CreateDatabaseSchema();

            var baseDataCreation = new BaseDataCreation(this._database, this._logger);

            baseDataCreation.InitializeBaseData("merchTypeField");
            baseDataCreation.InitializeBaseData("merchInvoiceStatus");
            baseDataCreation.InitializeBaseData("merchOrderStatus");
            baseDataCreation.InitializeBaseData("merchWarehouse");
            baseDataCreation.InitializeBaseData("merchGatewayProviderSettings");
            baseDataCreation.InitializeBaseData("merchStoreSetting");
            baseDataCreation.InitializeBaseData("merchShipmentStatus");

            return(false);
        }
예제 #2
0
 public void Init()
 {
     var syntax = (DbSyntax)Enum.Parse(typeof(DbSyntax), ConfigurationManager.AppSettings["syntax"]);
     var worker = new DbPreTestDataWorker {SqlSyntax = syntax };
     var logger = Logger.CreateWithDefaultLog4NetConfiguration();
     var sqlSyntax = SqlSyntaxProviderTestHelper.SqlSyntaxProvider(syntax);
     _database = worker.Database;
     _databaseSchemaHelper = new MerchelloDatabaseSchemaHelper(_database, logger, sqlSyntax);
 }
예제 #3
0
        /// <summary>
        /// Ensures the Merchello database has been installed.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        internal bool EnsureDatabase()
        {
            var databaseSchemaCreation = new DatabaseSchemaCreation(_database, _logger, new DatabaseSchemaHelper(_database, _logger, _sqlSyntaxProvider), _sqlSyntaxProvider);
            var schemaResult           = databaseSchemaCreation.ValidateSchema();
            var databaseVersion        = schemaResult.DetermineInstalledVersion();

            if (databaseVersion != new Version("0.0.0"))
            {
                return(true);
            }

            // install the database
            var schemaHelper = new MerchelloDatabaseSchemaHelper(this._database, this._logger, this._sqlSyntaxProvider);

            schemaHelper.CreateDatabaseSchema();

            var baseDataCreation = new BaseDataCreation(this._database, this._logger);

            baseDataCreation.InitializeBaseData("merchTypeField");
            baseDataCreation.InitializeBaseData("merchInvoiceStatus");
            baseDataCreation.InitializeBaseData("merchOrderStatus");
            baseDataCreation.InitializeBaseData("merchWarehouse");
            baseDataCreation.InitializeBaseData("merchGatewayProviderSettings");
            baseDataCreation.InitializeBaseData("merchStoreSetting");
            baseDataCreation.InitializeBaseData("merchShipmentStatus");

            // Add 'merchello' to the admin group
            var ug = new UserGroup2AppDto {
                UserGroupId = 1, AppAlias = "merchello"
            };

            _database.Insert(ug);

            // TODO clear cache

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Ensures the Merchello database has been installed.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        internal bool EnsureDatabase()
        {
            var databaseSchemaCreation = new DatabaseSchemaCreation(_database, _logger, new DatabaseSchemaHelper(_database, _logger, _sqlSyntaxProvider), _sqlSyntaxProvider);
            var schemaResult = databaseSchemaCreation.ValidateSchema();
            var databaseVersion = schemaResult.DetermineInstalledVersion();

            if (databaseVersion != new Version("0.0.0")) return true;

            // install the database
            var schemaHelper = new MerchelloDatabaseSchemaHelper(this._database, this._logger, this._sqlSyntaxProvider);
            schemaHelper.CreateDatabaseSchema();

            var baseDataCreation = new BaseDataCreation(this._database, this._logger);
            baseDataCreation.InitializeBaseData("merchTypeField");
            baseDataCreation.InitializeBaseData("merchInvoiceStatus");
            baseDataCreation.InitializeBaseData("merchOrderStatus");
            baseDataCreation.InitializeBaseData("merchWarehouse");
            baseDataCreation.InitializeBaseData("merchGatewayProviderSettings");
            baseDataCreation.InitializeBaseData("merchStoreSetting");
            baseDataCreation.InitializeBaseData("merchShipmentStatus");

            return false;
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateDatabase"/> class.
 /// </summary>
 /// <param name="database">
 /// The database.
 /// </param>
 /// <param name="sqlSyntaxProvider">
 /// The sql Syntax Provider.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 internal CreateDatabase(Database database, ISqlSyntaxProvider sqlSyntaxProvider, ILogger logger)
 {
     _database = database;
     _logger = logger;
     _schemaHelper = new MerchelloDatabaseSchemaHelper(database, logger, sqlSyntaxProvider);
 }