Exemplo n.º 1
0
        public static void Log_Email(string email, string rotina, Status status, string infoAdicionais)
        {
            LogEmail logEmail = new LogEmail
            {
                Data           = DateTime.Now.ToString("yyyyMMdd"),
                Hora           = DateTime.Now.ToString("HH:mm:ss.fff"),
                Email          = email,
                Rotina         = rotina,
                Status         = status.ToString(),
                InfoAdicionais = infoAdicionais,
                Aplicacao      = Service_Config.NomeServico
            };

            LogDAO logDAO = new LogDAO();

            logDAO.RegistrarLogEmail(logEmail, ConexaoGuardian.Conexao());
        }
Exemplo n.º 2
0
        public void RegistrarLogEmail(LogEmail logEmail, string conexao)
        {
            if (!Log_Config.LogEmail)
            {
                return;
            }

            string query =
                "INSERT INTO " + Tabelas_Guardian.LogEmail + " " +
                "(DATA, HORA, EMAIL, ROTINA, STATUS, INFO_ADICIONAIS, APLICACAO) " +
                "VALUES (" +
                " '" + logEmail.Data + "', " +
                " '" + logEmail.Hora + "', " +
                " '" + logEmail.Email + "', " +
                " '" + logEmail.Rotina + "', " +
                " '" + logEmail.Status + "', " +
                " '" + logEmail.InfoAdicionais + "', " +
                " '" + logEmail.Aplicacao + "' " +
                ")";

            try
            {
                using (SqlConnection connection = new SqlConnection(conexao))
                {
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                Guardian_LogTxt.LogAplicacao("Registrar Log Email ", "Erro " + ex.ToString() + Environment.NewLine + " Status: " + Log_Config.LogEmail + " Query: " + query);
            }
        }