Reformating charting, add DataError message
This commit is contained in:
@@ -10,12 +10,14 @@ using System.Web.UI.WebControls;
|
||||
using LeafWeb.Core.Charter;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Parsers;
|
||||
using LeafWeb.Core.Utility;
|
||||
using LeafWeb.Web.Services;
|
||||
using LeafWeb.Web.ViewModels.LeafCharter;
|
||||
using LeafWeb.Web.ViewModels.Chart;
|
||||
using NLog;
|
||||
|
||||
namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
public class LeafCharterController : ControllerBase
|
||||
public class ChartController : ControllerBase
|
||||
{
|
||||
public ActionResult Index(int leafInputId)
|
||||
{
|
||||
@@ -28,16 +30,30 @@ namespace LeafWeb.Web.Controllers
|
||||
if (leafOutputFile == null)
|
||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||
|
||||
var curveData = GetCurveData(leafOutputFile.Contents);
|
||||
try
|
||||
{
|
||||
var curveData = GetCurveData(leafOutputFile.Contents);
|
||||
|
||||
var curveIds = curveData.Select(c => c.CurveId).ToList();
|
||||
var curveIds = curveData.Select(c => c.CurveId).ToList();
|
||||
|
||||
var viewModel = new LeafCharterViewModel {AvailableCurveId = curveIds, LeafInputId = leafInputId};
|
||||
var viewModel = new ChartViewModel
|
||||
{
|
||||
AvailableCurveId = curveIds,
|
||||
LeafInputId = leafInputId,
|
||||
LeafInputIdentifier = leafOutputFile.LeafInput.Identifier
|
||||
};
|
||||
|
||||
return View(viewModel);
|
||||
return View(viewModel);
|
||||
}
|
||||
catch (ParseException parseException)
|
||||
{
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
logger.Warn(parseException);
|
||||
return View("DataError", model: parseException.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult LeafCharts(int leafInputId, string curveId)
|
||||
public ActionResult ChartCurve(int leafInputId, string curveId)
|
||||
{
|
||||
var leafOutputFile =
|
||||
DataService
|
||||
@@ -53,7 +69,7 @@ namespace LeafWeb.Web.Controllers
|
||||
var curveIdData = curveData.FirstOrDefault(c => c.CurveId == curveId);
|
||||
|
||||
if (curveIdData == null)
|
||||
return File("/Content/favicon/apple-icon-57x57.png", "image/png");
|
||||
return File("/Content/favicon/apple-icon-57x57.png", "image/png"); // TODO: different image ?
|
||||
|
||||
var charts = GetChartBitmaps(curveIdData).ToList();
|
||||
|
||||
@@ -65,7 +81,7 @@ namespace LeafWeb.Web.Controllers
|
||||
{
|
||||
combinedChart.Save(ms, ImageFormat.Png);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return File(ms.ToArray(), "image/png", curveId + ".png");
|
||||
return File(ms.ToArray(), "image/png", curveId.FilterValidFilename() + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user