Leaf Charter integration
This commit is contained in:
@@ -12,6 +12,10 @@ namespace LeafWeb.Core.Parsers
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CntrlComparisonParser(byte[] fileContents) : base(fileContents)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public CntrlComparison[] Parse()
|
public CntrlComparison[] Parse()
|
||||||
{
|
{
|
||||||
var fittingTitles = GetNextCsvRowValues();
|
var fittingTitles = GetNextCsvRowValues();
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using CsvHelper;
|
using CsvHelper;
|
||||||
using CsvHelper.Configuration;
|
using CsvHelper.Configuration;
|
||||||
|
using LeafWeb.Core.Utility;
|
||||||
|
|
||||||
namespace LeafWeb.Core.Parsers
|
namespace LeafWeb.Core.Parsers
|
||||||
{
|
{
|
||||||
public class CsvParserBase : IDisposable
|
public class CsvParserBase : IDisposable
|
||||||
{
|
{
|
||||||
private readonly StreamReader _reader;
|
private readonly StreamReader _reader;
|
||||||
|
private readonly MemoryStream _memoryStream;
|
||||||
protected readonly CsvReader CsvReader;
|
protected readonly CsvReader CsvReader;
|
||||||
|
|
||||||
protected CsvParserBase(FileSystemInfo csvFile)
|
protected CsvParserBase(FileSystemInfo csvFile)
|
||||||
@@ -17,6 +19,15 @@ namespace LeafWeb.Core.Parsers
|
|||||||
CsvReader = new CsvReader(_reader, csvConfiguration);
|
CsvReader = new CsvReader(_reader, csvConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected CsvParserBase(byte[] fileContents)
|
||||||
|
{
|
||||||
|
_memoryStream = new MemoryStream(fileContents);
|
||||||
|
_reader = new StreamReader(_memoryStream);
|
||||||
|
|
||||||
|
var csvConfiguration = new CsvConfiguration { HasHeaderRecord = false, IgnoreBlankLines = false, IgnoreReadingExceptions = true };
|
||||||
|
CsvReader = new CsvReader(_reader, csvConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
internal static StreamReader OpenCsv(FileSystemInfo csvFile)
|
internal static StreamReader OpenCsv(FileSystemInfo csvFile)
|
||||||
{
|
{
|
||||||
if (!csvFile.Exists)
|
if (!csvFile.Exists)
|
||||||
@@ -37,6 +48,8 @@ namespace LeafWeb.Core.Parsers
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_reader.Dispose();
|
_reader.Dispose();
|
||||||
|
if (_memoryStream != null)
|
||||||
|
_memoryStream.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,11 +10,11 @@ namespace LeafWeb.Web.Charter
|
|||||||
{
|
{
|
||||||
public static class LeafWebCharter
|
public static class LeafWebCharter
|
||||||
{
|
{
|
||||||
private static readonly Font TitleFont = new Font("Times New Roman", 10, FontStyle.Bold);
|
private static readonly Font TitleFont = new Font(new FontFamily("Times New Roman"), 10, FontStyle.Bold);
|
||||||
private static readonly Font AxisFont = new Font("Times New Roman", 10, FontStyle.Bold);
|
private static readonly Font AxisFont = new Font(new FontFamily("Times New Roman"), 10, FontStyle.Bold);
|
||||||
private static readonly Font Font = new Font(new FontFamily("Trebuchet MS"), 9, FontStyle.Bold);
|
private static readonly Font Font = new Font(new FontFamily("Trebuchet MS"), 9, FontStyle.Bold);
|
||||||
private const int ChartWidth = 550;
|
public const int ChartWidth = 550;
|
||||||
private const int ChartHeight = 400;
|
public const int ChartHeight = 400;
|
||||||
|
|
||||||
// cntrlcomparison
|
// cntrlcomparison
|
||||||
public static IEnumerable<Chart> ProduceCharts(CurveData curve)
|
public static IEnumerable<Chart> ProduceCharts(CurveData curve)
|
||||||
|
|||||||
@@ -12,19 +12,22 @@ using LeafWeb.Web.Charter;
|
|||||||
|
|
||||||
namespace LeafWeb.Web.Controllers
|
namespace LeafWeb.Web.Controllers
|
||||||
{
|
{
|
||||||
public class LeafCharterController : Controller
|
public class LeafCharterController : ControllerBase
|
||||||
{
|
{
|
||||||
public ActionResult Index()
|
public ActionResult Index(int leafInputFileId)
|
||||||
{
|
{
|
||||||
return View();
|
return View(leafInputFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult LeafCharts(int number)
|
public ActionResult LeafCharts(int leafInputFileId, int number)
|
||||||
{
|
{
|
||||||
var fileInfo = new FileInfo(@"C:\Users\poprhythm\Documents\code\LeafWeb\Core.Tests\Parsers\LeafOutputData\cntrlcomparison_Wild Capsicum.csv");
|
var leafInputFile = DataService.GetLeafInputFile(leafInputFileId);
|
||||||
|
var leafOutputFile = leafInputFile.LeafOutputFiles.FirstOrDefault(f => f.Filename.StartsWith("cntrlcomparison"));
|
||||||
|
//if (leafOutputFile == null)
|
||||||
|
// return View(); // TODO: break
|
||||||
|
|
||||||
CntrlComparison[] cntrlComparison;
|
CntrlComparison[] cntrlComparison;
|
||||||
using (var parser = new CntrlComparisonParser(fileInfo))
|
using (var parser = new CntrlComparisonParser(leafOutputFile.Contents))
|
||||||
cntrlComparison = parser.Parse();
|
cntrlComparison = parser.Parse();
|
||||||
|
|
||||||
var curveData = CurveDataConverter.Convert(cntrlComparison).ToArray();
|
var curveData = CurveDataConverter.Convert(cntrlComparison).ToArray();
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<img src="@Url.Action("LeafCharts", new {number=0})" alt="image" />
|
@using LeafWeb.Web.Charter
|
||||||
<img src="@Url.Action("LeafCharts", new {number=1})" alt="image" />
|
@model int
|
||||||
<img src="@Url.Action("LeafCharts", new {number=2})" alt="image" />
|
|
||||||
<img src="@Url.Action("LeafCharts", new {number=3})" alt="image" />
|
@for (int i = 0; i < 8; i++)
|
||||||
<img src="@Url.Action("LeafCharts", new {number=4})" alt="image" />
|
{
|
||||||
<img src="@Url.Action("LeafCharts", new {number=5})" alt="image" />
|
<img src="@Url.Action("LeafCharts", new {leafInputFileId = Model, number=@i})" alt="image" height="@LeafWebCharter.ChartHeight" width="@LeafWebCharter.ChartWidth" />
|
||||||
<img src="@Url.Action("LeafCharts", new {number=6})" alt="image" />
|
}
|
||||||
<img src="@Url.Action("LeafCharts", new {number=7})" alt="image" />
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
var grid = new WebGrid(Model, rowsPerPage: 45);
|
var grid = new WebGrid(Model, rowsPerPage: 45);
|
||||||
}
|
}
|
||||||
|
|
||||||
<h1>Results</h1>
|
<h1>Result Status</h1>
|
||||||
|
|
||||||
@grid.GetHtml(columns:
|
@grid.GetHtml(columns:
|
||||||
grid.Columns(
|
grid.Columns(
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
grid.Column("LeafInputSiteId", "Site Id"),
|
grid.Column("LeafInputSiteId", "Site Id"),
|
||||||
grid.Column("LeafInputFilename", "Filename"),
|
grid.Column("LeafInputFilename", "Filename"),
|
||||||
grid.Column("LeafInputName", "Submitted By"),
|
grid.Column("LeafInputName", "Submitted By"),
|
||||||
grid.Column("CurrentStatus", "Status")
|
grid.Column("CurrentStatus", "Status"),
|
||||||
|
grid.Column("Chart", "Chart", item => @Html.ActionLink("Chart", "Index", "LeafCharter", new { leafInputFileId = item.LeafInputFileId}, new {}))
|
||||||
),
|
),
|
||||||
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed" }
|
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed" }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -30,9 +30,8 @@
|
|||||||
<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="/LeafInput">Leaf Input</a></li>
|
<li><a href="/LeafInput">Submit Data</a></li>
|
||||||
<li><a href="/LeafOutput">Leaf Output</a></li>
|
<li><a href="/LeafOutput">Result Status</a></li>
|
||||||
<li><a href="/LeafCharter">Leaf Charts</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
Reference in New Issue
Block a user