Ejemplo n.º 1
0
        public async Task <string> ExecShrink(Model.ModelBackupSchedule _backupSchedule, Model.Enum.BackupStatus bkpStatus, bool bkpIsRunning, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            try
            {
                string url = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;
                _backupSchedule.BackupStatus = bkpStatus;

                var json          = JsonConvert.SerializeObject(_backupSchedule);
                var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

                var streamResult = await client.PostAsync(url + "/api/DatabaseService/Shrink", stringContent);

                if (!streamResult.IsSuccessStatusCode)
                {
                    return(await streamResult.Content.ReadAsStringAsync());
                }

                return("sucess");
            }
            catch (Exception err)
            {
                _utilTelegram.SendMessage($"Falha na atualização Status: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\n {err.Message}", _setting.UidTelegramDestino);
                return("false");
            }
        }
Ejemplo n.º 2
0
        private async Task <string> ExecChangeRecoveyModelType(ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting, int _recoveryTypeModel)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            try
            {
                string url = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;
                if (_recoveryTypeModel == 1)
                {
                    _backupSchedule.RecoveryTypeModel = 1;
                }
                else
                {
                    _backupSchedule.RecoveryTypeModel = 3;
                }

                var json          = JsonConvert.SerializeObject(_backupSchedule);
                var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

                var streamResult = await client.PostAsync(url + "/api/DatabaseService/ChangeRecoveryModel", stringContent);

                if (!streamResult.IsSuccessStatusCode)
                {
                    return(await streamResult.Content.ReadAsStringAsync());
                }

                return("sucess");
            }
            catch (Exception err)
            {
                _utilTelegram.SendMessage($"Falha alterar tipo de recuperação: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\n {err.Message}", _setting.UidTelegramDestino);
                return("false");
            }
        }
        public async Task <bool> ExecuteBackup(Model.ModelBackupSchedule _backupSchedule, ModelTaskMonitorSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            try
            {
                bool resp;
                // Marcar como backup status 2 Runing
                resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Runing, false);

                string url           = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;
                var    json          = JsonConvert.SerializeObject(_backupSchedule);
                var    stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");


                var streamResult = await client.PostAsync(url + "/api/DatabaseService/BackupExec", stringContent);

                if (streamResult.IsSuccessStatusCode)
                {
                    //resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Success, true);
                    return(true);
                }


                resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Failed, true);

                //_backupSchedule.DateHourLastExecution = DateTime.Now;
                //await UpdateDateHourLastExecution(_backupSchedule);
                _utilTelegram.SendMessage($"Falha na execução de Backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}", _setting.UidTelegramDestino);
                return(false);
            }
            catch (Exception err)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        private async Task <bool> ExecuteValidateBackup(Model.ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            try
            {
                string url = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;

                var json          = JsonConvert.SerializeObject(_backupSchedule);
                var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

                var streamResult = await client.PutAsync(url + "/api/DatabaseService/ValidateBackupExec", stringContent);

                if (!streamResult.IsSuccessStatusCode)
                {
                    var resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Corrupted, true, _setting);

                    var read = await streamResult.Content.ReadAsStringAsync();

                    _utilTelegram.SendMessage($"Falha na validação do backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToString()} \n" + read, _setting.UidTelegramDestino);
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public async Task <bool> ExecuteBackup(Model.ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);

            try
            {
                string url           = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;
                var    json          = JsonConvert.SerializeObject(_backupSchedule);
                var    stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");


                var streamResult = await client.PostAsync(url + "/api/DatabaseService/BackupExec", stringContent);

                if (streamResult.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    var errorResponse = await streamResult.Content.ReadAsStringAsync();

                    var isUpdated = await UpdateStatusDateTimeBackup(_backupSchedule, Model.Enum.BackupStatus.Failed, _setting);

                    _utilTelegram.SendMessage($"Falha na execução de Backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}", _setting.UidTelegramDestino);
                    return(false);
                }
            }
            catch (Exception err)
            {
                _utilTelegram.SendMessage($"Falha na execução de Backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\n {err.Message}", _setting.UidTelegramDestino);
                return(false);
            }
        }
Ejemplo n.º 6
0
        public async Task <string> UploadBackup(Model.ModelBackupSchedule _backupSchedule, ModelTaskMonitorSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            try
            {
                string url           = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;
                var    json          = JsonConvert.SerializeObject(_backupSchedule);
                var    stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

                var streamResult = await client.PostAsync(url + "/api/GoogleDriveService/Upload", stringContent);

                if (!streamResult.IsSuccessStatusCode)
                {
                    return("ERRO: " + await streamResult.Content.ReadAsStringAsync());
                }

                if (streamResult.IsSuccessStatusCode)
                {
                    var resp = await _helperSqlDatabase.UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Success, true);

                    if (_setting.IsDebug)
                    {
                        _utilTelegram.SendMessage($"Backup armazenado no GDrive com sucesso: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\brTipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);
                    }
                }
                return(await streamResult.Content.ReadAsStringAsync());
            }
            catch (Exception err)
            {
                var resp = await _helperSqlDatabase.UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.OutOfDate, true);

                _utilTelegram.SendMessage($"Falha durante armazenamento no GDrive: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToString()} \brMensagem: { err.Message}", _setting.UidTelegramDestino);
                throw err;
            }
        }
