Skip to content

Commit

Permalink
come work on sensorHisotries #77
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirAkopyan committed Oct 8, 2017
1 parent 00fb737 commit 74319cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions DbStructure/User/SensorHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public class SensorHistory
{

//EDIT EF code to make this NOT mapped to a table! Otherwise we will have trouble!
//this is used for network communication and by the program at runtime!
[Required]
Expand Down
9 changes: 6 additions & 3 deletions Quickbird/Services/DataSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ private static async Task<string> GetRequestSensorHistoryAsync(MainDbContext db)
var table = nameof(db.SensorsHistory);
var errors = "";

//Query local sensors and locations. Mostly used for debug.
var LocalSensors = db.Sensors.ToList();
var LocalLocation = db.Locations.ToList();

// Download all the data for each device in turn.
foreach (var device in devices)
{
Expand Down Expand Up @@ -322,8 +326,6 @@ private static async Task<string> GetRequestSensorHistoryAsync(MainDbContext db)

if (remoteBlocks.Any())
{
var LocalSensors = db.Sensors.ToList();
var LocalLocation = db.Locations.ToList();

var lastDayOfThisDownloadSet = DateTimeOffset.MinValue;
foreach (var remoteBlock in remoteBlocks)
Expand Down Expand Up @@ -378,7 +380,8 @@ private static async Task<string> GetRequestSensorHistoryAsync(MainDbContext db)
{
// The data is pulled from the database as serialised raw data blobs.
localBlock.DeserialiseData();
localBlock.LocationID = remoteBlock.LocationID;
localBlock.LocationID = remoteBlock.LocationID;
var linkedLocation = LocalLocation.FirstOrDefault(loc => loc.ID == remoteBlock.LocationID);

// The merged object merges using the deserialised Data property.
var merged = SensorHistory.Merge(localBlock, remoteBlock);
Expand Down

0 comments on commit 74319cc

Please sign in to comment.