Improve charting UI for error cases

This commit is contained in:
2016-05-27 11:17:51 -04:00
parent 55f7b68bf8
commit 5c82e51e86
2 changed files with 34 additions and 12 deletions
+14 -6
View File
@@ -4,6 +4,7 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Web.Mvc;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
@@ -57,7 +58,7 @@ namespace LeafWeb.Web.Controllers
var curveData = GetCurveData(leafOutputFile.FileContents.Contents, curveId);
if (curveData == null)
return File("/Content/favicon/apple-icon-57x57.png", "image/png"); // TODO: different image ?
return new HttpStatusCodeResult(HttpStatusCode.NotFound);
var charts = GetChartBitmaps(curveData).ToList();
@@ -75,11 +76,18 @@ namespace LeafWeb.Web.Controllers
private CurveData GetCurveData(byte[] fileContents, string curveId)
{
LeafGasComparison[] leafGasComparisons;
using (var parser = new LeafGasComparisonParser(fileContents))
leafGasComparisons = parser.Parse(curveId);
return CurveDataConverter.Convert(leafGasComparisons).First();
try
{
LeafGasComparison[] leafGasComparisons;
using (var parser = new LeafGasComparisonParser(fileContents))
leafGasComparisons = parser.Parse(curveId);
return CurveDataConverter.Convert(leafGasComparisons).First();
}
catch (Exception e)
{
LogManager.GetCurrentClassLogger().Warn(e);
}
return null;
}
private string[] GetCurveIds(byte[] fileContents)