Exemplo n.º 1
0
        public string Put(Notificaciones n)
        {
            try
            {
                DateTime time = n.FechaEnvio;

                string format = "yyyy-MM-dd HH:mm:ss";

                DataTable table = new DataTable();

                string query = @"update Notificaciones set Folio = " + n.Folio + ", IdUsuario = " + n.IdUsuario + ", Usuario = '" + n.Usuario + "', Mensaje = '" + n.Mensaje + "', ModuloOrigen = '" + n.ModuloOrigen + "', FechaEnvio = '" + time.ToLocalTime().ToString(format) + "' where IdNotificacion = " + n.IdNotificacion + ";";

                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["Prolapp"].ConnectionString))
                    using (var cmd = new SqlCommand(query, con))
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }

                return("Se Actualizo Correctamente");
            }
            catch (Exception exe)
            {
                return("Se produjo un error" + exe);
            }
        }
Exemplo n.º 2
0
        public static void Mensaje(int id, string titulo, string asunto) // esto me permite crear la notificaciones
        {
            Notificaciones ntf = new Notificaciones(0, id, titulo, asunto, DateTime.Now);

            ntf.visto = false;
            Guardar(ntf);
        }
Exemplo n.º 3
0
        public async Task <WrapperSimpleTypesDTO> EliminarPlan(Planes planParaEliminar)
        {
            using (SportsGoEntities context = new SportsGoEntities(false))
            {
                PlanesRepository planRepository = new PlanesRepository(context);

                int?codigoTipoPerfilPlan = await planRepository.BuscarCodigoTipoPerfilDeUnPlan(planParaEliminar);

                if (!codigoTipoPerfilPlan.HasValue)
                {
                    throw new InvalidOperationException("El plan no tiene un tipo de perfil especificado!. BUUUUUGGGGGG!.");
                }

                TipoPerfil tipoPerfil            = codigoTipoPerfilPlan.Value.ToEnum <TipoPerfil>();
                int        numeroDePlanesDefault = await planRepository.NumeroPlanesDefault(tipoPerfil);

                if (numeroDePlanesDefault <= 1)
                {
                    bool esPlanDefault = await planRepository.BuscarSiPlanEsDefault(planParaEliminar);

                    if (esPlanDefault)
                    {
                        throw new InvalidOperationException("No puedes quedarte sin planes default para el perfil de " + tipoPerfil.ToString() + "!.");
                    }
                }

                NoticiasRepository noticiasRepo = new NoticiasRepository(context);
                Notificaciones     notificacion = new Notificaciones
                {
                    CodigoPlanNuevo = planParaEliminar.Consecutivo
                };
                noticiasRepo.EliminarNotificacionesDeUnPlan(notificacion);

                PlanesContenidos planContenido = new PlanesContenidos
                {
                    CodigoPlan = planParaEliminar.Consecutivo
                };
                planRepository.EliminarMultiplesPlanesContenidos(planContenido);

                planRepository.EliminarPlan(planParaEliminar);

                ArchivosRepository archivoRepo = new ArchivosRepository(context);
                Archivos           archivo     = new Archivos
                {
                    Consecutivo = planParaEliminar.CodigoArchivo
                };
                archivoRepo.EliminarArchivo(archivo);

                WrapperSimpleTypesDTO wrapperEliminarPlan = new WrapperSimpleTypesDTO();

                wrapperEliminarPlan.NumeroRegistrosAfectados = await context.SaveChangesAsync();

                if (wrapperEliminarPlan.NumeroRegistrosAfectados > 0)
                {
                    wrapperEliminarPlan.Exitoso = true;
                }

                return(wrapperEliminarPlan);
            }
        }
