aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-10-29 15:08:39 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-10-29 15:08:39 +0200
commit5bf030a1137f09e9d9898c8a837e49a1af0468f9 (patch)
tree6535fef5affffe2b28bd87472c18383867510560 /Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
parent4973c8ff53c8758852f707af5cc7f4a6a82151e0 (diff)
downloadTango-5bf030a1137f09e9d9898c8a837e49a1af0468f9.tar.gz
Tango-5bf030a1137f09e9d9898c8a837e49a1af0468f9.zip
Improved some aspects of machine service and machine update.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs29
1 files changed, 23 insertions, 6 deletions
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<MachineSetupRequest, MachineSetupResponse>(machineServiceAddress + "/api/Synchronization/MachineSetup", request).Result;
+ using (var http = new ProtoWebClient())
+ {
+ setup_response = http.Post<MachineSetupRequest, MachineSetupResponse>(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();