Exemplo n.º 1
0
        /// <summary>
        /// Just download - doesn't record the fact like SourcesController.Download() does.
        /// </summary>
        /// <param name="id"></param>
        public ActionResult Download(int id)
        {
            SourceDTO dto = this.sourceTasks.GetSourceDTO(id);

            if (dto != null && dto.FileSize > 0)
            {
                if (((PrfPrincipal)User).CanAccess(dto, this.sourceTasks.GetSourceAuthors(id).ToArray(), this.sourceTasks.GetSourceOwners(id).ToArray()) && !dto.IsReadOnly)
                {
                    string contentType = dto.GetDTOFileExtension();
                    Stream stream      = this.sourceTasks.GetSourceData(id, dto.HasOcrText);
                    return(new FileStreamResult(stream, contentType)
                    {
                        FileDownloadName = dto.GetFileDownloadName()
                    });
                }
                else
                {
                    return(new HttpUnauthorizedResult());
                }
            }
            else
            {
                return(new HttpNotFoundResult());
            }
        }
Exemplo n.º 2
0
        public ActionResult Download(int id, int?adminSourceSearchId)
        {
            SourceDTO dto = this.sourceTasks.GetSourceDTO(id);

            if (dto != null && dto.FileSize > 0)
            {
                if (((PrfPrincipal)User).CanAccess(dto, this.sourceTasks.GetSourceAuthors(id).ToArray(), this.sourceTasks.GetSourceOwners(id).ToArray()))
                {
                    if (!dto.IsReadOnly)
                    {
                        // record WasDownloaded for this search
                        if (adminSourceSearchId.HasValue)
                        {
                            AdminReviewedSource ars = this.sourceAttachmentTasks.GetOrCreateAdminReviewedSource(id, adminSourceSearchId.Value);
                            ars.WasDownloaded = true;
                        }

                        string contentType = dto.GetDTOFileExtension();
                        Stream stream      = this.sourceTasks.GetSourceData(id, dto.HasOcrText);
                        return(new FileStreamResult(stream, contentType)
                        {
                            FileDownloadName = dto.GetFileDownloadName()
                        });
                    }
                    else
                    {
                        return(new HttpUnauthorizedResult());
                    }
                }
                else
                {
                    return(new HttpUnauthorizedResult());
                }
            }
            else
            {
                return(new HttpNotFoundResult());
            }
        }