Beispiel #1
0
        public DateTime?DescargarVehiculo(DateTime reloj, int dias)
        {
            if (Vehiculos.Count == 0)
            {
                Estado = "Libre";
                return(reloj.AddHours(1));
            }
            else
            {
                if (ProximaDescarga == new DateTime())
                {
                    var vehiculo = Vehiculos.First();

                    if (vehiculo.TipoVehiculo == "Auto")
                    {
                        Capacidad++;
                    }
                    else
                    {
                        Capacidad += 2;
                    }

                    var tiempoDescarga = DateTimeConverter.EnMinutos(vehiculo.TiempoCarga) / 2.0;
                    Descarga = dias > 1?
                               DateTime.Today.AddDays(dias - 1).AddMinutes(tiempoDescarga) :
                               DateTime.Today.AddMinutes(tiempoDescarga);
                    ProximaDescarga = Descarga.AddMinutes(DateTimeConverter.EnMinutos(reloj));

                    Vehiculos.Remove(vehiculo);
                }

                return(null);
            }
        }
    //protected void ComboListaValoracion_DataBound(object sender, EventArgs e)
    //{
    //    comboValoracion.Items.Insert(0, new ListItem("0", ""));
    //}


    protected void Descargar_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["USUARIO"] == null)
            {
                Response.Redirect("~/Usuario/LoginUsuario.aspx");
            }

            string   strId    = Request.Params["Id"];
            int      codLibro = Int32.Parse(strId);
            DateTime fec      = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy"));

            Usuario  user        = UsuarioBRL.getUsuariosActivos();
            Descarga objDescarga = new Descarga();
            objDescarga.libroId   = codLibro;
            objDescarga.usuarioId = user.UsuarioId;
            objDescarga.fecha     = fec;

            DescargaBRL.insertarDescarga(objDescarga);

            Libros lib = libroBRL.getLibroById(codLibro);

            string nombreLibro = "" + lib.Titulo;

            Response.Clear();
            string filePath = "~/Libros/Pdf/" + nombreLibro + ".pdf";
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment; filename =" + filePath);
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #3
0
    public static int insertarDescarga(Descarga obj)
    {
        if (obj == null)
        {
            throw new ArgumentException("El objeto a insertar no puede tener un valor nulo");
        }

        if (obj.DescargaId < 0)
        {
            throw new ArgumentException("El codigo Descarga debe de ser Mayor a 0");
        }

        if (obj.usuarioId < 0)
        {
            throw new ArgumentException("El codigo Descarga debe de ser Mayor a 0");
        }

        if (obj.libroId < 0)
        {
            throw new ArgumentException("El codigo Descarga debe de ser Mayor a 0");
        }

        int?descargaId = 0;

        DescargaDSTableAdapters.DescargarTableAdapter adapter = new DescargaDSTableAdapters.DescargarTableAdapter();
        adapter.Insert(obj.usuarioId, obj.libroId, obj.fecha, ref descargaId);

        if (descargaId == null || descargaId.Value <= 0)
        {
            throw new Exception("La llave primaria no se genero correctamente");
        }

        return(descargaId.Value);
    }
        public async Task <Object []> EliminarDescarga(int id_descarga)
        {
            Object [] response = new Object [2];
            try {
                Descarga downloadToDelete = await AppDbContext.descargas.Where(d =>
                                                                               d.id_descarga == id_descarga).FirstOrDefaultAsync();

                List <Enlace> enlaces = await AppDbContext.enlaces.Where(e =>
                                                                         e.id_descarga == downloadToDelete.id_descarga).ToListAsync();

                foreach (Enlace enlace in enlaces)
                {
                    AppDbContext.enlaces.Remove(enlace);
                }
                AppDbContext.descargas.Remove(downloadToDelete);
                await AppDbContext.SaveChangesAsync();

                response[0] = true;
            }
            catch (Exception exception) {
                response[1] = (exception.InnerException != null) ?
                              exception.InnerException.Message : exception.Message;
            }
            return(response);
        }
 public Object GetDescargas()
 {
     try
     {
         if (HttpContext.Current.Session["token"] == null)
         {
             return(Redirect(Request.RequestUri.GetLeftPart(UriPartial.Authority)));
         }
         List <Descarga> ListaDescargas = new List <Descarga>();
         var             pathFuentes    = ProcessMsg.Utils.GetPathSetting(HttpContext.Current.Server.MapPath("~/Fuentes"));
         var             pathDescargas  = Path.Combine(pathFuentes, "Descargas");
         new DirectoryInfo(pathDescargas).GetDirectories().ToList().OrderBy(dir => dir.Name).ToList().ForEach(dirs =>
         {
             Descarga descarga      = new Descarga();
             descarga.Nombre        = dirs.Name;
             var desc               = dirs.GetFiles().ToList().SingleOrDefault(fil => (fil.Name.Equals("Descripcion.txt", StringComparison.OrdinalIgnoreCase)));                                                                   //obtiene el archivo txt con la descripcion de la descarga
             descarga.Descripcion   = File.ReadAllText(desc.FullName);
             var file               = dirs.GetFiles().ToList().SingleOrDefault(fil => ((fil.Attributes & FileAttributes.System) != FileAttributes.System) && !(fil.Extension.Equals(".txt", StringComparison.OrdinalIgnoreCase))); //obtiene el archivo comprimido que se descargara
             descarga.NombreArchivo = file.Name;
             ListaDescargas.Add(descarga);
         });
         return(Content(HttpStatusCode.OK, ListaDescargas));
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.Message));
     }
 }
        public ActionResult Crear()
        {
            var Nuevolink = new Descarga();


            return(View(Nuevolink));
        }
 void Awake()
 {
     descarga    = GetComponent <Descarga>();
     mesh        = GetComponent <MeshRenderer>();
     comparacion = GameObject.FindGameObjectWithTag("comparacion").GetComponent <Comparacion>();
     if (comparacion == null)
     {
         print("objeto comparacion no encontrado");
     }
     currentCarta = GetComponent <Carta>();
 }
