Esempio n. 1
0
        public static void Log_Rotina(string nomeRotina, Tipo tipo, string textoLivre)
        {
            LogRotina logRotina = new LogRotina
            {
                Origem = "APLICACAO",
                Data   = DateTime.Now.ToString("yyyyMMdd"),
                Hora   = DateTime.Now.ToString("HH:mm:ss"),
                Tipo   = tipo.ToString(),
                Rotina = nomeRotina,
                Log    = textoLivre,
            };

            LogDAO logDAO = new LogDAO();

            logDAO.RegistrarLogRotina(logRotina, ConexaoERP.Conexao());
        }
Esempio n. 2
0
        public void RegistrarLogRotina(LogRotina logRotina, string conexao)
        {
            if (!Log_Config.LogRotina)
            {
                return;
            }

            byte[] log = Encoding.UTF8.GetBytes(guardian_Util.FormatarCaracter(logRotina.Log));

            string query =
                "INSERT INTO " + Tabelas_Guardian.ZA0 + " " +
                "(ZA0_ORIGEM, ZA0_DATA, ZA0_HORA, ZA0_TIPO, ZA0_ROTINA, ZA0_LOG) " +
                "VALUES (" +
                "'" + logRotina.Origem + "', " +
                "'" + logRotina.Data + "', " +
                "'" + logRotina.Hora + "', " +
                "'" + logRotina.Tipo + "', " +
                "'" + logRotina.Rotina + "', " +
                "@log " +
                ")";

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