Exemplo n.º 1
0
        public BaseJobUpdater GetUpdater(JobType.UpdateInfoType type)
        {
            //if (updateWorkers.ContainsKey(type)) return updateWorkers[type];

            IConnectionManager  connManager         = new ConnectionManager(logger, encryptionManager);
            InstanceInfoUpdater instanceInfoUpdater = new InstanceInfoUpdater(logger);

            IInstanceDataCollector instanceDataCollector = DependencyConfig.Initialize().Resolve <IInstanceDataCollector>(
                new ParameterOverride("connManager", connManager),
                new ParameterOverride("resourceManager", resourceManager),
                new ParameterOverride("logger", logger));

            //logger.Debug("instanceDataCollector = "+ instanceDataCollector.GetHashCode());

            if (type == JobType.UpdateInfoType.Full)
            {
                return(new FullJobUpdater(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector));
            }
            if (type == JobType.UpdateInfoType.CheckStatus)
            {
                return(new StatusJobUpdater(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector));
            }
            if (type == JobType.UpdateInfoType.RemoveInstances)
            {
                return(new RemoveJobUpdater(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector));
            }

            return(null);
        }
Exemplo n.º 2
0
        public async Task <InstanceInfo> UpdateAsync(Instance instance, IInstanceDataCollector collector)
        {
            // Get information about databases and their principals (inluding permissions).
            // Stars first because it has more data and more time to process it.
            DataTable databases = await collector.GetDatabasesAsync();                     // List of all databases on the instance with some basic information (size, date of creation).

            DataTable databaseRoles = await collector.GetDatabaseRolesAsync();             // List of all roles on all databases.

            DataTable databaseUsers = await collector.GetDatabaseUsersAsync();             // List of all users on all databases.

            DataTable databasePermissions = await collector.GetDatabasePermissionsAsync(); // List of all permissions on all databases.

            // Get information about instance and it's principals.
            var instanceDetailsTask     = collector.GetInstanceInfoAsync();
            var instanceRolesTask       = collector.GetInstanceRolesAsync();
            var instanceLoginsTask      = collector.GetInstanceLoginsAsync();
            var instancePermissionsTask = collector.GetInstancePermissionsAsync();
            // Start parsing databases and their principals.
            var parsedDatabases = ParseDatabasesAndTheirPrincipals(databases, databaseRoles, databaseUsers, databasePermissions);
            // Start parsing of instance principals
            InstanceInfo result = ParseInstancePrincipals(
                instance.Id,
                (await instanceDetailsTask).Rows[0],
                await instanceRolesTask,
                await instanceLoginsTask,
                await instancePermissionsTask);

            result.Databases.AddRange(parsedDatabases);
            return(result);
        }
Exemplo n.º 3
0
 public BaseJobUpdater(InstanceInfoUpdater instanceInfoUpdater, ISLogger logger, IUnitOfWork unitOfWork, IConnectionManager connManager, IInstanceDataCollector instanceDataCollector)
 {
     this.logger                = logger;
     this.unitOfWork            = unitOfWork;
     this.connManager           = connManager;
     this.instanceInfoUpdater   = instanceInfoUpdater;
     this.instanceDataCollector = instanceDataCollector;
 }
Exemplo n.º 4
0
 public RemoveJobUpdater(InstanceInfoUpdater instanceInfoUpdater, ISLogger logger, IUnitOfWork unitOfWork, IConnectionManager connManager,
                         IInstanceDataCollector instanceDataCollector) :
     base(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector)
 {
 }
Exemplo n.º 5
0
 public async Task <InstanceInfo> UpdateStatusOnlyAsync(int instanceID, IInstanceDataCollector collector)
 {
     return(ParseInstanceInfo(
                new InstanceInfo(instanceID),
                (await collector.GetInstanceInfoAsync()).Rows[0]));
 }
Exemplo n.º 6
0
 public InstanceInfo UpdateStatusOnly(Instance instance, IInstanceDataCollector collector)
 {
     return(ParseInstanceInfo(new InstanceInfo(instance.Id), collector.GetInstanceInfo().Rows[0]));
 }