コード例 #1
0
        /// <summary>
        /// Inserta una nueva notificacion en la tabla
        /// </summary>
        /// <param name="notif"></param>
        public void InsertNotification(NotificacionModel notif)
        {
            using (var entity = new Nosc.DAL.NoscDBEntities())
            {
                var res = (from o in entity.Notificacions
                           where o.IdNotificacion == notif.IdNotificacion
                           select o).FirstOrDefault();

                //insertar elemento ya que no existe
                if (res == null)
                {
                    entity.Notificacions.AddObject(new Notificacion()
                    {
                        Titulo=notif.Titulo,
                        Mensaje=notif.Mensaje,
                        Parametro=notif.Parametro,
                        IdApp=notif.App.IdApp,
                        IdUsuario=notif.Usuario.IdUsuario,
                        FechaCreacion=notif.FechaCreacion,
                        FechaNotificacion=notif.FechaNotificacion
                    });
                }

                entity.SaveChanges();

            }
        }
コード例 #2
0
        /// <summary>
        /// Inserta el registro generando un nuevo unid
        /// </summary>
        /// <param name="notif"></param>
        /// <param name="GenerateId"></param>
        public void InsertNotification(NotificacionModel notif, bool GenerateId)
        {
            if (GenerateId)
            {
                notif.IdNotificacion = (new UNID()).getNewUNID();
            }

            this.InsertNotification(notif);
        }
コード例 #3
0
        /// <summary>
        /// Inserta una nueva notificacion en la tabla
        /// </summary>
        /// <param name="notif"></param>
        public long InsertNotification(NotificacionModel notif)
        {
            long idNotificacion = 0;
            using (var entity = new NoscDBEntities())
            {
                var res = (from o in entity.Notificacions
                           where o.IdNotificacion == notif.IdNotificacion
                           select o).FirstOrDefault();

                //insertar elemento ya que no existe
                if (res == null)
                {
                    idNotificacion = new UNID().getNewUNID();
                    try
                    {
                        entity.Notificacions.AddObject(new Notificacion()
                        {
                            IdNotificacion = idNotificacion,
                            Titulo = notif.Titulo,
                            Mensaje = notif.Mensaje,
                            Parametro = notif.Parametro,
                            IdApp = notif.IdApp,
                            IdUsuario = notif.IdUsuario,
                            FechaCreacion = new UNID().getNewUNID(),
                            FechaNotificacion = notif.FechaNotificacion,
                            IsCerrado = notif.IsCerrado,
                            CanCerrar = notif.CanCerrar,
                            IsModified = false,
                            LastModifiedDate = new UNID().getNewUNID(),
                            Recurrencia = 30,
                            FechaUltimaMuestra = new UNID().getNewUNID(),
                            IsNotificacionActiva = true,
                            IsDescartarOnClick = false
                        });

                        entity.SaveChanges();
                        UpdateSync("Notificacion", entity);
                    }
                    catch (Exception)
                    {

                        return 0;
                    }

                }

            }
            return idNotificacion;
        }
コード例 #4
0
        public long GetFUMRecurrencia(NotificacionModel nof)
        {
            long result = 0;
            long fechaUM = nof.FechaUltimaMuestra;
            if (fechaUM !=0)
            {
                string convertStrig = null;
                string YYYY = null;
                string MM = null;
                string dd = null;
                string HH = null;
                string mm = null;
                string ss = null;
                string fff = null;
                string convertDateTime = null;
                //yyyy:MM:dd:HH:mm:ss:fff
                convertStrig = fechaUM.ToString();

                YYYY = convertStrig.Substring(0, 4);//YYYY
                MM = convertStrig.Substring(4, 2);//MM
                dd = convertStrig.Substring(6, 2);//dd
                HH = convertStrig.Substring(8, 2);//HH
                mm = convertStrig.Substring(10, 2);//mm
                ss = convertStrig.Substring(12, 2);//ss
                fff = convertStrig.Substring(14, 3);//fff

                convertDateTime = YYYY + "-" + MM + "-" + dd + " " + HH + ":" + mm + ":" + ss + "." + fff;

                DateTime convertTime = Convert.ToDateTime(convertDateTime);

                convertTime = convertTime.AddMinutes(nof.Recurrencia);

                result = long.Parse(String.Format("{0:yyyy:MM:dd:HH:mm:ss:fff}", convertTime).Replace(":", ""));
            }
            return result;
        }
コード例 #5
0
 public void IDesactiveNotification(NotificacionModel notification)
 {
     if (notification !=null)
     {
         if (notification.Recurrencia==0  )
         {
             notification.IsDescartarOnClick = true;
             notification.IsNotificacionActiva = false;
             this.NotificationRepository.UpdateNotification(notification);
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Actualiza la fecha Fecha Ultima Muestra en la tabla NOTIFICACION_ACTIVA
        /// </summary>
        /// <param name="notif"></param>
        public void UpdateNotificationRecurrencia(NotificacionModel notif)
        {
            using (var entity = new Nosc.DAL.NoscDBEntities())
            {
                if (notif != null)
                {
                    Notificacion result = null;
                    try
                    {
                        result = (from o in entity.Notificacions
                                    where
                                        o.IdNotificacion == notif.IdNotificacion
                                        &&
                                        o.Recurrencia > 0
                                    select o).FirstOrDefault();
                    }
                    catch (Exception)
                    {

                    }

                    //actualiza
                    if (result != null)
                    {
                        result.FechaUltimaMuestra = notif.FechaUltimaMuestra;
                    }
                    entity.SaveChanges();

                }

            }
        }
コード例 #7
0
        /// <summary>
        /// Actualiza un registro
        /// </summary>
        /// <param name="notif"></param>
        public void UpdateNotification(NotificacionModel notif)
        {
            using (var entity = new Nosc.DAL.NoscDBEntities())
            {
                var res = (from o in entity.Notificacions
                           where o.IdNotificacion == notif.IdNotificacion
                           select o).FirstOrDefault();

                //actualiza el elemento ya que no existe
                if (res != null)
                {
                    res.Titulo = notif.Titulo;
                    res.Mensaje = notif.Mensaje;
                    res.Parametro = notif.Parametro;
                    res.IdApp = notif.App.IdApp;
                    res.IdUsuario = notif.Usuario.IdUsuario;
                    res.FechaCreacion = notif.FechaCreacion;
                    res.FechaNotificacion = notif.FechaNotificacion;
                    res.IsDescartarOnClick = notif.IsDescartarOnClick;
                    res.IsNotificacionActiva = notif.IsNotificacionActiva;
                }

                entity.SaveChanges();
            }
        }
コード例 #8
0
        /// <summary>
        /// Desactiva Notificaciones (IsNotificacionActiva)
        /// </summary>
        /// <param name="notif"></param>
        public string UpdateNotification(NotificacionModel notif)
        {
            string response =null;
            using (var entity = new NoscDBEntities())
            {
                try
                {
                    var res = (from o in entity.Notificacions
                               where o.IdNotificacion == notif.IdNotificacion
                               select o).FirstOrDefault();

                    //actualiza el elemento dependiendo el parametro
                    if (res != null)
                    {
                        res.IsNotificacionActiva = notif.IsNotificacionActiva;
                        res.LastModifiedDate = new UNID().getNewUNID();

                        entity.SaveChanges();
                        response = "Exito";
                        UpdateSync("Notificacion", entity);
                    }

                }
                catch (Exception ex)
                {

                    return ex.Message;
                }
            }

            return response;
        }