Add PhotosynthesisType and start SSH work
modified: Core.Tests/Core.Tests.csproj modified: Core.Tests/Parsers/FluxnetSiteCsvParserTests.cs new file: Core.Tests/Remote/PiscalSshClientTests.cs modified: Core/Core.csproj modified: Core/DAL/LeafWebContext.cs modified: Core/DAL/LeafWebInitializer.cs modified: Core/Models/LeafInput.cs new file: Core/Models/PhotosynthesisType.cs new file: Core/Remote/IPiscalClient.cs Get Piscal
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using LeafWeb.Core.Models;
|
||||
using Renci.SshNet;
|
||||
|
||||
namespace LeafWeb.Core
|
||||
{
|
||||
public interface IPiscalClient
|
||||
{
|
||||
void SubmitLeafInputFile(LeafInputFile file);
|
||||
void RetrieveLeafInputResult();
|
||||
}
|
||||
|
||||
public class PiscalSshClient : IPiscalClient
|
||||
{
|
||||
private SshClient GetSshClient()
|
||||
{
|
||||
return new SshClient("40.76.47.173", "piscaladmin", "password");
|
||||
}
|
||||
private ScpClient GetScpClient()
|
||||
{
|
||||
return new ScpClient("40.76.47.173", "piscaladmin", "password");
|
||||
}
|
||||
|
||||
public void SubmitLeafInputFile(LeafInputFile file)
|
||||
{
|
||||
using (var scp = GetScpClient())
|
||||
using (var stream = new MemoryStream(file.Contents))
|
||||
{
|
||||
scp.Connect();
|
||||
scp.Upload(stream, file.Filename);
|
||||
}
|
||||
|
||||
using (var ssh = GetSshClient())
|
||||
{
|
||||
ssh.Connect();
|
||||
var cmd = ssh.CreateCommand("ps");
|
||||
cmd.Execute();
|
||||
//var extendedData = Encoding.ASCII.GetString(cmd.ExtendedOutputStream.ToArray());
|
||||
var extendedData = new StreamReader(cmd.ExtendedOutputStream, Encoding.ASCII).ReadToEnd();
|
||||
ssh.Disconnect();
|
||||
|
||||
Console.Write(cmd.Result);
|
||||
Console.Write(extendedData);
|
||||
//Assert.AreEqual("12345\n", cmd.Result);
|
||||
//Assert.AreEqual("654321\n", extendedData);
|
||||
}
|
||||
// copy file
|
||||
|
||||
// begin processing
|
||||
}
|
||||
|
||||
public void RetrieveLeafInputResult()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user