diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs index e172a29c3..4e1f1c741 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinort.cs @@ -52,7 +52,7 @@ namespace AYA.SlnSinort.WCF [OperationContract] FichaTecnicaJSON GuardarFichaTecnicaHistoricoPalabraClave(FichaTecnicaJSON model); - + [OperationContract] FichaTecnicaJSON GuardarFichaTecnicaPalabraClave(FichaTecnicaJSON model); @@ -73,7 +73,7 @@ namespace AYA.SlnSinort.WCF [OperationContract] FichaTecnicaJSON EliminarFichaTecnica(FichaTecnicaJSON model); - + [OperationContract] FichaTecnicaJSON ObtenerFichaTecnicaHistorico(FichaTecnicaJSON model); @@ -88,9 +88,9 @@ namespace AYA.SlnSinort.WCF [OperationContract] AdjuntosJSON RemoverAdjunto(AdjuntosJSON model); - [OperationContract] + [OperationContract] AdjuntosJSON CopiarAdjunto(AdjuntosJSON model); - + [OperationContract] AdjuntosJSON EliminarbaseAdjunto(AdjuntosJSON model); @@ -103,7 +103,7 @@ namespace AYA.SlnSinort.WCF #endregion - #region Tareas Pendientes + #region Tareas Pendientes [OperationContract] List ObtenerTareasPendientes(CatalogosPostJSON model); @@ -115,7 +115,7 @@ namespace AYA.SlnSinort.WCF [OperationContract] NotificacionesJSON ObtenerCantidadTareasPendientes(NotificacionesJSON model); - #endregion + #endregion #region Gotitas Normativas [OperationContract] @@ -126,8 +126,8 @@ namespace AYA.SlnSinort.WCF [OperationContract] NotificacionesJSON ObtenerCantidadGotitasPendientes(NotificacionesJSON model); - #endregion - #region Login + #endregion + #region Login [OperationContract] LoginJSON ObtenerUsuarioAD(LoginJSON model); @@ -137,7 +137,7 @@ namespace AYA.SlnSinort.WCF [OperationContract] List ObtenerPermisos(CatalogosPostJSON model); - #endregion + #endregion #region Solicitud [OperationContract] @@ -145,17 +145,17 @@ namespace AYA.SlnSinort.WCF [OperationContract] SolicitudJSON ObtenerSolicitud(SolicitudJSON model); - + [OperationContract] SolicitudJSON ObtenerSolicitudUsuario(SolicitudJSON model); [OperationContract] SolicitudJSON ObtenerSolicitudCompraAutorizadas(SolicitudJSON model); - - + + [OperationContract] SolicitudJSON ObtenerPorTipo(SolicitudJSON model); - + [OperationContract] SolicitudJSON EnviarCorreoSolicitud(SolicitudJSON model); #endregion @@ -189,7 +189,7 @@ namespace AYA.SlnSinort.WCF EncuestaJSON ObtenerUsuariosEncuestas(EncuestaJSON model); #endregion + [OperationContract] + UExternoJSON EnviarCorreoAExterno(UExternoJSON model); } - -} - +} \ No newline at end of file diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinortCatalogos.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinortCatalogos.cs index 013440935..091e41a59 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinortCatalogos.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/ISinortCatalogos.cs @@ -85,6 +85,8 @@ namespace AYA.SlnSinort.WCF [OperationContract] string VerificarUsuario(CatalogosPostJSON model); + [OperationContract] + UsuarioExterno BuscarEmail(CatalogosPostJSON model); [OperationContract] BaseJson InsertarUsuarioExterno(UsuarioExterno model); #endregion diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs index bcfb46c17..446e118c8 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/Sinort.svc.cs @@ -927,6 +927,59 @@ namespace AYA.SlnSinort.WCF model.CodigoRespuesta = (respuesta == 1) ? EnumTipoCodigoRespuesta.EXITOSO : EnumTipoCodigoRespuesta.ERROR; ; return model; } + public UExternoJSON EnviarCorreoAExterno(UExternoJSON model) { + + PlantillaEmailDAL PlantillalDAL = new PlantillaEmailDAL(); + PlantillaEmail plantilla = new PlantillaEmail(); + List Listaplantillas = new List(); + + int respuesta = 0; + + string email; + string body; + try + { + + //Obtener parametros + + ServiciosUsuariosWCF.ServicioUsuariosClient respuestaAyA = new ServiciosUsuariosWCF.ServicioUsuariosClient(); + ServiciosUsuariosWCF.correoEL correo = new ServiciosUsuariosWCF.correoEL(); + Listaplantillas = PlantillalDAL.ObtenerPlantillasEmail(); + + + switch (model.PlantillaEmail.NombrePlatilla) + { + case "Correo Registro Externo": + plantilla = Listaplantillas.Where(p => p.NombrePlatilla == model.PlantillaEmail.NombrePlatilla).FirstOrDefault(); + correo = new ServiciosUsuariosWCF.correoEL(); + correo.FORMATO = "html"; + correo.ASUNTO = plantilla.Subject; + + + body = plantilla.Body.Replace("$Nombre", model.UsuarioExterno.Nombre).Replace("$Apellido", model.UsuarioExterno.Apellido1) + .Replace("$Usuario", model.UsuarioExterno.Usuario).Replace("$Password", model.UsuarioExterno.Password).Replace("|", "
"); + correo.CUERPO = body; + email = model.UsuarioExterno.Email; + correo.DESTINATARIOS = email; + + respuesta = respuestaAyA.enviarCorreo(correo); + + + + break; + + } + + } + catch (Exception ex) + { + model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR; + throw; + } + model.CodigoRespuesta = (respuesta == 1) ? EnumTipoCodigoRespuesta.EXITOSO : EnumTipoCodigoRespuesta.ERROR; ; + return model; + + } #endregion #region Adjuntos diff --git a/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs b/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs index 91ee090ee..92e2fa81d 100644 --- a/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs +++ b/AYA.SlnSynor/AYA.SlnSynor.WCF/SinortCatalogos.svc.cs @@ -335,6 +335,19 @@ namespace AYA.SlnSinort.WCF } return model.codigo; } + public UsuarioExterno BuscarEmail(CatalogosPostJSON model) { + UsuarioExterno respuesta = null; + try + { + respuesta = new UsuarioExternoDAL().BuscarEmail(model); + + } + catch (Exception ex) + { + log.Error(ex); + } + return respuesta; + } public BaseJson InsertarUsuarioExterno(UsuarioExterno model) { BaseJson respuesta = new BaseJson(); diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Signup.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Signup.js index f60a4194d..481363836 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Signup.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Signup.js @@ -123,7 +123,6 @@ this.BuscarUsuario = function (model) { this.NombreUsuario = function (data) { usuario = data; LeerFormulario(); - RegistrarUsuario(); } this.LeerFormulario = function () { @@ -136,16 +135,46 @@ this.LeerFormulario = function () { Apellido2: $('#txtApellido2').val(), Email: $('#txtEmail').val() } + model = { + codigo: UsuarioExterno.Email + } + + var uri = SinorSignupWCF + '/api/BuscarEmail'; + AjaxPostData(uri, model, false, false, RegistrarUsuario, null, null); } -this.RegistrarUsuario = function () { +this.RegistrarUsuario = function (data) { - var uri = SinorSignupWCF + '/api/InsertarUsuarioExterno'; - AjaxPostData(uri, UsuarioExterno, true, false, null, null, null); + if (data == null) { + var uri = SinorSignupWCF + '/api/InsertarUsuarioExterno'; + AjaxPostData(uri, UsuarioExterno, false, false, null, null, null); - url = $("#hiddenHref").val(); - url = url.replace("View", "LoginExterno"); - url = url.replace("Controller", "Login"); - document.location.href = url; + EnviarCorreo(); + url = $("#hiddenHref").val(); + url = url.replace("View", "LoginExterno"); + url = url.replace("Controller", "Login"); + + document.location.href = url; + } + else { + toastr.error('El email digitado ya se encuentra registrado', Message_Warning); + ENDREQUEST(); + } + +} +this.EnviarCorreo = function() +{ + var Plantilla + = { + NombrePlatilla: 'Correo Registro Externo', + } + + correo = { } + correo.PlantillaEmail = Plantilla; + correo.UsuarioExterno = UsuarioExterno; + var uri = SinorLoginWCF + '/api/EnviarCorreoAExterno'; + AjaxPostData(uri, correo, false, false, null, null, null); + + ENDREQUEST(); } \ No newline at end of file diff --git a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/UsuarioExternoDAL.cs b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/UsuarioExternoDAL.cs index 273bccd1e..6416c4e8d 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/UsuarioExternoDAL.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel.DAL/Sinort/UsuarioExternoDAL.cs @@ -46,7 +46,30 @@ namespace AYA.SlnSinortModel.DAL.Sinort } #endregion + public UsuarioExterno BuscarEmail(CatalogosPostJSON model) + { + UsuarioExterno usuario = new UsuarioExterno(); + string filtro = model != null ? model.filtro : null; + try + { + using (SinortContex db = new SinortContex()) + { + + + usuario = db.UsuarioExterno.Where(r => r.Email.ToString() == model.codigo).FirstOrDefault(); + + + } + } + catch (Exception ex) + { + log.Error(ex); + + } + + return usuario; + } public BaseJson InsertarUsuarioExterno(UsuarioExterno model) { BaseJson Respuesta = new BaseJson(); diff --git a/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs b/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs index d0b7411a1..7b127a868 100644 --- a/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs +++ b/AYA.SlnSynor/AYA.SlnSynorModel/Entidades/Json.cs @@ -132,6 +132,9 @@ namespace AYA.SlnSinortModel.Entidades public bool Estado { get; set; } } - + public class UExternoJSON : BaseJson { + public UsuarioExterno UsuarioExterno { get; set; } + public PlantillaEmail PlantillaEmail { get; set; } + } }