From 85bf374d2dd37b135dd336ae430c364ae5a65350 Mon Sep 17 00:00:00 2001 From: "jzuniga:1" Date: Sat, 9 Jun 2018 21:10:16 +0000 Subject: [PATCH] git-tfs-id: [http://192.168.1.10:8080/tfs/AyA]$/SINORT;C18 --- .../AYA.SlnSynor/AYA.SlnSinort.csproj | 1 + .../Matenimimento/EmisorAPIController.cs | 52 +++++++++++++ .../AYA.SlnSynor/Sinort-Scripts/EmisorPN.js | 4 +- .../AYA.SlnSynor/Sinort-Scripts/Global.js | 2 +- .../AYA.SlnSynorModel.DAL/Sinort/EmisorDAL.cs | 72 +++++++++--------- .../Sinort/Partial/Contex.cs | 4 +- .../Atesa.Utilitarios/ObtieneParametros.cs | 75 ++++++++++++++++--- 7 files changed, 158 insertions(+), 52 deletions(-) create mode 100644 AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/EmisorAPIController.cs diff --git a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj index 50d3b9f5b..9f23b5aa3 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj +++ b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj @@ -182,6 +182,7 @@ + diff --git a/AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/EmisorAPIController.cs b/AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/EmisorAPIController.cs new file mode 100644 index 000000000..8948458f4 --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/ControllersWebApi/Matenimimento/EmisorAPIController.cs @@ -0,0 +1,52 @@ +using AYA.SlnSinortModel.DAL.Sinort; +using AYA.SlnSinortModel.Entidades; +using AYA.SlnSinortModel.Synort; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + +namespace AYA.SlnSinort.ControllersWebApi.Matenimimento +{ + public class EmisorAPIController : ApiController + { + #region Emisor + [HttpGet] + public List ObtenerEmisor() + { + List respuesta = null; + try + { + respuesta = new EmisorDAL().ObtenerEmisor(); + + } + catch (Exception ex) + { + throw; + } + return respuesta; + } + + [HttpPost] + public BaseJson InsertarActualizarEmisor(Emisor model) + { + BaseJson respuesta = new BaseJson(); + try + { + respuesta = new EmisorDAL().InsertarActualizarEmisor(model); + } + catch (Exception ex) + { + + throw; + } + return respuesta; + } + + + #endregion + + + } +} \ No newline at end of file diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js index d8597af7b..6e4911de4 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js @@ -48,7 +48,7 @@ this.getDataModel = function () { this.obtenerItems = function () { - var uri = CatalogosWCF + '/api/ObtenerEmisor'; + var uri = server + 'api/EmisorAPI/ObtenerEmisor'; var DTO = JSON.stringify(Item); STARTREQUEST(); @@ -66,7 +66,7 @@ this.obtenerItems = function () { $('#TableItems').TableInit(0, false, true, true, false, null, null); var TableItems = $('#TableItems').DataTable(); - var lista = data.d; + var lista = data; $.each(lista, function (key, item) { diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js index cffbef4aa..99c060726 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js @@ -1,6 +1,6 @@ var CatalogosWCF = $("#hiddenSinortCatalogosWCF").val(); var SinortWCF = $("#hiddenSinortWCF").val(); -var server = "http://" + location.host + "/AYA.SlnSynor.WCF/"; +var server = "http://" + location.host + "/AYA.SlnSynor/"; function Mensajes(mensaje) { if (mensaje.CodigoRespuesta === "1") { diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/EmisorDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/EmisorDAL.cs index 6b85a066c..048168bd9 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/EmisorDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/EmisorDAL.cs @@ -61,7 +61,7 @@ namespace AYA.SlnSinortModel.DAL.Sinort #region InsertarActualizar - public BaseJson InsertarActualizarCliente(Emisor model) + public BaseJson InsertarActualizarEmisor(Emisor model) { Emisor Actual = new Emisor(); BaseJson Respuesta = new BaseJson(); @@ -111,43 +111,43 @@ namespace AYA.SlnSinortModel.DAL.Sinort } - public BaseJson ModificarEstadoEmisorPN(Emisor model) - { - BaseJson Respuesta = new BaseJson(); - Emisor Actual = new Emisor(); - try - { - using (SinortContex Conn = new SinortContex()) - { - Emisor _model = Conn.Emisor.Where(x => x.IdEmisor == model.IdEmisor).FirstOrDefault(); - if (_model != null) - { - _model.Estado = model.Estado; - _model.UsuarioModificacion = "jnunez"; - _model.FechaModificacion = DateTime.Now; - Conn.SaveChanges(); - Respuesta.CodigoRespuesta = Constantes.TipoCodigoRespuesta.EXITOSO.ToString(); - } - } - } - catch (DbEntityValidationException ex) - { - //logger.Error(exs); - Respuesta.CodigoRespuesta = Constantes.TipoCodigoRespuesta.ERROR.ToString(); - } - catch (Exception ex) - { - //logger.Error(ex); - Respuesta.CodigoRespuesta = Constantes.TipoCodigoRespuesta.ERROR.ToString(); - } - finally - { - Actual = null; - } - return Respuesta; + //public BaseJson ModificarEstadoEmisorPN(Emisor model) + //{ + // BaseJson Respuesta = new BaseJson(); + // Emisor Actual = new Emisor(); + // try + // { + // using (SinortContex Conn = new SinortContex()) + // { + // Emisor _model = Conn.Emisor.Where(x => x.IdEmisor == model.IdEmisor).FirstOrDefault(); + // if (_model != null) + // { + // _model.Estado = model.Estado; + // _model.UsuarioModificacion = "jnunez"; + // _model.FechaModificacion = DateTime.Now; + // Conn.SaveChanges(); + // Respuesta.CodigoRespuesta = Constantes.TipoCodigoRespuesta.EXITOSO.ToString(); + // } + // } + // } + // catch (DbEntityValidationException ex) + // { + // //logger.Error(exs); + // Respuesta.CodigoRespuesta = Constantes.TipoCodigoRespuesta.ERROR.ToString(); + // } + // catch (Exception ex) + // { + // //logger.Error(ex); + // Respuesta.CodigoRespuesta = Constantes.TipoCodigoRespuesta.ERROR.ToString(); + // } + // finally + // { + // Actual = null; + // } + // return Respuesta; - } + //} #endregion } diff --git a/AYA.SlnSynor/AYA.SlnSynorModel/Sinort/Partial/Contex.cs b/AYA.SlnSynor/AYA.SlnSynorModel/Sinort/Partial/Contex.cs index 896ad7fc8..b5f462108 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel/Sinort/Partial/Contex.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel/Sinort/Partial/Contex.cs @@ -13,9 +13,9 @@ namespace AYA.SlnSinortModel.Sinort.Partial private bool WasCommitted = false; private bool disposed = false; public Contex() - : base("data source=192.168.1.37;initial catalog=SinortAyA;persist security info=True;user id=sinort;password=sinort2018;MultipleActiveResultSets=True;App=EntityFramework") + : base(new Atesa.Utilitarios.ObtieneParametros().GetValueKeyRegedit("SinortAyAConnectionString", false)) { - var instacia = System.Data.Entity.SqlServer.SqlProviderServices.Instance; + Database.SetInitializer(null); Configuration.ProxyCreationEnabled = false; Configuration.LazyLoadingEnabled = true; diff --git a/AYA.SlnSynor/Atesa.Utilitarios/ObtieneParametros.cs b/AYA.SlnSynor/Atesa.Utilitarios/ObtieneParametros.cs index 724bac047..aadc9b788 100644 --- a/AYA.SlnSynor/Atesa.Utilitarios/ObtieneParametros.cs +++ b/AYA.SlnSynor/Atesa.Utilitarios/ObtieneParametros.cs @@ -10,24 +10,77 @@ namespace Atesa.Utilitarios public class ObtieneParametros { - public string GetValueKeyRegedit(string SubKey, string Key, bool Decrypt) + private string key = @"SOFTWARE\\Parametros"; + + public void AddValueKeyRegedit(string KeyStringName, string KeyStringValue, bool Encrypt) { - string Respuesta = string.Empty; - try { - using (RegistryKey RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE")) + RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key, true); + if (key2 != null) { - RegistryKey SubRegistryKey = RegistryKey.OpenSubKey(SubKey); - Respuesta = SubRegistryKey.GetValue(Key, "Value", RegistryValueOptions.DoNotExpandEnvironmentNames).ToString(); - } + if (Encrypt) + { + //key2.SetValue(KeyStringName, new Crypt().EncryptString(KeyStringValue), RegistryValueKind.String); + } + else + { + key2.SetValue(KeyStringName, KeyStringValue, RegistryValueKind.String); + } + } } - catch (Exception ex) + catch { - - throw; } - return Respuesta; } + + public Dictionary GetRegistrySubKeys() + { + Dictionary dictionary = new Dictionary(); + using (RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key)) + { + if (key2 == null) + { + return dictionary; + } + string[] valueNames = key2.GetValueNames(); + foreach (string str in valueNames) + { + object obj2 = key2.GetValue(str); + dictionary.Add(str, obj2); + } + key2.Close(); + } + return dictionary; + } + + public string GetValueKeyRegedit(string KeyStringName, bool Decrypt) + { + string str = string.Empty; + try + { + RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key, false); + if (key2 == null) + { + return str; + } + if (Decrypt) + { + //str = new Crypt().DecryptString(Convert.ToString(key2.GetValue(KeyStringName))); + } + else + { + str = Convert.ToString(key2.GetValue(KeyStringName)); + } + key2.Close(); + } + catch + { + } + return str; + } + } + } +