This commit is contained in:
jnunez 2018-06-14 21:05:04 +00:00
parent c27c342d8b
commit e6cac49bed
22 changed files with 314 additions and 160 deletions

View file

@ -48,7 +48,16 @@ namespace AYA.SlnSinort.WCF
#region Pantallas
[OperationContract]
List<Pantallas> ObtenerPantallas(Usuario model);
List<Pantallas> ObtenerPantallas(CatalogosPostJSON model);
[OperationContract]
List<RolesPantallas> ObtenerPantallasRol(CatalogosPostJSON model);
#endregion
#region RolesPantallas
[OperationContract]
RolesPantallasJSON InsertarActualizarRolesPantallas(RolesPantallasJSON model);
#endregion
}

View file

@ -132,7 +132,7 @@ namespace AYA.SlnSinort.WCF
#endregion
#region Pantallas
public List<Pantallas> ObtenerPantallas(Usuario model)
public List<Pantallas> ObtenerPantallas(CatalogosPostJSON model)
{
List<Pantallas> respuesta = new List<Pantallas>();
try
@ -146,6 +146,33 @@ namespace AYA.SlnSinort.WCF
}
return respuesta;
}
public List<RolesPantallas> ObtenerPantallasRol(CatalogosPostJSON model)
{
return new PantallasDAL().ObtenerPantallasRol(model);
}
#endregion
#region RolesPantallas
public RolesPantallasJSON InsertarActualizarRolesPantallas(RolesPantallasJSON model)
{
var rolesDAL = new RolesDAL();
try
{
foreach(var rolPantalla in model.ListaRolesPantallas)
rolesDAL.InsertarActualizarRolesPantallas(rolPantalla);
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO;
}
catch (Exception ex)
{
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
throw;
}
return model;
}
#endregion
}

View file

@ -7680,7 +7680,6 @@
<Content Include="Sinort-Scripts\Mantenimientos.js" />
<Content Include="Sinort-Scripts\ProyectoNormativo.js" />
<Content Include="Sinort-Scripts\Rol.js" />
<Content Include="Sinort-Scripts\RolesPantallas.js" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
@ -7712,7 +7711,6 @@
<Content Include="Views\Catalogos\Aplicacion.cshtml" />
<Content Include="Views\Home\Proyecto_Normativo.cshtml" />
<Content Include="Views\Catalogos\Rol.cshtml" />
<Content Include="Views\Catalogos\RolesPantallas.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View file

