/// <summary> /// Validate table /// </summary> /// <param name="tableName"></param> public void Validate(string tableName) { // // Get DbSet DbSet dbSet = this._sourceDatabase.GetTable(tableName); if (dbSet == null) { return; } // // Get type accessor to access record's value TypeAccessor typeAccessor = this._sourceDatabase.GetTableTypeAccessor(tableName); if (typeAccessor == null) { return; } // // Get list reference of table List<ReferenceInformation> listReference = this._sourceDatabase.GetListReference(tableName); if (listReference.Count == 0) { return; } // // Load table into memory dbSet.Load(); this._listTask = dbSet.Local; this._numberOfTask = this._listTask.Count; this._currentIndex = 0; LogService.Log.Info("Total records : " + this._numberOfTask.ToString()); if (this._numberOfTask == 0) { return; } // // Calculate how many thread will we need int numberOfThreads = this.MaximumNumberOfThread; if (this._numberOfTask < numberOfThreads * this.MinimumTaskForThread) { numberOfThreads = this._numberOfTask / this.MinimumTaskForThread; if (numberOfThreads == 0) { numberOfThreads = 1; } } // // Create thread and start LogService.Log.Info("Creating " + numberOfThreads.ToString() + " threads to validate."); this._threadHandler = new List<OrphanRecordValidationThread>(); for (int counter = 0; counter < numberOfThreads; ++counter) { OrphanRecordValidationThread thread = new OrphanRecordValidationThread(this, this._sourceDatabase.GetNewDbContext(), tableName, typeAccessor, listReference); thread.Start(); this._threadHandler.Add(thread); } // // Wait until done bool done = false; while (done == false) { done = true; foreach (OrphanRecordValidationThread thread in this._threadHandler) { if (thread.IsDone == false) { done = false; break; } } LogService.Log.Info(this._currentIndex.ToString() + " / " + this._numberOfTask.ToString()); System.Threading.Thread.Sleep(1000); } }
/// <summary> /// Validate table /// </summary> /// <param name="tableName"></param> public void Validate(string tableName) { // // Get DbSet DbSet dbSet = this._sourceDatabase.GetTable(tableName); if (dbSet == null) { return; } // // Get type accessor to access record's value TypeAccessor typeAccessor = this._sourceDatabase.GetTableTypeAccessor(tableName); if (typeAccessor == null) { return; } // // Get list reference of table List <ReferenceInformation> listReference = this._sourceDatabase.GetListReference(tableName); if (listReference.Count == 0) { return; } // // Load table into memory dbSet.Load(); this._listTask = dbSet.Local; this._numberOfTask = this._listTask.Count; this._currentIndex = 0; LogService.Log.Info("Total records : " + this._numberOfTask.ToString()); if (this._numberOfTask == 0) { return; } // // Calculate how many thread will we need int numberOfThreads = this.MaximumNumberOfThread; if (this._numberOfTask < numberOfThreads * this.MinimumTaskForThread) { numberOfThreads = this._numberOfTask / this.MinimumTaskForThread; if (numberOfThreads == 0) { numberOfThreads = 1; } } // // Create thread and start LogService.Log.Info("Creating " + numberOfThreads.ToString() + " threads to validate."); this._threadHandler = new List <OrphanRecordValidationThread>(); for (int counter = 0; counter < numberOfThreads; ++counter) { OrphanRecordValidationThread thread = new OrphanRecordValidationThread(this, this._sourceDatabase.GetNewDbContext(), tableName, typeAccessor, listReference); thread.Start(); this._threadHandler.Add(thread); } // // Wait until done bool done = false; while (done == false) { done = true; foreach (OrphanRecordValidationThread thread in this._threadHandler) { if (thread.IsDone == false) { done = false; break; } } LogService.Log.Info(this._currentIndex.ToString() + " / " + this._numberOfTask.ToString()); System.Threading.Thread.Sleep(1000); } }