agregado procesos y bd clases
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
@@ -31,40 +31,57 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraRegistroCorreon(tscgestionasegasa bd, string Asunto, string Cuerpo, bdAsegasa.db.cuentascorreo cuenta, string Destinatario, string ConCopia, string ConCopiaOculta, byte[] FicheroAdjunto = null, string NombreFicheroAdjunto = "", int? idAplicacion = default, string CodigoAplicacion = "", int? idEntidad = default)
|
||||
public static int GeneraRegistroCorreoConAdjunto(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, byte[] Fichero, string NombreFichero, string DescripcionFichero, string Destinatario, string Copia = "", string CopiaOculta = "", bool MarcarComoAnulado = false, string Remitente = "", int? idAplicacion = null, string CodigoAplicacion = "")
|
||||
{
|
||||
int resultado = 0;
|
||||
try
|
||||
{
|
||||
string sRutaAdjunto = "";
|
||||
var correo = new correos()
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
int idTipoAdjunto = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
|
||||
var f = new ficheros
|
||||
{
|
||||
idTipo = idTipoAdjunto,
|
||||
Descripcion = DescripcionFichero,
|
||||
Fichero = Fichero,
|
||||
NombreFichero = NombreFichero,
|
||||
Fecha = DateTime.Now
|
||||
};
|
||||
bd.ficheros.Add(f);
|
||||
bd.SaveChanges();
|
||||
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = ConCopia,
|
||||
CopiaOculta = ConCopiaOculta,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
Copia = Copia,
|
||||
CopiaOculta = CopiaOculta,
|
||||
DireccionRespuesta = cuenta.ResponderA,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
idFicheroAdjunto = f.idFichero,
|
||||
idAplicacion = idAplicacion,
|
||||
CodigoAplicacion = CodigoAplicacion,
|
||||
// idEntidad = idEntidad
|
||||
CodigoAplicacion = CodigoAplicacion
|
||||
};
|
||||
//if (bdAsegasa.db.Utilidades.idUsuario > 0)
|
||||
// correo.idUsuario = bdAsegasa.db.Utilidades.idUsuario;
|
||||
bd.correos.Add(correo);
|
||||
if (FicheroAdjunto is not null)
|
||||
|
||||
if (string.IsNullOrEmpty(Remitente))
|
||||
{
|
||||
var fi = new bdAsegasa.db.ficheros();
|
||||
fi.Descripcion = "Fichero Adjunto Correo";
|
||||
fi.NombreFichero = NombreFicheroAdjunto;
|
||||
fi.Fichero = FicheroAdjunto;
|
||||
fi.Fecha = DateTime.Now;
|
||||
fi.idTipo = bd.enumeraciones.First(x => x.Codigo == "TIPFIC.ADJCOR").idEnumeracion;
|
||||
correo.idFicheroAdjuntoNavigation = fi;
|
||||
correo.Remitente = cuenta.Remitente;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.Remitente = Remitente;
|
||||
}
|
||||
|
||||
if (MarcarComoAnulado)
|
||||
{
|
||||
correo.FechaAnulacion = DateTime.Now;
|
||||
}
|
||||
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -73,5 +90,96 @@ namespace bdAsegasa.db
|
||||
}
|
||||
}
|
||||
|
||||
public static int GeneraRegistroCorreo(tscgestionasegasa bd, string Asunto, string Cuerpo, bdAsegasa.db.cuentascorreo cuenta, string Destinatario, string Copia = "", string CopiaOculta = "", int? idfichero = null, bool MarcarComoAnulado = false, string Remitente = "", string ResponderA = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = Copia,
|
||||
CopiaOculta = CopiaOculta,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
idFicheroAdjunto = idfichero
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(ResponderA))
|
||||
{
|
||||
correo.DireccionRespuesta = ResponderA;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.DireccionRespuesta = cuenta.ResponderA;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Remitente))
|
||||
{
|
||||
correo.Remitente = Remitente;
|
||||
}
|
||||
else
|
||||
{
|
||||
correo.Remitente = cuenta.Remitente;
|
||||
}
|
||||
if (MarcarComoAnulado) correo.FechaAnulacion = DateTime.Now;
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Write(ex.Message);
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static int GeneraRegistroCorreoVariosFicheros(tscgestionasegasa bd, string Asunto, string Cuerpo, cuentascorreo cuenta, string Destinatario, System.Collections.Generic.List<int> idficheros = null, DateTime? FechaAnulacion = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var correo = new correos
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
FechaAnulacion = FechaAnulacion
|
||||
};
|
||||
if (idficheros != null)
|
||||
{
|
||||
foreach (var f in idficheros)
|
||||
{
|
||||
var nf = new ficherosadjuntos { idFichero = f };
|
||||
correo.ficherosadjuntos.Add(nf);
|
||||
}
|
||||
}
|
||||
bd.correos.Add(correo);
|
||||
bd.GuardarCambios();
|
||||
return correo.idcorreo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Error en GeneraRegistroCorreoVariosFicheros. Asunto:" + Asunto + " " + ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public class CorreoReducido
|
||||
{
|
||||
public int idCorreo { get; set; }
|
||||
public string Destinatario { get; set; }
|
||||
public string Asunto { get; set; }
|
||||
public DateTime FechaCreacion { get; set; }
|
||||
public DateTime? FechaAnulacion { get; set; }
|
||||
public string MensajeError { get; set; }
|
||||
public string Aplicacion { get; set; }
|
||||
public string CodigoAplicacion { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user