예제 #1
0
        /// <summary>
        /// Valida as permissões das tabelas passadas
        /// </summary>
        /// <param name="tablesDiagnostics"></param>
        /// <returns></returns>
        public async Task <IList <Diagnostic> > HealthCheckAsync(ITablesDiagnostics tablesDiagnostics)
        {
            var diagnosticResults = new List <Diagnostic>();

            var checksTablesResult = await _heathCheckRepository.CheckTablePermissionsAsync(tablesDiagnostics);

            foreach (var databaseDiagnostic in checksTablesResult)
            {
                var dataBasePermissionDiagnostic = await Check(async() => databaseDiagnostic).ConfigureAwait(false);

                diagnosticResults.Add(dataBasePermissionDiagnostic);
            }

            return(diagnosticResults);
        }
        /// <summary>
        /// Valida a permissão das tabelas necessárias para o funcionamento do ptolemeu
        /// </summary>
        /// <param name="tablesDiagnostics"></param>
        /// <returns></returns>
        public async Task <IList <Diagnostic> > CheckTablePermissionsAsync(ITablesDiagnostics tablesDiagnostics)
        {
            foreach (var table in tablesDiagnostics.TablePermissions)
            {
                // Recupera as permissões da tabela passada
                var permissions = GetPermissions(table);

                // Adiciona as tabelas e as permissões necessárias para o funcionamento
                _dbDependency.AddTableDependency(table.Name, permissions);
            }

            // Executa o healthCheck
            var healthData = await Task.Run(() => _healthChecker.CheckHealth()).ConfigureAwait(false);

            // Constrói uma lista de Diagnostico
            var buildHealthData = BuildHealthData(healthData);

            return(buildHealthData);
        }