420 lines
18 KiB
C#
420 lines
18 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
|
|
using AyABL.AUT;
|
|
using AyAEL.APL;
|
|
using AyADAL;
|
|
|
|
|
|
namespace AyABL.APL
|
|
{
|
|
public class RolBL : AyABL
|
|
{
|
|
private DbProviderFactory dpfConector = DbProviderFactories.GetFactory("System.Data.SqlClient");
|
|
private DbParameter[] dbpParametros;
|
|
|
|
public RolBL()
|
|
{
|
|
this.objRolEL = new RolEL();
|
|
this.objRolAccesoActividadEL = new rolaccesoactividadesEL();
|
|
this.NombreTabla = Modulos.T_APL_.ToString() + Tablas.ROL.ToString();
|
|
this.NombreConeccionBD = BASESDEDATOS.ADS.ToString();
|
|
}
|
|
|
|
public RolEL objRolEL { get; set; }
|
|
|
|
public rolaccesoactividadesEL objRolAccesoActividadEL { get; set; }
|
|
|
|
public int insertarRol(ref int intPkRolAcceso)
|
|
{
|
|
int num;
|
|
try
|
|
{
|
|
this.CamposTabla = t_apl_rol.NOMBRE.ToString() + Tablas.ROL.ToString() + ", " + t_apl_rol.DESCRIPCION.ToString() + Tablas.ROL.ToString() + ", " + t_apl_rol.ACTIVO.ToString() + Tablas.ROL.ToString();
|
|
this.ValoresCampos = new object[3]
|
|
{
|
|
(object) this.objRolEL.Nombre,
|
|
(object) this.objRolEL.Descripcion,
|
|
(object) this.objRolEL.Activo
|
|
};
|
|
num = this.baseDAL.Insertar(this.NombreTabla, this.CamposTabla, this.ValoresCampos, this.NombreConeccionBD);
|
|
this.NombreTabla = Modulos.t_seg_.ToString() + Tablas.rolacceso.ToString();
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
this.CamposTabla = t_seg_rolacceso.FKROL.ToString() + ", " + t_seg_rolacceso.ACCESOINFORMACION.ToString() + Tablas.rolacceso.ToString() + ", " + Auditoria.ASTATE.ToString() + Tablas.rolacceso.ToString();
|
|
this.ValoresCampos = new object[3]
|
|
{
|
|
(object) num,
|
|
(object) this.objRolEL.ACCESOINFORMACION,
|
|
(object) true
|
|
};
|
|
intPkRolAcceso = this.baseDAL.Insertar(this.NombreTabla, this.CamposTabla, this.ValoresCampos, this.NombreConeccionBD);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
public void actualizarRol()
|
|
{
|
|
ArrayList p_arlCondiciones1 = new ArrayList();
|
|
try
|
|
{
|
|
int? pk = this.objRolEL.PK;
|
|
if ((pk.GetValueOrDefault() != 0 ? 1 : (!pk.HasValue ? 1 : 0)) == 0)
|
|
return;
|
|
p_arlCondiciones1.Add((object)this.buscarPorPK(this.objRolEL.PK, Tablas.ROL, operadorLogico.AND));
|
|
this.CamposTabla = Concepto.NOMBRE.ToString() + Tablas.ROL.ToString() + ", " + Concepto.DESCRIPCION.ToString() + Tablas.ROL.ToString();
|
|
this.ValoresCampos = new object[2]
|
|
{
|
|
(object) this.objRolEL.Nombre,
|
|
(object) this.objRolEL.Descripcion
|
|
};
|
|
this.baseDAL.Actualizar(this.NombreTabla, this.CamposTabla, this.ValoresCampos, this.NombreConeccionBD, p_arlCondiciones1);
|
|
this.NombreTabla = Modulos.t_seg_.ToString() + Tablas.rolacceso.ToString();
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
ArrayList p_arlCondiciones2 = new ArrayList();
|
|
p_arlCondiciones2.Add((object)this.buscarPorRolAcceso(this.objRolEL.PK, operadorLogico.NONE));
|
|
this.CamposTabla = t_seg_rolacceso.FKROL.ToString() + ", " + t_seg_rolacceso.ACCESOINFORMACION.ToString() + Tablas.rolacceso.ToString();
|
|
this.ValoresCampos = new object[2]
|
|
{
|
|
(object) this.objRolEL.PK,
|
|
(object) this.objRolEL.ACCESOINFORMACION
|
|
};
|
|
this.baseDAL.Actualizar(this.NombreTabla, this.CamposTabla, this.ValoresCampos, this.NombreConeccionBD, p_arlCondiciones2);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet dsListaRoles(ArrayList arlCondicionesFiltroBusqueda)
|
|
{
|
|
try
|
|
{
|
|
this.NombreTabla = Vistas.v_listaroles.ToString();
|
|
this.CamposTabla = Constraints.PK.ToString() + Tablas.ROL.ToString() + ", " + Concepto.NOMBRE.ToString() + Tablas.ROL.ToString() + ", " + Concepto.DESCRIPCION.ToString() + Tablas.ROL.ToString() + ", " + Concepto.ACTIVO.ToString() + Tablas.ROL.ToString() + ", " + Concepto.ETIQUETA.ToString() + Tablas.APLICACION.ToString();
|
|
int? usuario = this.objRolEL.Usuario;
|
|
if ((usuario.GetValueOrDefault() != 0 ? 1 : (!usuario.HasValue ? 1 : 0)) != 0 && this.objRolEL.Usuario.HasValue)
|
|
arlCondicionesFiltroBusqueda.Add((object)this.buscarPorPK(this.objRolEL.Usuario, Tablas.USUARIO, operadorLogico.AND));
|
|
int? rol = this.objRolEL.Rol;
|
|
if ((rol.GetValueOrDefault() != 0 ? 1 : (!rol.HasValue ? 1 : 0)) != 0 && this.objRolEL.Rol.HasValue)
|
|
arlCondicionesFiltroBusqueda.Add((object)this.buscarPorPK(this.objRolEL.Rol, Tablas.ROL, operadorLogico.AND));
|
|
if (this.objRolEL.Aplicacion != 0)
|
|
arlCondicionesFiltroBusqueda.Add((object)this.buscarPorPK(new int?(this.objRolEL.Aplicacion), Tablas.APLICACION, operadorLogico.AND));
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, arlCondicionesFiltroBusqueda, funcionesTLAgg.DISTINCT.ToString(), FuncionesBLAggDAL.OrderByASC(Constraints.PK.ToString() + Tablas.ROL.ToString()));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public void eliminarRol()
|
|
{
|
|
try
|
|
{
|
|
ArrayList p_arlCondiciones = new ArrayList();
|
|
int? pk = this.objRolEL.PK;
|
|
if ((pk.GetValueOrDefault() != 0 ? 1 : (!pk.HasValue ? 1 : 0)) == 0)
|
|
return;
|
|
p_arlCondiciones.Add((object)this.buscarPorPK(this.objRolEL.PK, Tablas.ROL, operadorLogico.AND));
|
|
this.CamposTabla = t_apl_rol.ACTIVO.ToString() + Tablas.ROL.ToString();
|
|
this.ValoresCampos = new object[1] { (object)false };
|
|
this.baseDAL.Actualizar(this.NombreTabla, this.CamposTabla, this.ValoresCampos, this.NombreConeccionBD, p_arlCondiciones);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public int RolUsuario(int p_intPkApp, int p_PkUsuario)
|
|
{
|
|
try
|
|
{
|
|
this.NombreTabla = Vistas.v_rolxaplicacion.ToString();
|
|
this.CamposTabla = Constraints.PK.ToString() + Tablas.ROL.ToString();
|
|
return int.Parse(this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, new ArrayList()
|
|
{
|
|
(object) this.buscarPorApl(p_intPkApp, false, false, operadorLogico.AND),
|
|
(object) this.buscarPorUsuario(p_PkUsuario, operadorLogico.AND)
|
|
}, (string)null, (string)null).Tables[0].Rows[0]["PKROL"].ToString());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet getComandosxItemxApl(int p_intFkApp)
|
|
{
|
|
try
|
|
{
|
|
this.NombreTabla = Vistas.v_comandosxitemxapp.ToString();
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, new ArrayList()
|
|
{
|
|
(object) this.buscarPorPadre(this.objRolEL.Padre, Tablas.ITEMMENU, operadorLogico.AND, operadorGeneral.EQUAL),
|
|
(object) this.buscarPorApl(1, true, false, operadorLogico.OR),
|
|
(object) this.buscarPorApl(this.objRolEL.Aplicacion, false, true, operadorLogico.NONE)
|
|
}, (string)null, FuncionesBLAggDAL.OrderByASC(Concepto.PADRE.ToString() + Tablas.ITEMMENU.ToString() + ", " + t_ads_menuitem.ORDEN.ToString() + Tablas.ITEMMENU.ToString()));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet getComandosxItemxRol()
|
|
{
|
|
try
|
|
{
|
|
this.NombreTabla = Vistas.v_comandosxitemxrol.ToString();
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, new ArrayList()
|
|
{
|
|
(object) this.buscarPorRol(this.objRolEL.Rol, operadorLogico.AND),
|
|
(object) this.buscarPorItem(this.objRolEL.ItemMenu, operadorLogico.AND),
|
|
(object) this.buscarPorApl(1, true, false, operadorLogico.OR),
|
|
(object) this.buscarPorApl(this.objRolEL.Aplicacion, false, true, operadorLogico.NONE)
|
|
}, (string)null, FuncionesBLAggDAL.OrderByASC("PADREITEMMENU, ORDENITEMMENU"));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet getComandosxItem()
|
|
{
|
|
try
|
|
{
|
|
this.NombreTabla = Vistas.v_comandosxitem.ToString();
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, new ArrayList()
|
|
{
|
|
(object) this.buscarPorItem(this.objRolEL.ItemMenu, operadorLogico.AND),
|
|
(object) this.buscarPorApl(1, true, false, operadorLogico.OR),
|
|
(object) this.buscarPorApl(this.objRolEL.Aplicacion, false, true, operadorLogico.NONE)
|
|
}, (string)null, (string)null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet dsAccesoUsuario(RolEL p_objRolEL)
|
|
{
|
|
try
|
|
{
|
|
this.NombreTabla = Modulos.t_seg_.ToString() + Tablas.rolacceso.ToString();
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, new ArrayList()
|
|
{
|
|
(object) this.buscarPorRolAcceso(p_objRolEL.PK, operadorLogico.NONE)
|
|
}, (string)null, (string)null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet dsListaActividadesPorRol(ArrayList arlCondicionesFiltroBusqueda)
|
|
{
|
|
try
|
|
{
|
|
ArrayList arrayList = new ArrayList();
|
|
this.cargarCondicionBusqueda(arrayList, arlCondicionesFiltroBusqueda);
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
int? pk = this.objRolEL.PK;
|
|
if ((pk.GetValueOrDefault() != 0 ? 1 : (!pk.HasValue ? 1 : 0)) != 0 && this.objRolEL.PK.HasValue)
|
|
arrayList.Add((object)this.buscarActividadesPorPKRol(this.objRolEL.PK, operadorLogico.AND));
|
|
this.NombreTabla = Vistas.v_obtener_actividades_rolacceso.ToString();
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, arrayList, (string)null, (string)null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public DataSet dsRolAccesoPorRol(ArrayList arlCondicionesFiltroBusqueda)
|
|
{
|
|
try
|
|
{
|
|
ArrayList arrayList = new ArrayList();
|
|
this.cargarCondicionBusqueda(arrayList, arlCondicionesFiltroBusqueda);
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
int? pk = this.objRolEL.PK;
|
|
if ((pk.GetValueOrDefault() != 0 ? 1 : (!pk.HasValue ? 1 : 0)) != 0 && this.objRolEL.PK.HasValue)
|
|
arrayList.Add((object)this.buscarRolAccesoPorPKRol(this.objRolEL.PK, operadorLogico.AND));
|
|
this.NombreTabla = Modulos.t_seg_.ToString() + Tablas.rolacceso.ToString();
|
|
return this.baseDAL.EjecutarConsulta(this.NombreTabla, this.CamposTabla, this.NombreConeccionBD, arrayList, (string)null, (string)null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public int asociarActividadRol(TransaccionDAL ptdlTransaccion)
|
|
{
|
|
try
|
|
{
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
this.NombreTabla = Modulos.t_adm_.ToString() + Tablas.rolaccesoactividad.ToString();
|
|
this.CamposTabla = t_adm_rolaccesoactividad.FKROLACCESO.ToString() + "," + t_adm_rolaccesoactividad.FKACTIVIDAD.ToString();
|
|
this.ValoresCampos = new object[2]
|
|
{
|
|
(object) this.objRolAccesoActividadEL.FKROLACCESO,
|
|
(object) this.objRolAccesoActividadEL.FKACTIVIDAD
|
|
};
|
|
return this.baseDAL.Insertar(this.NombreTabla, this.CamposTabla, this.ValoresCampos, this.NombreConeccionBD, ptdlTransaccion);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public int elminarActividadRol()
|
|
{
|
|
int num = 0;
|
|
try
|
|
{
|
|
ArrayList p_arlCondiciones = new ArrayList();
|
|
int? pk = this.objRolAccesoActividadEL.PK;
|
|
if ((pk.GetValueOrDefault() != 0 ? 1 : (!pk.HasValue ? 1 : 0)) != 0)
|
|
{
|
|
if (this.objRolAccesoActividadEL.PK.HasValue)
|
|
{
|
|
p_arlCondiciones.Add((object)this.buscarPorPK(this.objRolAccesoActividadEL.PK, Tablas.rolaccesoactividad, operadorLogico.AND));
|
|
this.NombreConeccionBD = BASESDEDATOS.SIGDD.ToString();
|
|
this.NombreTabla = Modulos.t_adm_.ToString() + Tablas.rolaccesoactividad.ToString();
|
|
this.baseDAL.eliminarFisico(this.NombreTabla, this.NombreConeccionBD, p_arlCondiciones);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
private CondicionDAL buscarActividadesPorPKRol(
|
|
int? p_strRol,
|
|
operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = t_seg_rolacceso.FKROL.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_strRol
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarRolAccesoPorPKRol(int? p_strRol, operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = t_seg_rolacceso.FKROL.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_strRol
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarActividadesPorFK(
|
|
int? p_strActividad,
|
|
operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = t_seg_rolacceso.FKACTIVIDAD.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_strActividad
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarPorRolAcceso(int? p_strRol, operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = t_seg_rolacceso.FKROL.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_strRol
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarPorUsuario(int p_intPkUsuario, operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = Constraints.PK.ToString() + Tablas.USUARIO.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_intPkUsuario
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarPorItem(int? p_intPkItemMenu, operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = Constraints.PK.ToString() + Tablas.ITEMMENU.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_intPkItemMenu
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarPorRol(int? p_intPkRol, operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = Constraints.PK.ToString() + Tablas.ROL.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_intPkRol
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarPorComando(int p_intPkComando, operadorLogico operador)
|
|
{
|
|
return new CondicionDAL()
|
|
{
|
|
valorIzquierdo = Constraints.PK.ToString() + Tablas.COMANDO.ToString(),
|
|
operadorGeneral = operadorGeneral.EQUAL,
|
|
operadorLogico = operador,
|
|
valorDerecho = (object)p_intPkComando
|
|
};
|
|
}
|
|
|
|
private CondicionDAL buscarPorApl(
|
|
int p_intPkApl,
|
|
bool p_blnParentesis1,
|
|
bool p_blnParentesis2,
|
|
operadorLogico operador)
|
|
{
|
|
CondicionDAL condicionDal = new CondicionDAL();
|
|
if (p_blnParentesis1)
|
|
condicionDal.parentesisInicio = true;
|
|
condicionDal.valorIzquierdo = Constraints.FK.ToString() + Tablas.APLICACION.ToString();
|
|
condicionDal.operadorGeneral = operadorGeneral.EQUAL;
|
|
condicionDal.operadorLogico = operador;
|
|
condicionDal.valorDerecho = (object)p_intPkApl;
|
|
if (p_blnParentesis2)
|
|
condicionDal.parentesisFinal = true;
|
|
return condicionDal;
|
|
}
|
|
}
|
|
}
|