Пример #1
0
        public static void Log_Rotina(string siglaRotina, string nomeRotina, Tipo tipo)
        {
            LogRotina logRotina = new LogRotina
            {
                IdLog     = DateTime.Now.ToString("yyyyMMddHHmmss") + siglaRotina,
                IdCiclo   = Main.IdCiclo,
                Rotina    = nomeRotina,
                Tipo      = tipo.ToString(),
                Data      = DateTime.Now.ToString("yyyyMMdd"),
                Hora      = DateTime.Now.ToString("HH:mm:ss.fff"),
                Aplicacao = Service_Config.NomeServico,
                Cliente   = Service_Config.NomeCliente
            };

            LogDAO logDAO = new LogDAO();

            logDAO.RegistrarLogRotina(logRotina, ConexaoGuardian.Conexao());
        }
Пример #2
0
        public void RegistrarLogRotina(LogRotina logRotina, string conexao)
        {
            if (!Log_Config.LogRotina)
            {
                return;
            }

            string query =
                "INSERT INTO " + Tabelas_Guardian.LogRotina + " " +
                "(ID_LOG, ID_CICLO, ROTINA, TIPO, DATA, HORA, APLICACAO, CLIENTE) " +
                "VALUES (" +
                "'" + logRotina.IdLog + "', " +   // ID LOG
                "'" + logRotina.IdCiclo + "', " + // ID CICLO
                "'" + logRotina.Rotina + "', " +
                "'" + logRotina.Tipo + "', " +
                "'" + logRotina.Data + "', " +
                "'" + logRotina.Hora + "', " +
                "'" + logRotina.Aplicacao + "', " +
                "'" + logRotina.Cliente + "' " +
                ")";

            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 Rotina ", "Erro " + ex.ToString() + Environment.NewLine + " Status: " + Log_Config.LogRotina + " Query: " + query);
            }
        }