/// <summary> /// Executes all executable in the given ExecutableCollection /// </summary> public void Execute(ExecutableCollection executables, Database databaseModel, IEnumerable <TableID> tablesToCheckNames, IssueCollector issueCollector) { this.providerCollection = new ProviderCollection(); var tablesToCheck = databaseModel.Tables.Where(t => tablesToCheckNames.Any(c => c.TableName == t.TableName && c.SchemaName == t.SchemaName)); this.database = databaseModel; this.issueCollector = issueCollector; this.ExecutionStarted(); this.executionClockTotal.Start(); var plan = scheduler.GetExecutionPlan(executables, tablesToCheck); this.progressTracker = new ProgressTracker(plan.GetExecutables(), tablesToCheck); plan.ExecutePlan(this.runExecutable, this.finishedHandler); }
/// <summary> /// //Executes the SQL code specified in the "SQLCode" property and constructs issues which are added to the issueCollector parameter /// </summary> public void Execute(Model.Database database, IssueCollector issueCollector) { try { System.Data.DataTable sqlResult = database.Query(this.SQLCode.Value.Code); this.HandleSQLResult(sqlResult, issueCollector, database); } catch (Exception e) { //Rule execution failed (probably because of bad SQL). Raise an issue. Issue sqlErrorIssue = new Issue(this, this.DefaultSeverity.Value); sqlErrorIssue.Name = "Failed to execute SQL rule"; sqlErrorIssue.Description = new Description("Failed to execute SQL rule '{0}'", this.Name); sqlErrorIssue.ExtendedDescription = new Description("The error is:\n\n{0}\n\nThe SQL code is:\n\n{1}", e.Message, this.SQLCode.Value); sqlErrorIssue.Context = new DatabaseContext(database); issueCollector.ReportIssue(sqlErrorIssue); } }