Beispiel #8
0
    public static Descarga getAutorNombreById(int libroId)
    {
        DescargaDSTableAdapters.DescargarTableAdapter adapter = new DescargaDSTableAdapters.DescargarTableAdapter();
        DescargaDS.DescargarDataTable table = adapter.GetDescargasById(libroId);

        var row = table[0];

        Descarga obj = new Descarga();

        obj.DescargaId = row.descargaId;
        obj.usuarioId  = row.usuarioId;
        obj.libroId    = row.libroId;
        obj.fecha      = row.fecha;

        return(obj);
    }
        public async Task <Object []> CrearDescarga(Descarga descarga)
        {
            Object [] response = new Object [2];
            try {
                await AppDbContext.descargas.AddAsync(descarga);

                await AppDbContext.SaveChangesAsync();

                response[0] = true;
            }
            catch (Exception exception) {
                response[1] = (exception.InnerException != null) ?
                              exception.InnerException.Message : exception.Message;
            }
            return(response);
        }
Beispiel #10
0
    public static List <Descarga> getDescargas()
    {
        DescargaDSTableAdapters.DescargarTableAdapter adapter = new DescargaDSTableAdapters.DescargarTableAdapter();
        DescargaDS.DescargarDataTable table = adapter.GetDescarga();

        List <Descarga> resultado = new List <Descarga>();

        foreach (var row in table)
        {
            Descarga obj = new Descarga();

            obj.DescargaId = row.descargaId;
            obj.usuarioId  = row.usuarioId;
            obj.libroId    = row.libroId;
            obj.fecha      = row.fecha;

            resultado.Add(obj);
        }

        return(resultado);
    }
        public async Task <Object []> ActualizarDescarga(Descarga descarga)
        {
            Object [] response = new Object [2];
            try {
                Descarga downloadToUpdate = await AppDbContext.descargas.Where(d =>
                                                                               d.id_descarga == descarga.id_descarga).FirstOrDefaultAsync();

                downloadToUpdate.password_descarga = descarga.password_descarga;
                downloadToUpdate.id_tipo_archivo   = descarga.id_tipo_archivo;
                downloadToUpdate.id_servidor       = descarga.id_servidor;
                downloadToUpdate.id_pelicula       = descarga.id_pelicula;
                AppDbContext.descargas.Update(downloadToUpdate);
                await AppDbContext.SaveChangesAsync();

                response[0] = true;
            }
            catch (Exception exception) {
                response[1] = (exception.InnerException != null) ?
                              exception.InnerException.Message : exception.Message;
            }
            return(response);
        }
