aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
diff options
context:
space:
mode:
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();