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"); } }