Exemplo n.º 4
0
        private void btnNotificaciones_Click(object sender, EventArgs e)
        {
            btnTemas.BackColor           = Color.FromArgb(41, 66, 91);
            btnNotificaciones.BackColor  = Color.FromArgb(50, 81, 112);
            panelContTemas.Visible       = false;
            contNotificicaciones.Visible = true;

            listNotificaciones.Items.Clear();
            //el siguiente bucle comentado puede ser reutilizado
            //creo un objeto de tipo CNNotificacion(clase que se crea en la capa de negocios)
            Notificaciones objNotificacion = new Notificaciones();
            //Creo un objeto tipo lista, donde almacenaré lo que me retorna el procedimiento
            List <object> verNotificacion = new List <object>();

            //asigno variables al objeto (getters y setters creados en la clase de negocios) esto servirá para saber de quien es la notificacion
            objNotificacion.Fk_emisor1 = MenuVertical.usuarioSesion;
            //mando a llamar el procedimiento y lo almaceno en verNotificacion(el que cree arriba)
            verNotificacion = objNotificacion.verNotificacion();
            try
            {
                verNotificacion.Reverse();                                                                                  //para invertir el orden, ya que las ultimas notificaciones deben mostrarse de primero en la lista
                foreach (object[] datos in verNotificacion)
                {                                                                                                           //lleno la lista
                    listNotificaciones.Items.Add("[" + datos[1].ToString().Replace(" ", "") + "]--" + datos[3].ToString()); //construllo el formato de la notificacion
                }
            }
            catch (Exception) {
            }
        }
