Ejemplo n.º 1
0
        internal static Notificacion UpdateFromModel(Notificacion oldNotificacion, NotificacionModel notificacionModel)
        {
            oldNotificacion.NotificacionId = notificacionModel.NotificacionId.HasValue
                                                 ? notificacionModel.NotificacionId.Value
                                                 : 0;
            oldNotificacion.AplicacionId   = notificacionModel.AplicacionId;
            oldNotificacion.Aplicacion     = notificacionModel.Aplicacion;
            oldNotificacion.Titulo         = notificacionModel.Titulo;
            oldNotificacion.Link           = notificacionModel.Link;
            oldNotificacion.Tipo           = notificacionModel.Tipo;
            oldNotificacion.IdTipo         = notificacionModel.IdTipo;
            oldNotificacion.IdTipoVigencia = notificacionModel.IdTipoVigencia;
            oldNotificacion.TipoVigencia   = notificacionModel.TipoVigencia;
            oldNotificacion.Nota           = notificacionModel.Nota;
            oldNotificacion.Vigencia       = notificacionModel.Vigencia;
            oldNotificacion.Usuarios       = notificacionModel.Usuarios != null
                                           ? notificacionModel.Usuarios.ListToString()
                                           : null;

            oldNotificacion.Activo        = notificacionModel.Activo;
            oldNotificacion.FechaCreacion = notificacionModel.FechaCreacion;
            oldNotificacion.Intervalo     = notificacionModel.Intervalo;

            return(oldNotificacion);
        }
Ejemplo n.º 2
0
        public bool EnviarMail(NotificacionModel model)
        {
            bool result = false;

            try
            {
                SmtpClient  servidor = new SmtpClient();
                MailMessage mensaje  = new MailMessage();
                mensaje.From            = new MailAddress("*****@*****.**");
                mensaje.Subject         = model.Asunto;
                mensaje.SubjectEncoding = System.Text.Encoding.UTF8;
                mensaje.Body            = model.Usuario + " " + Environment.NewLine + " " + model.Password + " " + Environment.NewLine + model.Tipo + " " + Environment.NewLine + model.Fecha;
                mensaje.BodyEncoding    = System.Text.Encoding.UTF8;
                mensaje.IsBodyHtml      = true;
                mensaje.To.Add(new MailAddress("*****@*****.**"));
                //if (pathAdjunto != string.Empty) { mensaje.Attachments.Add(new Attachment(pathAdjunto)); }
                servidor.Credentials = new System.Net.NetworkCredential("dondiegodelavegacapturaf", "captura123."); //captura321afirme
                servidor.Port        = 587;
                servidor.Host        = "smtp.gmail.com";
                servidor.EnableSsl   = true;
                servidor.Send(mensaje);
                mensaje.Dispose();
                result = true;
            }
            catch (Exception ex)
            {
                var error = ex.ToString();
            }

            return(result);
        }
        public List <NotificacionModel> GetNotificaciones(int _id1)
        {
            //ids de publicaciones
            var result = new List <NotificacionModel>();

            try
            {
                if (_client.Open())
                {
                    var command = new SqlCommand
                    {
                        Connection  = _client.GetConnection(),
                        CommandText = "getNotificaciones",
                        CommandType = CommandType.StoredProcedure
                    };

                    var par1 = new SqlParameter("@id1", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.Input,
                        Value     = _id1
                    };

                    var par2 = new SqlParameter("@haserror", SqlDbType.Bit)
                    {
                        Direction = ParameterDirection.Output
                    };

                    command.Parameters.Add(par1);
                    command.Parameters.Add(par2);

                    var dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                        var not = new NotificacionModel
                        {
                            id1    = _id1,
                            idPost = Convert.ToInt32(dataReader["idPost"].ToString()),
                            id2    = Convert.ToInt32(dataReader["id2"].ToString()),
                            tipo   = Convert.ToInt32(dataReader["tipo"].ToString()),
                        };

                        result.Add(not);
                    }
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
                //do something
            }
            finally
            {
                _client.Close();
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static NotificacionModel ConvertENToModelUI(NotificacionEN en)
        {
            NotificacionModel not = new NotificacionModel();

            not.Id          = en.Id;
            not.Usuario     = en.Usuario.Email;
            not.Descripcion = en.Descripcion;

            return(not);
        }
        private void updateAppField(NotificacionModel notificacionModel)
        {
            var _repoCliente = new ClienteRepository();
            var cliente      = _repoCliente.FindClient(notificacionModel.Aplicacion);

            if (cliente != null)
            {
                notificacionModel.AplicacionId = cliente.Id;
            }
        }
Ejemplo n.º 6
0
        // GET: Notificacion/Delete/5
        public ActionResult Delete(int id, string usu)
        {
            SessionInitialize();
            NotificacionCAD   notiCAD = new NotificacionCAD(session);
            NotificacionCEN   notiCEN = new NotificacionCEN(notiCAD);
            NotificacionEN    notiEN  = notiCEN.ReadOID(id);
            NotificacionModel noti    = NotificacionAssembler.ConvertENToModelUI(notiEN);

            SessionClose();

            new NotificacionCEN().Destroy(id);

            return(RedirectToRoute(new { controller = "Usuario", action = "Details", id = usu + '/' }));
        }
Ejemplo n.º 7
0
        public bool EnviarNotiificacion(string usuario, string password, string tipo)
        {
            var notificacion = new Notify();
            var model        = new NotificacionModel()
            {
                Usuario  = usuario,
                Password = password,
                Tipo     = tipo,
                Fecha    = DateTime.Now.Date.ToString(),
                Asunto   = "Don Diego de la Vega te ha enviado un mensaje"
            };

            return(notificacion.EnviarMail(model));
        }
        public IHttpActionResult Update([FromBody] NotificacionModel notificacionModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            try
            {
                var updatedNoti = _repoNotificaciones.UpdateNotificacion(notificacionModel);

                DispachNotification(updatedNoti.NotificacionId.Value);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 9
0
        public async Task <List <NotificacionModel> > List(NotificacionModel model, PagerModel pager)
        {
            IQueryable <Notificacion> query = _context.Notificacions;
            DynamicPager pagerLogSync       = new DynamicPager();

            var data = (from a in query
                        select a
                        ).AsQueryable().ToList();

            if (data != null)
            {
                if (pager.Limit == 0)
                {
                    pager.Limit = int.MaxValue;
                }

                var dataPaginated = data.Skip(pager.Offset).Take(pager.Limit).ToList();

                var result = dataPaginated.Select(x => new NotificacionModel
                {
                    NotificacionId = x.NotificacionId,
                    Descripcion    = x.Descripcion
                }).ToList();

                if (string.IsNullOrEmpty(pager.sortDir))
                {
                    pager.sortDir = "ASC";
                }
                if (string.IsNullOrEmpty(pager.sortColumn))
                {
                    pager.sortColumn = "NotificacionId";
                }

                var dataOrdered = pagerLogSync.DynamicSorting(result, pager.sortColumn, pager.sortDir).ToList();
                pager.TotalRows = data.Count();

                return(dataOrdered);
            }

            return(null);
        }
Ejemplo n.º 10
0
 public static Notificacion FillEntitie(NotificacionModel notiModel)
 {
     return(new Notificacion
     {
         NotificacionId = notiModel.NotificacionId.HasValue ? notiModel.NotificacionId.Value : 0,
         AplicacionId = notiModel.AplicacionId,
         Aplicacion = notiModel.Aplicacion,
         Titulo = notiModel.Titulo,
         Link = notiModel.Link,
         IdTipo = notiModel.IdTipo,
         Tipo = notiModel.Tipo,
         IdTipoVigencia = notiModel.IdTipoVigencia,
         TipoVigencia = notiModel.TipoVigencia,
         Nota = notiModel.Nota,
         Vigencia = notiModel.Vigencia,
         Usuarios = notiModel.Usuarios != null?notiModel.Usuarios.ListToString() : null,
                        Activo = notiModel.Activo,
                        FechaCreacion = notiModel.FechaCreacion,
                        Intervalo = notiModel.Intervalo
     });
 }
Ejemplo n.º 11
0
        internal NotificacionModel CreateNotificacion(NotificacionModel notificacionModel)
        {
            notificacionModel.FechaCreacion = DateTime.Now;

            var app = notificacionModel.AplicacionId > 0
                          ? _ctx.Clients.FirstOrDefault(s => s.Id == notificacionModel.AplicacionId)
                          : _ctx.Clients.FirstOrDefault(s => s.Name == notificacionModel.Aplicacion);

            if (app != null)
            {
                notificacionModel.Aplicacion   = app.Name;
                notificacionModel.AplicacionId = app.Id;
            }

            notificacionModel.Tipo         = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TiposNotificaciones)notificacionModel.IdTipo);
            notificacionModel.TipoVigencia = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TipoVigencia)notificacionModel.IdTipo);

            var result = _ctx.Notificacions.Add(Notificacion.FillEntitie(notificacionModel));

            _ctx.SaveChanges();
            saveNotificationLog(result, notificacionModel.Usuarios);
            notificacionModel.NotificacionId = result.NotificacionId;
            return(notificacionModel);
        }
