public int ABClogSesiones(char op, Sis.LOG_SESIONES logSesiones) { try { return(_objAdSistema.ABCLogSesiones(op, logSesiones)); } catch (Exception) { throw; } }
/// <summary> /// ''' Rutina que registra el acceso a un modulo en la bitacora de sesiones /// ''' </summary> /// ''' <param name="IdModulo">En modulo al cual se accede</param> /// ''' <param name="IdAccionSesion">Accion sobre el modulo (acceso/salida)</param> /// ''' <remarks></remarks> public void RegistraSesion(int IdModulo, int IdAccionSesion) { try { LnSistema objLnSistemas = new LnSistema(ModUsuario.SessionObjEnDatosConn); Sis.LOG_SESIONES objenLogSesiones = new Sis.LOG_SESIONES { IdModulo = IdModulo, IdAccionSesion = IdAccionSesion, IdUsuario = ModUsuario.SessionIdUsuario }; objLnSistemas.ABClogSesiones('A', objenLogSesiones); } catch (Exception) { throw; } }
public int ABCLogSesiones(char op, Sis.LOG_SESIONES logSesion) { const string querySql = "Sis.prLOG_SESIONES"; int IntReturn; try { // Definir la conexion a la base de datos mediante un "SqlConnection" using (SqlConnection connection = _objPersistencia.GetSqlConnection()) { // Abrir la conexion connection.Open(); // Definir un "SqlCommand" con funcionalidad de "Stored Procedure" using (SqlCommand sqlCmnd = _objPersistencia.GetSqlCommand(connection, querySql, CommandType.StoredProcedure)) { // Asignar los parametros del SP sqlCmnd.Parameters.Add("@Op", SqlDbType.Char); sqlCmnd.Parameters["@Op"].Value = op; sqlCmnd.Parameters.Add("@IdLogSesiones", SqlDbType.Int); sqlCmnd.Parameters["@IdLogSesiones"].Value = logSesion.IdLogSesiones; sqlCmnd.Parameters.Add("@IdModulo", SqlDbType.Int); sqlCmnd.Parameters["@IdModulo"].Value = logSesion.IdModulo; sqlCmnd.Parameters.Add("@IdAccionSesion", SqlDbType.Int); sqlCmnd.Parameters["@IdAccionSesion"].Value = logSesion.IdAccionSesion; sqlCmnd.Parameters.Add("@IdUsuario", SqlDbType.Int); sqlCmnd.Parameters["@IdUsuario"].Value = logSesion.IdUsuario; // Ejecutar el comando using (SqlDataReader reader = sqlCmnd.ExecuteReader()) { if (!reader.Read()) { throw new Exception("La ejecución del Store Procedure no arrojó ningun dato"); } // Asignar los valores obtenidos de la ejecución del comando // Verificamos el resultado de la ejecucion de sp 0 = correcto y 1 existe algun error IntReturn = (int)reader["Result"]; // Revisar si el SP generó un resultado de error if (IntReturn == 1) { throw new Exception((string)reader["MensajeError"]); } // Cerrar el Reader reader.Close(); } // Cerrar la conexion connection.Close(); } } return(IntReturn); } catch (Exception ex) { throw new Exception(ex.Message + "\n\n" + "SP: " + querySql); } }