From 5bf030a1137f09e9d9898c8a837e49a1af0468f9 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 29 Oct 2018 15:08:39 +0200 Subject: Improved some aspects of machine service and machine update. --- .../MachineSetup/MachineSetupManager.cs | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 252491669..a3012ffd8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -113,9 +113,16 @@ namespace Tango.PPC.Common.MachineSetup MachineSetupResponse setup_response = null; - using (var http = new ProtoWebClient()) + try { - setup_response = http.Post(machineServiceAddress + "/api/Synchronization/MachineSetup", request).Result; + using (var http = new ProtoWebClient()) + { + setup_response = http.Post(machineServiceAddress + "/api/Synchronization/MachineSetup", request).Result; + } + } + catch (Exception ex) + { + throw LogManager.Log(ex, $"An error occurred while trying to contact machine service: {ex.Message}"); } LogManager.Log($"Machine setup response received: {Environment.NewLine}{setup_response.ToJsonString()}"); @@ -178,14 +185,24 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log($"Synchronizing database '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'..."); - LogManager.Log("Initializing database manager..."); - DbManager db = DbManager.FromAddressAndName(localAddress, db_name); + LogManager.Log($"Connecting to local database at {localAddress}..."); + DbManager db = DbManager.FromAddress(localAddress); - LogManager.Log("Checking Tango database exists on the local machine..."); + LogManager.Log($"Ensuring {db_name} database exists on the local machine..."); if (!db.Exists(db_name)) { - throw new InvalidProgramException("Database tango does not exists."); + LogManager.Log("Database does not exist. Creating new database..."); + db.Create(db_name); } + else + { + LogManager.Log("Database exists."); + } + + db.Dispose(); + + LogManager.Log("Initializing database manager..."); + db = DbManager.FromAddressAndName(localAddress, db_name); LogManager.Log("Clearing database..."); db.ClearDb(); -- cgit v1.3.1