public void SetupInstall(string[] productList) { _hasInstallers = false; _installControl = null; _installManager = new InstallManager(); _productList = new List <string>(); _installManager.InstallerStatusUpdated += new EventHandler <InstallStatusEventArgs>(InstallerStatusUpdated); _installManager.InstallCompleted += new EventHandler <EventArgs>(InstallerCompletedCallback); var productManager = new ProductManager(); // Load feed specifying that enclosure files are needed. productManager.Load(new Uri(WebPiFeedUrl), true, true, false, Path.GetTempPath()); var productsToInstall = new List <Product>(); var uniqueInstallerList = new Dictionary <string, Installer>(StringComparer.OrdinalIgnoreCase); var languageOfInstallers = productManager.GetLanguage(Thread.CurrentThread.CurrentCulture.ToString()); var english = productManager.GetLanguage("en"); foreach (var productName in productList) { Product product = productManager.GetProduct(productName); LogInformation("Initial Product to install: {0}", product.ProductId); if (!product.IsInstalled(true)) { AddProductWithDependencies(product, productsToInstall); foreach (Product productToInstall in productsToInstall) { Installer currentInstaller = productToInstall.GetInstaller(languageOfInstallers); if (currentInstaller == null) { currentInstaller = productToInstall.GetInstaller(english); } if (currentInstaller != null) { if (!uniqueInstallerList.ContainsKey(currentInstaller.Product.ProductId)) { uniqueInstallerList[currentInstaller.Product.ProductId] = currentInstaller; LogInformation("Adding product: {0}", currentInstaller.Product.ProductId); _productList.Add(currentInstaller.Product.ProductId); } _hasInstallers = true; } } } } if (_hasInstallers) { _installManager.Load(uniqueInstallerList.Values); } }
public void InstallProducts( IEnumerable <string> productIdsToInstall, bool installDependencies, string languageId, EventHandler <InstallStatusEventArgs> installStatusUpdatedHandler, EventHandler <EventArgs> installCompleteHandler) { List <Product> productsToInstall = null; if (installDependencies) { // Get products & dependencies list to install productsToInstall = GetProductsToInstallWithDependencies(productIdsToInstall); } else { productsToInstall = GetProductsToInstall(productIdsToInstall); } // Get installers Language lang = GetLanguage(languageId); List <Installer> installersToUse = GetInstallers(productsToInstall, lang); // Prepare install manager & set event handlers _installManager = new InstallManager(); _installManager.Load(installersToUse); if (null != installStatusUpdatedHandler) { _installManager.InstallerStatusUpdated += installStatusUpdatedHandler; } _installManager.InstallerStatusUpdated += InstallManager_InstallerStatusUpdated; if (null != installCompleteHandler) { _installManager.InstallCompleted += installCompleteHandler; } _installManager.InstallCompleted += InstallManager_InstallCompleted; // Download installer files foreach (InstallerContext installerContext in _installManager.InstallerContexts) { if (null != installerContext.Installer.InstallerFile) { string failureReason; if (!_installManager.DownloadInstallerFile(installerContext, out failureReason)) { WriteLog(string.Format("DownloadInstallerFile '{0}' failed: {1}", installerContext.Installer.InstallerFile.InstallerUrl, failureReason)); throw new Exception( string.Format("Can't install {0} DownloadInstallerFile '{1}' failed: {2}", installerContext.ProductName, installerContext.Installer.InstallerFile.InstallerUrl, failureReason) ); } } } if (installersToUse.Count > 0) { // Start installation _installCompleted = false; _installManager.StartInstallation(); while (!_installCompleted) { Thread.Sleep(100); } //save logs SaveLogDirectory(); _installCompleted = false; } else { //Log("Nothing to install"); } }
public void InstallProducts( IEnumerable<string> productIdsToInstall, bool installDependencies, string languageId, EventHandler<InstallStatusEventArgs> installStatusUpdatedHandler, EventHandler<EventArgs> installCompleteHandler) { List<Product> productsToInstall = null; if (installDependencies) { // Get products & dependencies list to install productsToInstall = GetProductsToInstallWithDependencies(productIdsToInstall); } else { productsToInstall = GetProductsToInstall(productIdsToInstall); } // Get installers Language lang = GetLanguage(languageId); List<Installer> installersToUse = GetInstallers(productsToInstall, lang); // Prepare install manager & set event handlers _installManager = new InstallManager(); _installManager.Load(installersToUse); if (null != installStatusUpdatedHandler) { _installManager.InstallerStatusUpdated += installStatusUpdatedHandler; } _installManager.InstallerStatusUpdated += InstallManager_InstallerStatusUpdated; if (null != installCompleteHandler) { _installManager.InstallCompleted += installCompleteHandler; } _installManager.InstallCompleted += InstallManager_InstallCompleted; // Download installer files foreach (InstallerContext installerContext in _installManager.InstallerContexts) { if (null != installerContext.Installer.InstallerFile) { string failureReason; if (!_installManager.DownloadInstallerFile(installerContext, out failureReason)) { WriteLog(string.Format("DownloadInstallerFile '{0}' failed: {1}", installerContext.Installer.InstallerFile.InstallerUrl, failureReason)); throw new Exception( string.Format("Can't install {0} DownloadInstallerFile '{1}' failed: {2}", installerContext.ProductName, installerContext.Installer.InstallerFile.InstallerUrl, failureReason) ); } } } if (installersToUse.Count > 0) { // Start installation _installCompleted = false; _installManager.StartInstallation(); while (!_installCompleted) { Thread.Sleep(100); } //save logs SaveLogDirectory(); _installCompleted = false; } else { //Log("Nothing to install"); } }
public void SetupInstall(string[] productList) { _hasInstallers = false; _installControl = null; _installManager = new InstallManager(); _productList = new List<string>(); _installManager.InstallerStatusUpdated += new EventHandler<InstallStatusEventArgs>(InstallerStatusUpdated); _installManager.InstallCompleted += new EventHandler<EventArgs>(InstallerCompletedCallback); var productManager = new ProductManager(); // Load feed specifying that enclosure files are needed. productManager.Load(new Uri(WebPiFeedUrl), true, true, false, Path.GetTempPath()); var productsToInstall = new List<Product>(); var uniqueInstallerList = new Dictionary<string, Installer>(StringComparer.OrdinalIgnoreCase); var languageOfInstallers = productManager.GetLanguage(Thread.CurrentThread.CurrentCulture.ToString()); var english = productManager.GetLanguage("en"); foreach (var productName in productList) { Product product = productManager.GetProduct(productName); LogInformation("Initial Product to install: {0}", product.ProductId); if (!product.IsInstalled(true)) { AddProductWithDependencies(product, productsToInstall); foreach (Product productToInstall in productsToInstall) { Installer currentInstaller = productToInstall.GetInstaller(languageOfInstallers); if (currentInstaller == null) { currentInstaller = productToInstall.GetInstaller(english); } if (currentInstaller != null) { if (!uniqueInstallerList.ContainsKey(currentInstaller.Product.ProductId)) { uniqueInstallerList[currentInstaller.Product.ProductId] = currentInstaller; LogInformation("Adding product: {0}", currentInstaller.Product.ProductId); _productList.Add(currentInstaller.Product.ProductId); } _hasInstallers = true; } } } } if (_hasInstallers) { _installManager.Load(uniqueInstallerList.Values); } }