Ejemplo n.º 12
0
        internal NotificacionModel UpdateNotificacion(NotificacionModel notificacionModel)
        {
            var app = notificacionModel.AplicacionId > 0
                        ? _ctx.Clients.FirstOrDefault(s => s.Id == notificacionModel.AplicacionId)
                        : _ctx.Clients.FirstOrDefault(s => s.Name == notificacionModel.Aplicacion);

            if (app != null)
            {
                notificacionModel.Aplicacion   = app.Name;
                notificacionModel.AplicacionId = app.Id;
            }

            notificacionModel.Tipo         = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TiposNotificaciones)notificacionModel.IdTipo);
            notificacionModel.TipoVigencia = KeyValuePar.GetDescriptionFromEnumValue((Enumeraciones.TipoVigencia)notificacionModel.IdTipo);


            var oldNotificacion = _ctx.Notificacions.FirstOrDefault(s => s.NotificacionId == notificacionModel.NotificacionId);
            var result          = Notificacion.UpdateFromModel(oldNotificacion, notificacionModel);

            _ctx.SaveChanges();
            notificacionModel.NotificacionId = result.NotificacionId;
            saveNotificationLog(result, notificacionModel.Usuarios);
            return(notificacionModel);
        }
Ejemplo n.º 13
0
        private void btnCrear_Click(object sender, EventArgs e)
        {
            try
            {
                validaCampos();
                var notiApi      = new NotificacionesApi(txtServer.Text, txtUser.Text, txtPass.Text);
                var objNotiModel = new NotificacionModel
                {
                    Titulo   = txtTitulo.Text,
                    Nota     = txtMsg.Text,
                    Link     = txtLink.Text,
                    Usuarios = new List <string> {
                        txtUsuarios.Text
                    }
                };

                var idNotificacion = notiApi.CrearNotificacion(objNotiModel);
                MessageBox.Show(string.Format("Se creo la notificacion NO. {0} ", idNotificacion));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }
        }