diff --git a/Core/Core.csproj b/Core/Core.csproj
index 1335eeb..5049f03 100644
--- a/Core/Core.csproj
+++ b/Core/Core.csproj
@@ -61,6 +61,7 @@
+
diff --git a/Core/Entities/LeafInput.cs b/Core/Entities/LeafInput.cs
index e75118c..df22a3f 100644
--- a/Core/Entities/LeafInput.cs
+++ b/Core/Entities/LeafInput.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.IO;
+using System.IO.Compression;
using System.Linq;
namespace LeafWeb.Core.Entities
@@ -41,5 +43,24 @@ namespace LeafWeb.Core.Entities
{
return $"{Id}_{Identifier}";
}
+
+ ///
+ /// Contains all output files in a zip
+ ///
+ public byte[] GetOutputFileZip()
+ {
+ using (var compressedFileStream = new MemoryStream())
+ using (var archive = new ZipArchive(compressedFileStream, ZipArchiveMode.Create, true))
+ {
+ foreach (var outputFile in OutputFiles)
+ {
+ var entry = archive.CreateEntry(outputFile.Filename);
+ using (var originalFileStream = new MemoryStream(outputFile.Contents))
+ using (var entryStream = entry.Open())
+ originalFileStream.CopyTo(entryStream);
+ }
+ return compressedFileStream.ToArray();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Web/Controllers/LeafInputController.cs b/Web/Controllers/LeafInputController.cs
index 0073e78..f1761e0 100644
--- a/Web/Controllers/LeafInputController.cs
+++ b/Web/Controllers/LeafInputController.cs
@@ -1,6 +1,10 @@
using System;
+using System.Collections;
+using System.Collections.Generic;
using System.IO;
+using System.IO.Compression;
using System.Linq;
+using System.Runtime.InteropServices.ComTypes;
using System.Web;
using System.Web.Mvc;
using LeafWeb.Core.Entities;
@@ -100,6 +104,15 @@ namespace LeafWeb.Web.Controllers
return View("Index", viewModel);
}
+ public FileContentResult DownloadResults(int d)
+ {
+ var leafInput = DataService.GetLeafInput(d);
+
+ var zip = leafInput.GetOutputFileZip();
+
+ return new FileContentResult(zip, "application/zip") {FileDownloadName = leafInput.Identifier + ".zip"};
+ }
+
private FileInfo[] GetBackloadDirectoryFiles(string directoryName)
{
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
diff --git a/Web/packages.config b/Web/packages.config
index 61802f3..3a6c61a 100644
--- a/Web/packages.config
+++ b/Web/packages.config
@@ -33,6 +33,7 @@
+
\ No newline at end of file