Ejemplo n.º 1
0
        /// <summary>
        /// Traduce los argumentos seleccionados del GroupBox filtro a un diccionario
        /// </summary>
        /// <returns>Arguementos para filtrar los Elementos a mostrar</returns>
        private Dictionary <Type, Object> ArgumentosSelccionados()
        {
            Dictionary <Type, object> argumentos = new Dictionary <Type, object>();
            string nombre = "";

            if (this.checkBox_Nombre.Checked)
            {
                nombre = this.textBox_Nombre.Text;
            }
            argumentos.Add(nombre.GetType(), nombre);
            if (this.checkBox_Tipo.Checked)
            {
                IFuente fuenteTipo;
                if (this.radioButton_RSS.Checked)
                {
                    fuenteTipo = new FuenteRSS();
                }
                else
                {
                    fuenteTipo = new FuenteTextoFijo();
                }
                argumentos.Add(typeof(IFuente), fuenteTipo);
            }
            if (this.checkBox_RangoFechas.Checked)
            {
                RangoFecha pRangoFecha = new RangoFecha()
                {
                    FechaInicio = this.dateTimePicker_FechaDesde.Value,
                    FechaFin    = this.dateTimePicker_FechaHasta.Value
                };
                argumentos.Add(pRangoFecha.GetType(), pRangoFecha);
            }
            return(argumentos);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Evento que surge cuando el Proceso en segundo plano empieza trabajar para guardar el RSS y devolverlo
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void backgroundWorker_FuenteRSSSeleccion_DoWork(object sender, DoWorkEventArgs e)
        {
            FuenteRSS pFuente = (FuenteRSS)e.Argument;

            ControladorFuente.Agregar(pFuente);
            e.Result = pFuente;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Carga todos los datos de la fuente seleccionada en sus correspondientes componentes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSeleccionarFuente_Click(object sender, EventArgs e)
 {
     if (dataGridViewFuentes.CurrentRow.Index != -1)
     {
         if (comboBoxTipoFuente.Text == "RSS")
         {
             FuenteRSS mFuente = new FuenteRSS {
                 Id = Convert.ToInt32(dataGridViewFuentes["Id", dataGridViewFuentes.CurrentRow.Index].Value)
             };
             mFuente = cFachada.GetFuenteRSS(mFuente);
             textBoxTituloFuente.Text = mFuente.Titulo;
             textBoxValorFuente.Text  = mFuente.Valor;
             textBoxId.Text           = mFuente.Id.ToString();
         }
         else
         {
             FuenteTextoFijo mFuente = new FuenteTextoFijo {
                 Id = Convert.ToInt32(dataGridViewFuentes["Id", dataGridViewFuentes.CurrentRow.Index].Value)
             };
             mFuente = cFachada.GetFuenteTXT(mFuente);
             textBoxTituloFuente.Text = mFuente.Titulo;
             textBoxValorFuente.Text  = mFuente.Valor;
             textBoxId.Text           = mFuente.Id.ToString();
         }
     }
 }
Ejemplo n.º 4
0
        public void Banner1Insercion()
        {
            Persistencia.FachadaPersistencia fachada = new Persistencia.FachadaPersistencia();
            FuenteRSS       pFuenteRSS = this.CrearFuenteRSS(3, "Predeterminado");
            Banner          pBanner;
            FuenteTextoFijo pTextoFijo;

            for (int i = 1; i < 61; i++)
            {
                pBanner = new Banner()
                {
                    Codigo = i,
                    Nombre = "Banner N° " + i.ToString()
                };
                if (i < 31)
                {
                    pBanner.Fuente        = pFuenteRSS;
                    pBanner.Fuente_Codigo = pFuenteRSS.Codigo;
                }
                else
                {
                    pTextoFijo            = this.CrearFuenteTextoFijo(i, "Texto Fijo N° " + (i - 30).ToString());
                    pBanner.Fuente        = pTextoFijo;
                    pBanner.Fuente_Codigo = pTextoFijo.Codigo;
                }
                List <RangoFecha> listaRangosFecha = new List <RangoFecha>(); listaRangosFecha.Add(this.CrearRangoFecha(1, DateTime.Today.AddDays(10), pBanner));
                pBanner.RangosFecha = listaRangosFecha;
                fachada.CrearBanner(pBanner);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Crea una fuente de RSS
        /// </summary>
        /// <param name="pCodigo">Código de la fuente de RSS</param>
        /// <param name="pValor">Valor de la fuente de RSS</param>
        /// <returns>Tipo de dato fuente de RSS que representa el creado</returns>
        private FuenteRSS CrearFuenteRSS(int pCodigo, string pValor)
        {
            FuenteRSS pFuenteRSS = new FuenteRSS()
            {
                Codigo      = pCodigo,
                Descripcion = "Inserción " + pCodigo.ToString(),
                URL         = "URL N° " + pCodigo.ToString(),
                Valor       = pValor
            };

            return(pFuenteRSS);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Evento que surge cuando se hace clic en el botón Modificar
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void button_Modificar_Click(object sender, EventArgs e)
        {
            FuenteRSS pFuente = this.FuenteSeleccionada();

            this.textBox_URL.Text         = pFuente.URL;
            this.textBox_Descripcion.Text = pFuente.Descripcion;
            this.iValorRSS = pFuente.Valor;
            this.VisualizarEdicionRSS(true);
            this.HabilitarBotones(false);
            this.button_AceptarModificar.Visible = true;
            this.button_AceptarModificar.Enabled = true;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Actualiza el valor de la fuente RSS a partir de la URL
 /// </summary>
 /// <param name="pFuenteRSS"></param>
 public void UpdateValueRSS(FuenteRSS pFuenteRSS)
 {
     if (Utilidades.InternetDisponible())
     {
         pFuenteRSS.Valor = Utilidades.GetStringFromXMLRSSUrl(pFuenteRSS.URL);
     }
     else
     {
         throw new Exception("No pudo descargarse el feed RSS por falta de conectividad.");
     }
     cRepositoryBaseRSS.Update(pFuenteRSS);
     cRepositoryBaseRSS.SaveChanges();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Evento que surge al hacer clic en el Aceptar luego del modificar
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void button_AceptarModificar_Click(object sender, EventArgs e)
        {
            FuenteRSS pFuente = this.FuenteSeleccionada();

            pFuente.URL         = this.textBox_URL.Text;
            pFuente.Descripcion = this.textBox_Descripcion.Text;
            pFuente.Valor       = this.iValorRSS;
            this.VisualizarEdicionRSS(true);
            if (!this.iListaFuenteRSSAgregar.Contains(pFuente))
            {
                this.iListaFuenteRSSActualizar.Add(pFuente);
            }
            this.HabilitarBotones(true);
            this.ActualizarDGV();
            this.VisualizarEdicionRSS(false);
            this.ActivarAceptar();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Evento que surge cuando se hace clic en el botón Agregar
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void button_AceptarAgregar_Click(object sender, EventArgs e)
        {
            FuenteRSS nuevaFuente = new FuenteRSS()
            {
                Codigo      = 0,
                Valor       = this.iValorRSS,
                Descripcion = this.textBox_Descripcion.Text,
                URL         = this.textBox_URL.Text
            };

            this.iListaFuenteRSSAgregar.Add(nuevaFuente);
            this.iListaFuenteRSS.Add(nuevaFuente);
            this.HabilitarBotones(true);
            this.ActualizarDGV();
            this.VisualizarEdicionRSS(false);
            this.ActivarAceptar();
        }
Ejemplo n.º 10
0
        private void btn_modificar_Click(object sender, EventArgs e)
        {
            //Obtiene la fuente a modificar a partir del ID de la grilla
            FuenteRSS fuente = iFachadaFuente.ObtenerFuenteRSS(Convert.ToInt32(DGV_Fuentes.CurrentRow.Cells[0].Value));

            // Abre el formulario de alta de fuente tomando los datos de la fuente a modificar
            AgregarFuenteRSS fuenteRSSInterfaz = new AgregarFuenteRSS(fuente);

            fuenteRSSInterfaz.ShowDialog();

            DGV_Fuentes.Refresh();

            btn_eliminar.Enabled  = false;
            btn_modificar.Enabled = false;

            this.Close();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Evento que surge cuando el Proceso en segundo plano comienza a obtener el valor de la fuente de RSS
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void backgroundWorker_ValorRSS_DoWork(object sender, DoWorkEventArgs e)
        {
            FuenteRSS pFuente = new FuenteRSS()
            {
                URL = (string)e.Argument
            };

            try
            {
                pFuente.Valor = pFuente.ValorActualizado();
                e.Result      = pFuente.Valor;
            }
            catch (Exception ex)
            {
                e.Result = ex;
            }
        }
 /// <summary>
 /// guarda una fuente en la base de datos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnFuenteGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         //se realizan controles de valor nulo y de url valida
         if (textBoxTitulo.Text == "")
         {
             throw new Exception("Por favor, ingrese un titulo para la fuente.");
         }
         else
         {
             if (radioButtonRSS.Checked)
             {
                 if (!Utilidades.UrlValida(textBoxURLfuente.Text))
                 {
                     throw new Exception("La URL no es válida. Por favor verifíquela.");
                 }
                 else
                 {
                     FuenteRSS mFuenteRSS = new FuenteRSS {
                         Titulo = textBoxTitulo.Text, URL = textBoxURLfuente.Text
                     };
                     string mCadena = "Se agregó la fuente: Id " + mFuenteRSS.Id + ", Título: " + mFuenteRSS.Titulo;
                     cLogger.Debug(mCadena);
                     cFachada.AddFuenteRSS(mFuenteRSS);
                     MessageBox.Show("La fuente RSS se agregó con éxito");
                 }
             }
             else
             {
                 FuenteTextoFijo mFuenteTextoFijo = new FuenteTextoFijo {
                     Titulo = textBoxTitulo.Text, Valor = textBoxTextoFijo.Text
                 };
                 string mCadena = "Se agregó la fuente: Id " + mFuenteTextoFijo.Id + ", Título: " + mFuenteTextoFijo.Titulo;
                 cLogger.Debug(mCadena);
                 cFachada.AddFuenteTXT(mFuenteTextoFijo);
                 MessageBox.Show("La fuente se agregó con éxito");
             }
         }
     }
     catch (Exception mException)
     {
         MessageBox.Show(mException.Message);
         cLogger.Debug(mException.ToString());
     }
 }
Ejemplo n.º 13
0
        public void Banner3Eliminar()
        {
            int i = 33;
            List <RangoFecha> listaRangosFecha = new List <RangoFecha>();
            FuenteRSS         pFuenteRSS       = this.CrearFuenteRSS(33, "Fuente RSS " + i.ToString());

            Persistencia.FachadaPersistencia fachada = new Persistencia.FachadaPersistencia();
            Banner pBanner = new Banner()
            {
                Codigo        = i,
                Fuente        = pFuenteRSS,
                Fuente_Codigo = pFuenteRSS.Codigo
            };

            listaRangosFecha.Add(this.CrearRangoFecha(i, DateTime.Today, pBanner));
            pBanner.RangosFecha = listaRangosFecha;
            fachada.EliminarBanner(pBanner);
        }
 /// <summary>
 /// Borra una fuente.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewEliminar.CurrentRow.Index != -1)
         {
             if (radioButtonRSS.Checked)
             {
                 FuenteRSS mFuenteRSS = new FuenteRSS {
                     Id = Convert.ToInt32(dataGridViewEliminar["Id", dataGridViewEliminar.CurrentRow.Index].Value)
                 };
                 DialogResult mMessageBoxResultado = MessageBox.Show("¿Desea borrar la Fuente?", "Borrar Fuente", MessageBoxButtons.YesNo);
                 if (mMessageBoxResultado == DialogResult.Yes)
                 {
                     string mCadena = "Se borra la fuente: Id: " + mFuenteRSS.Id;
                     cLogger.Debug(mCadena);
                     cFachada.DeleteFuenteRSS(mFuenteRSS);
                     radioButtonRSS_CheckedChanged(sender, e);
                     MessageBox.Show("La fuente se ha borrado exitosamente");
                 }
             }
             else
             {
                 FuenteTextoFijo mFuenteTXT = new FuenteTextoFijo {
                     Id = Convert.ToInt32(dataGridViewEliminar["Id", dataGridViewEliminar.CurrentRow.Index].Value)
                 };
                 DialogResult mMessageBoxResultado = MessageBox.Show("¿Desea borrar la Fuente?", "Borrar Fuente", MessageBoxButtons.YesNo);
                 if (mMessageBoxResultado == DialogResult.Yes)
                 {
                     string mCadena = "Se borra la fuente: Id: " + mFuenteTXT.Id;
                     cLogger.Debug(mCadena);
                     cFachada.DeleteFuenteTXT(mFuenteTXT);
                     radioButtonTXT_CheckedChanged(sender, e);
                     MessageBox.Show("La fuente se ha borrado exitosamente");
                 }
             }
         }
     }
     catch (Exception mException)
     {
         cLogger.Debug(mException.Message);
         MessageBox.Show("Ocurrio un error: " + mException.Message);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Evento que surge cuando se hace clic en el botón Eliminar
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void button_Eliminar_Click(object sender, EventArgs e)
        {
            FuenteRSS pFuente = this.FuenteSeleccionada();

            if (!this.iListaFuenteRSSAgregar.Contains(pFuente))
            {
                DialogResult result = MessageBox.Show("¿Está seguro que desea eliminar la fuente junto con sus Banner Asociados?", "Atención",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    this.iListaFuenteRSSEliminar.Add(pFuente);
                    this.iListaFuenteRSS.Remove(pFuente);
                }
            }
            else
            {
                this.iListaFuenteRSSAgregar.Remove(pFuente);
                this.iListaFuenteRSS.Remove(pFuente);
            }
            this.ActualizarDGV();
            this.ActivarAceptar();
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Agrega una fuente RSS
 /// </summary>
 /// <param name="pFuenteRSS"></param>
 public void AddFuenteRSS(FuenteRSS pFuenteRSS)
 {
     if (Utilidades.InternetDisponible())
     {
         //si no existe una con el mismo nombre
         if (cRepositoryBaseRSS.Filter(x => x.Titulo == pFuenteRSS.Titulo) != null)
         {
             //convierto en string la URL de la fuente RSS y la agrego
             pFuenteRSS.Valor = Utilidades.GetStringFromXMLRSSUrl(pFuenteRSS.URL);
             cRepositoryBaseRSS.Add(pFuenteRSS);
             cRepositoryBaseRSS.SaveChanges();
         }
         else
         {
             throw new Exception("Una fuente con ese nombre ya existe.");
         }
     }
     else
     {
         throw new Exception("No pudo descargarse el feed RSS por falta de conectividad.");
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Evento que surge cuando se hace clic en el botón Aceptar
        /// </summary>
        /// <param name="sender">Objeto que  envía el evento</param>
        /// <param name="e">Argumentos del evento</param>
        private void button_Aceptar_Click(object sender, EventArgs e)
        {
            AdministracionRSS admininistracionRSS = new AdministracionRSS();

            admininistracionRSS.ListaRSSActualizar = this.iListaFuenteRSSActualizar;
            admininistracionRSS.ListaRSSEliminar   = this.iListaFuenteRSSEliminar;
            admininistracionRSS.ListaRSSAgregar    = this.iListaFuenteRSSAgregar;
            if (this.iNecesitaSeleccionar)
            {
                FuenteRSS pFuente = this.FuenteSeleccionada();
                if (this.iListaFuenteRSSAgregar.Contains(pFuente))
                {
                    this.iListaFuenteRSSAgregar.Remove(pFuente);
                    this.backgroundWorker_FuenteRSSSeleccion.RunWorkerAsync(pFuente);
                }
                else
                {
                    ((Form_Configuracion_Banner)this.Owner).ActualizarFuente(pFuente);
                }
            }
            this.backgroundWorker_Fuentes.RunWorkerAsync(admininistracionRSS);
            this.Hide();
        }
 /// <summary>
 /// Carga una fuente seleccionada y muestra los datos de la misma.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonCargar_Click(object sender, EventArgs e)
 {
     if (dataGridViewModificar.CurrentRow.Index != -1)
     {
         if (radioButtonRSS.Checked)
         {
             FuenteRSS mFuenteRSS = new FuenteRSS {
                 Id = Convert.ToInt32(dataGridViewModificar["Id", dataGridViewModificar.CurrentRow.Index].Value)
             };
             cFuenteRSS            = cFachada.GetFuenteRSS(mFuenteRSS);
             textBoxTitulo.Text    = cFuenteRSS.Titulo;
             textBoxURLfuente.Text = cFuenteRSS.URL;
         }
         else
         {
             FuenteTextoFijo mFuenteTXT = new FuenteTextoFijo {
                 Id = Convert.ToInt32(dataGridViewModificar["Id", dataGridViewModificar.CurrentRow.Index].Value)
             };
             cFuenteTXT            = cFachada.GetFuenteTXT(mFuenteTXT);
             textBoxTitulo.Text    = cFuenteTXT.Titulo;
             textBoxTextoFijo.Text = cFuenteTXT.Valor;
         }
     }
 }
Ejemplo n.º 19
0
 public AgregarFuenteRSS(FuenteRSS pFuente)
 {
     this.iFuente = pFuente;
     InitializeComponent();
 }
Ejemplo n.º 20
0
        private void btn_guardarFuente_Click(object sender, EventArgs e)
        {
            try
            {
                vistaPrevia = false;
                if (!this.bwRssReader.IsBusy)
                {
                    Uri mUrl;

                    if (!string.IsNullOrWhiteSpace(txt_nombreFuente.Text) && !string.IsNullOrWhiteSpace(txt_url.Text))
                    {
                        FuenteRSS fuente = new FuenteRSS
                        {
                            iDescripcion = txt_nombreFuente.Text,
                            iUrl         = txt_url.Text,
                        };

                        ControladorFuenteBanner fachada = new ControladorFuenteBanner();

                        //NUEVA FuenteRSS
                        if (btn_guardarFuente.Text == "Guardar ")
                        {
                            if (!Uri.TryCreate(fuente.iUrl.Trim(), UriKind.Absolute, out mUrl))
                            {
                                throw new ArgumentException("La URL que se ingreso no es válida.");
                            }

                            this.Cursor = Cursors.WaitCursor;
                            this.bwRssReader.RunWorkerAsync(mUrl);

                            fachada.AgregarFuenteRSS(fuente);
                            MessageBox.Show("Fuente RSS guardada con exito!");
                            lbl_vistaPrevia.Text    = string.Empty;
                            lbl_vistaPrevia.Visible = false;
                        }

                        else//MODIFICAR FuenteRSS
                        {
                            if (!Uri.TryCreate(txt_url.Text.Trim(), UriKind.Absolute, out mUrl))
                            {
                                throw new ArgumentException("La URL que se ingreso no es válida.");
                            }

                            this.Cursor = Cursors.WaitCursor;
                            this.bwRssReader.RunWorkerAsync(mUrl);

                            iFuente.iDescripcion = txt_nombreFuente.Text;
                            iFuente.iUrl         = txt_url.Text;
                            fachada.ModificarFuenteRSS(iFuente);
                            MessageBox.Show("Fuente RSS modificada con exito!");
                            this.Close();
                        }

                        txt_nombreFuente.Text = "";
                        txt_nombreFuente.Refresh();
                        txt_url.Text = "";
                        txt_url.Refresh();
                    }

                    else
                    {
                        MessageBox.Show("Complete los campos faltantes");
                    }
                }
            }

            catch (Exception bEx)
            {
                MessageBox.Show(bEx.Message, "Ha ocurrido un error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Borra una fuente RSS
 /// </summary>
 /// <param name="pFuenteRSS"></param>
 public void DeleteFuenteRSS(FuenteRSS pFuenteRSS)
 {
     cRepositoryBaseRSS.DeleteById(pFuenteRSS.Id);
     cRepositoryBaseRSS.SaveChanges();
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Verifica los datos y guarda el nuevo banner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBannerGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Verifia si tiene nombre
                if (textBoxBannerNombre.Text == "")
                {
                    throw new Exception("Falta ingresar el nombre del Banner");
                }

                //Verifica si las fechas forman un rango aceptable
                if (dateTimePickerBannerFechaInicio.Value.Date < DateTime.Now.Date)
                {
                    throw new Exception("No se admiten Fechas de Inicios pasadas");
                }

                if (dateTimePickerBannerFechaFin.Value.Date < dateTimePickerBannerFechaInicio.Value.Date)
                {
                    throw new Exception("La Fecha Final debe ser mayor a la Fecha de Inicio");
                }

                //Verifica si se han seleccionado imágenes
                if (dataGridViewFuentes.CurrentRow.Index < 0)
                {
                    throw new Exception("Debe seleccionar al menos una fuente");
                }

                //Pasa la info del datePicker y el combo a una sola variable
                DateTime mFechaInicio = new DateTime(
                    dateTimePickerBannerFechaInicio.Value.Year,
                    dateTimePickerBannerFechaInicio.Value.Month,
                    dateTimePickerBannerFechaInicio.Value.Day,
                    Convert.ToInt32(comboBoxBannerHoraInicio.Text),
                    0,
                    0);
                DateTime mFechaFin = new DateTime(
                    dateTimePickerBannerFechaFin.Value.Year,
                    dateTimePickerBannerFechaFin.Value.Month,
                    dateTimePickerBannerFechaFin.Value.Day,
                    Convert.ToInt32(comboBoxBannerHoraFin.Text),
                    0,
                    0);

                Banner mBanner = new Banner();
                mBanner.Nombre      = textBoxBannerNombre.Text;
                mBanner.FechaInicio = mFechaInicio;
                mBanner.FechaFin    = mFechaFin;

                //Verifica si la hora seleccionada está disponible
                Dictionary <string, List <Banner> > mDiccionario = cFachada.AvailableTimesBanner(dateTimePickerBannerFechaInicio.Value, dateTimePickerBannerFechaFin.Value);
                bool mDisponible = cFachada.AvailableHoursBanner(mBanner, mDiccionario);
                if (!mDisponible)
                {
                    throw new Exception("El horario seleccionado no está disponible");
                }

                if (comboBoxTipoFuente.Text == "RSS")
                {
                    FuenteRSS mFuente = new FuenteRSS {
                        Id = Convert.ToInt32(textBoxId.Text)
                    };
                    mFuente        = cFachada.GetFuenteRSS(mFuente);
                    mBanner.Fuente = mFuente;
                }
                else
                {
                    FuenteTextoFijo mFuente = new FuenteTextoFijo {
                        Id = Convert.ToInt32(textBoxId.Text)
                    };
                    mFuente        = cFachada.GetFuenteTXT(mFuente);
                    mBanner.Fuente = mFuente;
                }
                string mCadena = "Se agregó el Banner: Id " + mBanner.Id + ", Nombre: " + mBanner.Nombre + ", Fecha y Hora de inicio: " + mBanner.FechaInicio + ", Fecha y Hora de fin: " + mBanner.FechaFin + " Y la Fuente: " + mBanner.Fuente.Titulo;
                cLogger.Debug(mCadena);
                cFachada.AddBanner(mBanner);
                MessageBox.Show("El Banner se ha guardado con éxito");
            }
            catch (Exception mExcepcion)
            {
                MessageBox.Show(mExcepcion.Message);
                cLogger.Debug(mExcepcion.Message);
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Obtiene una fuente RSS dado el ID
 /// </summary>
 /// <param name="pFuenteRSS"></param>
 /// <returns></returns>
 public FuenteRSS GetFuenteRSS(FuenteRSS pFuenteRSS)
 {
     return(cRepositoryBaseRSS.GetById(pFuenteRSS.Id));
 }
Ejemplo n.º 24
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Variable auxiliar, para controlar que la hora de fin no supere la que se almacena aqui.
                TimeSpan tiempoMaximo = new TimeSpan(23, 59, 59);

                if (
                    (TimeSpan.Parse(mtxt_horaFin.Text) < tiempoMaximo ||
                     TimeSpan.Parse(mtxt_horaInicio.Text) < tiempoMaximo) &&
                    (TimeSpan.Parse(mtxt_horaInicio.Text) < TimeSpan.Parse(mtxt_horaFin.Text)) &&
                    (Convert.ToDateTime(dtp_fechaInicio.Text) < Convert.ToDateTime(dtp_fechaFin.Text)) &&
                    (Convert.ToDateTime(dtp_fechaInicio.Text) >= DateTime.Today && Convert.ToDateTime(dtp_fechaFin.Text) > DateTime.Today))
                {
                    if (!this.iModificar)    //Agregando un NUEVO banner
                    {
                        if (rb_fuenteRSS.Checked)
                        {
                            BannerFuenteRSS bannerRSS = new BannerFuenteRSS();
                            bannerRSS.iIdFuenteRSS = Convert.ToInt32(dgv_fuentesRSS.CurrentRow.Cells[0].Value);
                            this.iBanner           = bannerRSS;
                        }

                        else
                        {
                            BannerFuenteTextoFijo bannerTextoFijo = new BannerFuenteTextoFijo();
                            bannerTextoFijo.TextoFijo = txt_textoFijo.Text;
                            this.iBanner = bannerTextoFijo;
                        }

                        this.iBanner.iHoraFin     = TimeSpan.Parse(mtxt_horaFin.Text);
                        this.iBanner.iHoraInicio  = TimeSpan.Parse(mtxt_horaInicio.Text);
                        this.iBanner.iFechaInicio = Convert.ToDateTime(dtp_fechaInicio.Text);
                        this.iBanner.iFechaFin    = Convert.ToDateTime(dtp_fechaFin.Text);
                        this.iBanner.iNombre      = txt_nombre.Text;
                        this.iFachadaBanner.AgregarBanner(this.iBanner);

                        MessageBox.Show("El banner fue guardado con exito");
                        this.Close();
                    }

                    else//MODIFICACION de banner
                    {
                        if (rb_fuenteRSS.Checked && (this.iBanner is BannerFuenteTextoFijo))
                        {
                            if (MessageBox.Show(@"Advertencia, este banner contiene un texto fijo configurado si continua y configura una fuente RSS para este banner los datos del texto fijo se perderan. 
                                             
                                      ¿Esta seguro de continuar?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                //En caso de modificar un banner fuente texto fijo para convertirlo en un banner rss, lo que
                                //hacemos es borrarlo y agregarlo nuevamente pero como texto fijo
                                int id = this.iBanner.iIdBanner;
                                this.iFachadaBanner.EliminarBanner(id);

                                BannerFuenteRSS bannerRSS = new BannerFuenteRSS();
                                bannerRSS.iIdFuenteRSS    = Convert.ToInt32(dgv_fuentesRSS.CurrentRow.Cells[0].Value);
                                this.iBanner              = bannerRSS;
                                this.iBanner.iHoraFin     = TimeSpan.Parse(mtxt_horaFin.Text);
                                this.iBanner.iHoraInicio  = TimeSpan.Parse(mtxt_horaInicio.Text);
                                this.iBanner.iNombre      = txt_nombre.Text;
                                this.iBanner.iFechaInicio = Convert.ToDateTime(dtp_fechaInicio.Text);
                                this.iBanner.iFechaFin    = Convert.ToDateTime(dtp_fechaFin.Text);

                                this.iFachadaBanner.AgregarBanner(this.iBanner);
                                MessageBox.Show("El banner fue modificado con exito");
                                this.Close();
                            }
                        }

                        else
                        {
                            if (rb_fuenteRSS.Checked && this.iBanner is BannerFuenteRSS)
                            {
                                int             id            = this.iBanner.iIdBanner;
                                BannerFuenteRSS bannerRSS     = new BannerFuenteRSS();
                                FuenteRSS       fuenteAsociar = new FuenteRSS
                                {
                                    iIdFuenteRSS            = Convert.ToInt32(dgv_fuentesRSS.CurrentRow.Cells[0].Value),
                                    iDescripcion            = Convert.ToString(dgv_fuentesRSS.CurrentRow.Cells[2].Value),
                                    iUltimaObtencionDeFeeds = Convert.ToString(dgv_fuentesRSS.CurrentRow.Cells[3].Value),
                                    iUrl = Convert.ToString(dgv_fuentesRSS.CurrentRow.Cells[1].Value)
                                };

                                bannerRSS.iIdFuenteRSS    = Convert.ToInt32(dgv_fuentesRSS.CurrentRow.Cells[0].Value);
                                this.iBanner              = bannerRSS;
                                this.iBanner.iHoraFin     = TimeSpan.Parse(mtxt_horaFin.Text);
                                this.iBanner.iHoraInicio  = TimeSpan.Parse(mtxt_horaInicio.Text);
                                this.iBanner.iNombre      = txt_nombre.Text;
                                this.iBanner.iFechaInicio = Convert.ToDateTime(dtp_fechaInicio.Text);
                                this.iBanner.iFechaFin    = Convert.ToDateTime(dtp_fechaFin.Text);
                                this.iBanner.iIdBanner    = id;

                                this.iFachadaBanner.ModificarBanner(this.iBanner);
                                MessageBox.Show("El banner fue modificado con exito");
                                this.Close();
                            }

                            else
                            {
                                if (rb_textoFijo.Checked && this.iBanner is BannerFuenteRSS)
                                {
                                    if (MessageBox.Show(@"Advertencia, este banner contiene un fuente RSS configurada si continua y configura un texto fijo para este banner los datos de la fuente rss se perderan. 
                                             
                                      ¿Esta seguro de continuar?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                    {
                                        //En caso de modificar un banner rss para convertirlo en un banner texto fijo, lo que
                                        //hacemos es borrarlo y agregarlo nuevamente pero como texto fijo
                                        int id = this.iBanner.iIdBanner;
                                        this.iFachadaBanner.EliminarBanner(id);

                                        BannerFuenteTextoFijo bannerTextoFijo = new BannerFuenteTextoFijo();
                                        bannerTextoFijo.TextoFijo = txt_textoFijo.Text;
                                        this.iBanner              = bannerTextoFijo;
                                        this.iBanner.iHoraFin     = TimeSpan.Parse(mtxt_horaFin.Text);
                                        this.iBanner.iHoraInicio  = TimeSpan.Parse(mtxt_horaInicio.Text);
                                        this.iBanner.iNombre      = txt_nombre.Text;
                                        this.iBanner.iFechaInicio = Convert.ToDateTime(dtp_fechaInicio.Text);
                                        this.iBanner.iFechaFin    = Convert.ToDateTime(dtp_fechaFin.Text);
                                        this.iBanner.iIdBanner    = id;

                                        this.iFachadaBanner.AgregarBanner(this.iBanner);
                                        MessageBox.Show("El banner fue modificado con exito");
                                        this.Close();
                                    }
                                }

                                else
                                {
                                    if (rb_textoFijo.Checked && this.iBanner is BannerFuenteTextoFijo)
                                    {
                                        int id = this.iBanner.iIdBanner;
                                        BannerFuenteTextoFijo bannerTextoFijo = new BannerFuenteTextoFijo();
                                        bannerTextoFijo.TextoFijo = txt_textoFijo.Text;
                                        this.iBanner              = bannerTextoFijo;
                                        this.iBanner.iHoraFin     = TimeSpan.Parse(mtxt_horaFin.Text);
                                        this.iBanner.iHoraInicio  = TimeSpan.Parse(mtxt_horaInicio.Text);
                                        this.iBanner.iNombre      = txt_nombre.Text;
                                        this.iBanner.iFechaInicio = Convert.ToDateTime(dtp_fechaInicio.Text);
                                        this.iBanner.iFechaFin    = Convert.ToDateTime(dtp_fechaFin.Text);
                                        this.iBanner.iIdBanner    = id;

                                        this.iFachadaBanner.ModificarBanner(this.iBanner);
                                        MessageBox.Show("El banner fue modificado con exito");
                                        this.Close();
                                    }
                                }
                            }
                        }
                    }
                }

                else
                {
                    //Aqui se entra si hay errores en los ingresos de datos. A la error string le concatenamos
                    //los errores segun coincidan en las condiciones de los if.

                    string ErrorString = "Se han detectado el (o los) siguente(s) error(es): \n";

                    /*
                     * if (this.iBanner == null)
                     * {
                     *  ErrorString = ErrorString + ("• El banner no fue configurado con ninguna fuente rss o texto fijo \n");
                     * }
                     */

                    if (TimeSpan.Parse(mtxt_horaFin.Text) > tiempoMaximo ||
                        TimeSpan.Parse(mtxt_horaInicio.Text) > tiempoMaximo)
                    {
                        ErrorString = ErrorString + ("• La hora de inicio y/o de fin estan mal ingresadas. Valores validos desde 00:00:00 hasta 23:59:59 \n");
                    }

                    if ((TimeSpan.Parse(mtxt_horaInicio.Text) >= TimeSpan.Parse(mtxt_horaFin.Text)))
                    {
                        ErrorString = ErrorString + ("• La hora de inicio no puede ser mayor o igual a la de fin \n");
                    }

                    if (Convert.ToDateTime(dtp_fechaInicio.Text) >= Convert.ToDateTime(dtp_fechaFin.Text))
                    {
                        ErrorString = ErrorString + ("• La fecha de inicio no puede ser mayor que la de fin \n");
                    }

                    if ((Convert.ToDateTime(dtp_fechaInicio.Text) <= DateTime.Today || Convert.ToDateTime(dtp_fechaFin.Text) < DateTime.Today))
                    {
                        ErrorString = ErrorString + ("• La fecha de inicio y/o fin deben ser mayores a la actual \n");
                    }

                    MessageBox.Show(ErrorString);
                }
            }

            catch (FormatException)
            {
                MessageBox.Show("Error, revise los datos ingresados");
            }
            catch (BannerNoDisponibleException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Actualiza una fuente RSS
 /// </summary>
 /// <param name="pFuenteRSS"></param>
 public void UpdateFuenteRSS(FuenteRSS pFuenteRSS)
 {
     cRepositoryBaseRSS.Update(pFuenteRSS);
     cRepositoryBaseRSS.SaveChanges();
 }
        /// <summary>
        /// Verifica si están todos los datos necesarios cargados y guarda el banner que se modificó
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (cBanner != null)
                {
                    //Verifia si tiene nombre
                    if (textBoxNombreBanner.Text == "")
                    {
                        throw new Exception("Falta ingresar el nombre del Banner");
                    }

                    //Verifica si la hora de inicio está en el rango aceptado
                    if ((Convert.ToInt32(comboBoxHoraInicioBanner.Text) < 0) ||
                        (Convert.ToInt32(comboBoxHoraInicioBanner.Text) > 23))
                    {
                        throw new Exception("La hora de inicio ingresada no es válida");
                    }

                    //Verifica si la hora de fin está en el rango aceptado
                    if ((Convert.ToInt32(comboBoxHoraFinBanner.Text) < 0) ||
                        (Convert.ToInt32(comboBoxHoraFinBanner.Text) > 23))
                    {
                        throw new Exception("La hora de fin ingresada no es válida");
                    }

                    //Verifica si las fechas forman un rango aceptable
                    if (dateTimePickerBannerFechaInicio.Value.Date < DateTime.Now.Date)
                    {
                        throw new Exception("No se admiten Fechas de Inicios pasadas");
                    }

                    if (dateTimePickerBannerFechaFin.Value.Date < dateTimePickerBannerFechaInicio.Value.Date)
                    {
                        throw new Exception("La Fecha Final debe ser mayor a la Fecha de Inicio");
                    }

                    //Pasa la info del datePicker y el combo a una sola variable
                    DateTime mFechaInicio = new DateTime(
                                                        dateTimePickerBannerFechaInicio.Value.Year,
                                                        dateTimePickerBannerFechaInicio.Value.Month,
                                                        dateTimePickerBannerFechaInicio.Value.Day,
                                                        Convert.ToInt32(comboBoxHoraInicioBanner.Text),
                                                        0,
                                                        0);
                    DateTime mFechaFin = new DateTime(
                                                     dateTimePickerBannerFechaFin.Value.Year,
                                                     dateTimePickerBannerFechaFin.Value.Month,
                                                     dateTimePickerBannerFechaFin.Value.Day,
                                                     Convert.ToInt32(comboBoxHoraFinBanner.Text),
                                                     0,
                                                     0);

                    Banner mBanner = new Banner();
                    mBanner.Id = cBanner.Id;
                    mBanner.FechaInicio = cBanner.FechaInicio;
                    mBanner.FechaFin = cBanner.FechaFin;
                    //Verifica si la hora seleccionada está disponible
                    Dictionary<string, List<Banner>> mDiccionario = cFachada.AvailableTimesBanner(dateTimePickerBannerFechaInicio.Value, dateTimePickerBannerFechaFin.Value);
                    bool mDisponible = cFachada.AvailableHoursBanner(mBanner, mDiccionario);
                    if (!mDisponible)
                    {
                        throw new Exception("El horario seleccionado no está disponible");
                    }

                    cBanner.Nombre = textBoxNombreBanner.Text;
                    cBanner.FechaInicio = mFechaInicio;
                    cBanner.FechaFin = mFechaFin;

                    if (comboBoxTipoFuente.Text == "RSS")
                    {
                        FuenteRSS mFuente = new FuenteRSS { Id = Convert.ToInt32(textBoxId.Text) };
                        mFuente = cFachada.GetFuenteRSS(mFuente);
                        cBanner.Fuente = mFuente;
                    }
                    else
                    {
                        FuenteTextoFijo mFuente = new FuenteTextoFijo { Id = Convert.ToInt32(textBoxId.Text) };
                        mFuente = cFachada.GetFuenteTXT(mFuente);
                        cBanner.Fuente = mFuente;
                    }
                    DialogResult mMessageBoxResultado = MessageBox.Show("¿Desea modificar el Banner?", "Modificar Banner", MessageBoxButtons.YesNo);
                    if (mMessageBoxResultado == DialogResult.Yes)
                    {
                        cFachada.UpdateBanner(cBanner);
                        MessageBox.Show("El Banner se ha modificado con éxito");
                        dataGridViewBanners.DataSource = cFachada.GetAllBanner();
                        string mCadena = "Se modificó el Banner: Id: " + cBanner.Id + " Nombre: " + cBanner.Nombre + " Fecha y Hora de inicio: " + cBanner.FechaInicio + " Fecha y Hora de fin: " + cBanner.FechaFin + " Y la fuente; " + cBanner.Fuente.Titulo;
                        cLogger.Debug(mCadena);
                    }
                }
                else
                {
                    throw new Exception("No hay modificaciones para guardar");
                }
            }
            catch (Exception mExcepcion)
            {
                MessageBox.Show(mExcepcion.Message);
                cLogger.Debug(mExcepcion.Message);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Timer que consulta con cada tick el banner y su fuente a mostrar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerBanner_Tick(object sender, EventArgs e)
        {
            //Se obtiene el banner activo para la fecha y horario actual
            Banner bActivo = iControladorBanner.bannerActivo();

            //Si existe un banner activo y no es nulo
            if (bActivo != null)
            {
                //Si el banner posee una FuenteRSS para mostrar
                if (bActivo is BannerFuenteRSS)
                {
                    //Se obtiene el URL de la FuenteRSS
                    string url = iControladorFuente.ObtenerFuenteRSS((bActivo as BannerFuenteRSS).iIdFuenteRSS).iUrl;

                    //Se asigna al atributo de la pantalla fuenteActual para poder actualizar la ultima obtencion de feeds
                    //en el background worker
                    this.fuenteActual = iControladorFuente.ObtenerFuenteRSS((bActivo as BannerFuenteRSS).iIdFuenteRSS);

                    //Se comprueba que el servicio no este ocupado
                    if (!this.bwRssReader.IsBusy)
                    {
                        Uri mUrl;

                        //Se comprueba que la URL sea valida
                        if (!Uri.TryCreate(url.Trim(), UriKind.Absolute, out mUrl))
                        {
                            label1.Text = "URL no valida";
                        }
                        //Se activa el timer para el movimiento de texto
                        timer1.Enabled = true;
                        //Si el label esta vacio se carga el texto con los feeds
                        if (label1.Text == "")
                        {
                            //
                            this.bwRssReader.RunWorkerAsync(mUrl);
                        }

                        //this.bwRssReader.RunWorkerAsync(mUrl);
                    }
                }
                else//Si el banner posee una FuenteTextoFijo para mostrar
                {
                    //Se utiliza una lista auxiliar para la muestra repetida del texto deslizante
                    List <BannerFuenteTextoFijo> listaTextoFijo = new List <BannerFuenteTextoFijo>();
                    listaTextoFijo.Add(bActivo as BannerFuenteTextoFijo);

                    if (textoBanner == null)
                    {
                        textoBanner = listaTextoFijo[0].TextoFijo;
                    }
                    //Se activa el timer para el movimiento de texto
                    timer1.Enabled = true;

                    if ((bActivo as BannerFuenteTextoFijo).TextoFijo != textoBanner)
                    {
                        //esta condicion actua como un control para poder limpiar el texto del banner cuando se hace una
                        //transicion de banner.
                        textoBanner = (bActivo as BannerFuenteTextoFijo).TextoFijo;
                        label1.Text = textoBanner + "       ";
                    }
                    //Se va concatenando la cadena ingresada de texto
                    //a medida que el texto se desliza, para que no se deje de mostrar
                    label1.Text = label1.Text + (listaTextoFijo[0].TextoFijo) + "       ";
                }
            }
            else//Si el banner activo es nulo y no hay nada para mostrar
            {
                label1.Text = String.Empty;
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Metodo para agregar una fuente rss a la base de datos desde la interfaz de usuario
 /// </summary>
 /// <param name="pFuenteRSS">objeto que contiene la fuente rss a agregar</param>
 public void AgregarFuenteRSS(FuenteRSS pFuenteRSS)
 {
     this.iUnitOfWork.FuenteRSSRepository.Insert(pFuenteRSS);
     this.iUnitOfWork.Save();
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Metodo para modificar una fuente rss de la base de datos desde la interfaz de usuario
 /// </summary>
 /// <param name="pFuenteRSS">objeto que contiene la fuente rss a modificar</param>
 public void ModificarFuenteRSS(FuenteRSS pFuenteRSS)
 {
     this.iUnitOfWork.FuenteRSSRepository.Update(pFuenteRSS);
     this.iUnitOfWork.Save();
 }