Retrieve LeafOutput operational
This commit is contained in:
@@ -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 + "\\");
|
||||
|
||||
Reference in New Issue
Block a user