Get chart file a bit quicker from DB
This commit is contained in:
@@ -51,6 +51,23 @@ namespace LeafWeb.Core.DAL
|
|||||||
return _db.LeafInputs.FirstOrDefault(li => li.Id == id);
|
return _db.LeafInputs.FirstOrDefault(li => li.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LeafOutputFile GetLeafOutput_ChartFile(int leafInputId)
|
||||||
|
{
|
||||||
|
return GetLeafOutput_FilenameLike(leafInputId, LeafOutputFile.Filename_LeafChart);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LeafOutputFile GetLeafOutput_FilenameLike(int leafInputId, string filename)
|
||||||
|
{
|
||||||
|
var leafOutputChartFile =
|
||||||
|
from leafInput in _db.LeafInputs
|
||||||
|
where leafInput.Id == leafInputId
|
||||||
|
from leafOutput in leafInput.OutputFiles
|
||||||
|
where leafOutput.Filename.Contains(filename)
|
||||||
|
select leafOutput;
|
||||||
|
|
||||||
|
return leafOutputChartFile.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public LeafInput GetLeafInput(string uniqueToken)
|
public LeafInput GetLeafInput(string uniqueToken)
|
||||||
{
|
{
|
||||||
return _db.LeafInputs.FirstOrDefault(li => li.UniqueToken == uniqueToken);
|
return _db.LeafInputs.FirstOrDefault(li => li.UniqueToken == uniqueToken);
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ namespace LeafWeb.Core.Entities
|
|||||||
{
|
{
|
||||||
public class LeafOutputFile
|
public class LeafOutputFile
|
||||||
{
|
{
|
||||||
|
// convention for the filename which LeafCharter uses
|
||||||
|
public const string Filename_LeafChart = "leafgascomparison";
|
||||||
|
public const string Filename_ErrorMessage = "errormessage";
|
||||||
|
public const string Filename_WarningMessage = "warningmessage";
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public virtual LeafInput LeafInput { get; set; }
|
public virtual LeafInput LeafInput { get; set; }
|
||||||
@@ -11,9 +16,8 @@ namespace LeafWeb.Core.Entities
|
|||||||
|
|
||||||
public byte[] Contents { get; set; }
|
public byte[] Contents { get; set; }
|
||||||
|
|
||||||
// convention for the filename which LeafCharter uses
|
public bool IsLeafChartFile => Filename?.Contains(Filename_LeafChart) ?? false;
|
||||||
public bool IsLeafChartFile => Filename?.Contains("leafgascomparison") ?? false;
|
public bool IsErrorMessage => Filename?.Contains(Filename_ErrorMessage) ?? false;
|
||||||
public bool IsErrorMessage => Filename?.Contains("errormessage") ?? false;
|
public bool IsWarningMessage => Filename?.Contains(Filename_WarningMessage) ?? false;
|
||||||
public bool IsWarningMessage => Filename?.Contains("warningmessage") ?? false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,7 @@ namespace LeafWeb.Web.Controllers
|
|||||||
{
|
{
|
||||||
public ActionResult Index(int leafInputId)
|
public ActionResult Index(int leafInputId)
|
||||||
{
|
{
|
||||||
var leafOutputFile =
|
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId);
|
||||||
DataService
|
|
||||||
.GetLeafInput(leafInputId)?
|
|
||||||
.OutputFiles?
|
|
||||||
.FirstOrDefault(f => f.IsLeafChartFile);
|
|
||||||
|
|
||||||
if (leafOutputFile == null)
|
if (leafOutputFile == null)
|
||||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||||
@@ -53,13 +49,9 @@ namespace LeafWeb.Web.Controllers
|
|||||||
|
|
||||||
public ActionResult ChartCurve(int leafInputId, string curveId)
|
public ActionResult ChartCurve(int leafInputId, string curveId)
|
||||||
{
|
{
|
||||||
var leafOutputFile =
|
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId);
|
||||||
DataService
|
|
||||||
.GetLeafInput(leafInputId)?
|
|
||||||
.OutputFiles?
|
|
||||||
.FirstOrDefault(f => f.IsLeafChartFile);
|
|
||||||
|
|
||||||
if (leafOutputFile == null)
|
if (leafOutputFile == null)
|
||||||
throw new ArgumentOutOfRangeException(); // TODO: break
|
throw new ArgumentOutOfRangeException(); // TODO: break
|
||||||
|
|
||||||
var curveData = GetCurveData(leafOutputFile.Contents, curveId);
|
var curveData = GetCurveData(leafOutputFile.Contents, curveId);
|
||||||
|
|||||||
Reference in New Issue
Block a user