diff --git a/Core/Parsers/CntrlComparisonParser.cs b/Core/Parsers/CntrlComparisonParser.cs index 91959e0..6e0c8d7 100644 --- a/Core/Parsers/CntrlComparisonParser.cs +++ b/Core/Parsers/CntrlComparisonParser.cs @@ -12,6 +12,10 @@ namespace LeafWeb.Core.Parsers { } + public CntrlComparisonParser(byte[] fileContents) : base(fileContents) + { + } + public CntrlComparison[] Parse() { var fittingTitles = GetNextCsvRowValues(); diff --git a/Core/Parsers/CsvParserBase.cs b/Core/Parsers/CsvParserBase.cs index dfa65c7..0ad9ac7 100644 --- a/Core/Parsers/CsvParserBase.cs +++ b/Core/Parsers/CsvParserBase.cs @@ -2,12 +2,14 @@ using System; using System.IO; using CsvHelper; using CsvHelper.Configuration; +using LeafWeb.Core.Utility; namespace LeafWeb.Core.Parsers { public class CsvParserBase : IDisposable { private readonly StreamReader _reader; + private readonly MemoryStream _memoryStream; protected readonly CsvReader CsvReader; protected CsvParserBase(FileSystemInfo csvFile) @@ -17,6 +19,15 @@ namespace LeafWeb.Core.Parsers 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) { if (!csvFile.Exists) @@ -37,6 +48,8 @@ namespace LeafWeb.Core.Parsers public void Dispose() { _reader.Dispose(); + if (_memoryStream != null) + _memoryStream.Dispose(); } } } \ No newline at end of file diff --git a/Web/Charter/LeafWebCharter.cs b/Web/Charter/LeafWebCharter.cs index 5aacff1..c8b0f49 100644 --- a/Web/Charter/LeafWebCharter.cs +++ b/Web/Charter/LeafWebCharter.cs @@ -10,11 +10,11 @@ namespace LeafWeb.Web.Charter { public static class LeafWebCharter { - private static readonly Font TitleFont = new Font("Times New Roman", 10, FontStyle.Bold); - private static readonly Font AxisFont = 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(new FontFamily("Times New Roman"), 10, FontStyle.Bold); private static readonly Font Font = new Font(new FontFamily("Trebuchet MS"), 9, FontStyle.Bold); - private const int ChartWidth = 550; - private const int ChartHeight = 400; + public const int ChartWidth = 550; + public const int ChartHeight = 400; // cntrlcomparison public static IEnumerable ProduceCharts(CurveData curve) diff --git a/Web/Controllers/LeafCharterController.cs b/Web/Controllers/LeafCharterController.cs index 4b6f9ea..959e685 100644 --- a/Web/Controllers/LeafCharterController.cs +++ b/Web/Controllers/LeafCharterController.cs @@ -12,19 +12,22 @@ using LeafWeb.Web.Charter; namespace LeafWeb.Web.Controllers { - public class LeafCharterController : Controller - { - public ActionResult Index() + public class LeafCharterController : ControllerBase + { + 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; - using (var parser = new CntrlComparisonParser(fileInfo)) + CntrlComparison[] cntrlComparison; + using (var parser = new CntrlComparisonParser(leafOutputFile.Contents)) cntrlComparison = parser.Parse(); var curveData = CurveDataConverter.Convert(cntrlComparison).ToArray(); diff --git a/Web/Views/LeafCharter/Index.cshtml b/Web/Views/LeafCharter/Index.cshtml index 3d42a7a..f3bc429 100644 --- a/Web/Views/LeafCharter/Index.cshtml +++ b/Web/Views/LeafCharter/Index.cshtml @@ -1,8 +1,7 @@ -image -image -image -image -image -image -image -image \ No newline at end of file +@using LeafWeb.Web.Charter +@model int + +@for (int i = 0; i < 8; i++) +{ + image +} \ No newline at end of file diff --git a/Web/Views/LeafOutput/Index.cshtml b/Web/Views/LeafOutput/Index.cshtml index 9890038..baabab8 100644 --- a/Web/Views/LeafOutput/Index.cshtml +++ b/Web/Views/LeafOutput/Index.cshtml @@ -5,7 +5,7 @@ var grid = new WebGrid(Model, rowsPerPage: 45); } -

Results

+

Result Status

@grid.GetHtml(columns: grid.Columns( @@ -13,7 +13,8 @@ grid.Column("LeafInputSiteId", "Site Id"), grid.Column("LeafInputFilename", "Filename"), 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" } ) diff --git a/Web/Views/Shared/_Layout.cshtml b/Web/Views/Shared/_Layout.cshtml index e26c8fb..a38b24e 100644 --- a/Web/Views/Shared/_Layout.cshtml +++ b/Web/Views/Shared/_Layout.cshtml @@ -30,9 +30,8 @@