Ejemplo n.º 7
0
        public async Task <string> ExecuteDatabaseSchedule(Model.ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            bool isUpdated;

            try
            {
                bool response = false;

                response = await ExecuteBackup(_backupSchedule, _setting);

                if (response)
                {
                    bool res = await ExecuteValidateBackup(_backupSchedule, _setting);

                    if (!res)
                    {
                        response = false;
                    }
                }
                else
                {
                    _utilTelegram.SendMessage($"Falha na execução de backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\n Tipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);

                    isUpdated = await UpdateStatusDateTimeBackup(_backupSchedule, Model.Enum.BackupStatus.Corrupted, _setting);

                    return("Arquivo corrompido.");
                }

                if (response)
                {
                    if (_setting.IsDebug)
                    {
                        _utilTelegram.SendMessage($"Backup Executado com sucesso: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\n Tipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);
                    }
                    return("OK");
                }
                _utilTelegram.SendMessage($"Falha ao validar arquivo backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\n Tipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);

                isUpdated = await UpdateStatusDateTimeBackup(_backupSchedule, Model.Enum.BackupStatus.Corrupted, _setting);

                return("Arquivo corrompido.");
            }
            catch (Exception err)
            {
                isUpdated = await UpdateStatusDateTimeBackup(_backupSchedule, Model.Enum.BackupStatus.Failed, _setting);

                _utilTelegram.SendMessage($"Falha no sistema de backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToString()} - { err.Message}", _setting.UidTelegramDestino);

                if (err.InnerException != null)
                {
                    HelperLogs.WriteLog("HelperSqlDatabase", err.Message + "\n" + err.InnerException.Message);
                    return(err.Message + "\n" + err.InnerException.Message);
                }
                HelperLogs.WriteLog("HelperSqlDatabase", err.Message);
                return(err.Message);
            }
        }
Ejemplo n.º 8
0
        public async Task <string> BackupRun(Model.ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);

            try
            {
                var isExecuted = await ExecuteDatabaseSchedule(_backupSchedule, _setting);

                if (isExecuted.ToUpperInvariant().Contains("OK"))
                {
                    var resp = await UpdateStatusDateTimeBackup(_backupSchedule, Model.Enum.BackupStatus.Success, _setting);

                    return(isExecuted);

                    #region lixeira
                    ////backup garantido.. então inicie o upload
                    //var googleDriveFileId = await _helperGoogleDrive.UploadBackup(_backupSchedule, _setting);
                    //if (googleDriveFileId.Contains("ERRO"))
                    //{
                    //    resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.OutOfDate, true, _setting);
                    //    _utilTelegram.SendMessage($"Falha no Upload do Backup {_backupSchedule.Databases.DatabaseName}, tipo {_backupSchedule.Type}: {googleDriveFileId}", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                    //    new Exception(googleDriveFileId);
                    //}
                    //else
                    //{
                    //    _backupSchedule.GoogleDriveFileId = googleDriveFileId;
                    //    resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Success, true, _setting);
                    //    if (!resp.Equals("sucess"))
                    //    {
                    //        _utilTelegram.SendMessage($"Falha no serviço TaskManager: Erro ao atualizar status do backup, GoogleFileId e Status. " + resp, _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                    //    }
                    //}
                    #endregion
                }

                return(isExecuted);
            }
            catch (Exception err)
            {
                var isUpdated = await UpdateStatusDateTimeBackup(_backupSchedule, Model.Enum.BackupStatus.Failed, _setting);

                _utilTelegram.SendMessage($"Falha no serviço TaskManager: " + err.Message + "\n" + err.StackTrace, _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                if (err.InnerException != null)
                {
                    HelperLogs.WriteLog("HelperSqlDatabase", err.Message + "\n" + err.InnerException.Message);
                    return(err.Message + "\n" + err.InnerException.Message);
                }
                return(err.Message);
            }
        }
Ejemplo n.º 9
0
        public async Task <string> ExecuteUpload(Model.ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            bool isUpdated;

            try
            {
                string resp = null;
                isUpdated = await UpdateStatusDateTimeUpload(_backupSchedule, Model.Enum.BackupStatus.Uploading, _setting);

                var googleDriveFileId = await _helperGoogleDrive.UploadBackup(_backupSchedule, _setting);

                if (googleDriveFileId.ToUpperInvariant().Contains("ERRO"))
                {
                    isUpdated = await UpdateStatusDateTimeUpload(_backupSchedule, Model.Enum.BackupStatus.OutOfDate, _setting);

                    _utilTelegram.SendMessage($"Falha no Upload do Backup {_backupSchedule.Databases.DatabaseName}, tipo {_backupSchedule.Type}: {googleDriveFileId}", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                    new Exception(googleDriveFileId);
                }
                else
                {
                    _backupSchedule.GoogleDriveFileId = googleDriveFileId;
                    isUpdated = await UpdateStatusDateTimeUpload(_backupSchedule, Model.Enum.BackupStatus.Success, _setting);

                    if (!isUpdated)
                    {
                        _utilTelegram.SendMessage($"Falha ao atualizar status do backup, TaskService ExecUpload. \n" + resp, _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                    }
                }

                return(resp);
            }
            catch (Exception err)
            {
                isUpdated = await UpdateStatusDateTimeUpload(_backupSchedule, Model.Enum.BackupStatus.OutOfDate, _setting);

                if (!isUpdated)
                {
                    _utilTelegram.SendMessage($"Falha ao atualizar status do backup, TaskService ExecUpload. \n", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                }
                if (err.InnerException != null)
                {
                    HelperLogs.WriteLog("HelperSqlDatabase", err.Message + "\n" + err.InnerException.Message);
                    return(err.Message + "\n" + err.InnerException.Message);
                }
                HelperLogs.WriteLog("HelperSqlDatabase", err.Message);
                return(err.Message);
            }
        }
Ejemplo n.º 10
0
        public async Task <string> UploadBackup(Model.ModelBackupSchedule _backupSchedule, ModelTaskServiceSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);

            try
            {
                string url           = "http://" + _backupSchedule.CustomerProduct.Server.IpAddress + ":" + _backupSchedule.CustomerProduct.Server.Port;
                var    json          = JsonConvert.SerializeObject(_backupSchedule);
                var    stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

                var streamResult = await client.PostAsync(url + "/api/GoogleDriveService/Upload", stringContent);

                if (!streamResult.IsSuccessStatusCode)
                {
                    _utilTelegram.SendMessage($"Falha no Upload {_backupSchedule.Databases.DatabaseName}, tipo {_backupSchedule.Type}: \n Retorno Status Code Http: {streamResult.StatusCode} \n Chamada api: /api/GoogleDriveService/Upload.", _setting.UidTelegramDestino);
                    return("ERRO: " + await streamResult.Content.ReadAsStringAsync());
                }

                if (streamResult.IsSuccessStatusCode)
                {
                    if (_setting.IsDebug)
                    {
                        _utilTelegram.SendMessage($"Backup armazenado no GDrive com sucesso: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\rTipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);
                    }
                }

                return(await streamResult.Content.ReadAsStringAsync());
            }
            catch (Exception err)
            {
                if (err.InnerException != null)
                {
                    HelperLogs.WriteLog("HelperSqlDatabase", err.Message + "\n" + err.InnerException.Message);
                    _utilTelegram.SendMessage($"Falha durante armazenamento no GDrive: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToString()} \n Mensagem: { err.Message} \n {err.InnerException.Message}", _setting.UidTelegramDestino);
                    return(err.Message + "\n" + err.InnerException.Message);
                }
                HelperLogs.WriteLog("HelperSqlDatabase", err.Message);
                _utilTelegram.SendMessage($"Falha durante armazenamento no GDrive: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToString()} \n Mensagem: { err.Message}", _setting.UidTelegramDestino);
                return(err.Message);
            }
        }
        public async Task <bool> ExecuteDatabaseSchedule(Model.ModelBackupSchedule _backupSchedule, ModelTaskMonitorSettings _setting)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_setting.UidTelegramToken);
            try
            {
                bool response = false;

                response = await ExecuteBackup(_backupSchedule, _setting);

                if (response)
                {
                    bool res = await ExecuteValidateBackup(_backupSchedule, _setting);

                    if (!res)
                    {
                        response = false;
                    }
                }

                if (response)
                {
                    if (_setting.IsDebug)
                    {
                        _utilTelegram.SendMessage($"Backup Executado com sucesso: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\brTipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);
                    }
                    return(true);
                }
                _utilTelegram.SendMessage($"Falha ao validar arquivo backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToShortTimeString()}\brTipo: {_backupSchedule.Type}", _setting.UidTelegramDestino);
                var resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Corrupted, true);

                return(false);
            }
            catch (Exception err)
            {
                var resp = await UpdateStatusBackup(_backupSchedule, Model.Enum.BackupStatus.Failed, true);

                _utilTelegram.SendMessage($"Falha no sistema de backup: {_backupSchedule.Databases.DatabaseName}:{_backupSchedule.DateHourExecution.ToString()} - { err.Message}", _setting.UidTelegramDestino);
                throw err;
            }
        }
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            UtilitariosInfra.UtilTelegram _utilTelegram = new UtilitariosInfra.UtilTelegram(_configuration.GetSection("Services").GetSection("UidTelegramToken").Value);
            try
            {
                await WriteLog("Serviço iniciado.");

                while (!stoppingToken.IsCancellationRequested)
                {
                    // _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                    // carregar as configurações
                    listOfSettings = HelperTaskService.LoadSettings(_configuration);
                    bool[] arrayActive = new bool[5];

                    foreach (var setting in listOfSettings)
                    {
                        #region BackupRun
                        if (setting.IsActive && setting.Name.Contains("SqlDatabase"))
                        {
                            arrayActive[0] = true;
                        }
                        #endregion

                        #region BackupUpload
                        if (setting.IsActive && setting.Name.Contains("UploadGoogleDrive"))
                        {
                            arrayActive[4] = true;
                        }
                        #endregion
                    }

                    Task t0 = null;
                    Task t4 = null;

                    if (arrayActive[0])
                    {
                        t0 = Task.Run(() =>
                        {
                            ExecuteSqlDatabase(listOfSettings.Find(s => s.Name.Contains("SqlDatabase")));
                        });
                    }

                    // = ExecuteSqlDatabase(listOfSettings.Find(s => s.Name.Contains("SqlDatabase")));

                    if (arrayActive[4])
                    {
                        t4 = Task.Run(() =>
                        {
                            ExecuteUploadGoogleDrive(listOfSettings.Find(s => s.Name.Contains("UploadGoogleDrive")));
                        });
                    }

                    if (arrayActive[0] && arrayActive[4])
                    {
                        while (!t0.IsCompleted || !t4.IsCompleted)
                        {
                        }
                    }

                    while (!t0.IsCompleted)
                    {
                    }

                    await Task.Delay((2 * 60) * 1000);
                }
            }
            catch (Exception err)
            {
                _utilTelegram.SendMessage($"Falha no serviço TaskManager: {err.Message}", _configuration.GetSection("Services").GetSection("UidTelegramDestino").Value);
                await WriteLog(err.Message);
            }
        }
        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);
            }
        }