Leaf Chart streamline

This commit is contained in:
2016-03-22 07:38:10 -04:00
parent c761952a8a
commit 4b2757b19a
4 changed files with 36 additions and 12 deletions
+28 -11
View File
@@ -16,30 +16,47 @@ namespace LeafWeb.Web.Controllers
{
public ActionResult Index(int leafInputFileId)
{
var hasLeafOutputFile =
DataService
.GetLeafInputFile(leafInputFileId)?
.LeafOutputFiles?
.FirstOrDefault(f => f.IsLeafChartFile) != null;
return View(leafInputFileId);
}
public ActionResult LeafCharts(int leafInputFileId, int number)
{
var leafInputFile = DataService.GetLeafInputFile(leafInputFileId);
var leafOutputFile = leafInputFile.LeafOutputFiles.FirstOrDefault(f => f.Filename.StartsWith("cntrlcomparison"));
//if (leafOutputFile == null)
// return View(); // TODO: break
var leafOutputFile =
DataService
.GetLeafInputFile(leafInputFileId)?
.LeafOutputFiles?
.FirstOrDefault(f => f.IsLeafChartFile);
CntrlComparison[] cntrlComparison;
using (var parser = new CntrlComparisonParser(leafOutputFile.Contents))
if (leafOutputFile == null)
return View(); // TODO: break
return File(GetChartImage(leafOutputFile.Contents, number), "image/png", "mychart.png");
}
private byte[] GetChartImage(byte[] fileContents, int number, ChartImageFormat format = ChartImageFormat.Png)
{
CntrlComparison[] cntrlComparison;
using (var parser = new CntrlComparisonParser(fileContents))
cntrlComparison = parser.Parse();
var curveData = CurveDataConverter.Convert(cntrlComparison).ToArray();
var curveData = CurveDataConverter.Convert(cntrlComparison).ToArray();
var charts = LeafWebCharter.ProduceCharts(curveData[2]);
var charts = LeafWebCharter.ProduceCharts(curveData[2]);
using (var ms = new MemoryStream())
//Image.FromFile()
using (var ms = new MemoryStream())
{
charts.Skip(number).First().SaveImage(ms, ChartImageFormat.Png);
charts.Skip(number).First().SaveImage(ms, format);
ms.Seek(0, SeekOrigin.Begin);
return File(ms.ToArray(), "image/png", "mychart.png");
return ms.ToArray();
}
}