142 lines
No EOL
5.3 KiB
C#
142 lines
No EOL
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using Ultimus.Utilitarios;
|
|
using System.Data.Entity;
|
|
using System.Data.Entity.Validation;
|
|
|
|
namespace ULA.Cathay.CreditoModel.DAL.Credito
|
|
{
|
|
|
|
public class EstructuraOrgChartDAL
|
|
{
|
|
private UltimusLogs logger = new UltimusLogs("EstructuraOrgChartDAL");
|
|
|
|
|
|
public List<EstructuraOrgChart> Obtener(int? IdRolFuncional = null, int? IdEstructuraOrgChart = null)
|
|
{
|
|
List<EstructuraOrgChart> ListaEstructuraOrgChart = null;
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
ListaEstructuraOrgChart = new List<EstructuraOrgChart>();
|
|
ListaEstructuraOrgChart = db.EstructuraOrgChart
|
|
.Include("RolFuncionalEstructuraOrgChart.RolFuncional")
|
|
.Include(x => x.TipoEstructuraOrgChart)
|
|
.Where(x => ((IdRolFuncional == null) || (x.RolFuncionalEstructuraOrgChart.Any(z => z.IdRolFuncional == IdRolFuncional)))
|
|
&& ((IdEstructuraOrgChart == null) || (x.IdEstructuraOrgChart == IdEstructuraOrgChart)))
|
|
.ToList();
|
|
}
|
|
}
|
|
catch (DbEntityValidationException exs)
|
|
{
|
|
logger.Error(exs);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
}
|
|
|
|
return ListaEstructuraOrgChart;
|
|
}
|
|
|
|
public EstructuraOrgChart Obtener(string Nombre)
|
|
{
|
|
EstructuraOrgChart ListaEstructuraOrgChart = null;
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
ListaEstructuraOrgChart = db.EstructuraOrgChart
|
|
.Include("RolFuncionalEstructuraOrgChart.RolFuncional")
|
|
.Include(x => x.TipoEstructuraOrgChart)
|
|
.Where(x => x.Name == Nombre).FirstOrDefault();
|
|
}
|
|
}
|
|
catch (DbEntityValidationException exs)
|
|
{
|
|
logger.Error(exs);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error("Error: Obtener=" + ex.Message + ex.StackTrace);
|
|
}
|
|
|
|
return ListaEstructuraOrgChart;
|
|
}
|
|
|
|
public string ObtenerSintaxisUltimus(string NombreRecipiente)
|
|
{
|
|
EstructuraOrgChart ListaEstructuraOrgChart = null;
|
|
string recipiente = null;
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
ListaEstructuraOrgChart = db.EstructuraOrgChart
|
|
.Include(x => x.TipoEstructuraOrgChart)
|
|
.Where(x => x.Name == NombreRecipiente).FirstOrDefault();
|
|
|
|
if (ListaEstructuraOrgChart != null)
|
|
{
|
|
switch (ListaEstructuraOrgChart.IdTipoEstructuraOrgChart)
|
|
{
|
|
case 1:
|
|
recipiente = "JF:org=Business Organization,dept=Cathay OC,jf=" + ListaEstructuraOrgChart.Name;
|
|
break;
|
|
case 2:
|
|
recipiente = "JFG:org=Business Organization,dept=Cathay OC,jfg=" + ListaEstructuraOrgChart.Name;
|
|
break;
|
|
case 3:
|
|
recipiente = "GRP:org=organization,grp=" + ListaEstructuraOrgChart.Name;
|
|
break;
|
|
default:
|
|
recipiente = "USER:org=Business Organization,user=" + ListaEstructuraOrgChart.Name;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
}
|
|
|
|
return recipiente;
|
|
}
|
|
|
|
|
|
public EstructuraOrgChart ObtenerEstructura(int IdEstructuraOrgChart)
|
|
{
|
|
EstructuraOrgChart ListaEstructuraOrgChart = null;
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
ListaEstructuraOrgChart = db.EstructuraOrgChart
|
|
.Include("RolFuncionalEstructuraOrgChart.RolFuncional")
|
|
.Include(x => x.TipoEstructuraOrgChart)
|
|
.Where(x => x.IdEstructuraOrgChart == IdEstructuraOrgChart)
|
|
.FirstOrDefault();
|
|
}
|
|
}
|
|
catch (DbEntityValidationException exs)
|
|
{
|
|
logger.Error(exs);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
}
|
|
|
|
return ListaEstructuraOrgChart;
|
|
}
|
|
|
|
|
|
}
|
|
} |