Retrieve LeafOutput operational

This commit is contained in:
2016-02-26 11:54:07 -05:00
parent 76722345a8
commit 59e2f9d8bd
14 changed files with 296 additions and 64 deletions
+17 -2
View File
@@ -1,9 +1,12 @@
using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Hangfire;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Remote;
using LeafWeb.Web.Attributes;
using LeafWeb.Web.ViewModels;
using LeafWeb.Web.ViewModels.LeafInput;
@@ -69,7 +72,7 @@ namespace LeafWeb.Web.Controllers
// convert viewModel into Model
var leafInput = viewModel.GetFileInput(DataService);
// load files into LeafInputFile
leafInput.LeafInputFiles =
leafInput.Files =
(from f in files
let bytes = System.IO.File.ReadAllBytes(f.FullName)
select new LeafInputFile {Filename = f.Name, Contents = bytes}).ToList();
@@ -78,7 +81,13 @@ namespace LeafWeb.Web.Controllers
DataService.AddLeafInput(leafInput);
DeleteBackloadDirectory(Session.SessionID);
foreach (var file in leafInput.Files.Select(f => new PiscalLeafInputFile(f)))
{
BackgroundJob.Enqueue(() => ProcessLeafInput(file));
}
SetStatusMessage(
HttpUtility.HtmlEncode(
$"A data set has submitted for '{viewModel.Identifier}' from '{viewModel.SiteId}'. " + Environment.NewLine
@@ -91,6 +100,12 @@ namespace LeafWeb.Web.Controllers
return View("Index", viewModel);
}
public void ProcessLeafInput(PiscalLeafInputFile leafInputFile)
{
var piscalSshClient = new PiscalSshClient(ConfigurationManager.ConnectionStrings["PiscalServer"].ConnectionString);
piscalSshClient.SubmitLeafInputFile(leafInputFile);
}
private FileInfo[] GetBackloadDirectoryFiles(string directoryName)
{
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");