/// <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);
        }
Beispiel #2
0
 public DatabaseSchemaHelper(Database db, ILogger logger, ISqlSyntaxProvider syntaxProvider)
 {
     _db               = db;
     _logger           = logger;
     _syntaxProvider   = syntaxProvider;
     _baseDataCreation = new BaseDataCreation(db, logger);
 }
Beispiel #3
0
        public void Init()
        {
            var worker = new DbPreTestDataWorker();

            _database = worker.Database;
            _creation = new BaseDataCreation(_database);
        }
        private bool CreateInitialMerchelloData(BaseDataCreation baseDataCreation)
        {
            baseDataCreation.InitializeBaseData("merchTypeField");
            baseDataCreation.InitializeBaseData("merchInvoiceStatus");
            baseDataCreation.InitializeBaseData("merchOrderStatus");
            baseDataCreation.InitializeBaseData("merchWarehouse");
            baseDataCreation.InitializeBaseData("merchGatewayProviderSettings");
            baseDataCreation.InitializeBaseData("merchStoreSetting");

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Executes the specified package name.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <returns></returns>
        public bool Execute(string packageName, System.Xml.XmlNode xmlData)
        {
            try
            {
                _schemaHelper.CreateDatabaseSchema();

                var creationData       = new BaseDataCreation(_database, _logger);
                var dataCreationResult = CreateInitialMerchelloData(creationData);

                return(true);
            }
            catch (Exception ex)
            {
                var message = string.Concat("Error at install ", this.Alias(), " package action: ", ex);
                LogHelper.Error(typeof(CreateDatabase), message, ex);
            }

            return(false);
        }
        /// <summary>
        /// Executes the specified package name.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <returns></returns>
        public bool Execute(string packageName, System.Xml.XmlNode xmlData)
        {
            try
            {
                var creation = new DatabaseSchemaCreation(Umbraco.Core.ApplicationContext.Current.DatabaseContext.Database);
                creation.InitializeDatabaseSchema();

                var  creationData       = new BaseDataCreation(Umbraco.Core.ApplicationContext.Current.DatabaseContext.Database);
                bool dataCreationResult = CreateInitialMerchelloData(creationData);

                return(true);
            }
            catch (Exception ex)
            {
                var message = string.Concat("Error at install ", this.Alias(), " package action: ", ex);
                LogHelper.Error(typeof(CreateDatabase), message, ex);
            }

            return(false);
        }
Beispiel #7
0
        private void RebuildDatabase()
        {
            // migration
            var schema = new DatabaseSchemaCreation(Database);

            // drop all the tables
            schema.UninstallDatabaseSchema();

            // install the schema
            schema.InitializeDatabaseSchema();

            // add the default data
            var baseDataCreation = new BaseDataCreation(Database);

            baseDataCreation.InitializeBaseData("merchDBTypeField");
            baseDataCreation.InitializeBaseData("merchInvoiceStatus");
            baseDataCreation.InitializeBaseData("merchOrderStatus");
            baseDataCreation.InitializeBaseData("merchWarehouse");
            baseDataCreation.InitializeBaseData("merchGatewayProviderSettings");
            baseDataCreation.InitializeBaseData("merchStoreSetting");
        }
Beispiel #8
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);
        }
Beispiel #9
0
        private static void PetaPocoExtensions_NewTable(string tableName, Database db, TableCreationEventArgs e)
        {
            var baseDataCreation = new BaseDataCreation(db);

            baseDataCreation.InitializeBaseData(tableName);
        }