Beispiel #12
0
 private void btnDescargar_Click(object sender, RoutedEventArgs e)//Boton para descargar el contenido de la base de datos en formato csv
 {
     try
     {
         Descarga       archivos = new Descarga();
         string         ruta     = TtxRuta.Text;
         string         query    = "select *from final.registros ";
         SaveFileDialog guardar  = new SaveFileDialog()
         {
             Filter = "(Archivo CSV|*.csv)"
         };                                                                               //Se especifica de  que tipo sera el archivo que se creara
         if (guardar.ShowDialog() == true)
         {
             ruta = guardar.FileName;                               //Si se agrega un nombre se guardara en la ruta elegida
         }
         conectar.Open();
         archivos.Rellenar(query, conectar, ruta);
         conectar.Close();
     }catch (Exception ex)
     {
         MessageBox.Show("Ocurrio un error en la descarga" + ex.Message);
     }
 }
 public async Task <Object []> UpdateDownloadAsync([FromBody] Descarga descarga)
 {
     return(await descargas.ActualizarDescarga(descarga));
 }
 public async Task <Object []> CreateDownloadAsync([FromBody] Descarga descarga)
 {
     return(await descargas.CrearDescarga(descarga));
 }
Beispiel #15
0
        public async Task RegistrarDescarga(Descarga descarga)
        {
            await _appContext.Descargas.AddAsync(descarga);

            _appContext.SaveChanges();
        }
Beispiel #16
0
        protected void MiEstadoRedChanged(object sender, Peer2PeerApp.Comunicacion.EstadoRedChangedEventArgs e)
        {
            if (Chat != null)
            {
                Chat.SetEstadoRedCambiado(Utilidades.GetTextoTextbox(TextBoxNombreUsuario), e);
            }

            if (Imagen != null)
            {
                Imagen.SetEstadoRedCambiado(Utilidades.GetTextoTextbox(TextBoxNombreUsuario), e);
            }

            if (Fichero != null)
            {
                Fichero.SetEstadoRedCambiado(Utilidades.GetTextoTextbox(TextBoxNombreUsuario), e);
            }

            if (Video != null)
            {
                Video.SetEstadoRedCambiado(Utilidades.GetTextoTextbox(TextBoxNombreUsuario), e);
            }

            if (Audio != null)
            {
                Audio.SetEstadoRedCambiado(Utilidades.GetTextoTextbox(TextBoxNombreUsuario), e);
            }

            if (Descarga != null)
            {
                Descarga.SetEstadoRedCambiado(Utilidades.GetTextoTextbox(TextBoxNombreUsuario), e);
            }

            if (e.Miembro == Utilidades.GetTextoTextbox(TextBoxNombreUsuario))
            {
                if (e.EsNuevoNodoUnidoARed)
                {
                    Utilidades.SetTextoLabel(LabelValorEstado, "¡Conectado!");
                    Utilidades.SetEstadoActivadoContentControl(lblTitulo, true);
                    Utilidades.SetEstadoActivadoContentControl(BotonConectar, true);
                    mEstado = EstadoRed.Conectado;
                }

                if (e.EsNodoQueAbandonaRed)
                {
                    Utilidades.SetTextoLabel(LabelValorEstado, "Desconectado");
                    Utilidades.SetEstadoActivadoContentControl(lblTitulo, false);
                    Utilidades.SetEstadoActivadoContentControl(BotonConectar, true);
                    mEstado = EstadoRed.Desconectado;
                }
            }
            else
            {
                if (e.EsNuevoNodoUnidoARed)
                {
                    Chat_ChatChanged(this, new ChatChangedEventArgs(string.Format("{0} se unió a la red P2P.\n", e.Miembro)));
                }

                if (e.EsNodoQueAbandonaRed)
                {
                    Chat_ChatChanged(this, new ChatChangedEventArgs(string.Format("{0} abandonó la red P2P.\n", e.Miembro)));
                }
            }
        }