Skip to content

Commit

Permalink
Merge pull request #55 from KrishnaBrahmarouthu/master
Browse files Browse the repository at this point in the history
using yield return in ReadLoggedData
  • Loading branch information
strhea authored Oct 2, 2019
2 parents bbc2506 + 43ee339 commit 6c26284
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions ADMPlugin/Serializers/DocumentsSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,26 +372,27 @@ private IEnumerable<Load> ReadLoads(IBaseSerializer baseSerializer, string docum

private IEnumerable<LoggedData> ReadLoggedData(IBaseSerializer baseSerializer, string documentsPath)
{
var loggedDataCol = new List<LoggedData>();

var loggedDataFiles = Directory.EnumerateFiles(documentsPath, ConvertToSearchPattern(DatacardConstants.LoggedDataFile));
foreach (var loggedDataFile in loggedDataFiles)
{
var loggedData = baseSerializer.Deserialize<LoggedData>(loggedDataFile);
foreach (var operationData in loggedData.OperationData)
{
ImportSpatialRecords(baseSerializer, documentsPath, operationData);
ImportSections(baseSerializer, documentsPath, operationData);
ImportMeters(baseSerializer, documentsPath, operationData);
yield return MapLoggedData(baseSerializer, documentsPath, loggedDataFile);
}
}

loggedDataCol.Add(loggedData);
}
private LoggedData MapLoggedData(IBaseSerializer baseSerializer, string documentsPath, string loggedDataFile)
{
var loggedData = baseSerializer.Deserialize<LoggedData>(loggedDataFile);
foreach (var operationData in loggedData.OperationData)
{
ImportSpatialRecords(baseSerializer, documentsPath, operationData);
ImportSections(baseSerializer, documentsPath, operationData);
ImportMeters(baseSerializer, documentsPath, operationData);
}

return loggedDataCol;
}
return loggedData;
}

private void ImportMeters(IBaseSerializer baseSerializer, string documentsPath, OperationData operationData)
private void ImportMeters(IBaseSerializer baseSerializer, string documentsPath, OperationData operationData)
{
var deviceElementUses = GetAllDeviceElementUses(operationData).Where(x => x.Value != null).SelectMany(x => x.Value);

Expand Down

0 comments on commit 6c26284

Please sign in to comment.