@ -27,6 +27,7 @@
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
filter: alpha(opacity=80);
}
.toast-close-button:hover,
.toast-close-button:focus {
color: #000000;

View file

@ -1,7 +1,7 @@
//$("#formCatalogo").EnableValidationToolTip();
var DataCatalogo;
var id_column = 1;
var Item = {};
var model = {};
//#region READY
@ -40,6 +40,7 @@ this.getDataModel = function () {
});
$('#TableItems').TableInit(0, false, true, true, false, null, null);
$('#GridRolesPantallas').TableInit(0, false, true, true, false, null, null);
ObtenerRoles();
@ -56,6 +57,7 @@ this.CargarGridRoles = function (data) {
var pantallas = $("#ucbtnVistaPantallas").html();
var usuarios = $("#ucbtnVistaUsuarios").html();
option = replaceAll("[$CodItem]", item.IdRol, option);
pantallas = replaceAll("[$CodItem]", item.IdRol, pantallas);
var stateIcon = $("#ucItemsIcon").html();
@ -216,33 +218,82 @@ this.LimpiarControles = function () {
$('#lbTituloAccion').append('Ingresar Nuevo Rol');
}
this.AbrirRolesPantallas = function () {
this.AbrirRolesPantallas = function (id) {
$("#modalRolesPantallas").modal('show');
CargarPantallas();
CargarPantallas(id);
}
this.CargarPantallas = function () {
this.CargarPantallas = function (id) {
$('#hiddenIdRol').val(id)
var uri = CatalogosWCF + '/api/ObtenerPantallasRol';
model = {
codigo: id
};
AjaxPostData(uri, model, true, false, CargarTablaPantallas, null, null);
var uri = CatalogosWCF + '/api/ObtenerPantallas';
AjaxPostData(uri, Item, true, false, CargarTablaPantallas, null, null);
}
this.CargarTablaPantallas = function (data) {
if (data != null) {
lista = data;
var Seleccionar = $("#ucbtnCheck").html();
var columnDefinition = [
{ "data": "Descripcion" },
{ "data": null, className: "center", defaultContent: Seleccionar }
];
var TableItems = $('#GridRolesPantallas').DataTable();
TableItems.clear().draw();
var lista = data;
$('#GridRolesPantallas').TableInit(1, true, true, true, true, columnDefinition, lista);
$.each(lista, function (key, item) {
if ($.fn.DataTable.isDataTable('#GridRolesPantallas')) {
var pantallas = $("#ucbtnCheck").html();
var id = item.IdPantalla;
TableItems.row.add([id,
item.Descripcion,
'<input type="checkbox" id="chkSeleccionar_' + id + '" >']).draw();
});
$('#GridRolesPantallas').DataTable().search('').draw();
ENDREQUEST();
}
}
}
this.GuardarRolesPantallas = function () {
if (!confirm("Va registrar las pantallas.\n ¿Desea continuar?"))
{ return; }
TablePantallas = $('#GridRolesPantallas').DataTable();
var IdRoles = $('#hiddenIdRol').val();
var ArrayRolesPantallas = [];
var data = TablePantallas
.rows()
.data();
$.each(data, function (key, item) {
var cheched = $("#chkSeleccionar_" + item[0]).prop("checked") ? true : false
RolesPantallas = {
IdRol: IdRoles,
IdPantalla: item[0],
Estado: cheched
}
ArrayRolesPantallas.push(RolesPantallas);
});
var uri = CatalogosWCF + '/api/InsertarActualizarRolesPantallas';
var model = {
ListaRolesPantallas: ArrayRolesPantallas
};
AjaxPostData(uri, model, true, true, null, null, null);
ENDREQUEST();
}

View file

@ -1,46 +0,0 @@

var Item = {};
jQuery(document).ready(function () {
CargarPantallas();
});
this.CargarPantallas = function () {
var uri = CatalogosWCF + '/api/ObtenerPantallas';
AjaxPostData(uri, Item, true, false, CargarTablaPantallas, null, null);
}
this.CargarTablaPantallas = function (data) {
if (data != null) {
lista = data;
var Seleccionar = $("#ucbtnVista").html();
var columnDefinition = [
{ "data": "Descripcion" },
{ "data": null, className: "center", defaultContent: Seleccionar }
];
$('#tablePantallas').TableInit(1, true, true, true, true, columnDefinition, lista);
if ($.fn.DataTable.isDataTable('#tablePantallas')) {
$('#tablePantallas').DataTable().search('').draw();
ENDREQUEST();
}
}
}
$('#tablePantallas').on('click', 'button', function () {
var data = $('#tablePantallas').DataTable().row($(this).parents('tr')).data();
var mtzView = data.Vista.split('/')
url = $("#hiddenHref").val();
url = url.replace("View", mtzView[1]);
url = url.replace("Controller", mtzView[0]);
document.location.href = url;
});

View file

@ -7,9 +7,11 @@
<br />
<input type="hidden" id="hiddenId" value="true">
<input type="hidden" id="hiddenIdRol" value="true">
<form id="formCatalogo" class="form-horizontal" role="form">
<h3>&nbsp;<i class="fa fa-briefcase"></i>&nbsp; Roles</h3>
<br />
<div class="panel panel-success">
<div class="panel-body">
@ -50,7 +52,7 @@
</div>
<div id="ucbtnVistaPantallas" style=" display:none;">
<button type="button" id="btnseleccionar" class="btn btn-default btn-xs" onclick="AbrirRolesPantallas()">
<button type="button" id="btnseleccionar" class="btn btn-default btn-xs" onclick="AbrirRolesPantallas([$CodItem])">
<i class="fa fa-check"></i>&nbsp;&nbsp;Seleccionar
</button>
</div>
@ -109,7 +111,7 @@
<div class="modal fade" id="modalRolesPantallas" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" style="display: none;">
<div class="modal-dialog modal-lg" style="width:80%;">
<div class="modal-dialog modal-lg" style="width:40%;">
<div class="modal-content">
<div class="modal-header">
<h4><i class="fa fa-bars"></i>&nbsp;&nbsp;Pantallas</h4>
@ -119,21 +121,24 @@
<table id="GridRolesPantallas" class="table table-condensed dataTable no-footer">
<thead>
<tr>
<th class="col-sm-1">ID</th>
<th class="col-sm-4">Descripción</th>
<th>Seleccionar</th>
<th></th>
</tr>
</thead>
</table>
</div>
<div id="ucbtnCheck" style=" display:none;">
<input type="radio">
@*<div id="ucbtnCheck" style="display:none;" class="checkbox">
<input type="checkbox" id="chkSeleccionar" value="true">
</div>
</div>*@
<div class="modal-footer">
<button type="button" class="btn btn-success btn-sm" onclick="javascript: GuardarRolesPantallas()">Guardar</button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>

View file

@ -1,40 +0,0 @@

@{
ViewBag.Title = "RolesPantallas";
}
<input type="hidden" id="hiddenHref" value="@string.Concat(Url.Action("View", "Controller", null), ViewBag.QueryEncripted)">
<form id="formCatalogo" class="form-horizontal" role="form">
<div class="panel-body">
<h3>&nbsp;<i class="fa fa-list-ul"></i> Selección de Pantallas </h3>
<br />
<br />
<div>
<table id="tablePantallas" class="table table-condensed dataTable no-footer">
<thead>
<tr>
<th class="col-sm-4">Descripción</th>
<th>Acción</th>
</tr>
</thead>
</table>
</div>
<div id="ucbtnVista" style=" display:none;">
<input type="checkbox" checked="checked">
</div>
</div>
</form>
@Scripts.Render("~/Sinort-Scripts/RolesPantallas.js")

View file

@ -25,7 +25,7 @@
<!-- Google Font -->
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
<link rel="stylesheet" href="~/Content/Principal.css">
@*@Styles.Render("~/Content/dashboard")*@
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@ -34,6 +34,12 @@
@Styles.Render("~/Content/sinort-css")
@* Seccion futuros scripts *@
<style>
input[type=checkbox]
{
-webkit-appearance:checkbox;
}
</style>
</head>
<body class="hold-transition skin-blue sidebar-mini">

View file

@ -46,6 +46,10 @@
<HintPath>..\packages\NLog.4.5.6\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
@ -99,7 +103,9 @@
<ItemGroup />
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -18,14 +18,16 @@ namespace AYA.SlnSinortModel.DAL.Sinort
Log log = new Log("AplicacionDAL");
#region ObtenerAplicacion
public List<CatalogosJSON> ObtenerAplicacion(string filtro = null)
public List<CatalogosJSON> ObtenerAplicacion(CatalogosPostJSON model)
{
List<CatalogosJSON> registros = null;
string filtro = model != null ? model.filtro : null;
try
{
using (SinortContex db = new SinortContex())
{
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Aplicacion.Where(t => t.Estado == true) : db.Aplicacion.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true))
registros = db.Aplicacion.Where(t => t.Estado == true && (string.IsNullOrEmpty(filtro) || t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower())))
.Select(t => new CatalogosJSON()
{
codigo = t.IdAplicacion.ToString(),

View file

@ -17,14 +17,16 @@ namespace AYA.SlnSinortModel.DAL.Sinort
Log log = new Log("EmisorDAL");
#region ObtenerEmisor
public List<CatalogosJSON> ObtenerEmisor(string filtro = null)
public List<CatalogosJSON> ObtenerEmisor(CatalogosPostJSON model)
{
List<CatalogosJSON> registros = null;
string filtro = model != null ? model.filtro : null;
try
{
using (SinortContex db = new SinortContex())
{
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Emisor.Where(t => t.Estado == true) : db.Emisor.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true))
registros = db.Emisor.Where(t => t.Estado == true && (string.IsNullOrEmpty(filtro) || t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower())))
.Select(t => new CatalogosJSON()
{
codigo = t.IdEmisor.ToString(),

View file

@ -1,27 +1,49 @@
using Atesa.Utilitarios;
using AYA.SlnSinortModel.Sinort;
using AYA.SlnSinortModel.Sinort;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using System.Data.Entity.Validation;
using AYA.SlnSinortModel.Entidades;
namespace AYA.SlnSinortModel.DAL.Sinort
{
public class PantallasDAL
{
Log log = new Log("MatrizDAL");
public List<Pantallas> ObtenerPantallas(Usuario model)
public List<Pantallas> ObtenerPantallas(CatalogosPostJSON model)
{
List<Pantallas> registros = null;
string filtro = model != null ? model.filtro : null;
try
{
using (SinortContex db = new SinortContex())
{
registros = db.Pantallas.Where(t => t.Estado == true).OrderBy(q => q.IdPantalla).ToList();
registros = db.Pantallas.Where(t => t.Estado == true && (string.IsNullOrEmpty(filtro) || t.Descripcion.Trim().ToLower() == filtro.Trim().ToLower())).OrderBy(q => q.IdPantalla).ToList();
}
}
catch (Exception ex)
{
//log.Error(ex);
}
return registros;
}
public List<RolesPantallas> ObtenerPantallasRol(CatalogosPostJSON model)
{
List<RolesPantallas> registros = null;
string filtro = model != null ? model.filtro : null;
try
{
using (SinortContex db = new SinortContex())
{
registros = db.RolesPantallas.Where(r => r.IdRol.ToString() == model.codigo).Include(p => p.Pantallas).AsNoTracking().ToList();
}
}
catch (Exception ex)

View file

@ -18,14 +18,16 @@ namespace AYA.SlnSinortModel.DAL.Sinort
#region ObtenerRol
public List<CatalogosJSON> ObtenerRol(string filtro = null)
public List<CatalogosJSON> ObtenerRol(CatalogosPostJSON model)
{
List<CatalogosJSON> registros = null;
string filtro = model != null ? model.filtro : null;
try
{
using (SinortContex db = new SinortContex())
{
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Roles.Where(t => t.Estado == true) : db.Roles.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true))
registros = db.Roles.Where(t => t.Estado == true && (string.IsNullOrEmpty(filtro) || t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower())))
.Select(t => new CatalogosJSON()
{
codigo = t.IdRol.ToString(),
@ -117,6 +119,63 @@ namespace AYA.SlnSinortModel.DAL.Sinort
#endregion
#region InsertarActualizarRolesPantallas
public BaseJson InsertarActualizarRolesPantallas(RolesPantallas model)
{
RolesPantallas Actual = new RolesPantallas();
BaseJson Respuesta = new BaseJson();
try
{
model.ClearProperties();
using (SinortContex Conn = new SinortContex())
{
Actual = Conn.RolesPantallas.Where(x => x.IdRol == model.IdRol && x.IdPantalla == model.IdPantalla ).FirstOrDefault();
if (Actual == null)
{
int? Next_id = Conn.RolesPantallas.Max(t => (int?)t.IdRolesPantallas);
model.IdRolesPantallas = (Next_id == null) ? 1 : Next_id.Value + 1;
model.FechaCreacion = DateTime.Now;
Conn.RolesPantallas.Add(model);
}
else
{
//model.FechaModificacion = DateTime.Now;
//model.FechaCreacion = Actual.FechaCreacion;
//model.UsuarioCreacion = Actual.UsuarioCreacion;
//model.Descripcion = string.IsNullOrEmpty(model.Descripcion) ? Actual.Descripcion : model.Descripcion;
//Conn.Entry(Actual).State = System.Data.Entity.EntityState.Detached;
//Conn.Roles.Attach(model);
//Conn.Entry(model).State = System.Data.Entity.EntityState.Modified;
}
Conn.SaveChanges();
Conn.Commit();
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
}
}
catch (DbEntityValidationException ex)
{
//logger.Error(exs);
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
}
catch (Exception ex)
{
//logger.Error(ex);
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
}
finally
{
Actual = null;
}
return Respuesta;
}
#endregion
}
}

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
<package id="NLog" version="4.5.6" targetFramework="net45" />
</packages>

View file

@ -87,6 +87,7 @@
<Compile Include="Sinort\RolesPantallas.cs" />
<Compile Include="Sinort\RolesUsuario.cs" />
<Compile Include="Sinort\SinortContex.cs" />
<Compile Include="Sinort\sysdiagrams.cs" />
<Compile Include="Sinort\TipoAplicacion.cs" />
<Compile Include="Sinort\TipoDocumento.cs" />
<Compile Include="Sinort\TipoEmisor.cs" />

View file

@ -1,4 +1,5 @@

using AYA.SlnSinortModel.Sinort;
using System;
using System.Collections.Generic;
using System.Linq;
@ -12,4 +13,16 @@ namespace AYA.SlnSinortModel.Entidades
public string codigo { get; set; }
public string descripcion { get; set; }
}
public class CatalogosPostJSON
{
public object dataModel { get; set; }
public string codigo { get; set; }
public string filtro { get; set; }
}
public class RolesPantallasJSON : BaseJson
{
public List<RolesPantallas> ListaRolesPantallas { get; set; }
}
}

View file

@ -9,6 +9,12 @@ namespace AYA.SlnSinortModel.Sinort
[Table("Catalogos.Pantallas")]
public partial class Pantallas
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Pantallas()
{
RolesPantallas = new HashSet<RolesPantallas>();
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int IdPantalla { get; set; }
@ -32,5 +38,8 @@ namespace AYA.SlnSinortModel.Sinort
[StringLength(200)]
public string UsuarioModificacion { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<RolesPantallas> RolesPantallas { get; set; }
}
}

View file

@ -1,14 +1,15 @@
namespace AYA.SlnSinortModel.Sinort
{
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using AYA.SlnSinortModel.Sinort.Partial;
namespace AYA.SlnSinortModel.Sinort
{
public partial class SinortContex : Contex
{
public virtual DbSet<Aplicacion> Aplicacion { get; set; }
public virtual DbSet<Categoria> Categoria { get; set; }
public virtual DbSet<Emisor> Emisor { get; set; }
@ -26,6 +27,7 @@ namespace AYA.SlnSinortModel.Sinort
public virtual DbSet<TipoForo> TipoForo { get; set; }
public virtual DbSet<TipoMatriz> TipoMatriz { get; set; }
public virtual DbSet<Usuario> Usuario { get; set; }
public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
public virtual DbSet<BitacoraDocumentos> BitacoraDocumentos { get; set; }
public virtual DbSet<Documentos> Documentos { get; set; }
public virtual DbSet<DocumentosAdjuntos> DocumentosAdjuntos { get; set; }
@ -117,14 +119,6 @@ namespace AYA.SlnSinortModel.Sinort
.Property(e => e.UsuarioModificacion)
.IsUnicode(false);
modelBuilder.Entity<PermisosUsuario>()
.Property(e => e.UsuarioCreacion)
.IsUnicode(false);
modelBuilder.Entity<Pantallas>()
.Property(e => e.UsuarioModificacion)
.IsUnicode(false);
modelBuilder.Entity<PlantillaEmail>()
.Property(e => e.NombrePlatilla)
.IsUnicode(false);

View file

@ -0,0 +1,24 @@
namespace AYA.SlnSinortModel.Sinort
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
public partial class sysdiagrams
{
[Required]
[StringLength(128)]
public string name { get; set; }
public int principal_id { get; set; }
[Key]
public int diagram_id { get; set; }
public int? version { get; set; }
public byte[] definition { get; set; }
}
}

View file

@ -109,7 +109,9 @@ namespace Atesa.Utilitarios
byte[] body;
var serializer = new JsonSerializer();
serializer.Converters.Add(new StringEnumConverter { AllowIntegerValues = false, CamelCaseText = false });
Message replyMessage = null;
try
{
using (var ms = new MemoryStream())
{
using (var sw = new StreamWriter(ms, Encoding.UTF8))
@ -124,12 +126,20 @@ namespace Atesa.Utilitarios
}
}
Message replyMessage = Message.CreateMessage(messageVersion, action, new RawBodyWriter(body));
replyMessage = Message.CreateMessage(messageVersion, action, new RawBodyWriter(body));
replyMessage.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
var respProp = new HttpResponseMessageProperty();
respProp.Headers[HttpResponseHeader.ContentType] = "application/json";
respProp.StatusCode = statusCode;
replyMessage.Properties.Add(HttpResponseMessageProperty.Name, respProp);
}
catch (Exception ex)
{
throw ex;
}
return replyMessage;
}
}