Umbraco update
Error email updates Piscal communication error handling Empty page for terms of service
This commit is contained in:
@@ -4,6 +4,7 @@ namespace LeafWeb.Core.Remote
|
||||
{
|
||||
public interface IPiscalClient
|
||||
{
|
||||
string Host { get; }
|
||||
void RunLeafInput(PiscalLeafInput leafInput);
|
||||
PiscalStatus GetLeafInputStatus(PiscalLeafInput leafInput);
|
||||
IEnumerable<PiscalLeafOutputFile> RetrieveLeafOutput(PiscalLeafInput leafInput);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
@@ -12,6 +13,7 @@ namespace LeafWeb.Core.Remote
|
||||
{
|
||||
private const string BaseDirectory = "./LeafWeb";
|
||||
private const string RemoteScriptPath = BaseDirectory + "/piscal_manager.sh";
|
||||
private readonly string _host;
|
||||
private readonly PasswordConnectionInfo _connectionInfo;
|
||||
|
||||
private const string StatusComplete = "complete";
|
||||
@@ -24,10 +26,10 @@ namespace LeafWeb.Core.Remote
|
||||
{
|
||||
var conn = new DbConnectionStringBuilder {ConnectionString = connectionString};
|
||||
|
||||
var host = conn["host"] as string;
|
||||
_host = conn["host"] as string;
|
||||
var username = conn["username"] as string;
|
||||
var password = conn["password"] as string;
|
||||
_connectionInfo = new PasswordConnectionInfo(host, username, password);
|
||||
_connectionInfo = new PasswordConnectionInfo(_host, username, password);
|
||||
}
|
||||
|
||||
private SshClient GetSshClient()
|
||||
@@ -40,6 +42,34 @@ namespace LeafWeb.Core.Remote
|
||||
return new ScpClient(_connectionInfo);
|
||||
}
|
||||
|
||||
private void Connect(PiscalLeafInput leafInput, BaseClient scp)
|
||||
{
|
||||
try
|
||||
{
|
||||
scp.Connect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var message = $"Exception while connecting to client. Message: {ex.Message}";
|
||||
_logger.Error(message);
|
||||
throw new PiscalClientException(leafInput.LeafInputId, message);
|
||||
}
|
||||
}
|
||||
|
||||
private void Disconnect(PiscalLeafInput leafInput, BaseClient client)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Disconnect();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var message = $"Exception while disconnecting from client. Message: {ex.Message}";
|
||||
_logger.Error(message);
|
||||
throw new PiscalClientException(leafInput.LeafInputId, message);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyLeafInput(PiscalLeafInput leafInput, string directory)
|
||||
{
|
||||
// copy files
|
||||
@@ -50,13 +80,15 @@ namespace LeafWeb.Core.Remote
|
||||
using (var stream = new MemoryStream(file.Contents))
|
||||
{
|
||||
_logger.Debug("Copying " + inputPath);
|
||||
scp.Connect();
|
||||
Connect(leafInput, scp);
|
||||
scp.Upload(stream, inputPath);
|
||||
scp.Disconnect();
|
||||
Disconnect(leafInput, scp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Host => _host;
|
||||
|
||||
public void RunLeafInput(PiscalLeafInput leafInput)
|
||||
{
|
||||
if (string.IsNullOrEmpty(leafInput.PhotosyntheticType))
|
||||
@@ -69,7 +101,7 @@ namespace LeafWeb.Core.Remote
|
||||
// begin processing
|
||||
using (var ssh = GetSshClient())
|
||||
{
|
||||
ssh.Connect();
|
||||
Connect(leafInput, ssh);
|
||||
var commandText = $"{RemoteScriptPath} -d {leafInput.PiscalDirectoryName} -p {leafInput.PhotosyntheticType} -s";
|
||||
|
||||
if (leafInput.SuppressStorageCopy)
|
||||
@@ -80,7 +112,7 @@ namespace LeafWeb.Core.Remote
|
||||
|
||||
var command = ssh.CreateCommand(commandText);
|
||||
command.Execute();
|
||||
ssh.Disconnect();
|
||||
Disconnect(leafInput, ssh);
|
||||
|
||||
if (command.ExitStatus != 0)
|
||||
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
|
||||
@@ -115,11 +147,11 @@ namespace LeafWeb.Core.Remote
|
||||
{
|
||||
using (var ssh = GetSshClient())
|
||||
{
|
||||
ssh.Connect();
|
||||
Connect(leafInput, ssh);
|
||||
var commandText = $"{RemoteScriptPath} -d {leafInput.PiscalDirectoryName}";
|
||||
var command = ssh.CreateCommand(commandText);
|
||||
command.Execute();
|
||||
ssh.Disconnect();
|
||||
Disconnect(leafInput, ssh);
|
||||
|
||||
if (command.ExitStatus != 0)
|
||||
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
|
||||
@@ -145,7 +177,7 @@ namespace LeafWeb.Core.Remote
|
||||
|
||||
using (var scp = GetScpClient())
|
||||
{
|
||||
scp.Connect();
|
||||
Connect(leafInput, scp);
|
||||
string outputFileType = string.Empty;
|
||||
foreach (var filePath in filePaths)
|
||||
{
|
||||
@@ -168,7 +200,7 @@ namespace LeafWeb.Core.Remote
|
||||
}
|
||||
}
|
||||
|
||||
scp.Disconnect();
|
||||
Disconnect(leafInput, scp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +208,11 @@ namespace LeafWeb.Core.Remote
|
||||
{
|
||||
using (var ssh = GetSshClient())
|
||||
{
|
||||
ssh.Connect();
|
||||
Connect(leafInput, ssh);
|
||||
var commandText = $"{RemoteScriptPath} -d {leafInput.PiscalDirectoryName} -c";
|
||||
var command = ssh.CreateCommand(commandText);
|
||||
command.Execute();
|
||||
ssh.Disconnect();
|
||||
Disconnect(leafInput, ssh);
|
||||
|
||||
if (command.ExitStatus != 0)
|
||||
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
|
||||
|
||||
Reference in New Issue
Block a user