public static List <ModelTaskMonitorSettings> LoadSettings(IConfiguration configuration)
        {
            List <ModelTaskMonitorSettings> listOfSettings = new List <ModelTaskMonitorSettings>();

            if (Convert.ToBoolean(configuration.GetSection("Services").GetSection("SqlDatabase").GetSection("IsActive").Value))
            {
                listOfSettings.Add(HelperTaskMonitor.LoadSetting("SqlDatabase", configuration));
            }
            if (Convert.ToBoolean(configuration.GetSection("Services").GetSection("MysqlDatabase").GetSection("IsActive").Value))
            {
                listOfSettings.Add(HelperTaskMonitor.LoadSetting("MysqlDatabase", configuration));
            }
            if (Convert.ToBoolean(configuration.GetSection("Services").GetSection("CeltaBSSynch").GetSection("IsActive").Value))
            {
                listOfSettings.Add(HelperTaskMonitor.LoadSetting("CeltaBSSynch", configuration));
            }
            if (Convert.ToBoolean(configuration.GetSection("Services").GetSection("OpenVpn").GetSection("IsActive").Value))
            {
                listOfSettings.Add(HelperTaskMonitor.LoadSetting("OpenVpn", configuration));
            }

            return(listOfSettings);
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_configuration.GetSection("Services").GetSection("UidTelegramToken").Value);
            try
            {
                while (!stoppingToken.IsCancellationRequested)
                {
                    WriteLog("Serviço iniciado.");
                    // obter os tipos de monitoramento!
                    listOfSettings = HelperTaskMonitor.LoadSettings(_configuration);

                    foreach (var setting in listOfSettings)
                    {
                        if (setting.IsActive && setting.Name.Contains("SqlDatabase"))
                        {
                            //executa este setting de backup SQL
                            Adapters.AdapterSqlDatabase sqlDatabase = new Adapters.AdapterSqlDatabase(setting);

                            var schedules = await sqlDatabase.GetDatabaseBackupSchedule(setting.Url, DateTime.Now.Hour);

                            while (schedules.Count > 0)
                            {
                                for (int i = 0; i < schedules.Count; i++)
                                {
                                    int isExecute     = schedules[i].DateHourExecution.Minute.CompareTo(DateTime.Now.Minute);
                                    int lastExecution = schedules[i].DateHourLastExecution.Date.CompareTo(DateTime.Now.Date);
                                    if ((isExecute == 0 && lastExecution == -1) || (isExecute == -1 && lastExecution == -1) && !schedules[i].BackupStatus.Equals(Model.Enum.BackupStatus.Runing))
                                    {
                                        // está dentro do horario então executa!!!
                                        var isExecuted = await _helperSqlDatabase.ExecuteDatabaseSchedule(schedules[i], setting);

                                        if (isExecuted)
                                        {
                                            //backup garantido.. então inicie o upload
                                            var googleDriveFileId = await _helperGoogleDrive.UploadBackup(schedules[i], setting);

                                            if (googleDriveFileId.Contains("ERRO:"))
                                            {
                                                var resp = await _helperSqlDatabase.UpdateStatusBackup(schedules[i], Model.Enum.BackupStatus.OutOfDate, true);

                                                _utilTelegram.SendMessage($"Falha no Upload do Backup: {googleDriveFileId}", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                                                new Exception(googleDriveFileId);
                                            }
                                            else
                                            {
                                                schedules[i].GoogleDriveFileId = googleDriveFileId;
                                                var resp = await _helperSqlDatabase.UpdateStatusBackup(schedules[i], Model.Enum.BackupStatus.Success, true);

                                                if (!resp)
                                                {
                                                    _utilTelegram.SendMessage($"Falha no serviço TaskManager: Erro ao atualizar status do backup, GoogleFileId e Status", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                                                }
                                            }
                                        }
                                    }
                                }
                                // schedules.Remove(schedules[i]);
                                schedules = await sqlDatabase.GetDatabaseBackupSchedule(setting.Url, DateTime.Now.Hour);
                            }
                            await Task.Delay((setting.UpdateInterval * 60) * 1000, stoppingToken);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                _utilTelegram.SendMessage($"Falha no serviço TaskManager: {err.Message}", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                WriteLog(err.Message);
            }
        }