Add backload for multiple file upload
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
<Compile Include="Models\CntrlComparisonPhotosyntheticInfo.cs" />
|
||||
<Compile Include="Models\FluxnetSite.cs" />
|
||||
<Compile Include="Models\LeafInput.cs" />
|
||||
<Compile Include="Models\LeafInputInfo.cs" />
|
||||
<Compile Include="Models\LeafInputData.cs" />
|
||||
<Compile Include="Models\LeafInputFile.cs" />
|
||||
<Compile Include="Models\LeafInputPhotosynthetic.cs" />
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
public class FluxnetSite
|
||||
{
|
||||
public string FluxnetId { get; set; }
|
||||
|
||||
public string SiteName { get; set; }
|
||||
|
||||
public string Country { get; set; }
|
||||
|
||||
public string LandUnit { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+15
-40
@@ -1,55 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LeafWeb.Core.Parsers;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Descriptive information about the investigator,
|
||||
/// contact information, the site,the sample leaf and its general environmental condition
|
||||
/// </summary>
|
||||
public class LeafInput
|
||||
{
|
||||
[Key]
|
||||
public string LeafInputId { get; set; }
|
||||
public int LeafInputId { get; set; }
|
||||
|
||||
public string FileName { get; set; }
|
||||
public virtual IEnumerable<LeafInputFile> LeafInputFiles { get; set; }
|
||||
|
||||
[ParseInfo(1, exampleValue: "First and last name")]
|
||||
public string InvestigatorName { get; set; }
|
||||
[Required(ErrorMessage = "Name required")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[ParseInfo(2, exampleValue: "Your email / mail addresses")]
|
||||
public string ContactInformation { get; set; }
|
||||
[Required(ErrorMessage = "An email address is required")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[ParseInfo(3, alternateTitle: "Site name in full", exampleValue: "Your site's identifier / name")]
|
||||
public string SiteName { get; set; }
|
||||
[Required(ErrorMessage = "A unique identifier is required")]
|
||||
public string Identifier { get; set; }
|
||||
|
||||
[ParseInfo(4, exampleValue: "Mixed forest / grasslands / croplands/ etc")]
|
||||
public string VegetationType { get; set; }
|
||||
[Required(ErrorMessage = "")]
|
||||
public string SiteId { get; set; }
|
||||
|
||||
[ParseInfo(5, exampleValue: "Soil type at your site")]
|
||||
public string SoilType { get; set; }
|
||||
|
||||
[ParseInfo(6, exampleValue: "List of major species at the site")]
|
||||
public string MajorSpecies { get; set; }
|
||||
|
||||
[ParseInfo(7,
|
||||
alternateTitle: "Sample leaf light environment",
|
||||
exampleValue: "The general light environment in which the leaf is in (e.g. heavily shaded from above)")]
|
||||
public string SampleLeafLightEnv { get; set; }
|
||||
|
||||
[ParseInfo(8, exampleValue: "Indicate whether there is water stress at the time of sampling")]
|
||||
public string WaterStressAssessment { get; set; }
|
||||
|
||||
[ParseInfo(9, exampleValue: "For example - Licor-6400")]
|
||||
public string InstrumentUsed { get; set; }
|
||||
|
||||
[ParseInfo(10, exampleValue: "Any extra information you feel would be helpful to put the sampled leaf in context")]
|
||||
public string ExtraInfo { get; set; }
|
||||
|
||||
public virtual LeafInputSite Site { get; set; }
|
||||
public virtual LeafInputPhotosynthetic Photosynthetic { get; set; }
|
||||
public virtual IEnumerable<LeafInputData> Data { get; set; }
|
||||
[DataType(DataType.Date)]
|
||||
[Required]
|
||||
public DateTime Created { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LeafWeb.Core.Parsers;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Models
|
||||
@@ -9,6 +8,11 @@ namespace LeafWeb.Core.Models
|
||||
/// </summary>
|
||||
public class LeafInputData
|
||||
{
|
||||
[Key]
|
||||
public int LeafInputDataId { get; set; }
|
||||
|
||||
public virtual LeafInputInfo LeafInputInfo { get; set; }
|
||||
|
||||
public int ListOrder { get; set; }
|
||||
|
||||
/// <summary>the data point No.</summary>
|
||||
@@ -140,7 +144,5 @@ namespace LeafWeb.Core.Models
|
||||
/// <summary>atmospheric O2 partial pressure</summary>
|
||||
[ParseInfo(31, units: "Pa")]
|
||||
public double? OxygenPress { get; set; }
|
||||
|
||||
public virtual LeafInput LeafInput { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,14 @@ namespace LeafWeb.Core.Models
|
||||
public class LeafInputFile
|
||||
{
|
||||
[Key]
|
||||
public string LeafInputId { get; set; }
|
||||
public byte[] File { get; set; }
|
||||
public int LeafInputFileId { get; set; }
|
||||
|
||||
public virtual LeafInput LeafInput { get; set; }
|
||||
|
||||
public virtual LeafInputInfo LeafInputInfo { get; set; }
|
||||
|
||||
public string Filename { get; set; }
|
||||
|
||||
public byte[] Contents { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Descriptive information about the investigator,
|
||||
/// contact information, the site,the sample leaf and its general environmental condition
|
||||
/// </summary>
|
||||
public class LeafInputInfo
|
||||
{
|
||||
[Key]
|
||||
public int LeafInputInfoId { get; set; }
|
||||
|
||||
public virtual LeafInputSite Site { get; set; }
|
||||
public virtual LeafInputPhotosynthetic Photosynthetic { get; set; }
|
||||
public virtual IEnumerable<LeafInputData> Data { get; set; }
|
||||
|
||||
[ParseInfo(1, exampleValue: "First and last name")]
|
||||
public string InvestigatorName { get; set; }
|
||||
|
||||
[ParseInfo(2, exampleValue: "Your email / mail addresses")]
|
||||
public string ContactInformation { get; set; }
|
||||
|
||||
[ParseInfo(3, alternateTitle: "Site name in full", exampleValue: "Your site's identifier / name")]
|
||||
public string SiteName { get; set; }
|
||||
|
||||
[ParseInfo(4, exampleValue: "Mixed forest / grasslands / croplands/ etc")]
|
||||
public string VegetationType { get; set; }
|
||||
|
||||
[ParseInfo(5, exampleValue: "Soil type at your site")]
|
||||
public string SoilType { get; set; }
|
||||
|
||||
[ParseInfo(6, exampleValue: "List of major species at the site")]
|
||||
public string MajorSpecies { get; set; }
|
||||
|
||||
[ParseInfo(7,
|
||||
alternateTitle: "Sample leaf light environment",
|
||||
exampleValue: "The general light environment in which the leaf is in (e.g. heavily shaded from above)")]
|
||||
public string SampleLeafLightEnv { get; set; }
|
||||
|
||||
[ParseInfo(8, exampleValue: "Indicate whether there is water stress at the time of sampling")]
|
||||
public string WaterStressAssessment { get; set; }
|
||||
|
||||
[ParseInfo(9, exampleValue: "For example - Licor-6400")]
|
||||
public string InstrumentUsed { get; set; }
|
||||
|
||||
[ParseInfo(10, exampleValue: "Any extra information you feel would be helpful to put the sampled leaf in context")]
|
||||
public string ExtraInfo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using LeafWeb.Core.Parsers;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LeafWeb.Core.Parsers;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Models
|
||||
@@ -8,6 +9,11 @@ namespace LeafWeb.Core.Models
|
||||
/// </summary>
|
||||
public class LeafInputPhotosynthetic
|
||||
{
|
||||
[Key]
|
||||
public int LeafInputPhotosyntheticId { get; set; }
|
||||
|
||||
public virtual LeafInputInfo LeafInputInfo { get; set; }
|
||||
|
||||
/// <summary>chloroplastic CO2 photocompensation point</summary>
|
||||
/// <remarks>must be positive</remarks>
|
||||
[ParseInfo(1, alternateTitle:"Gamma*", units: "Pa")]
|
||||
@@ -36,7 +42,5 @@ namespace LeafWeb.Core.Models
|
||||
/// <summary>internal (also known as mesophyll) conductance</summary>
|
||||
[ParseInfo(6, units: "umol/m2/s/Pa")]
|
||||
public double gi { get; set; }
|
||||
|
||||
public virtual LeafInput LeafInput { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using LeafWeb.Core.Parsers;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using LeafWeb.Core.Parsers;
|
||||
using LeafWeb.Core.Utility;
|
||||
|
||||
namespace LeafWeb.Core.Models
|
||||
@@ -8,10 +9,15 @@ namespace LeafWeb.Core.Models
|
||||
/// </summary>
|
||||
public class LeafInputSite
|
||||
{
|
||||
[Key]
|
||||
public int LeafInputSiteId { get; set; }
|
||||
|
||||
public virtual LeafInputInfo LeafInputInfo { get; set; }
|
||||
|
||||
/// <summary>Site identifier</summary>
|
||||
/// <remarks>do not leave blank between letters</remarks>
|
||||
[ParseInfo(1)]
|
||||
public string SiteID { get; set; }
|
||||
public string SiteId { get; set; }
|
||||
|
||||
/// <summary>Site latitude, northern hermisphere positive</summary>
|
||||
[ParseInfo(2, units:"degrees")]
|
||||
@@ -92,6 +98,5 @@ namespace LeafWeb.Core.Models
|
||||
|
||||
// DataType,TissueArea,TissueMass,Fo'_or_Fo,Fm'_or_Fm,Fs,MeasLight
|
||||
|
||||
public virtual LeafInput LeafInput { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,13 @@ namespace LeafWeb.Core.Parsers
|
||||
{
|
||||
}
|
||||
|
||||
public LeafInput Parse()
|
||||
public LeafInputInfo Parse()
|
||||
{
|
||||
// First 10 lines
|
||||
var leafInput = ParseLeafInput();
|
||||
leafInput.FileName = CsvFile.Name;
|
||||
|
||||
// filename will be stored in LeafInputFile
|
||||
//leafInput.FileName = CsvFile.Name;
|
||||
|
||||
// Next 3 (Header, Units, and Values)
|
||||
leafInput.Site = ParseLeafInputSite();
|
||||
@@ -31,7 +33,7 @@ namespace LeafWeb.Core.Parsers
|
||||
return leafInput;
|
||||
}
|
||||
|
||||
private LeafInput ParseLeafInput()
|
||||
private LeafInputInfo ParseLeafInput()
|
||||
{
|
||||
var items = new List<string>();
|
||||
for (var i = 0; i < 10; i++)
|
||||
@@ -44,7 +46,7 @@ namespace LeafWeb.Core.Parsers
|
||||
throw new ParseException("Could not read first field on line number " + CsvReader.Row);
|
||||
items.Add(field);
|
||||
}
|
||||
return ParsedObjectFactory<LeafInput>.Create(items.ToArray());
|
||||
return ParsedObjectFactory<LeafInputInfo>.Create(items.ToArray());
|
||||
}
|
||||
|
||||
private LeafInputSite ParseLeafInputSite()
|
||||
@@ -109,7 +111,7 @@ namespace LeafWeb.Core.Parsers
|
||||
return ParsedObjectFactory<LeafInputData>.Create(titles, valueArrays.ToArray());
|
||||
}
|
||||
|
||||
public static void ExportCsv(string filename, IEnumerable<LeafInput> leafInputs)
|
||||
public static void ExportCsv(string filename, IEnumerable<LeafInputInfo> leafInputs)
|
||||
{
|
||||
using (var textWriter = new StreamWriter(filename))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user