コード例 #1
0
        public ResponseBD add_ParametrosSeguridad(ParametrosSeguridad p)
        {
            try
            {
                ResponseBD response = new ResponseBD();

                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        response.Flujo = Constantes.FALLA;
                        response.Mensaje = "Error al abrir la conexión a BD";
                        return response;
                    }

                    SqlCommand sqlCmd = new SqlCommand("PARAMETRO_SEGURIDAD_INSERT", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter flujo = new SqlParameter("@opsFlujo", SqlDbType.VarChar)
                    {
                        Direction = ParameterDirection.Output,
                        Size = 10

                    };

                    SqlParameter mensaje = new SqlParameter("@opsMsj", SqlDbType.VarChar)
                    {
                        Direction = ParameterDirection.Output,
                        Size = 100
                    };

                    sqlCmd.Parameters.Add("@ipsCaracteresContrasena", SqlDbType.VarChar).Value = p.CaracteresContrasena;
                    sqlCmd.Parameters.Add("@ipnTiempoVigenciaDias", SqlDbType.Int).Value = p.TiempoVigenciaDias;
                    sqlCmd.Parameters.Add("@ipnCantidadIntentosFallidos", SqlDbType.Int).Value = p.CantidadIntentosFallidos;
                    sqlCmd.Parameters.Add("@ipnLongitudContrasena", SqlDbType.Int).Value = p.LongitudContrasena;
                    sqlCmd.Parameters.Add("@ipnTiempoMaximoSesion", SqlDbType.Int).Value = p.TiempoMaximoSesion;

                    sqlCmd.Parameters.Add("@ipsAccion", SqlDbType.VarChar).Value = Constantes.LOG_CREAR;
                    sqlCmd.Parameters.Add("@ipsClase", SqlDbType.VarChar).Value = p.GetType().Name;
                    sqlCmd.Parameters.Add("@ipnIdUsuario", SqlDbType.Int).Value = 1;

                    sqlCmd.Parameters.Add(flujo);
                    sqlCmd.Parameters.Add(mensaje);

                    sqlCmd.ExecuteNonQuery();

                    response.Flujo = flujo.Value.ToString();
                    response.Mensaje = mensaje.Value.ToString();

                    SqlConn.Close();

                }

                return response;
            }
            catch (Exception ex)
            {
                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_CREAR,
                    Servicio = Constantes.Add_ParametrosSeguridad,
                    Input = "", //TODO
                    Descripcion = ex.ToString(),
                    Clase = (p == null) ? "null" : p.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                ResponseBD response = new ResponseBD();
                response.Flujo = Constantes.FALLA;
                response.Mensaje = "Error al abrir la conexión a BD";
                return response;
            }
        }
コード例 #2
0
        public List<ParametrosSeguridad> selectAll_ParametrosSeguridad()
        {
            try
            {
                List<ParametrosSeguridad> parametros = new List<ParametrosSeguridad>();
                ParametrosSeguridad p = new ParametrosSeguridad();

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return parametros;
                    }

                    SqlCommand sqlCmd = new SqlCommand("PARAMETRO_SEGURIDAD_SELECT_ALL", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.Add("@ipsAccion", SqlDbType.VarChar).Value = Constantes.LOG_LISTAR;
                    sqlCmd.Parameters.Add("@ipsClase", SqlDbType.VarChar).Value = p.GetType().Name;
                    sqlCmd.Parameters.Add("@ipnIdUsuario", SqlDbType.Int).Value = 1;

                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    p = Utils.parametroSeguridad_parse(rows[i]);
                    parametros.Add(p);
                }

                return parametros;
            }
            catch (Exception ex)
            {
                ParametrosSeguridad p = new ParametrosSeguridad();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.SelectAll_ParametrosSeguridad,
                    Input = "",
                    Descripcion = ex.ToString(),
                    Clase = p.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new List<ParametrosSeguridad>();
            }
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: pcyip/servicios
        public static ParametrosSeguridad parametroSeguridad_parse(DataRow r)
        {
            ParametrosSeguridad p = new ParametrosSeguridad();
            p.IdParametrosSeguridad = Int32.Parse(r["idParametrosSeguridad"].ToString());
            p.CaracteresContrasena = r["caracteresContrasena"].ToString();
            p.TiempoVigenciaDias = Int32.Parse(r["tiempoVigenciaDias"].ToString());
            p.CantidadIntentosFallidos = Int32.Parse(r["cantidadIntentosFallidos"].ToString());
            p.LongitudContrasena = Int32.Parse(r["longitudContrasena "].ToString());
            p.TiempoMaximoSesion = Int32.Parse(r["tiempoMaximoSesion"].ToString());

            return p;
        }