Notify complete from Piscal to LeafWeb

This commit is contained in:
2016-05-04 12:12:35 -04:00
parent e9a9ae186c
commit e0788154ec
5 changed files with 23 additions and 7 deletions
+1
View File
@@ -13,6 +13,7 @@ namespace LeafWeb.Core.Remote
public string DirectoryName { get; set; } public string DirectoryName { get; set; }
public bool SuppressStorageCopy { get; set; } public bool SuppressStorageCopy { get; set; }
public PiscalLeafInputFile[] InputFiles { get; set; } public PiscalLeafInputFile[] InputFiles { get; set; }
public string NotifyCompleteUrl { get; set; }
static PiscalLeafInput() static PiscalLeafInput()
{ {
+3
View File
@@ -73,6 +73,9 @@ namespace LeafWeb.Core.Remote
if (leafInput.SuppressStorageCopy) if (leafInput.SuppressStorageCopy)
commandText += " -t"; commandText += " -t";
if (!string.IsNullOrEmpty(leafInput.NotifyCompleteUrl))
commandText += $" -u {leafInput.NotifyCompleteUrl}";
var command = ssh.CreateCommand(commandText); var command = ssh.CreateCommand(commandText);
command.Execute(); command.Execute();
ssh.Disconnect(); ssh.Disconnect();
+7 -6
View File
@@ -1,10 +1,6 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using LeafWeb.Core.Entities; using LeafWeb.Core.Entities;
@@ -104,15 +100,20 @@ namespace LeafWeb.Web.Controllers
return View("Index", viewModel); return View("Index", viewModel);
} }
public FileContentResult DownloadResults(int d) public FileContentResult DownloadResults(int id)
{ {
var leafInput = DataService.GetLeafInput(d); var leafInput = DataService.GetLeafInput(id);
var zip = leafInput.GetOutputFileZip(); var zip = leafInput.GetOutputFileZip();
return new FileContentResult(zip, "application/zip") {FileDownloadName = leafInput.Identifier + ".zip"}; return new FileContentResult(zip, "application/zip") {FileDownloadName = leafInput.Identifier + ".zip"};
} }
public void NotifyComplete()
{
HangfireStartup.TriggerPiscalProcessQueue();
}
private FileInfo[] GetBackloadDirectoryFiles(string directoryName) private FileInfo[] GetBackloadDirectoryFiles(string directoryName)
{ {
var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\"); var path = Path.Combine(Server.MapPath("~/Files/"), directoryName + "\\");
+10 -1
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using LeafWeb.Core.Entities; using LeafWeb.Core.Entities;
using LeafWeb.Core.Remote; using LeafWeb.Core.Remote;
@@ -11,10 +12,14 @@ namespace LeafWeb.Web.Services.PiscalQueue
public class PiscalService public class PiscalService
{ {
private readonly IPiscalClient _piscalClient; private readonly IPiscalClient _piscalClient;
private readonly string _notifyCompleteUrl;
public PiscalService(IPiscalClient piscalClient) public PiscalService(IPiscalClient piscalClient)
{ {
_piscalClient = piscalClient; _piscalClient = piscalClient;
_notifyCompleteUrl =
ConfigurationManager.AppSettings["LeafWebUrl"] +
ConfigurationManager.AppSettings["PiscalNotifyCompleteUrlPath"];
} }
public PiscalService() : this(new PiscalSshClient(ConfigurationManager.ConnectionStrings["PiscalServer"].ConnectionString)) public PiscalService() : this(new PiscalSshClient(ConfigurationManager.ConnectionStrings["PiscalServer"].ConnectionString))
@@ -24,6 +29,10 @@ namespace LeafWeb.Web.Services.PiscalQueue
public void Run(LeafInput leafInput) public void Run(LeafInput leafInput)
{ {
var inputFile = new PiscalLeafInput(leafInput); var inputFile = new PiscalLeafInput(leafInput);
if (!string.IsNullOrEmpty(_notifyCompleteUrl))
inputFile.NotifyCompleteUrl = _notifyCompleteUrl;
// TODO: remove this, just for testing // TODO: remove this, just for testing
if (string.Equals(leafInput.Email, "james.kolpack@gmail.com", StringComparison.InvariantCultureIgnoreCase)) if (string.Equals(leafInput.Email, "james.kolpack@gmail.com", StringComparison.InvariantCultureIgnoreCase))
inputFile.SuppressStorageCopy = true; inputFile.SuppressStorageCopy = true;
+2
View File
@@ -30,6 +30,8 @@
<add key="SmtpPort" value="25"/> <add key="SmtpPort" value="25"/>
<add key="SmtpUserName" value=""/> <add key="SmtpUserName" value=""/>
<add key="SmtpPassword" value=""/> <add key="SmtpPassword" value=""/>
<add key="LeafWebUrl" value="http://192.168.1.133:1640/" />
<add key="PiscalNotifyCompleteUrlPath" value="LeafInput/NotifyComplete" />
</appSettings> </appSettings>
<system.web> <system.web>
<compilation debug="true" targetFramework="4.5" /> <compilation debug="true" targetFramework="4.5" />