From e0b0859f62924d38c8cd7ac9975303c4bfb08624 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 20 Dec 2018 14:24:19 +0200 Subject: Added environments support for users & roles !! --- .../MachineUpdate/DownloadUpdateResponse.cs | 5 +-- .../MachineUpdate/MachineUpdateManager.cs | 47 +++++++--------------- .../MachineUpdate/UpdateDBResponse.cs | 5 +-- 3 files changed, 19 insertions(+), 38 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs index c42c06f3b..de978ed66 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/DownloadUpdateResponse.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core; using Tango.Transport.Web; namespace Tango.PPC.Common.MachineUpdate @@ -13,8 +14,6 @@ namespace Tango.PPC.Common.MachineUpdate public String BlobAddress { get; set; } - public String DbAddress { get; set; } - public String DbUserName { get; set; } - public String DbPassword { get; set; } + public DataSource DataSource { get; set; } } } 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 6df7117d7..69df627fb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -164,18 +164,16 @@ namespace Tango.PPC.Common.MachineUpdate //Synchronize database UpdateProgress("Updating Database", "Initializing..."); - String db_name = "Tango"; - String localAddress = SettingsManager.Default.GetOrCreate().DataSource.Address; - String remote_address = update_response.DbAddress; + var localDataSource = SettingsManager.Default.GetOrCreate().DataSource; - LogManager.Log($"Synchronizing database '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'..."); + LogManager.Log($"Synchronizing database '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); UpdateProgress("Updating Database", "Connecting to local database..."); LogManager.Log("Initializing database manager..."); - DbManager db = DbManager.FromAddressAndName(localAddress, db_name); + DbManager db = DbManager.FromDataSource(localDataSource); LogManager.Log("Checking Tango database exists on the local machine..."); - if (!db.Exists(db_name)) + if (!db.Exists(localDataSource.Catalog)) { throw new InvalidProgramException("Database tango does not exists."); } @@ -190,20 +188,9 @@ namespace Tango.PPC.Common.MachineUpdate ExaminerSequenceConfigurationRunner runner = new ExaminerSequenceConfigurationRunner( Path.Combine(_newPackageTempFolder, "Update Scripts", "config.xml"), Path.Combine(_newPackageTempFolder, "Update Scripts"), - new ExaminerSequenceDataSource() - { - Address = remote_address, - DataBaseName = db_name, - IntegratedSecurity = false, - UserName = update_response.DbUserName, - Password = update_response.DbPassword, - }, - new ExaminerSequenceDataSource() - { - Address = localAddress, - DataBaseName = db_name, - IntegratedSecurity = true, - }, serialNumber); + update_response.DataSource, + localDataSource, + serialNumber); runner.Log += (x, msg) => { @@ -331,15 +318,13 @@ namespace Tango.PPC.Common.MachineUpdate UpdateDBResponse update_response = dbCompareResult.UpdateDBResponse; - String db_name = "Tango"; - String localAddress = SettingsManager.Default.GetOrCreate().DataSource.Address; - String remote_address = update_response.DbAddress; + var localDataSource = SettingsManager.Default.GetOrCreate().DataSource; - LogManager.Log($"Overriding database static tables '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'..."); + LogManager.Log($"Overriding database static tables '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(config_file); - builder.SetSourceServer(remote_address, db_name, false, update_response.DbUserName, update_response.DbPassword); - builder.SetTargetServer(localAddress, db_name, true); + builder.SetSource(update_response.DataSource); + builder.SetTarget(localDataSource); builder.Synchronize(); var config = builder.Build(); @@ -410,17 +395,15 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Update DB response received: {Environment.NewLine}{update_response.ToJsonString()}"); - String db_name = "Tango"; - String localAddress = SettingsManager.Default.GetOrCreate().DataSource.Address; - String remote_address = update_response.DbAddress; + var localDataSource = SettingsManager.Default.GetOrCreate().DataSource; - LogManager.Log($"Comparing database static tables '{remote_address}\\{db_name}' => '{localAddress}\\{db_name}'..."); + LogManager.Log($"Comparing database static tables '{update_response.DataSource.ToString()}' => '{localDataSource.ToString()}'..."); var report_file = TemporaryManager.CreateFile(".xml"); ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(config_file); - builder.SetSourceServer(remote_address, db_name, false, update_response.DbUserName, update_response.DbPassword); - builder.SetTargetServer(localAddress, db_name, true); + builder.SetSource(update_response.DataSource); + builder.SetTarget(localDataSource); builder.SetReportFile(report_file); var config = builder.Build(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs index 212cd02d2..36be14750 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdateDBResponse.cs @@ -3,14 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core; using Tango.Transport.Web; namespace Tango.PPC.Common.MachineUpdate { public class UpdateDBResponse : WebResponseMessage { - public String DbAddress { get; set; } - public String DbUserName { get; set; } - public String DbPassword { get; set; } + public DataSource DataSource { get; set; } } } -- cgit v1.3.1