Leaf Input and Submit

This commit is contained in:
2016-12-06 11:53:30 -05:00
parent a3b8b7a881
commit 6fd7e46f5d
74 changed files with 56144 additions and 1291 deletions
+12 -4
View File
@@ -2,8 +2,8 @@ using System.Collections.Generic;
using System.Data.Common;
using System.IO;
using System.Linq;
using log4net;
using LeafWeb.Core.Utility;
using NLog;
using Renci.SshNet;
namespace LeafWeb.Core.Remote
@@ -18,7 +18,7 @@ namespace LeafWeb.Core.Remote
private const string StatusRunning = "running";
private const string StatusNotStarted = "not started";
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly ILog _logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public PiscalSshClient(string connectionString)
{
@@ -49,7 +49,7 @@ namespace LeafWeb.Core.Remote
var inputPath = $"{directory}/input/{file.Filename}";
using (var stream = new MemoryStream(file.Contents))
{
_logger.Trace("Copying " + inputPath);
_logger.Debug("Copying " + inputPath);
scp.Connect();
scp.Upload(stream, inputPath);
scp.Disconnect();
@@ -59,6 +59,9 @@ namespace LeafWeb.Core.Remote
public void RunLeafInput(PiscalLeafInput leafInput)
{
if (string.IsNullOrEmpty(leafInput.PhotosyntheticType))
throw new PiscalClientException(leafInput.LeafInputId, "No PhotosyntheticType set");
var inputDirectory = $"{BaseDirectory}/{leafInput.PiscalDirectoryName}";
CopyLeafInput(leafInput, inputDirectory);
@@ -82,7 +85,11 @@ namespace LeafWeb.Core.Remote
if (command.ExitStatus != 0)
throw new PiscalClientException(leafInput.LeafInputId, command.Error.TrimEndNewLine());
_logger.Debug("RunLeafInput result: " + command.Result.TrimEndNewLine());
var result = command.Result.TrimEndNewLine();
if (result == "started")
_logger.Info($"RunLeafInput result: {result}");
else
_logger.Warn($"RunLeafInput result: {result}, commandText: {commandText}");
}
}
@@ -101,6 +108,7 @@ namespace LeafWeb.Core.Remote
default:
throw new PiscalClientException(leafInput.LeafInputId, "Unknown status: " + statusRaw[0]);
}
}
private string[] GetLeafInputStatusRaw(PiscalLeafInput leafInput)