/// <summary> /// Initialize hasMapped dictionary with tableName /// To determinate which record has been mapped /// </summary> /// <param name="tableName"></param> /// <param name="sourceDatabase"></param> /// <param name="destinationDatabase"></param> protected void Initialize(string tableName, DatabaseSnapshot sourceSnapshot, DatabaseSnapshot destSnapshot, DatabaseSnapshot outputSnapshot) { //TableSnapshot sourceTable = sourceSnapshot.GetTableSnapshot(tableName); TableSnapshot destTable = destSnapshot.GetTableSnapshot(tableName); //// //// Get common record from source table and destTable //// Then try to save to database //TableSnapshot commonTable = TableSnapshot.GetCommonRecord(sourceTable, destTable); //if (commonTable.IsEmpty == false) //{ // this._listTableToCheck.Add(tableName); //} if (destTable.IsEmpty == false) { this._listTableToCheck.Add(tableName); } // // Add outputSnapshot.Add(destTable); LogService.Log.Info("Saved snapshot of table : " + tableName); }
/// <summary> /// Initialize DatabaseSentinel for sourceDatabase and destinationDatabase /// </summary> /// <param name="source"></param> /// <param name="destination"></param> public void Initialize(SourceDatabase source, DestinationDatabase destination) { // // Create database snapshot // To store record which has been mapped DatabaseSnapshot sourceDatabaseSnapshot = new DatabaseSnapshot(source); DatabaseSnapshot destDatabaseSnapshot = new DatabaseSnapshot(destination); // // Get all table of destination database // Validate source table, and destination table List<string> listTables = destination.GetListTableHasPrimaryKey(); foreach (string table in listTables) { try { this.Initialize(table, sourceDatabaseSnapshot, destDatabaseSnapshot, destDatabaseSnapshot); } catch (Exception excSaveSnapshot) { LogService.Log.Error("Can not save snapshot of table " + table + ". Please check your schema again.", excSaveSnapshot); Environment.Exit(0); } } // // Save snapshot this._databaseSnapshot = destDatabaseSnapshot; }