Update zip archive functionality

add download buttons for multiple input/output
This commit is contained in:
2020-07-10 21:06:23 -04:00
parent e4e753c64a
commit 0fd57812e7
4 changed files with 155 additions and 54 deletions
+37 -9
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;
@@ -92,7 +93,7 @@ namespace LeafWeb.WebCms.Controllers
return serviceDescription;
}
public ActionResult Details(int id)
public ActionResult Details(int id)
{
var leafInput = DataService.GetLeafInput(id);
@@ -106,27 +107,37 @@ namespace LeafWeb.WebCms.Controllers
return View(viewModel);
}
public ActionResult DownloadInput(int id)
public ActionResult DownloadInput(int id)
{
return GetInputZip(id);
}
public ActionResult DownloadOutputToUser(int id)
public ActionResult DownloadOutputToUser(int id)
{
return GetOutputZip(id, LeafOutputFileType.ToUser);
}
public ActionResult DownloadOutputNotToUser(int id)
public ActionResult DownloadOutputNotToUser(int id)
{
return GetOutputZip(id, LeafOutputFileType.NotToUser);
}
public ActionResult DownloadOutputCleanedInput(int id)
public ActionResult DownloadOutputCleanedInput(int id)
{
return GetOutputZip(id, LeafOutputFileType.CleanedInput);
}
private ActionResult GetOutputZip(int id, LeafOutputFileType type)
public ActionResult DownloadResultsInputZip(LeafDataQuery q)
{
return GetResults(q, LeafInput.GetInputFilesZip, $"LeafWeb_{DateTime.Now:yyyy-dd-MM--HH-mm-ss}_Input.zip");
}
public ActionResult DownloadResultsOutputZip(LeafDataQuery q)
{
return GetResults(q, LeafInput.GetOutputFilesZip_ToUser, $"LeafWeb_{DateTime.Now:yyyy-dd-MM--HH-mm-ss}_Output.zip");
}
private ActionResult GetOutputZip(int id, LeafOutputFileType type)
{
var leafInput = DataService.GetLeafInput(id);
@@ -140,7 +151,7 @@ namespace LeafWeb.WebCms.Controllers
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
}
private ActionResult GetInputZip(int id)
private ActionResult GetInputZip(int id)
{
var leafInput = DataService.GetLeafInput(id);
@@ -154,7 +165,24 @@ namespace LeafWeb.WebCms.Controllers
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
}
[ActionLog]
private ActionResult GetResults(LeafDataQuery query, Func<IEnumerable<LeafInput>, byte[]> getZip, string filename)
{
var resultItems =
DataService.GetLeafInputsOrdered();
resultItems = QueryFilter.Search(resultItems, query);
if (resultItems == null)
return View("DownloadNotFound");
var zip = getZip(resultItems);
//var filename = $"LeafWeb_{DateTime.Now:yyyy-dd-MM--HH-mm-ss}_Input.zip";
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
}
[ActionLog]
public ActionResult Delete(int id)
{
var leafInput = DataService.GetLeafInput(id);
@@ -178,7 +206,7 @@ namespace LeafWeb.WebCms.Controllers
return RedirectToUmbracoPage(LeafWebPageIds.ManageQueue);
}
[ActionLog]
[ActionLog]
public ActionResult Cancel(int id)
{
var leafInput = DataService.GetLeafInput(id);