Пример #1
0
        /// <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);
        }
Пример #2
0
        public static ExecutableCollection LoadRules(String dir)
        {
            //Get files from specified directory
            DirectoryInfo di = new DirectoryInfo(dir);

            FileInfo[] ruleFiles = di.GetFiles("*.dll");

            //List of Types implementing IExecutable
            List <Type> executables = new List <Type>();

            //Loop over assemblies and find Types which implement IExecutable
            foreach (FileInfo file in ruleFiles)
            {
                try
                {
                    Type[] types = Assembly.LoadFrom(file.FullName).GetTypes();
                    var    exec  = types.Where(type => type.GetInterface("IExecutable") != null &&
                                               type.IsClass == true &&
                                               type.IsAbstract == false &&
                                               type.Name != "SQLRule").ToList();
                    executables.AddRange(exec);
                }
                catch (Exception e)
                {
                    //Do nothing. Some dll's are not the right format, then skip
                }
            }

            //Instantiate and return all executable Types
            ExecutableCollection c = new ExecutableCollection();

            executables.ForEach(e => c.AddExecutable((IExecutable)Activator.CreateInstance(e)));

            //c.AddExecutables(SQLRuleCollection.GetRules()); //SQL rules are now added when reading the config file

            return(c);
        }