Beispiel #1
0
        public async Task <Documento> NuevaImagen(HttpPostedFileBase archivo, string nombre = "")
        {
            if (string.IsNullOrEmpty(nombre))
            {
                nombre = archivo.FileName;
            }

            var doc = new Documento()
            {
                Tipo   = DocumentoTipo.Imagen,
                Nombre = nombre,
                Mime   = archivo.GetMime(),
                Fecha  = DateTime.Now,
                Tamano = archivo.ContentLength,
            };

            doc.Ruta = await GuardarArchivoAsync(archivo, nombre);

            GuardarThumbnail(doc.Ruta, doc.Ruta);

            IDocumentosServicio srv = servicios.DocumentosServicio();

            srv.Insert(doc);
            await srv.ApplyChangesAsync();

            return(doc);
        }
Beispiel #2
0
        public FileStream ObtenerMiniatura(long documentoID)
        {
            IDocumentosServicio srv = servicios.DocumentosServicio();
            Documento           doc = srv.GetSingle(d => d.DocumentoID == documentoID);

            return(ObtenerMiniatura(doc));
        }
Beispiel #3
0
        public async Task ObtenerDocumento(long documentoID, Stream stream)
        {
            IDocumentosServicio srv = servicios.DocumentosServicio();
            Documento           doc = srv.GetSingle(d => d.DocumentoID == documentoID);

            await ObtenerDocumento(doc, stream);
        }
Beispiel #4
0
        public async Task <ActionResult> ImagenSinEnlazar(long id)
        {
            IDocumentosServicio srv    = Servicios.DocumentosServicio();
            Documento           imagen = srv.GetSingle(c => c.DocumentoID == id);

            if (imagen != null)
            {
                var cd = new ContentDisposition
                {
                    FileName = imagen.Nombre,
                    Inline   = false,
                };

                Response.Buffer  = false;
                Response.Charset = "UTF-8";
                Response.AppendHeader(name: "Content-Disposition", value: cd.ToString());
                Response.AddHeader(name: "Content-Length", value: imagen.Tamano.ToString());
                Response.ContentType = imagen.Mime;
                Response.Flush();
                await FileManager.ObtenerDocumento(imagen, Response.OutputStream);

                return(new EmptyResult());
            }
            else
            {
                return(HttpNotFound());
            }
        }
Beispiel #5
0
        public async Task EliminarDocumento(long documentoID, bool persistir = true)
        {
            IDocumentosServicio srv = servicios.DocumentosServicio();
            Documento           doc = srv.GetSingle(d => d.DocumentoID == documentoID);

            await EliminarArchivoAsync(doc);

            srv.Delete(documentoID);
            if (persistir)
            {
                await srv.ApplyChangesAsync();
            }
        }