Ejemplo n.º 1
0
        private void InsertTraza(string mensaje, int acceso = -1, Nivel nivel = 0, SubNivel subNivel = 0, int elemento = 0, SubElemento subElemento = 0, Terciario terciario = 0, Accion accion = 0, SubAccion subAccion = 0)
        {
            using (var connection = new MySql.Data.MySqlClient.MySqlConnection(_config.GetConnectionString(_connectionString)))
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "INSERT INTO log (IdNivel,IdSubNivel,IdentificadorAcceso,IdElemento,IdSubElemento,IdTerciario,IdAccion,IdSubAccion,Texto) " +
                                          " VALUES ( @IdNivel,@IdSubNivel,@IdentificadorAcceso,@IdElemento,@IdSubElemento,@IdTerciario,@IdAccion,@IdSubAccion,@Texto);";

                    command.Parameters.Add("@IdNivel", MySqlDbType.Int16);
                    command.Parameters.Add("@IdSubNivel", MySqlDbType.Int16);
                    command.Parameters.Add("@IdentificadorAcceso", MySqlDbType.Int16);
                    command.Parameters.Add("@IdElemento", MySqlDbType.Int16);
                    command.Parameters.Add("@IdSubElemento", MySqlDbType.Int16);
                    command.Parameters.Add("@IdTerciario", MySqlDbType.Int16);
                    command.Parameters.Add("@IdAccion", MySqlDbType.Int16);
                    command.Parameters.Add("@IdSubAccion", MySqlDbType.Int16);
                    command.Parameters.Add("@Texto", MySqlDbType.String);

                    command.Parameters["@IdNivel"].Value             = (int)nivel;
                    command.Parameters["@IdSubNivel"].Value          = (int)subNivel;
                    command.Parameters["@IdentificadorAcceso"].Value = acceso;
                    command.Parameters["@IdElemento"].Value          = elemento;
                    command.Parameters["@IdSubElemento"].Value       = (int)subElemento;
                    command.Parameters["@IdTerciario"].Value         = (int)terciario;
                    command.Parameters["@IdAccion"].Value            = (int)accion;
                    command.Parameters["@IdSubAccion"].Value         = (int)subAccion;
                    command.Parameters["@Texto"].Value = LimitSize(mensaje, 5000);

                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();
                }
        }
Ejemplo n.º 2
0
        public void InsertException(Exception ex, int acceso = -1, int elemento = 0, SubElemento subElemento = 0, Terciario terciario = 0, Accion accion = 0, SubAccion subAccion = 0)
        {
            try
            {
                SubNivel       subNivel = SubNivel.Base;
                TrazaException traza    = new TrazaException(ex);

                if (ex is UriFormatException)
                {
                    subNivel = SubNivel.UriFormatException;
                }
                if (ex is System.Data.DataException)
                {
                    subNivel = SubNivel.DataException;
                }

                using (var connection = new MySql.Data.MySqlClient.MySqlConnection(_config.GetConnectionString(_connectionString)))
                    using (var command = connection.CreateCommand())
                    {
                        command.CommandText = "INSERT INTO log (IdNivel,IdSubNivel,IdentificadorAcceso,IdElemento,IdSubElemento,IdTerciario,IdAccion,IdSubAccion,Texto) " +
                                              " VALUES ( @IdNivel,@IdSubNivel,@IdentificadorAcceso,@IdElemento,@IdSubElemento,@IdTerciario,@IdAccion,@IdSubAccion,@Texto);";

                        command.Parameters.Add("@IdNivel", MySqlDbType.Int16);
                        command.Parameters.Add("@IdSubNivel", MySqlDbType.Int16);
                        command.Parameters.Add("@IdentificadorAcceso", MySqlDbType.Int16);
                        command.Parameters.Add("@IdElemento", MySqlDbType.Int16);
                        command.Parameters.Add("@IdSubElemento", MySqlDbType.Int16);
                        command.Parameters.Add("@IdTerciario", MySqlDbType.Int16);
                        command.Parameters.Add("@IdAccion", MySqlDbType.Int16);
                        command.Parameters.Add("@IdSubAccion", MySqlDbType.Int16);
                        command.Parameters.Add("@Texto", MySqlDbType.String);

                        command.Parameters["@IdNivel"].Value             = (int)Nivel.Error;
                        command.Parameters["@IdSubNivel"].Value          = (int)subNivel;
                        command.Parameters["@IdentificadorAcceso"].Value = acceso;
                        command.Parameters["@IdElemento"].Value          = elemento;
                        command.Parameters["@IdSubElemento"].Value       = (int)subElemento;
                        command.Parameters["@IdTerciario"].Value         = (int)terciario;
                        command.Parameters["@IdAccion"].Value            = (int)accion;
                        command.Parameters["@IdSubAccion"].Value         = (int)subAccion;
                        command.Parameters["@Texto"].Value = LimitSize(JsonConvert.SerializeObject(traza), 5000);

                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                    }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
 public void SetTraza(string mensaje, int acceso = -1, Nivel nivel = 0, SubNivel subNivel = 0, int elemento = 0, SubElemento subElemento = 0, Terciario terciario = 0, Accion accion = 0, SubAccion subAccion = 0)
 {
     try
     {
         InsertTraza(mensaje, acceso, nivel, subNivel, elemento, subElemento, terciario, accion, subAccion);
     }
     catch (Exception ex)
     {
         InsertException(ex, -101);
     }
 }