Example #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();
                }
        }
Example #2
0
        public TransactionResult create(SubNivelVo subnivel_vo, User user_log)
        {
            SubNivel obj = SubNivelAdapter.voToObject(subnivel_vo);

            obj.user = user_log;
            return(subnivel_repository.create(obj));
        }
Example #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);
     }
 }
Example #4
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
            {
            }
        }
Example #5
0
        public HttpResponseMessage detail(int id)
        {
            SubNivel subnivel = subnivel_service.detail(id);

            if (subnivel != null)
            {
                IDictionary <string, SubNivel> data = new Dictionary <string, SubNivel>();
                data.Add("data", subnivel);
                return(Request.CreateResponse(HttpStatusCode.OK, data));
            }
            else
            {
                IDictionary <string, string> data = new Dictionary <string, string>();
                data.Add("message", "Object not found.");
                return(Request.CreateResponse(HttpStatusCode.BadRequest, data));
            }
        }
Example #6
0
        public TransactionResult update(SubNivel subnivel)
        {
            SqlConnection connection = null;

            using (connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Coz_Operaciones_DB"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("sp_updateSubNivel", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("status", subnivel.status ? 1 : 0));
                    command.Parameters.Add(new SqlParameter("nombre", Validations.defaultString(subnivel.nombre)));
                    command.Parameters.Add(new SqlParameter("id", subnivel.id));
                    command.Parameters.Add(new SqlParameter("user_id", subnivel.user.id));
                    command.Parameters.Add(new SqlParameter("nivel_id", subnivel.nivel.id));
                    command.Parameters.Add(new SqlParameter("cuenta_id", subnivel.cuenta.id));
                    command.Parameters.Add(new SqlParameter("proceso_id", subnivel.proceso.id));
                    command.ExecuteNonQuery();
                    return(TransactionResult.OK);
                }
                catch (SqlException ex)
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    if (ex.Number == 2627)
                    {
                        return(TransactionResult.EXISTS);
                    }
                    return(TransactionResult.NOT_PERMITTED);
                }
                catch
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    return(TransactionResult.ERROR);
                }
            }
        }
Example #7
0
 public static SubNivelVo objectToVo(SubNivel obj)
 {
     return(new SubNivelVo
     {
     });
 }