modified: Core.Tests/Charter/CurveDataConverterTests.cs modified: Core.Tests/Parsers/CntrlComparisonParserTests.cs modified: Core.Tests/Parsers/LeafInputCsvParserTests.cs modified: Core.Tests/Remote/PiscalSshClientTests.cs modified: Core/Charter/CurveDataConverter.cs modified: Core/Core.csproj modified: Core/DAL/DataService.cs modified: Core/DAL/LeafWebContext.cs modified: Core/DAL/LeafWebInitializer.cs renamed: Core/Models/CntrlComparison.cs -> Core/Entities/CntrlComparison.cs renamed: Core/Models/CntrlComparisonFittingInfo.cs -> Core/Entities/CntrlComparisonFittingInfo.cs renamed: Core/Models/CntrlComparisonPhotosyntheticInfo.cs -> Core/Entities/CntrlComparisonPhotosyntheticInfo.cs renamed: Core/Models/FluxnetSite.cs -> Core/Entities/FluxnetSite.cs renamed: Core/Models/LeafInput.cs -> Core/Entities/LeafInput.cs renamed: Core/Models/LeafInputData.cs -> Core/Entities/LeafInputData.cs renamed: Core/Models/LeafInputFile.cs -> Core/Entities/LeafInputFile.cs renamed: Core/Models/LeafInputInfo.cs -> Core/Entities/LeafInputInfo.cs renamed: Core/Models/LeafInputPhotosynthetic.cs -> Core/Entities/LeafInputPhotosynthetic.cs renamed: Core/Models/LeafInputSite.cs -> Core/Entities/LeafInputSite.cs renamed: Core/Models/LeafInputStatus.cs -> Core/Entities/LeafInputStatus.cs renamed: Core/Models/PhotosynthesisType.cs -> Core/Entities/PhotosynthesisType.cs modified: Core/Parsers/CntrlComparisonParser.cs modified: Core/Parsers/FluxnetSiteCsvParser.cs modified: Core/Parsers/LeafInputCsvParser.cs modified: Web/Controllers/LeafCharterController.cs modified: Web/Controllers/LeafInputController.cs modified: Web/ViewModels/LeafInput/CreateViewModel.cs
80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using LeafWeb.Core.Entities;
|
|
using LeafWeb.Core.Utility;
|
|
|
|
namespace LeafWeb.Core.Parsers
|
|
{
|
|
public class CntrlComparisonParser : CsvParserBase
|
|
{
|
|
public CntrlComparisonParser(FileSystemInfo csvFile) : base(csvFile)
|
|
{
|
|
}
|
|
|
|
public CntrlComparison[] Parse()
|
|
{
|
|
var fittingTitles = GetNextCsvRowValues();
|
|
if (fittingTitles == null)
|
|
throw new ParseException($"Could not read data header row on line number {CsvReader.Row}");
|
|
var fitUnits = GetNextCsvRowValues();
|
|
if (fitUnits == null)
|
|
throw new ParseException($"Could not read data units row on line number {CsvReader.Row}");
|
|
|
|
return ParseCntrlComparisonSet(fittingTitles).ToArray();
|
|
}
|
|
|
|
private IEnumerable<CntrlComparison> ParseCntrlComparisonSet(string[] fittingTitles)
|
|
{
|
|
var endOfFile = false;
|
|
while (!endOfFile)
|
|
{
|
|
// First Section
|
|
var fittingValues = new List<string[]>();
|
|
string[] photosyntheticTitles;
|
|
while (true)
|
|
{
|
|
var values = GetNextCsvRowValues();
|
|
if (CsvReader.IsRecordEmpty())
|
|
throw new ParseException($"Encountered empty line while readding fitting info on line {CsvReader.Row}");
|
|
if (values == null) // end of file
|
|
yield break;
|
|
if (ParsedObjectFactory<CntrlComparisonPhotosyntheticInfo>.IsPropertiesTitlesMatch(values))
|
|
{
|
|
photosyntheticTitles = values;
|
|
break;
|
|
}
|
|
fittingValues.Add(values);
|
|
}
|
|
|
|
var photosyntheticValues = new List<string[]>();
|
|
while (true)
|
|
{
|
|
var values = GetNextCsvRowValues();
|
|
if (CsvReader.IsRecordEmpty()) // end of set
|
|
break;
|
|
if (values == null)
|
|
{
|
|
endOfFile = true;
|
|
break;
|
|
}
|
|
photosyntheticValues.Add(values);
|
|
}
|
|
|
|
var fittingInfo =
|
|
ParsedObjectFactory<CntrlComparisonFittingInfo>
|
|
.Create(fittingTitles, fittingValues.ToArray());
|
|
var photosyntheticInfo =
|
|
ParsedObjectFactory<CntrlComparisonPhotosyntheticInfo>
|
|
.Create(photosyntheticTitles, photosyntheticValues.ToArray());
|
|
|
|
yield return new CntrlComparison
|
|
{
|
|
FittingInfo = fittingInfo,
|
|
PhotosyntheticInfo = photosyntheticInfo
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|