268 lines
9.5 KiB
C#
268 lines
9.5 KiB
C#
|
|
using Atesa.Utilitarios;
|
|
using AYA.SlnSinortModel.Constantes;
|
|
using AYA.SlnSinortModel.DAL.Sinort;
|
|
using AYA.SlnSinortModel.Entidades;
|
|
using AYA.SlnSinortModel.Sinort;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.DirectoryServices;
|
|
using System.DirectoryServices.ActiveDirectory;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.ServiceModel;
|
|
using System.ServiceModel.Web;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
////using AYA.SlnSinort.WCF.ServiciosUsuariosWCF;
|
|
|
|
namespace AYA.SlnSinort.WCF
|
|
{
|
|
|
|
public class Sinort : ISinort
|
|
{
|
|
Log log = new Log("SinortWCF");
|
|
|
|
#region ProyectoNormativo
|
|
public ProyectoNormativoJSON GuardarProyectoNormativo(ProyectoNormativoJSON model)
|
|
{
|
|
try
|
|
{
|
|
if (model.ProyectoNormativo == null)
|
|
{
|
|
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
model.DescripcionRespuesta = "No se encontraron datos del proyecto normativo";
|
|
return model;
|
|
}
|
|
|
|
model = new ProyectoNormativoDAL().GuardarProyectoNormativo(model);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex);
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
|
}
|
|
return model;
|
|
}
|
|
|
|
public ProyectoNormativoJSON GuardarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model)
|
|
{
|
|
|
|
try
|
|
{
|
|
var convocatoriaDAL = new ConvocatoriaDAL();
|
|
if (model.ListaConvocatoria == null)
|
|
{
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
model.DescripcionRespuesta = "No se encontraron datos de los convocados";
|
|
return model;
|
|
}
|
|
|
|
foreach (var convocados in model.ListaConvocatoria)
|
|
{
|
|
model.Convocado = convocados;
|
|
convocatoriaDAL.GuardarConvocatoriaProyectoNormativo(model);
|
|
}
|
|
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex);
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
|
}
|
|
return model;
|
|
}
|
|
|
|
public ProyectoNormativoJSON ObtenerProyectoNormativo(ProyectoNormativoJSON model)
|
|
{
|
|
try
|
|
{
|
|
if (model.ProyectoNormativo == null)
|
|
{
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
model.DescripcionRespuesta = "No se encontraron datos del proyecto normativo";
|
|
return model;
|
|
}
|
|
|
|
model = new ProyectoNormativoDAL().ObtenerProyectoNormativo(model);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex);
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
|
}
|
|
return model;
|
|
}
|
|
|
|
public ProyectoNormativoJSON GuardarComentarioProyectoNormativo(ProyectoNormativoJSON model)
|
|
{
|
|
try
|
|
{
|
|
if (model.ProyectoNormativo == null)
|
|
{
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
model.DescripcionRespuesta = "No se encontraron datos del proyecto normativo";
|
|
return model;
|
|
}
|
|
|
|
if (model.Comentario == null)
|
|
{
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
model.DescripcionRespuesta = "No se encontraron datos del nuevo comentario";
|
|
return model;
|
|
}
|
|
|
|
model = new ComentariosDAL().GuardarComentariosProyectoNormativo(model);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex);
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
|
}
|
|
return model;
|
|
}
|
|
|
|
//public ProyectoNormativoJSON EliminarConvocatoriaProyectoNormativo(ProyectoNormativoJSON model)
|
|
//{
|
|
// try
|
|
// {
|
|
// if (model.ProyectoNormativo == null)
|
|
// {
|
|
// model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
// model.DescripcionRespuesta = "No se encontraron datos del proyecto normativo";
|
|
// return model;
|
|
// }
|
|
|
|
// if (model.Convocado == null)
|
|
// {
|
|
// model.CodigoRespuesta = EnumTipoCodigoRespuesta.ADVERTENCIA;
|
|
// model.DescripcionRespuesta = "No se encontraron datos del usuario";
|
|
// return model;
|
|
// }
|
|
|
|
// model = new ConvocatoriaDAL().EliminarConvocatoriaProyectoNormativo(model);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// log.Error(ex);
|
|
// model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
|
// }
|
|
// return model;
|
|
//}
|
|
#endregion
|
|
|
|
#region WCFAYA Envio Correo
|
|
|
|
public int EnviarCorreo(ProyectoNormativoJSON model)
|
|
{
|
|
PlantillaEmailDAL PlantillalDAL = new PlantillaEmailDAL();
|
|
UsuarioDAL UsuarioDAL = new UsuarioDAL();
|
|
List<PlantillaEmail> Listaplantillas = new List<PlantillaEmail>();
|
|
PlantillaEmail plantilla = new PlantillaEmail();
|
|
Usuario usuario = new Usuario();
|
|
CatalogosPostJSON catalogo = new CatalogosPostJSON();
|
|
|
|
|
|
int respuesta = 0;
|
|
|
|
try
|
|
{
|
|
|
|
//Obtener parametros
|
|
|
|
ServiciosUsuariosWCF.ServicioUsuariosClient respuestaAyA = new ServiciosUsuariosWCF.ServicioUsuariosClient();
|
|
ServiciosUsuariosWCF.correoEL correo = new ServiciosUsuariosWCF.correoEL();
|
|
Listaplantillas = PlantillalDAL.ObtenerPlantillasEmail();
|
|
catalogo.codigo = model.ProyectoNormativo.PromotorProyecto;
|
|
usuario = UsuarioDAL.BuscarUsuario(catalogo);
|
|
|
|
//Envio correo analista
|
|
|
|
plantilla = Listaplantillas.Where(p => p.IdPlantilla == 1).FirstOrDefault();
|
|
correo.FORMATO = "html";
|
|
correo.ASUNTO = plantilla.Subject.Replace("$NombreProyecto", model.ProyectoNormativo.NombreProyectoNormativo);
|
|
var body = plantilla.Body.Replace("$NombreProyecto", model.ProyectoNormativo.NombreProyectoNormativo).Replace("$Usuario", usuario.NombreUsuario).Replace("|", "</br>");
|
|
var usu = usuario.EmailUsuario;
|
|
correo.DESTINATARIOS = "jnunez@atesacr.com";
|
|
correo.CUERPO = body;
|
|
|
|
respuesta = respuestaAyA.enviarCorreo(correo);
|
|
|
|
//Envio correo convocados
|
|
plantilla = Listaplantillas.Where(p => p.IdPlantilla == 2).FirstOrDefault();
|
|
correo = new ServiciosUsuariosWCF.correoEL();
|
|
correo.FORMATO = "html";
|
|
correo.ASUNTO = plantilla.Subject.Replace("$NombreProyecto", model.ProyectoNormativo.NombreProyectoNormativo);
|
|
|
|
|
|
foreach (var participantes in model.ListaConvocatoria)
|
|
{
|
|
catalogo.codigo = participantes.UsuarioSistema;
|
|
usuario = UsuarioDAL.BuscarUsuario(catalogo);
|
|
var body2 = plantilla.Body.Replace("$NombreProyecto", model.ProyectoNormativo.NombreProyectoNormativo).Replace("$FechaMaxima", Convert.ToString(model.ProyectoNormativo.FechaMaximaConfirmarParticipacion)).Replace("$Usuario", usuario.NombreUsuario).Replace("|", "</br>");
|
|
correo.CUERPO = body2;
|
|
var usu1 = usuario.EmailUsuario;
|
|
correo.DESTINATARIOS = "jnunez@atesacr.com";
|
|
|
|
respuesta = respuestaAyA.enviarCorreo(correo);
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
#region Adjuntos
|
|
|
|
public AdjuntosJSON RemoverAdjunto(AdjuntosJSON model)
|
|
{
|
|
|
|
string Serverpath = HttpContext.Current.Server.MapPath("DocumentosSINORT");
|
|
Serverpath += "\\" + model.Carpeta;
|
|
try
|
|
{
|
|
string file;
|
|
string fileDirectory = Serverpath;
|
|
file = model.Nombre.Replace(" ", "_");
|
|
fileDirectory = fileDirectory + "\\" + file;
|
|
|
|
|
|
|
|
|
|
if (File.Exists(fileDirectory))
|
|
{
|
|
File.Delete(fileDirectory);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex);
|
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR;
|
|
}
|
|
return model;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|