Example #1
0
 /// <summary>
 /// Create new orphan record validation thread
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="dbContext"></param>
 public OrphanRecordValidationThread(OrphanRecordValidationThreadManager manager,
                                     DbContext dbContext,
                                     string tableName,
                                     TypeAccessor typeAccessor,
                                     List <ReferenceInformation> listReference)
 {
     this._manager        = manager;
     this._dbContext      = dbContext;
     this._tableName      = tableName;
     this._typeAccessor   = typeAccessor;
     this._listReferences = listReference;
     this._isDone         = false;
 }
 /// <summary>
 /// Create new orphan record validation thread
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="dbContext"></param>
 public OrphanRecordValidationThread(OrphanRecordValidationThreadManager manager,
                                     DbContext dbContext,
                                     string tableName,
                                     TypeAccessor typeAccessor,
                                     List<ReferenceInformation> listReference)
 {
     this._manager = manager;
     this._dbContext = dbContext;
     this._tableName = tableName;
     this._typeAccessor = typeAccessor;
     this._listReferences = listReference;
     this._isDone = false;
 }
        /// <summary>
        /// Validate database
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="sourceDatabase"></param>
        /// <param name="destinationDatabase"></param>
        public override void Validate(MappingManager manager, SourceDatabase sourceDatabase, DestinationDatabase destinationDatabase)
        {
            //
            // Initialize
            this.MigrationReference(manager, sourceDatabase, destinationDatabase);
            this._threadManager = new OrphanRecordValidationThreadManager(sourceDatabase, destinationDatabase);
            List<string> listTable = sourceDatabase.GetListTable();

            //
            // Start validate
            LogService.Log.Info("Start validate orphan record from database.");
            foreach (string table in listTable)
            {
                LogService.Log.Info("Validate table : " + table);
                this._threadManager.Validate(table);
            }

            //
            // Write SQLScript to Orphans.sql
            LogService.Log.Info("Create Orphans.sql to delete orphan record.");
            ErrorHandlerManager.ExportScriptToDeleteOrphan(sourceDatabase, @"Orphans.sql");
        }