Agregar archivos de proyecto.
This commit is contained in:
127
bdGrupoSanchoToro/extensiones/correos.cs
Normal file
127
bdGrupoSanchoToro/extensiones/correos.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Net.Mime;
|
||||
using tsEFCore8.Extensiones;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
[NotMapped]
|
||||
public partial class correos
|
||||
{
|
||||
[NotMapped]
|
||||
public virtual string FicheroAdjunto
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idFicheroAdjunto.HasValue)
|
||||
{
|
||||
return this.idFicheroAdjuntoNavigation.NombreFichero;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GeneraRegistroCorreon(tscGrupoSanchoToro bd, string Asunto, string Cuerpo, bdGrupoSanchoToro.db.cuentascorreo cuenta, string Destinatario, string ConCopia, string ConCopiaOculta, byte[] FicheroAdjunto = null, string NombreFicheroAdjunto = "", int? idAplicacion = default, string CodigoAplicacion = "", int? idEntidad = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sRutaAdjunto = "";
|
||||
var correo = new correos()
|
||||
{
|
||||
Asunto = Asunto,
|
||||
Cuerpo = Cuerpo,
|
||||
Destinatario = Destinatario,
|
||||
Copia = ConCopia,
|
||||
CopiaOculta = ConCopiaOculta,
|
||||
DireccionRespuesta = cuenta.Remitente,
|
||||
FechaCreacion = bd.AhoraMySql(),
|
||||
idcuenta = cuenta.idCuenta,
|
||||
Remitente = cuenta.Remitente,
|
||||
idAplicacion = idAplicacion,
|
||||
CodigoAplicacion = CodigoAplicacion,
|
||||
idEntidad = idEntidad
|
||||
};
|
||||
if (bdGrupoSanchoToro.db.Utilidades.idUsuario > 0)
|
||||
correo.idUsuario = bdGrupoSanchoToro.db.Utilidades.idUsuario;
|
||||
bd.correos.Add(correo);
|
||||
if (FicheroAdjunto is not null)
|
||||
{
|
||||
var fi = new bdGrupoSanchoToro.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;
|
||||
}
|
||||
bd.GuardarCambios();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Write(ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//public static void ProcesaCorreos()
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
// var EmailEnPruebas = bd.enumeraciones.First(x => x.Codigo == @"CONF.EMAILENPRUEBAS").ValorAlfabeticoLargo;
|
||||
// var EmailCopiaOculta = bd.enumeraciones.First(x => x.Codigo == @"CONF.EMAILCOPIAOCULTAS").ValorAlfabeticoLargo;
|
||||
// // Dim EmailCopiaOculta = bd.enumeraciones.First(Function(x) x.Codigo = "CONF.EMAILCOPIAOCULTA").ValorAlfabeticoLargo
|
||||
|
||||
// var cors = bd.correos.Where(x=>x.FechaAnulacion == null && x.FechaEnvio == null && x.idcuenta !=null).ToList();
|
||||
// foreach (var c in cors)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// c.Asunto = c.Asunto.Replace(Environment.NewLine, " ");
|
||||
// bool bIntentar = false;
|
||||
// if (c.FechaUltimoIntento == null)
|
||||
// { bIntentar = true; }
|
||||
// else
|
||||
// {
|
||||
// if (DateTime.UtcNow.Subtract(c.FechaUltimoIntento.Value).TotalHours>1 ) bIntentar = true;
|
||||
// }
|
||||
// if (bIntentar)
|
||||
// {
|
||||
// string sPass = c.idcuentaNavigation.Password;
|
||||
// if (System.IO.Directory.Exists(@"C:\tecnosis.tfs"))
|
||||
// {
|
||||
// c.Destinatario = "manmog@tecnosis.net";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Debug.Write(ex.Message);
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user