aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Synchronization/DefaultMachineDataSynchronizer.cs')
-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();
}
}