Exemple #1
0
        /// <summary>
        /// Dont map this table
        /// </summary>
        /// <param name="tableName"></param>
        public void IgnoreTable(string tableName)
        {
            MapTable table = this.GetMapTable(tableName);

            if (table != null)
            {
                table.Map();
            }
        }
Exemple #2
0
        /// <summary>
        /// Start map database from source to destination database
        /// </summary>
        public void Map()
        {
            //
            // Validate data first
            //if (this._databaseSentinel.ValidateData(this, destination, @"D:\ValidateResult.txt") == false)
            //{
            //    Console.WriteLine("Validation failed. Terminated.");
            //    return;
            //}


            //
            // Initialize for DatabaseSentinel (checking duplicated data)
            // And DataConversionReflection
            LogService.Log.Info("Number of table in destination database : " + this._destinationDatabase.NumberOfTable.ToString());
            LogService.Log.Info("Creating snapshot of database.");
            this._databaseSentinel.Initialize(this._sourceDatabase, this._destinationDatabase);
            this._multiThreadManager    = new MultiThreadManager(this, this._sourceDatabase, this._destinationDatabase, this._databaseSentinel, this.MaximumNumberOfThread, this.MinimumTaskForThread);
            this._sqlMultiThreadManager = new SQLMultiThreadingManager(this._destinationDatabase, this.MaximumNumberOfThread, this.MinimumTaskForThread);


            //
            // Ok, start map
            LogService.Log.Info("Start mapping.");
            while (this._destinationDatabase.IsCompleted() == false)
            {
                //
                // Get next table to map
                MapTable nextTable = this._destinationDatabase.NextTable();
                if (nextTable == null)
                {
                    LogService.Log.Error("Can not get next table to map. Please check circle references again.");
                    break;
                }



                //
                // Is manual mapping or auto mapping
                nextTable.Map();
                LogService.Log.Info("Start mapping " + nextTable.Name);
                try
                {
                    if (this.IsManualMapping(nextTable.Name))
                    {
                        this.MapManual(nextTable.Name);
                    }
                    else
                    {
                        this.MapAutomatically(nextTable.Name);
                    }
                }
                catch (Exception exc)
                {
                    LogService.Log.Error("Error occurs when mapping with table " + nextTable.Name, exc);
                }


                //
                // Append to batch file to run SQL script
                if (this.IsGeneratedScript)
                {
                    this._batFileGenerator.RunSQLFile(Path.GetFileName(this.GetFilePath(nextTable.Name)));
                }
            }


            //
            // Run post migration script
            this.RunPostMigrationScript(this._destinationDatabase);


            //
            // Report, done mapping
            if (this.IsGeneratedScript)
            {
                this._batFileGenerator.ShowMessage("Done.");
                this._batFileGenerator.EchoOn();
            }
            LogService.Log.Info("Mapping completed.");
        }