public void ExecuteDatabaseQueries()
        {
            //Starting new tasks for each database
            List <Task> databaseTasks = new List <Task>();

            _dbList.ForEach((db) => databaseTasks.Add(Task.Factory.StartNew(() =>
            {
                RepositoryAccess repositoryAccess = new RepositoryAccess();
                db.InstanceId = _instanceId;
                db.Id         = repositoryAccess.SaveDatabase(db);
                //If database' state is not online, finishing task, else collecting data about database' tables
                if (db.DbState > 0)
                {
                    return;
                }
                GetListofTables getListofTables = new GetListofTables(_sqlConnection, db);
                getListofTables.Run();
                repositoryAccess.SaveTables(getListofTables.ListofTables);
            }
                                                                            )));
            try
            {
                Task.WaitAll(databaseTasks.ToArray());
            }
            catch (AggregateException ex)
            {
                throw ex.Flatten();
            }
        }
Ejemplo n.º 2
0
 public AllQueriesExecutor(SqlConnection sqlConnection)
 {
     _sqlConnection      = sqlConnection;
     getBaseInstanceInfo = new GetBaseInstanceInfo(_sqlConnection);
     getListofDatabases  = new GetListofDatabases(_sqlConnection);
     repositoryAccess    = new RepositoryAccess();
 }
Ejemplo n.º 3
0
 static Collector()
 {
     repositoryAccess = new RepositoryAccess();
     manager          = new ConnectionManager();
 }