diff options
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.cs | 38 |
1 files changed, 28 insertions, 10 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 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, + }; }); } } |
