Exemplo n.º 1
0
        public async Task <bool> Cadastrar(Log model)
        {
            try
            {
                using (IDbConnection conn = ConnectionsString.GetDefaultSqlServerConnection())
                {
                    var sql = $@"INSERT INTO Log(LogSistemaId,Data,Origem,Context,Severidade,Mensagem,ArquivoFonte,MetodoFonte,Maquina,LinhaFonte,Propriedades,Excecao,OrigemId,LogContextoId)
                                VALUES(@LogSistemaId,@Data,@Origem,@Context,@Severidade,@Mensagem,@ArquivoFonte,@MetodoFonte,@Maquina,@LinhaFonte,@Propriedades,@Excecao,@OrigemId,@LogContextoId)";

                    var result = await conn.ExecuteAsync(sql, new {
                        model.ArquivoFonte,
                        model.Context,
                        model.Data,
                        model.Excecao,
                        model.LinhaFonte,
                        model.LogContextoId,
                        model.LogSistemaId,
                        model.Maquina,
                        model.Mensagem,
                        model.MetodoFonte,
                        model.Origem,
                        model.OrigemId,
                        model.Propriedades,
                        model.Severidade
                    });

                    return(result > 0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
 public async void DeleteAll()
 {
     try
     {
         using (IDbConnection conn = ConnectionsString.GetDefaultSqlServerConnection())
         {
             var sql = $@"DELETE FROM Log";
             await conn.ExecuteAsync(sql);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        public async Task <IList <Log> > ListarLog()
        {
            try
            {
                using (IDbConnection conn = ConnectionsString.GetDefaultSqlServerConnection())
                {
                    var sql  = $@"SELECT TOP 10 * FROM Log";
                    var data = await conn.QueryAsync <Log>(sql);

                    return(data.AsList());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }