aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-12 19:00:36 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-12 19:00:36 +0300
commit18fc4053deb06af6643f28a6bb4fd66c6a9a93e0 (patch)
treedb2e3b344e30a95a3a09d662930ce129246a57d9 /Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup
parentbbbc155a96729050b9aa7d966055726df46696af (diff)
downloadTango-18fc4053deb06af6643f28a6bb4fd66c6a9a93e0.tar.gz
Tango-18fc4053deb06af6643f28a6bb4fd66c6a9a93e0.zip
Implemented temporary DB user login for machine service machine setup.
Implemented Tango updater! Implemented support for software update on machine setup.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs38
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResult.cs2
3 files changed, 30 insertions, 12 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs
index 096431d63..8856bcfd4 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/IMachineSetupManager.cs
@@ -13,6 +13,6 @@ namespace Tango.PPC.Common.MachineSetup
double DownloadingPackagesProgress { get; }
String DownloadingPackagesStatus { get; }
event EventHandler<MachineSetupSteps> ProgressStep;
- Task Setup(String serialNumber, String hostAddress);
+ Task<MachineSetupResult> Setup(String serialNumber, String hostAddress);
}
}
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 72c6da515..01f828c3f 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs
@@ -11,8 +11,10 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.Core;
+using Tango.Core.DB;
using Tango.Core.IO;
using Tango.PMR.Synchronization;
+using Tango.PPC.Common.Application;
using Tango.Settings;
using Tango.SQLExaminer;
using Tango.Transport.Web;
@@ -21,6 +23,8 @@ namespace Tango.PPC.Common.MachineSetup
{
public class MachineSetupManager : ExtendedObject, IMachineSetupManager
{
+ private IPPCApplicationManager _applicationManager;
+
public event EventHandler<string> ProgressLog;
public event EventHandler<MachineSetupSteps> ProgressStep;
@@ -53,9 +57,14 @@ namespace Tango.PPC.Common.MachineSetup
set { _updatingPackagesStatus = value; RaisePropertyChangedAuto(); }
}
- public Task Setup(string serialNumber, string machineServiceAddress)
+ public MachineSetupManager(IPPCApplicationManager applicationManager)
{
- return Task.Factory.StartNew(() =>
+ _applicationManager = applicationManager;
+ }
+
+ public Task<MachineSetupResult> Setup(string serialNumber, string machineServiceAddress)
+ {
+ return Task.Factory.StartNew<MachineSetupResult>(() =>
{
//Connect to machine service and get matching packages for this machine.
@@ -94,15 +103,15 @@ namespace Tango.PPC.Common.MachineSetup
});
}))
{
- using (FtpClient ftp = new FtpClient(setup_response.FtpAddress, setup_response.UserName, setup_response.Password))
+ using (FtpClient ftp = new FtpClient(setup_response.FtpAddress, setup_response.FtpUserName, setup_response.FtpPassword))
{
LogManager.Log("Connecting to FTP site: " + setup_response.FtpAddress);
ftp.ConnectAsync().Wait();
LogManager.Log("Retrieving download size...");
- fileSize = (int)ftp.GetFileSize(setup_response.FilePath);
+ fileSize = (int)ftp.GetFileSize(setup_response.FtpFilePath);
LogManager.Log("Download size: " + fileSize + " bytes.");
LogManager.Log("Starting download...");
- ftp.DownloadAsync(fs, setup_response.FilePath).Wait();
+ ftp.DownloadAsync(fs, setup_response.FtpFilePath).Wait();
}
}
@@ -117,14 +126,16 @@ namespace Tango.PPC.Common.MachineSetup
String localAddress = SettingsManager.Default.GetOrCreate<CoreSettings>().DataBaseSource;
String remote_address = setup_response.DbAddress;
- DbManager db = new DbManager(new SqlConnection(String.Format("Server={0};Integrated security=SSPI", localAddress)));
+ DbManager db = DbManager.FromAddressAndName(localAddress, db_name);
if (!db.Exists(db_name))
{
throw new InvalidProgramException("Database tango does not exists.");
}
- db.ClearDb(db_name); //TODO: This is not working!
+ db.ClearDb();
+
+ db.Dispose();
ExaminerSequenceConfigurationRunner runner = new ExaminerSequenceConfigurationRunner(
Path.Combine(_newPackageTempFolder, "Synchronization Scripts", "config.xml"),
@@ -133,7 +144,9 @@ namespace Tango.PPC.Common.MachineSetup
{
Address = remote_address,
DataBaseName = db_name,
- IntegratedSecurity = true,
+ IntegratedSecurity = false,
+ UserName = setup_response.DbUserName,
+ Password = setup_response.DbPassword,
},
new ExaminerSequenceDataSource()
{
@@ -142,12 +155,12 @@ namespace Tango.PPC.Common.MachineSetup
IntegratedSecurity = true,
}, serialNumber);
- runner.Log += (x, msg) =>
+ runner.Log += (x, msg) =>
{
ProgressLog.Invoke(this, msg);
};
- runner.ScriptExecuting += (x, item) =>
+ runner.ScriptExecuting += (x, item) =>
{
if (item.Type == ExaminerSequenceItemType.Data && item.RequiresSerialNumber)
{
@@ -160,6 +173,11 @@ namespace Tango.PPC.Common.MachineSetup
};
runner.Run().Wait();
+
+ return new MachineSetupResult()
+ {
+ UpdatePackagePath = _newPackageTempFolder,
+ };
});
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResult.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResult.cs
index 5887a6d34..c459ddf50 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResult.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupResult.cs
@@ -8,6 +8,6 @@ namespace Tango.PPC.Common.MachineSetup
{
public class MachineSetupResult
{
- public bool Completed { get; set; }
+ public String UpdatePackagePath { get; set; }
}
}