Ejemplo n.º 1
0
        public ActionResult DownloadAttachment(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMessageQueue))
            {
                return(AccessDeniedView());
            }

            var qea = _queuedEmailService.GetQueuedEmailAttachmentById(id);

            if (qea == null)
            {
                return(HttpNotFound("List"));
            }

            if (qea.StorageLocation == EmailAttachmentStorageLocation.Blob)
            {
                var data = _queuedEmailService.LoadQueuedEmailAttachmentBinary(qea);
                if (data != null)
                {
                    return(File(data, qea.MimeType, qea.Name));
                }
            }
            else if (qea.StorageLocation == EmailAttachmentStorageLocation.Path)
            {
                var path = qea.Path;
                if (path[0] == '~' || path[0] == '/')
                {
                    path = CommonHelper.MapPath(VirtualPathUtility.ToAppRelative(path), false);
                }

                if (!System.IO.File.Exists(path))
                {
                    NotifyError(string.Concat(T("Admin.Common.FileNotFound"), ": ", path));

                    var referrer = Services.WebHelper.GetUrlReferrer();
                    if (referrer.HasValue())
                    {
                        return(Redirect(referrer));
                    }

                    return(RedirectToAction("List"));
                }

                return(File(path, qea.MimeType, qea.Name));
            }
            else if (qea.FileId.HasValue)
            {
                return(RedirectToAction("DownloadFile", "Download", new { downloadId = qea.FileId.Value }));
            }

            NotifyError(T("Admin.System.QueuedEmails.CouldNotDownloadAttachment"));
            return(RedirectToAction("List"));
        }
Ejemplo n.º 2
0
        public ActionResult DownloadAttachment(int id)
        {
            var qea = _queuedEmailService.GetQueuedEmailAttachmentById(id);

            if (qea == null)
            {
                return(HttpNotFound());
            }

            if (qea.StorageLocation == EmailAttachmentStorageLocation.Blob)
            {
                var data = _queuedEmailService.LoadQueuedEmailAttachmentBinary(qea);
                if (data != null)
                {
                    return(File(data, qea.MimeType, qea.Name));
                }
            }
            else if (qea.StorageLocation == EmailAttachmentStorageLocation.Path)
            {
                var path = qea.Path;
                if (path[0] == '~' || path[0] == '/')
                {
                    path = CommonHelper.MapPath(VirtualPathUtility.ToAppRelative(path), false);
                }

                if (!System.IO.File.Exists(path))
                {
                    NotifyError(string.Concat(T("Admin.Common.FileNotFound"), ": ", path));

                    return(RedirectToReferrer(null, () => RedirectToAction("List")));
                }

                return(File(path, qea.MimeType, qea.Name));
            }
            else if (qea.MediaFileId.HasValue)
            {
                return(RedirectToAction("DownloadFile", "Download", new { downloadId = qea.MediaFileId.Value }));
            }

            NotifyError(T("Admin.System.QueuedEmails.CouldNotDownloadAttachment"));
            return(RedirectToAction("List"));
        }