Add CurveId Selection for charter
This commit is contained in:
@@ -11,6 +11,7 @@ using LeafWeb.Core.Charter;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Parsers;
|
||||
using LeafWeb.Web.Charter;
|
||||
using LeafWeb.Web.ViewModels.LeafCharter;
|
||||
|
||||
namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
@@ -18,16 +19,25 @@ namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
public ActionResult Index(int leafInputId)
|
||||
{
|
||||
var hasLeafOutputFile =
|
||||
var leafOutputFile =
|
||||
DataService
|
||||
.GetLeafInput(leafInputId)?
|
||||
.OutputFiles?
|
||||
.FirstOrDefault(f => f.IsLeafChartFile) != null;
|
||||
.FirstOrDefault(f => f.IsLeafChartFile);
|
||||
|
||||
return View(leafInputId);
|
||||
if (leafOutputFile == null)
|
||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||
|
||||
var curveData = GetCurveData(leafOutputFile.Contents);
|
||||
|
||||
var curveIds = curveData.Select(c => c.CurveId).ToList();
|
||||
|
||||
var viewModel = new LeafCharterViewModel {AvailableCurveId = curveIds, LeafInputId = leafInputId};
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
public ActionResult LeafCharts(int leafInputId)
|
||||
public ActionResult LeafCharts(int leafInputId, string curveId)
|
||||
{
|
||||
var leafOutputFile =
|
||||
DataService
|
||||
@@ -40,7 +50,12 @@ namespace LeafWeb.Web.Controllers
|
||||
|
||||
var curveData = GetCurveData(leafOutputFile.Contents);
|
||||
|
||||
var charts = GetChartBitmaps(curveData).ToList();
|
||||
var curveIdData = curveData.FirstOrDefault(c => c.CurveId == curveId);
|
||||
|
||||
if (curveIdData == null)
|
||||
return File("/Content/favicon/apple-icon-57x57.png", "image/png");
|
||||
|
||||
var charts = GetChartBitmaps(curveIdData).ToList();
|
||||
|
||||
var combinedChart = CombineBitmaps(charts);
|
||||
|
||||
@@ -50,7 +65,7 @@ namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
combinedChart.Save(ms, ImageFormat.Png);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return File(ms.ToArray(), "image/png", "mychart.png");
|
||||
return File(ms.ToArray(), "image/png", curveId + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +78,9 @@ namespace LeafWeb.Web.Controllers
|
||||
return CurveDataConverter.Convert(leafGasComparisons).ToArray();
|
||||
}
|
||||
|
||||
private IEnumerable<Bitmap> GetChartBitmaps(CurveData[] curveData)
|
||||
private IEnumerable<Bitmap> GetChartBitmaps(CurveData curveData)
|
||||
{
|
||||
var charts = LeafWebCharter.ProduceCharts(curveData[0]);
|
||||
var charts = LeafWebCharter.ProduceCharts(curveData);
|
||||
|
||||
foreach (var chart in charts)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user