Adding LeafInput

This commit is contained in:
2016-01-11 23:11:38 -05:00
parent df8256f09b
commit 79baded8b1
14 changed files with 153 additions and 8 deletions
@@ -140,8 +140,9 @@ namespace LeafWeb.Core.Tests.Parsers
public void Parse_FindIssues() public void Parse_FindIssues()
{ {
var dir = @"C:\Users\poprhythm\Documents\code\LeafWeb\Notes\leafweb database work\newcurves\RemovableDisk\curves"; var dir = @"C:\Users\poprhythm\Documents\code\LeafWeb\Notes\leafweb database work\newcurves\RemovableDisk\curves";
var files = Directory.GetFiles(dir, "*.csv").Select(f => new FileInfo(f)); var files = Directory.GetFiles(dir, "*.csv").Select(f => new FileInfo(f)).ToList();
var leafInputs = new List<LeafInput>(); var leafInputs = new List<LeafInput>();
var num = 1;
foreach (var file in files) foreach (var file in files)
{ {
try try
@@ -149,10 +150,11 @@ namespace LeafWeb.Core.Tests.Parsers
var parser = new LeafInputCsvParser(file); var parser = new LeafInputCsvParser(file);
var leafInput = parser.Parse(); var leafInput = parser.Parse();
leafInputs.Add(leafInput); leafInputs.Add(leafInput);
//Console.WriteLine("{0}, {1}, {2}", leafInput.FileName, leafInput.InvestigatorName, leafInput.ContactInformation); Console.WriteLine("{3}/{4}, {0}, {1}, {2}", leafInput.FileName, leafInput.InvestigatorName, leafInput.ContactInformation, num++, files.Count);
} }
catch (Exception ex) catch (Exception ex)
{ {
File.AppendAllLines(@"C:\Temp\errors.txt", new[] { string.Format("{1} : {0}", ex.Message, file.Name) });
Console.WriteLine("{1} : {0}", ex.Message, file.Name); Console.WriteLine("{1} : {0}", ex.Message, file.Name);
} }
} }
+1
View File
@@ -4,6 +4,7 @@ using System.Linq;
namespace LeafWeb.Core.Models namespace LeafWeb.Core.Models
{ {
/// <summary> /// <summary>
/// Part of LeafOutput
/// The file 'cntrlcomparison.csv', which is in comma-separated-value format, contains outputs from PISCAL that /// The file 'cntrlcomparison.csv', which is in comma-separated-value format, contains outputs from PISCAL that
/// facilitates examination of how well the fitting is. /// facilitates examination of how well the fitting is.
/// </summary> /// </summary>
-1
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using CsvHelper; using CsvHelper;
using CsvHelper.Configuration; using CsvHelper.Configuration;
+13 -1
View File
@@ -1,4 +1,5 @@
using System.Globalization; using System;
using System.Globalization;
using System.Linq; using System.Linq;
namespace LeafWeb.Core.Utility namespace LeafWeb.Core.Utility
@@ -12,5 +13,16 @@ namespace LeafWeb.Core.Utility
(current, c) => (current, c) =>
current + (char.IsUpper(c) && current.Length > 0 ? " " + c : c.ToString(CultureInfo.InvariantCulture))); current + (char.IsUpper(c) && current.Length > 0 ? " " + c : c.ToString(CultureInfo.InvariantCulture)));
} }
public static string LowercaseFirst(string s)
{
// Check for empty string.
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}
// Return char and concat substring.
return char.ToLowerInvariant(s[0]) + s.Substring(1);
}
} }
} }
+19
View File
@@ -0,0 +1,19 @@
using System.Web.Mvc;
using LeafWeb.Web.ViewModels.LeafInput;
namespace LeafWeb.Web.Controllers
{
public class LeafInputController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(CreateViewModel viewModel)
{
return View();
}
}
}
@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web;
namespace LeafWeb.Web.ViewModels.LeafInput
{
public class CreateViewModel
{
[Required]
[Display(Name = "Your name")]
public string Name { get; set; }
[Required]
[Display(Name = "Your email address")]
public string Email { get; set; }
[Required]
[Display(Name = "A unique identifier for this data")]
public string LeafInputId { get; set; }
[Required]
[Display(Name = "The site's name/Fluxnet ID, if known")]
public string SiteID { get; set; }
[Required]
[UIHint("HttpPostedFileBase")]
public HttpPostedFileBase Files { get; set; }
}
}
+17
View File
@@ -0,0 +1,17 @@
@model LeafWeb.Web.ViewModels.LeafInput.CreateViewModel
<h1>Submitting Data and Retrieving EDO Results</h1>
<p>
There is no limit on the number of files you may submit for analysis. Keep selecting files and hitting the Add button until all of the files you need to upload are shown in the list. Then enter an identifier for this set of data and click the Upload button.
</p>
@using (Html.BeginForm("Index", "LeafInput", FormMethod.Post, new { @class = "form-horizontal well" }))
{
@Html.Partial("_ValidationSummary")
<fieldset>
<legend></legend>
@Html.EditorForModel()
<div class="form-actions">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</fieldset>
}
@@ -0,0 +1,5 @@
@model HttpPostedFileBase
@{
Layout = "~/Views/Shared/EditorTemplates/_FieldLayout.cshtml";
}
<input type="file" name="@ViewData.ModelMetadata.PropertyName" />
@@ -0,0 +1,5 @@
@{
Layout = "~/Views/Shared/EditorTemplates/_FieldLayout.cshtml";
}
@Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue)
@@ -0,0 +1,41 @@
@{
Layout = null;
var lowerPropertyName = @LeafWeb.Core.Utility.StringExtensions.LowercaseFirst(ViewData.ModelMetadata.PropertyName);
var values = ViewData.ModelMetadata.AdditionalValues;
var units = values.ContainsKey("Units") ? (string)values["Units"] : null;
var currency = values.ContainsKey("Currency") ? (string)values["Currency"] : null;
var formatHint = values.ContainsKey("FormatHint") ? (string)values["FormatHint"] : null;
var editLabel = values.ContainsKey("EditLabel") ? (bool)values["EditLabel"] : true;
}
@RenderBody()
@*<div class="form-group @lowerPropertyName">
@if (editLabel)
{
@Html.LabelForModel()
}
<div class="input-group">
@if (!string.IsNullOrEmpty(units))
{
<div class="input-append">
@RenderBody()
<span class="add-on">@units</span>
</div>
}
else if (!string.IsNullOrEmpty(currency))
{
<div class="input-prepend">
<span class="add-on">@currency</span>
@RenderBody()
</div>
}
else
{
@RenderBody()
}
@if (!string.IsNullOrEmpty(formatHint))
{
<div><small><em>@formatHint</em></small></div>
}
<span class="help-block">@Html.ValidationMessage("")</span>
</div>
</div>*@
+3 -3
View File
@@ -30,9 +30,9 @@
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Leaf Data <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Leaf Data <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Leaf Input</a></li> <li><a href="/LeafInput">Leaf Input</a></li>
<li><a href="#">Leaf Output</a></li> <li><a href="/LeafOutput">Leaf Output</a></li>
<li><a href="/Pages/LeafCharter">Leaf Charts</a></li> <li><a href="/LeafCharter">Leaf Charts</a></li>
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">
@@ -0,0 +1,7 @@
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Any())
{
<div class="alert alert-error">
<a class="close" data-dismiss="alert">×</a>
@Html.ValidationSummary(true)
</div>
}
+1 -1
View File
@@ -26,7 +26,7 @@
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+7
View File
@@ -144,11 +144,13 @@
<Compile Include="App_Start\RouteConfig.cs" /> <Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Charter\LeafWebCharter.cs" /> <Compile Include="Charter\LeafWebCharter.cs" />
<Compile Include="Controllers\LeafCharterController.cs" /> <Compile Include="Controllers\LeafCharterController.cs" />
<Compile Include="Controllers\LeafInputController.cs" />
<Compile Include="Controllers\PagesController.cs" /> <Compile Include="Controllers\PagesController.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\LeafInput\CreateViewModel.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\web.config" /> <Content Include="Views\web.config" />
@@ -163,6 +165,11 @@
<Content Include="Views\Pages\DataRequirements.cshtml" /> <Content Include="Views\Pages\DataRequirements.cshtml" />
<Content Include="Scripts\jquery-1.9.1.min.map" /> <Content Include="Scripts\jquery-1.9.1.min.map" />
<Content Include="Views\LeafCharter\Index.cshtml" /> <Content Include="Views\LeafCharter\Index.cshtml" />
<Content Include="Views\LeafInput\Index.cshtml" />
<Content Include="Views\Shared\_ValidationSummary.cshtml" />
<Content Include="Views\Shared\EditorTemplates\_FieldLayout.cshtml" />
<Content Include="Views\Shared\EditorTemplates\HttpPostedFileBase.cshtml" />
<Content Include="Views\Shared\EditorTemplates\String.cshtml" />
<None Include="Web.Debug.config"> <None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon> <DependentUpon>Web.config</DependentUpon>
</None> </None>