Exemplo n.º 5
0
 private void bgwEnvioNotificaciones_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         Notificaciones         DatosAux = this.ObtenerDatosNotificaciones();
         Notificaciones_Negocio NN       = new Notificaciones_Negocio();
         DatosAux.Conexion  = Comun.Conexion;
         DatosAux.IDUsuario = Comun.IDUsuario;
         NN.ObtenerReenvioNotificacion(DatosAux);
         int total = DatosAux.tablaNotificaciones.Rows.Count;
         int cont  = 0;
         foreach (DataRow notificacion in DatosAux.tablaNotificaciones.Rows)
         {
             int IDTipoCelular = 0, Badge = 0;
             IDTipoCelular = Convert.ToInt32(notificacion["id_tipoCelular"].ToString());
             Badge         = Convert.ToInt32(notificacion["Badge"].ToString());
             EnviaNotificaciones.EnviarMensaje(notificacion["tokenCelular"].ToString(), notificacion["nombre"].ToString(), notificacion["descripcion"].ToString(), Badge, IDTipoCelular);
             cont++;
             this.bgwEnvioNotificaciones.ReportProgress((cont * 100) / total);
             if (cont == total)
             {
                 System.Threading.Thread.Sleep(1000);
             }
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmNotificaciones ~ bgwEnvioNotificaciones_DoWork");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void EnviarMailRegistro(string mail, string contraseña)
        {
            try
            {
                Notificaciones.enviarNotificacion((string)Session["nomMov"], mail, "no-reply-" + ((string)Session["nomMov"]).ToLower() + "@indignadoframework.com",
                                                  "Bienvenido", mail, "te damos la bienvenida al movimiento " + (string)Session["nomMov"] + " de Indignado Framework.",
                                                  "Para iniciar sesión debe utilizar su dirección de e-mail y contraseña." + "</br>" +
                                                  "Su contraseña es: \"" + contraseña + "\". No se la digas a nadie.",
                                                  "http://developer.lulu.com/files/API_Key_Icon.png");

                /*
                 * Mensaje mn = new Mensaje();
                 * MailMessage mnsj = new MailMessage();
                 *
                 * mnsj.Subject = "Registro Exitoso";
                 *
                 * mnsj.To.Add(new MailAddress(mail));
                 *
                 * mnsj.From = new MailAddress("*****@*****.**", "Indignado Framework");
                 *
                 * /* Si deseamos Adjuntar algún archivo
                 * //mnsj.Attachments.Add(new Attachment("C:\\archivo.pdf"));
                 *
                 * mnsj.Body = "  Usted se ha registrado con exito a " + this.Site + " \n\n Su mail es: \"" + mail + "\"\n\n y su contraseña es: \"" + contraseña + "\"\n\nGracias por unirte a nuestra comunidad!!";
                 *
                 * mn.MandarCorreo(mnsj);
                 */
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 7
0
        public ActionResult PasswordRecovery(Usuario model)
        {
            if (ModelState.IsValid)
            {
                var username = CustomIdentity.GetIdUsuario(model.login);

                if (username != -1)
                {
                    //recuperamos el usuario
                    var usu = ConsultasBbdd.GetUsuariobyId(username);

                    // enviamos el email con la url magica..
                    var token   = Encodificacion.EncodeMessageWithPassword(usu.login, usu.password);
                    var retorno = Notificaciones.SendPasswordRetrieval(model.login, token);
                    if (!retorno)
                    {
                        ViewBag.error = "ErrorEnviandoNotification";
                        return(View());
                    }

                    return(RedirectToAction("EmailEnviado", "Seguridad"));
                }

                System.Diagnostics.Trace.WriteLine(String.Format("*** WARNING:  A user tried to retrieve their password but the email address used '{0}' does not exist in the database.", model.login));
                ViewBag.error = "error";
                return(View());
            }

            return(View(model));
        }
Exemplo n.º 8
0
 private Notificaciones ObtenerDatosNotificaciones()
 {
     try
     {
         Notificaciones DatosAux = new Notificaciones();
         Int32          RowData  = this.dgvNotificaciones.Rows.GetFirstRow(DataGridViewElementStates.Selected);
         if (RowData > -1)
         {
             DataGridViewRow FilaDatos = this.dgvNotificaciones.Rows[RowData];
             DatosAux.IDNotificaciones = FilaDatos.Cells["IDNotificacion"].Value.ToString();
             int IDTipo = 0;
             int.TryParse(FilaDatos.Cells["IDTipoNotificacion"].Value.ToString(), out IDTipo);
             DatosAux.IDTipoNotificaciones    = IDTipo;
             DatosAux.IDNivelEntrega          = FilaDatos.Cells["IDNivelEntrega"].Value.ToString();
             DatosAux.NombreNotificaciones    = FilaDatos.Cells["NombreNotificacion"].Value.ToString();
             DatosAux.DescripcionNotificacion = FilaDatos.Cells["DecripcionNotificacion"].Value.ToString();
             DatosAux.Descripcion             = FilaDatos.Cells["TipoNotificacion"].Value.ToString();
             DatosAux.IDCliente = FilaDatos.Cells["IDCliente"].Value.ToString();
             bool Enviada = false;
             bool.TryParse(FilaDatos.Cells["EnviarNotificacion"].Value.ToString(), out Enviada);
             DatosAux.EnviarNotificacion = Enviada;
         }
         return(DatosAux);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
        public async Task <NotificacionesDTO> BuscarNotificacion(Notificaciones notificacionParaBuscar)
        {
            IQueryable <Notificaciones> queryNotificaciones = _context.Notificaciones.Where(x => x.Consecutivo == notificacionParaBuscar.Consecutivo).AsQueryable();

            NotificacionesDTO notificacion = await queryNotificaciones
                                             .Select(x => new NotificacionesDTO
            {
                Consecutivo                = x.Consecutivo,
                CodigoPlanNuevo            = x.CodigoPlanNuevo,
                CodigoPersonaDestinoAccion = x.CodigoPersonaDestinoAccion,
                CodigoPersonaOrigenAccion  = x.CodigoPersonaOrigenAccion,
                CodigoTipoNotificacion     = x.CodigoTipoNotificacion,
                Creacion         = x.Creacion,
                TipoNotificacion = new TipoNotificacionDTO
                {
                    Consecutivo = x.TipoNotificacion.Consecutivo,
                    Descripcion = x.TipoNotificacion.Descripcion
                },
                Planes = _context.Planes.Where(y => y.Consecutivo == x.Planes.Consecutivo)
                         .Select(z => new PlanesDTO
                {
                    CodigoArchivo            = z.CodigoArchivo,
                    DescripcionIdiomaBuscado = z.PlanesContenidos.Where(t => t.CodigoIdioma == notificacionParaBuscar.CodigoIdiomaUsuarioBase).Select(h => h.Descripcion).FirstOrDefault()
                }).FirstOrDefault(),
                PersonasOrigenAccion = _context.Personas.Where(y => y.Consecutivo == x.PersonasOrigenAccion.Consecutivo)
                                       .Select(z => new PersonasDTO
                {
                    Consecutivo = z.Consecutivo,
                    CodigoArchivoImagenPerfil = z.CodigoArchivoImagenPerfil,
                    Nombres   = z.Nombres,
                    Apellidos = z.Apellidos
                }).FirstOrDefault(),
                GruposEventos = _context.GruposEventos.Where(y => y.Consecutivo == x.GruposEventos.Consecutivo)
                                .Select(z => new GruposEventosDTO
                {
                    Consecutivo      = z.Consecutivo,
                    CodigoGrupo      = z.CodigoGrupo,
                    Titulo           = z.Titulo,
                    Descripcion      = z.Descripcion,
                    FechaInicio      = z.FechaInicio,
                    FechaTerminacion = z.FechaTerminacion,
                    Grupos           = new GruposDTO
                    {
                        Consecutivo   = z.Grupos.Consecutivo,
                        CodigoPersona = z.Grupos.CodigoPersona,
                        Personas      = new PersonasDTO
                        {
                            Consecutivo = z.Grupos.Personas.Consecutivo,
                            CodigoArchivoImagenPerfil = z.Grupos.Personas.CodigoArchivoImagenPerfil,
                            Nombres   = z.Grupos.Personas.Nombres,
                            Apellidos = z.Grupos.Personas.Apellidos
                        }
                    }
                }).FirstOrDefault()
            })
                                             .AsNoTracking()
                                             .FirstOrDefaultAsync();

            return(notificacion);
        }
        private void setNotificaciones()
        {
            int x = 51, t = 26;

            if (SelectedItem != null)
            {
                notificaciones.Clear();
                switch (SelectedItem.Tag.ToString())
                {
                case "1":
                    x = 25;
                    break;

                case "2":
                    t = 1;
                    x = 25;
                    break;
                }
            }
            var hoy  = Fechas.GetFechaDateServer;
            int tipo = 1;

            for (int i = 1; i < x; i++)
            {
                if (i == t)
                {
                    tipo = 2;
                }
                Notificaciones.Add(new cNotificacion {
                    Id = i, Notificacion = string.Format("Notificacion de Prueba {0}", i), Fecha = hoy, Tipo = tipo
                });
            }

            NoNotificaciones = string.Format("{0} Notificaciones", Notificaciones.Count);
        }
Exemplo n.º 11
0
        public async Task <TimeLineNotificaciones> VerificarSiPagoEstaAprobadoYTraerNotificacion(HistorialPagosPersonas pagoParaVerificar)
        {
            using (SportsGoEntities context = new SportsGoEntities(false))
            {
                PagosRepository pagosRepo = new PagosRepository(context);

                int?codigoEstado = await pagosRepo.BuscarEstadoDeUnPago(pagoParaVerificar);

                if (!codigoEstado.HasValue)
                {
                    throw new InvalidOperationException("No se pudo encontrar el estado del pago");
                }

                TimeLineNotificaciones timeLineNotificacion = null;
                if (codigoEstado.Value == (int)EstadoDeLosPagos.Aprobado)
                {
                    Notificaciones notificacionDelPago = await pagosRepo.BuscarNotificacionDeUnPago(pagoParaVerificar);

                    PersonasRepository personaRepo = new PersonasRepository(context);
                    int codigoIdioma = await personaRepo.BuscarCodigoIdiomaDeLaPersona(notificacionDelPago.CodigoPersonaDestinoAccion.Value);

                    notificacionDelPago.CodigoIdiomaUsuarioBase = codigoIdioma;

                    NoticiasRepository noticiasRepo = new NoticiasRepository(context);
                    timeLineNotificacion = new TimeLineNotificaciones(await noticiasRepo.BuscarNotificacion(notificacionDelPago));

                    DateTimeHelperNoPortable helper = new DateTimeHelperNoPortable();
                    timeLineNotificacion.CreacionNotificacion = helper.ConvertDateTimeFromAnotherTimeZone(pagoParaVerificar.ZonaHorariaGMTBase, helper.DifferenceBetweenGMTAndLocalTimeZone, timeLineNotificacion.CreacionNotificacion);
                }

                return(timeLineNotificacion);
            }
        }
Exemplo n.º 12
0
        public ActionResult DeleteItem(int idTurno)
        {
            var turno = DbContext.Turno.Find(idTurno);

            //nos cargamos las citas que tenia ese turno
            var listacitas = DbContext.Cita.Where(o => o.idTurno == idTurno).ToList();

            foreach (var cita in listacitas)
            {
                if (Notificaciones.ModificarCitasMedicos(cita))
                {
                    DbContext.Cita.Remove(cita);
                }
                else
                {
                    //algo deberiamos hacer si falla..pero si no podemos enviar un email...chungo..
                    return(Json("ok", JsonRequestBehavior.AllowGet));
                }
            }
            DbContext.Turno.Remove(turno);

            DbContext.SaveChanges();

            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
        public ActionResult EditItem(int idTurno, string dia, string paralelas, string porhora, string strinicio, string strfin)
        {
            var turno = DbContext.Turno.Find(idTurno);

            turno.dia       = Convert.ToInt32(dia);
            turno.inicio    = DiasHoras.TimeToDecimal(strinicio);
            turno.fin       = DiasHoras.TimeToDecimal(strfin);
            turno.paralelas = Convert.ToInt32(paralelas);
            turno.porhora   = Convert.ToInt32(porhora);

            //si dejamos alguna cita fuera...debemos avisar
            var listacitas = DbContext.Cita.Where(o => o.idTurno == idTurno).ToList();

            listacitas = listacitas.Where(o => o.hora > turno.fin || o.hora < turno.inicio).ToList();

            foreach (var cita in listacitas)
            {
                if (Notificaciones.ModificarCitasMedicos(cita))
                {
                    DbContext.Cita.Remove(cita);
                }
                else
                {
                    //algo deberiamos hacer si falla..pero si no podemos enviar un email...chungo..
                    return(Json("ok", JsonRequestBehavior.AllowGet));
                }
            }

            DbContext.SaveChanges();

            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
        public ResponseViewModel CreateNotificacion(NotificacionesViewModel model)
        {
            ResponseViewModel reponse = new ResponseViewModel();

            try
            {
                Notificaciones noti = new Notificaciones
                {
                    Entregado     = "0",
                    Mensaje       = model.Mensaje,
                    Titulo        = model.Titulo,
                    IdLogin       = model.IdLogin,
                    Activo        = "1",
                    FechaRegistro = DateTime.Now
                };
                _eventPlusContext.Notificaciones.Add(noti);
                _eventPlusContext.SaveChanges();

                reponse.Type     = "success";
                reponse.Response = "El regitsro se creó exitosamente.";

                return(reponse);
            }
            catch (Exception ex)
            {
                reponse.Type     = "error";
                reponse.Response = "Error en el procedimiento. ---> " + ex.Message;
                return(reponse);
            }
        }
Exemplo n.º 15
0
        public async Task <Notificaciones> BuscarNotificacionDeUnPago(HistorialPagosPersonas pagoParaVerificar)
        {
            int            codigoNotificacionAprobada = (int)TipoNotificacionEnum.PlanAprobado;
            Notificaciones notificacionDelPago        = await _context.Notificaciones.Where(x => x.CodigoPlanNuevo == _context.HistorialPagosPersonas.Where(z => z.Consecutivo == pagoParaVerificar.Consecutivo).Select(z => z.CodigoPlan).FirstOrDefault() && x.CodigoPersonaDestinoAccion == _context.HistorialPagosPersonas.Where(z => z.Consecutivo == pagoParaVerificar.Consecutivo).Select(z => z.CodigoPersona).FirstOrDefault() && x.CodigoTipoNotificacion == codigoNotificacionAprobada).OrderByDescending(x => x.Creacion).FirstOrDefaultAsync();

            return(notificacionDelPago);
        }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (Entities c = new Entities())
                {
                    try {
                        if (Request["id"] == null)
                        {
                            Response.Redirect("VerDepartamentos.aspx", false);
                        }
                        else
                        {
                            DEPARTAMENTO d = c.DEPARTAMENTO.Find(Convert.ToInt32(Request["id"]));
                            this.lblDepartamento.Text = d.DESCRIPCION;
                            this.lblDpto.Text         = d.DESCRIPCION;

                            Page.Title           = "Plan de Gobierno del Departamento de " + d.DESCRIPCION + " | Transparencia Arag&oacute;n";
                            Page.MetaKeywords    = d.DESCRIPCION + ",plan de gobierno,transparencia, aragon, gobierno abierto";
                            Page.MetaDescription = "Plan de Gobierno del Departamento de " + d.DESCRIPCION + " del Gobierno de Aragón";
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Error en DetalleDepartamento.aspx. Error: " + ex.Message + " " + ex.InnerException);
                        Notificaciones.NotifySystemOps(ex);
                    }
                }
            }
        }
Exemplo n.º 17
0
 public Notificaciones Update(Notificaciones item)
 {
     try
     {
         _sisGmaEntities.Entry(item).State = EntityState.Modified;
         _sisGmaEntities.SaveChanges();
         return(item);
     }
     catch (EntryPointNotFoundException ep)
     {
         IsValid      = false;
         ErrorMessage = ep.GetBaseException().Message;
         return(null);
     }
     catch (Exception e)
     {
         IsValid      = false;
         ErrorMessage = e.GetBaseException().Message;
         return(null);
     }
     finally
     {
         _sisGmaEntities.Dispose();
     }
 }
Exemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        checaSesiones();
        lblFechaActual.Text = fechas.obtieneFechaLocal().ToString("yyyy-MM-d");
        lblFecha.Text       = fechas.obtieneFechaLocal().ToLongDateString();
        lblUsuarioLog.Text  = "Bienvenido: " + nombre;
        lblCaja.Text        = caja;
        Notificaciones noti = new Notificaciones();

        noti.Fecha   = Convert.ToDateTime(lblFechaActual.Text);
        noti.Estatus = "P";
        noti.obtieneNotificacionesPendientes();
        object[] pendientes = noti.Retorno;
        if (Convert.ToBoolean(pendientes[0]))
        {
            lblNotifi.Text = Convert.ToString(pendientes[1]);
        }
        else
        {
            lblNotifi.Text = "0";
        }
        if (!IsPostBack)
        {
            lblVersionSis.Text = ConfigurationManager.AppSettings["version"].ToString();
        }
    }
        public Notificaciones ConsultarNotificacionesLeidas(Notificaciones notificacion)
        {
            try
            {
                var conn = conexion.Builder;
                con = new MySqlConnection(conn.ToString());

                MySqlCommand cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM bd_applikt.detalle_notificacion_leida where cve_notificacion = @cve_notificacion";
                cmd.Parameters.AddWithValue("@cve_notificacion", notificacion.cve_notificacion);
                con.Open();
                MySqlDataReader reader = cmd.ExecuteReader();
                var             lstnotificacioneseliminadas = new List <int>();
                if (reader.Read())
                {
                    notificacion.estatus = "Leida";
                }
                else
                {
                    notificacion.estatus = "No Leida";
                }
                return(notificacion);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 20
0
 public Notificaciones Insert(Notificaciones item)
 {
     try
     {
         _sisGmaEntities.Notificaciones.Add(item);
         _sisGmaEntities.SaveChanges();
         return(item);
     }
     catch (EntryPointNotFoundException ep)
     {
         IsValid      = false;
         ErrorMessage = ep.GetBaseException().Message;
         return(null);
     }
     catch (Exception e)
     {
         IsValid      = false;
         ErrorMessage = e.GetBaseException().Message;
         return(null);
     }
     finally
     {
         _sisGmaEntities.Dispose();
     }
 }
Exemplo n.º 21
0
        public IHttpActionResult PostNotificaciones(Notificaciones notificaciones)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Notificaciones.Add(notificaciones);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (NotificacionesExists(notificaciones.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = notificaciones.Id }, notificaciones));
        }
        public IActionResult VerNotificacion(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }

            var notificacion = _db.Notificaciones.Where(n => n.ID_Notificacion == id).FirstOrDefault();

            if (notificacion != null)
            {
                var detalles = new Notificaciones {
                    Fecha       = notificacion.Fecha,
                    Titulo      = notificacion.Titulo,
                    Descripcion = notificacion.Descripcion
                };

                return(View(detalles));
            }

            else
            {
                return(View("Error"));
            }
        }
 public int EnviarNotificacionIndividuales(Notificaciones datos)
 {
     try
     {
         int     Resultado = 0;
         DataSet Ds        = SqlHelper.ExecuteDataset(datos.Conexion, CommandType.StoredProcedure, "spCSLDB_abc_NotificacionesIndividualesGrupales",
                                                      //new SqlParameter("@Opcion", datos.Opcion),
                                                      new SqlParameter("@IDNotificacion", datos.IDNotificaciones),
                                                      new SqlParameter("@IDTipoNotificacion", datos.IDTipoNotificaciones),
                                                      new SqlParameter("@IdNivelEntrega", datos.IDNivelEntrega),
                                                      new SqlParameter("@NombreNotificacion", datos.NombreNotificaciones),
                                                      new SqlParameter("@TextoNotificacion", datos.DescripcionNotificacion),
                                                      new SqlParameter("@Descripcion", datos.Descripcion),
                                                      new SqlParameter("@IndividualGrupo", datos.IndividualGrupo),
                                                      new SqlParameter("@IDCliente", datos.IDCliente),
                                                      new SqlParameter("@EnviarNotificacion", datos.EnviarNotificacion),
                                                      new SqlParameter("@Usuario", datos.IDUsuario));
         if (Ds != null)
         {
             if (Ds.Tables.Count > 0)
             {
                 int.TryParse(Ds.Tables[0].Rows[0][0].ToString(), out Resultado);
                 if (Resultado == 1)
                 {
                     if (Ds.Tables.Count == 2)
                     {
                         datos.Completado          = true;
                         datos.tablaNotificaciones = Ds.Tables[1];
                     }
                 }
                 else if (Resultado == -1)
                 {
                     if (Ds.Tables.Count == 2)
                     {
                         datos.Completado          = false;
                         datos.tablaNotificaciones = Ds.Tables[1];
                     }
                     datos.Resultado = Resultado;
                 }
                 else if (Resultado == 0)
                 {
                     if (Ds.Tables.Count == 2)
                     {
                         datos.Completado          = false;
                         datos.tablaNotificaciones = Ds.Tables[1];
                     }
                     datos.Resultado = Resultado;
                 }
             }
         }
         return(datos.Resultado = Resultado);
         //datos.tablaNotificaciones = dt.Tables[1];
         //datos.Completado = true;
         //return Convert.ToInt32(dt.Tables[0].Rows[0][0].ToString());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 24
0
        public IHttpActionResult PutNotificaciones(int id, Notificaciones notificaciones)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != notificaciones.Id)
            {
                return(BadRequest());
            }

            db.Entry(notificaciones).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NotificacionesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private Notificaciones ObtenerDatos()
 {
     try
     {
         Notificaciones DatosAux = new Notificaciones();
         DatosAux.IDNotificaciones        = TipoForm == 2 ? this._DatosNotificaciones.IDNotificaciones : string.Empty;
         DatosAux.NombreNotificaciones    = this.txtNombreNotificacion.Text.Trim();
         DatosAux.DescripcionNotificacion = this.txtDescripcionNotificaciones.Text.Trim();
         DatosAux.IDTipoNotificaciones    = 5;
         DatosAux.IndividualGrupo         = this.checkIndividual.Checked;
         if (DatosAux.IndividualGrupo == true)
         {
             DatosAux.IDCliente = this.CatalogoActual.IDCliente.ToString();
         }
         else
         {
             DatosAux.IDCliente = string.Empty;
         }
         DatosAux.EnviarNotificacion = true;
         DatosAux.Descripcion        = this.txtComentarios.GetHTML(true, true);
         DatosAux.IDNivelEntrega     = Convert.ToString(1);
         DatosAux.Opcion             = this.TipoForm;
         DatosAux.Conexion           = Comun.Conexion;
         DatosAux.IDUsuario          = Comun.IDUsuario;
         return(DatosAux);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 26
0
    protected void btnAccDeshacerCambio_Click(object sender, EventArgs e)
    {
        int iObjetivoId = Convert.ToInt32(this.hdObjetivoId.Value);

        using (Entities c = new Entities())
        {
            try
            {
                ACCION obj = c.CONTENIDO.OfType <ACCION>().Where(o => o.CONTENIDO_ID == iObjetivoId).FirstOrDefault();

                if (obj.TIPO_CAMBIO_CONTENIDO_ID != TIPO_CAMBIO_CONTENIDO.SIN_CAMBIOS)
                {
                    obj.DeshacerCambio(c);
                    SuccessMessage         = "Los cambios pendientes del Objetivo se han cancelado.";
                    successMessage.Visible = true;
                }
                else
                {
                    ErrorMessage         = "No hay ningún cambio que deshacer.";
                    errorMessage.Visible = true;
                }
            }
            catch (Exception ex)
            {
                logger.Fatal("Error al deshacer cambios en Objetivo. Error: " + ex.Message + " " + ex.InnerException);
                Notificaciones.NotifySystemOps(ex);
                ErrorMessage         = "Error al deshacer los cambios del Objetivo.";
                errorMessage.Visible = true;
            }
        }
    }
Exemplo n.º 27
0
        private SignInStatus verificaLdap(string login, string password, string dominio)
        {
            SignInStatus ret = SignInStatus.Failure;

            if ((dominio.ToLower() == "educa.aragon.es") || (dominio.ToLower() == "salud.aragon.es") || (dominio.ToLower() == "aragon.es"))
            {
                LdapConnection ldapConnection = new LdapConnection(new LdapDirectoryIdentifier(WebConfigurationManager.AppSettings["ServidorLDAP"],
                                                                                               Convert.ToInt32(WebConfigurationManager.AppSettings["PuertoLDAP"])));
                try
                {
                    ldapConnection.AuthType = AuthType.Basic;
                    ldapConnection.Bind(new NetworkCredential("uid=" + login + ",ou=people,o=" + dominio + ",o=isp", password));



                    ret = SignInStatus.Success;
                }
                catch (Exception ex)
                {
                    if ((!ex.Message.Contains("La credencial proporcionada no es válida")) && !(ex.Message.Contains("The supplied credential is invalid")))
                    {
                        logger.Fatal("VerificaLdap. Error: " + ex.Message + " " + ex.InnerException);
                        Notificaciones.NotifySystemOps(ex);
                    }
                    return(SignInStatus.Failure);
                }

                return(ret);
            }
            else
            {
                logger.Info("VerificaLdap. Dominio no válido: " + dominio);
                return(SignInStatus.Failure);
            }
        }
Exemplo n.º 28
0
        public async Task <Tuple <WrapperSimpleTypesDTO, TimeLineNotificaciones> > EliminarContacto(Contactos contactoParaEliminar)
        {
            using (SportsGoEntities context = new SportsGoEntities(false))
            {
                ChatsRepository chatsRepo = new ChatsRepository(context);

                Contactos contactoFiltro = new Contactos
                {
                    Consecutivo = contactoParaEliminar.Consecutivo
                };

                chatsRepo.EliminarContacto(contactoFiltro);

                Tuple <Contactos, int?> tupleBusqueda = await chatsRepo.BuscarConsecutivoContactoContrario(contactoParaEliminar);

                Contactos contactoOwner = tupleBusqueda.Item1;
                int?      consecutivoContrarioBuscado = tupleBusqueda.Item2;

                if (!consecutivoContrarioBuscado.HasValue)
                {
                    throw new InvalidOperationException("No existe el contacto contrario de esta persona!.");
                }

                Contactos contactoParaBorrar = new Contactos
                {
                    Consecutivo = consecutivoContrarioBuscado.Value
                };

                chatsRepo.EliminarContacto(contactoParaBorrar);

                NoticiasRepository noticiasRepo = new NoticiasRepository(context);
                Notificaciones     notificacion = new Notificaciones
                {
                    CodigoTipoNotificacion     = (int)TipoNotificacionEnum.PersonaEliminada,
                    CodigoPersonaOrigenAccion  = contactoOwner.CodigoPersonaOwner,
                    CodigoPersonaDestinoAccion = contactoOwner.CodigoPersonaContacto,
                    Creacion = DateTime.Now
                };

                noticiasRepo.CrearNotificacion(notificacion);

                WrapperSimpleTypesDTO  wrapperEliminarContacto = new WrapperSimpleTypesDTO();
                TimeLineNotificaciones timeLineNotificacion    = null;

                wrapperEliminarContacto.NumeroRegistrosAfectados = await context.SaveChangesAsync();

                if (wrapperEliminarContacto.NumeroRegistrosAfectados > 0)
                {
                    wrapperEliminarContacto.Exitoso = true;

                    if (notificacion.Consecutivo > 0)
                    {
                        timeLineNotificacion = new TimeLineNotificaciones(await noticiasRepo.BuscarNotificacion(notificacion));
                    }
                }

                return(Tuple.Create(wrapperEliminarContacto, timeLineNotificacion));
            }
        }
Exemplo n.º 29
0
        public void ModificarTest()
        {
            Notificaciones notificaciones = new Notificaciones(1, 1, "Info", "Test Run", DateTime.Now);
            bool           paso           = false;

            paso = NotificacionBLL.Modificar(notificaciones);
            Assert.AreEqual(paso, true);
        }
Exemplo n.º 30
0
        public void GuardarTest()
        {
            Notificaciones notificaciones = new Notificaciones(0, 1, "Info", "Test", DateTime.Now);
            bool           paso           = false;

            paso = NotificacionBLL.Guardar(notificaciones);
            Assert.AreEqual(paso, true);
        }