Ejemplo n.º 1
0
 public int InsertIAval(Aval p, List<ItemAval> itemAval)
 {
     try
     {
         var cons = 0;
         var consecu = bd.Aval.OrderByDescending(u => u.Registro).FirstOrDefault();
         if (consecu == null) { cons = 0; } else { cons = Convert.ToInt32(consecu.Registro); }
         // b.ENVIADO = DateTime.Now;
         p.Registro = (cons + 1);
         if (p.Aprueba == 1)
         {
             p.UsuarioAprueba = Membership.GetUser().ToString();
         }
         var Avalinsertado = bd.Aval.Add(p);
         bd.SaveChanges();
         // se gurada la primera fecha de inspeccion
         FechasAval fechas = new FechasAval();
         fechas.FechaInspeccion = DateTime.Now;
         fechas.idRegistro = Avalinsertado.id;
         InsertFechasAval(fechas);
         // se guarda los item por registro de aval
         InserItemAval(itemAval, Avalinsertado.id,p.ReferenciaInmueble);
         EnviarCorreoSolicitud(p, Avalinsertado.id);
         return 1;
     }
     catch (DbUpdateException)
     {
         return 0;
     }
     catch (Exception)
     {
         return 2;
         throw;
     }
 }
Ejemplo n.º 2
0
        public void EnviarCorreoSolicitud(Aval x, int aval)
        {
            var enviado = "";
            var dirobra = "";
            var nombre = "";
            var mz = "";
            var inmueb = "";
            var estado2 = "";
            var psotventa = "";
            var f = bd.VListadoEntegrasC.First(inm => inm.IdAval == aval);
            nombre = f.NOMBRE_PROYEC.Trim();
            mz = f.NOMBRE_BLO.Trim();
            inmueb = f.INMUEBLE;

            var ctx = bd.INMUEBLES_ENTREGAS.First(inm => inm.REFERENCIA_INMUEBLE == x.ReferenciaInmueble);
            var referencia = ctx.ID_ENTREGA;
            var estado = ctx.ESTADOAVAL;
            if (estado == 1)
            {
                estado2 = "Revisado con hallazgos";
            }
            else if (estado == 2)
            {
                estado2 = "Aprobado para entrega";
            }
            else
            {
                estado2 = "No revisado";
            }
            var cte = bd.Entregas.First(inm => inm.ID_ENTREGAS == referencia);
            enviado = cte.ENVIADOPOR;
            dirobra = cte.DIROBRA;
            var ctp = bd.ResponsableCalidad.First(inm => inm.Proyecto == "POSTVENTAS");
            psotventa = ctp.Usuario;
            string email = null;
            string emailAs = null;
            string cuerpo = null;
            var ctf = db.Usuarios.Where(p => p.Dominio == dirobra).ToList();
            foreach (var item2 in ctf)
            {
                email = item2.Correo;
            }
            ctf = db.Usuarios.Where(p => p.Dominio == enviado).ToList();
            foreach (var item2 in ctf)
            {
                email = email + "," + item2.Correo;
            }
            ctf = db.Usuarios.Where(p => p.Dominio == psotventa).ToList();
            foreach (var item3 in ctf)
            {
                emailAs =  item3.Correo;
            }
            MailMessage mmsg = new MailMessage();
            mmsg.To.Add(email);
            mmsg.CC.Add(emailAs);
            mmsg.Subject = "Constructora los mayales";
            mmsg.SubjectEncoding = System.Text.Encoding.UTF8;

            cuerpo = "<p style='text-align:justify'>" +
            "Un nuevo proceso de Aval se ha iniciado en el proyecto: " + nombre + ", manzana : "+ mz+", inmueble: " + inmueb+".</p>";
            //cuerpo += "</br>";
            cuerpo += "<p>Numero del Aval: " + aval + ". Con el estado:" + estado2;
            //cuerpo += "</br>";
            cuerpo += "<p>Ingrese al siguiene Link para mayor informacion.</p>";
            //cuerpo += "</br>";
            cuerpo += "<p>http://servidor.mayales.com:81/CRM/Entrega/RevisionCalidad/WebRevisionCalidad.aspx</p>";
            //cuerpo += "</br>";
            cuerpo += "<p>Cordial saludo,</p>";
            //cuerpo += "</br>";
            cuerpo += "<p>Este correo fue creado por un sistema automatico, favor no responder.</p>";

            AlternateView htmlView = AlternateView.CreateAlternateViewFromString("'<html><body>" + cuerpo + "</body></html>'<img src=cid:companylogo>", null, "text/html");
            //create the LinkedResource (embedded image)
            LinkedResource logo = new LinkedResource("C:\\logo.png");
            logo.ContentId = "companylogo";
            ////add the LinkedResource to the appropriate view
            htmlView.LinkedResources.Add(logo);
            mmsg.AlternateViews.Add(htmlView);
            //mmsg.Body = ;
            mmsg.IsBodyHtml = true; //Si no queremos que se envíe como HTML
            //Correo electronico desde la que enviamos el mensaje
            mmsg.From = new System.Net.Mail.MailAddress("*****@*****.**");
            /*-------------------------CLIENTE DE CORREO----------------------*/
            SmtpClient _Svcliente = new SmtpClient();
            //Hay que crear las credenciales del correo emisor
            _Svcliente.Credentials = new NetworkCredential("*****@*****.**", "Crm.2015#");
            //Lo siguiente es obligatorio si enviamos el mensaje desde Gmail
            /*
            cliente.Port = 587;
            cliente.EnableSsl = true;
            */
            _Svcliente.Host = "mail.mayales.com"; //Para Gmail "smtp.gmail.com";
            try
            {
                //Enviamos el mensaje
                _Svcliente.Send(mmsg);
            }
            catch (SmtpException ex)
            {
                throw ex;

            }
        }
Ejemplo n.º 3
0
 public int InsertAval(Aval b, List<ItemAval> ItemAval)
 {
     return cl.InsertIAval(b, ItemAval);
 }