aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-12-17 00:02:49 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-12-17 00:02:49 +0200
commitbdf56799cd6c4c42ec7a8dc36f56ddd17a5feeab (patch)
tree00ff21d8d2ee3d81b76fa12bc92460117cc693be /Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization
parente8ee7dfb8e166e34c7950e90d5fe9bcf31dc351b (diff)
downloadTango-bdf56799cd6c4c42ec7a8dc36f56ddd17a5feeab.tar.gz
Tango-bdf56799cd6c4c42ec7a8dc36f56ddd17a5feeab.zip
Added SOURCE to JOB.
Added IS_SYNCHRONIZED to TANGO_UPDATE. Added OfflineUpdates to Synchronization. Added TangoUpdates on PPC side.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs
index 8260eb4b3..22c3dbe20 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs
@@ -40,6 +40,7 @@ namespace Tango.PPC.Common.Synchronization
public int MaxJobs { get; set; }
public int MaxJobRuns { get; set; }
public int MaxMachinesEvents { get; set; }
+ public int MaxOfflineUpdates { get; set; }
private SynchronizationStatus _currentStatus;
public SynchronizationStatus CurrentStatus
@@ -80,6 +81,7 @@ namespace Tango.PPC.Common.Synchronization
MaxJobs = 10;
MaxJobRuns = 100;
MaxMachinesEvents = 100;
+ MaxOfflineUpdates = 50;
var settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
Interval = settings.SynchronizationInterval;
@@ -190,6 +192,21 @@ namespace Tango.PPC.Common.Synchronization
request.MachineEvents.Add(dto);
}
}
+
+ if (syncDiagnostics)
+ {
+ LogManager.Log("Checking Offline Updates...");
+
+ var tangoUpdates = await db.TangoUpdates.Where(x => !x.IsSynchronized && (x.Status == (int)TangoUpdateStatuses.OfflineUpdateCompleted || x.Status == (int)TangoUpdateStatuses.OfflineUpdateFailed)).Take(MaxOfflineUpdates).OrderByDescending(x => x.LastUpdated).ToListAsync();
+ List<TangoUpdateDTO> dtos = new List<TangoUpdateDTO>();
+
+ foreach (var tangoUpdate in tangoUpdates)
+ {
+ tangoUpdate.IsSynchronized = true;
+ var dto = TangoUpdateDTO.FromObservable(tangoUpdate);
+ request.OfflineUpdates.Add(dto);
+ }
+ }
}
return request;
@@ -247,6 +264,22 @@ namespace Tango.PPC.Common.Synchronization
}
}
+ //Finalize tango updates
+ foreach (var tangoUpdate in request.OfflineUpdates)
+ {
+ var failedTangoUpdate = response.FailedOfflineUpdates.SingleOrDefault(x => x.Guid == tangoUpdate.Guid);
+
+ if (failedTangoUpdate == null)
+ {
+ var dbTangoUpdate = await db.TangoUpdates.SingleOrDefaultAsync(x => x.Guid == tangoUpdate.Guid);
+ dbTangoUpdate.IsSynchronized = true;
+ }
+ else
+ {
+ LogManager.Log($"Synchronization Error - TangoUpdate '{tangoUpdate.ID}' cannot be stored on the server due to the following reason:\n{failedTangoUpdate.Reason}", LogCategory.Error);
+ }
+ }
+
await db.SaveChangesAsync();
}
}