diff --git a/Core.Tests/Core.Tests.csproj b/Core.Tests/Core.Tests.csproj
index d89f3c2..142d6bd 100644
--- a/Core.Tests/Core.Tests.csproj
+++ b/Core.Tests/Core.Tests.csproj
@@ -48,6 +48,7 @@
+
diff --git a/Core.Tests/Parsers/FluxnetSiteCsvParserTests.cs b/Core.Tests/Parsers/FluxnetSiteCsvParserTests.cs
index 25e30dd..b9042a8 100644
--- a/Core.Tests/Parsers/FluxnetSiteCsvParserTests.cs
+++ b/Core.Tests/Parsers/FluxnetSiteCsvParserTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using LeafWeb.Core.Parsers;
@@ -34,6 +35,17 @@ namespace LeafWeb.Core.Tests.Parsers
}
}
+ [Test]
+ public void Parse_Find_Misencoded_Characters_test()
+ {
+ var fileInfo = new FileInfo(@"C:\Users\poprhythm\Documents\code\LeafWeb\Core\DAL\InitialData\fluxnet_site_list_all_October2015_with_joins_corrected.csv");
+ var parser = new FluxnetSiteCsvParser(fileInfo);
+ foreach (var fns in parser.Parse().Where(f => Regex.IsMatch(f.SiteName, @"[^\x00-\x7F]") || f.SiteName.Contains("?")))
+ {
+ Console.WriteLine($"{fns.FluxnetId} / {fns.SiteName}");
+ }
+ }
+
[Test]
public void Parse_Find_Duplicate_Ids()
{
diff --git a/Core.Tests/Remote/PiscalSshClientTests.cs b/Core.Tests/Remote/PiscalSshClientTests.cs
new file mode 100644
index 0000000..be0612f
--- /dev/null
+++ b/Core.Tests/Remote/PiscalSshClientTests.cs
@@ -0,0 +1,17 @@
+using LeafWeb.Core.Models;
+using NUnit.Framework;
+
+namespace LeafWeb.Core.Tests.Remote
+{
+ [TestFixture]
+ public class PiscalSshClientTests
+ {
+ [Test]
+ public void Client()
+ {
+ var leafInputFile = new LeafInputFile {Filename = "blah", Id = 1};
+ var client = new PiscalSshClient();
+ client.SubmitLeafInputFile(leafInputFile);
+ }
+ }
+}
diff --git a/Core/Core.csproj b/Core/Core.csproj
index ac6f7a6..17fab8e 100644
--- a/Core/Core.csproj
+++ b/Core/Core.csproj
@@ -67,6 +67,8 @@
+
+
diff --git a/Core/DAL/LeafWebContext.cs b/Core/DAL/LeafWebContext.cs
index 81fd45b..480a8df 100644
--- a/Core/DAL/LeafWebContext.cs
+++ b/Core/DAL/LeafWebContext.cs
@@ -10,6 +10,7 @@ namespace LeafWeb.Core.DAL
public DbSet LeafInputFiles { get; set; }
public DbSet LeafInputStatus { get; set; }
public DbSet FluxnetSites { get; set; }
+ public DbSet PhotosynthesisTypes { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
diff --git a/Core/DAL/LeafWebInitializer.cs b/Core/DAL/LeafWebInitializer.cs
index 6a4fd53..c0a66b8 100644
--- a/Core/DAL/LeafWebInitializer.cs
+++ b/Core/DAL/LeafWebInitializer.cs
@@ -1,5 +1,6 @@
using System.Data.Entity;
using System.Linq;
+using LeafWeb.Core.Models;
using LeafWeb.Core.Parsers;
using LeafWeb.Core.Utility;
@@ -18,6 +19,16 @@ namespace LeafWeb.Core.DAL
// add to context
fluxnetSites.ForEach(s => context.FluxnetSites.Add(s));
+
+ var photosynthesisTypes = new []
+ {
+ new PhotosynthesisType {Id = "C3_photosynthesis_leafweb", Name = "C3 Photosynthesis"},
+ new PhotosynthesisType {Id = "C4_photosynthesis_leafweb", Name = "C4 Photosynthesis"},
+ new PhotosynthesisType {Id = "CAM_photosynthesis_leafweb", Name = "CAM Photosynthesis"}
+ };
+
+ context.PhotosynthesisTypes.AddRange(photosynthesisTypes);
+
context.SaveChanges();
base.Seed(context);
diff --git a/Core/Models/LeafInput.cs b/Core/Models/LeafInput.cs
index 00bf975..5fc672a 100644
--- a/Core/Models/LeafInput.cs
+++ b/Core/Models/LeafInput.cs
@@ -23,6 +23,8 @@ namespace LeafWeb.Core.Models
[Required(ErrorMessage = "")]
public string SiteId { get; set; }
+ public virtual PhotosynthesisType Photosynthesis { get; set; }
+
[DataType(DataType.Date)]
[Required]
public DateTime Created { get; set; }
diff --git a/Core/Models/PhotosynthesisType.cs b/Core/Models/PhotosynthesisType.cs
new file mode 100644
index 0000000..2d16b09
--- /dev/null
+++ b/Core/Models/PhotosynthesisType.cs
@@ -0,0 +1,14 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace LeafWeb.Core.Models
+{
+ public class PhotosynthesisType
+ {
+ [Key]
+ [DatabaseGenerated(DatabaseGeneratedOption.None)]
+ public string Id { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/Core/Remote/IPiscalClient.cs b/Core/Remote/IPiscalClient.cs
new file mode 100644
index 0000000..8de0923
--- /dev/null
+++ b/Core/Remote/IPiscalClient.cs
@@ -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();
+ }
+ }
+}