From d99c80d6633d2932cf67fc7013100a639882c6dc Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 17 Dec 2019 02:08:31 +0200 Subject: Implemented PPC Updates/Synchronization View. Refactored database updates to be deleted if no differences. Updated MS and PPC with Offline Updates. Refactored Machine Designer Updates View to take only last 100 update entries. --- .../MachineUpdate/MachineUpdateManager.cs | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 666b6813c..d0424254b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -473,7 +473,7 @@ namespace Tango.PPC.Common.MachineUpdate _isUpdating = false; } - private void OnCompleted(UpdateDBResponse response) + private void OnCompleted(UpdateDBResponse response, bool completedWithNoDifferences = false) { if (response != null) { @@ -483,6 +483,7 @@ namespace Tango.PPC.Common.MachineUpdate { Token = response.NotifyCompletedToken, Status = BL.Enumerations.TangoUpdateStatuses.DatabaseCompleted, + ReportsAboutDbCheckNoDifferences = completedWithNoDifferences, }).Result; } catch (Exception ex) @@ -490,23 +491,26 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log(ex, "Error notifying database completed."); } - try + if (!completedWithNoDifferences) { - using (ObservablesContext db = ObservablesContext.CreateDefault()) + try { - TangoUpdate update = new TangoUpdate(); - update.ApplicationVersion = _app_manager.Version.ToString(); - update.FirmwareVersion = _app_manager.FirmwareVersion.ToString(); - update.MachineGuid = _machineProvider.Machine.Guid; - update.UpdateStatus = BL.Enumerations.TangoUpdateStatuses.DatabaseCompleted; - update.StartDate = _updateStartDate; - update.EndDate = DateTime.UtcNow; - db.SaveChanges(); + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + TangoUpdate update = new TangoUpdate(); + update.ApplicationVersion = _app_manager.Version.ToString(); + update.FirmwareVersion = _app_manager.FirmwareVersion.ToString(); + update.MachineGuid = _machineProvider.Machine.Guid; + update.UpdateStatus = BL.Enumerations.TangoUpdateStatuses.DatabaseCompleted; + update.StartDate = _updateStartDate; + update.EndDate = DateTime.UtcNow; + db.SaveChanges(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving database update information to database."); } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error saving database update information to database."); } } @@ -1091,12 +1095,18 @@ namespace Tango.PPC.Common.MachineUpdate } catch (Exception ex) { + OnFailed(ex, update_response, false, null, null); throw LogManager.Log(ex, "Update manager error while trying to compare the database."); } } LogManager.Log("Comparison completed successfully."); + if (!has_differences) + { + OnCompleted(update_response, true); + } + return new DbCompareResult() { RequiresUpdate = has_differences, -- cgit v1.3.1